Commit c873adb9 authored by Navid Zolghadr's avatar Navid Zolghadr Committed by Commit Bot

Use PassKey pattern and make FloatingObject constructors public

Change-Id: If8d9e962ba907a670e3ee82bf64a30d48bdf5348
Bug: 1030176, 939691
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1980524Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Navid Zolghadr <nzolghadr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727327}
parent f831daf3
......@@ -47,7 +47,7 @@ struct SameSizeAsFloatingObject {
static_assert(sizeof(FloatingObject) == sizeof(SameSizeAsFloatingObject),
"FloatingObject should stay small");
FloatingObject::FloatingObject(LayoutBox* layout_object, Type type)
FloatingObject::FloatingObject(PassKey key, LayoutBox* layout_object, Type type)
: layout_object_(layout_object),
originating_line_(nullptr),
type_(type),
......@@ -63,7 +63,8 @@ FloatingObject::FloatingObject(LayoutBox* layout_object, Type type)
{
}
FloatingObject::FloatingObject(LayoutBox* layout_object,
FloatingObject::FloatingObject(PassKey key,
LayoutBox* layout_object,
Type type,
const LayoutRect& frame_rect,
bool should_paint,
......@@ -89,7 +90,7 @@ FloatingObject::FloatingObject(LayoutBox* layout_object,
std::unique_ptr<FloatingObject> FloatingObject::Create(LayoutBox* layout_object,
Type type) {
std::unique_ptr<FloatingObject> new_obj =
base::WrapUnique(new FloatingObject(layout_object, type));
base::WrapUnique(new FloatingObject(PassKey(), layout_object, type));
// If a layer exists, the float will paint itself. Otherwise someone else
// will.
......@@ -114,14 +115,14 @@ std::unique_ptr<FloatingObject> FloatingObject::CopyToNewContainer(
bool should_paint,
bool is_descendant) const {
return base::WrapUnique(new FloatingObject(
GetLayoutObject(), GetType(),
PassKey(), GetLayoutObject(), GetType(),
LayoutRect(FrameRect().Location() - offset, FrameRect().Size()),
should_paint, is_descendant, IsLowestNonOverhangingFloatInChild()));
}
std::unique_ptr<FloatingObject> FloatingObject::UnsafeClone() const {
std::unique_ptr<FloatingObject> clone_object = base::WrapUnique(
new FloatingObject(GetLayoutObject(), GetType(), frame_rect_,
new FloatingObject(PassKey(), GetLayoutObject(), GetType(), frame_rect_,
should_paint_, is_descendant_, false));
clone_object->is_placed_ = is_placed_;
#if DCHECK_IS_ON()
......
......@@ -27,6 +27,7 @@
#include <memory>
#include "base/macros.h"
#include "base/util/type_safety/pass_key.h"
#include "third_party/blink/renderer/platform/geometry/layout_rect.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/platform/wtf/list_hash_set.h"
......@@ -147,15 +148,17 @@ class FloatingObject {
RootInlineBox* OriginatingLine() const { return originating_line_; }
void SetOriginatingLine(RootInlineBox* line) { originating_line_ = line; }
private:
FloatingObject(LayoutBox*, Type);
FloatingObject(LayoutBox*,
using PassKey = util::PassKey<FloatingObject>;
FloatingObject(PassKey, LayoutBox*, Type);
FloatingObject(PassKey,
LayoutBox*,
Type,
const LayoutRect&,
bool should_paint,
bool is_descendant,
bool is_lowest_non_overhanging_float_in_child);
private:
LayoutBox* layout_object_;
RootInlineBox* originating_line_;
LayoutRect frame_rect_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment