Skip to content

Commit

Permalink
LayoutNG: Rename classes defined in layout/ng/custom/
Browse files Browse the repository at this point in the history
'NG' is removed from class names.
* NGLayoutInputNode::IsLayoutNGCustom is renamed to IsCustom. Other
  similar methods don't have 'Layout' in their names.
* A DCHECK in NGBlockNode::IsCustomLayoutLoaded() is removed because
  it's redundant.  To<LayoutCustom>() contains it.

This CL has no behavior changes.

Bug: 1492009
Change-Id: I9953a6e21f75e6dc66b81050f6534202c4294340
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4945234
Reviewed-by: Koji Ishii <kojii@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Auto-Submit: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1210722}
  • Loading branch information
tkent-google authored and Chromium LUCI CQ committed Oct 17, 2023
1 parent fdcf410 commit fcb0b0d
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state,
AdjustStyleForDisplay(builder, layout_parent_style, element,
element ? &element->GetDocument() : nullptr);

// If this is a child of a LayoutNGCustom, we need the name of the parent
// If this is a child of a LayoutCustom, we need the name of the parent
// layout function for invalidation purposes.
if (layout_parent_style.IsDisplayLayoutCustomBox()) {
builder.SetDisplayLayoutCustomParentName(
Expand Down
4 changes: 2 additions & 2 deletions third_party/blink/renderer/core/layout/layout_box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3106,7 +3106,7 @@ bool LayoutBox::SkipContainingBlockForPercentHeightCalculation(
!containing_block->IsOutOfFlowPositioned() &&
!containing_block->IsLayoutNGGrid() &&
!containing_block->IsFlexibleBoxIncludingNG() &&
!containing_block->IsLayoutNGCustom();
!containing_block->IsLayoutCustom();
}

LayoutUnit LayoutBox::ContainingBlockLogicalHeightForPositioned(
Expand Down Expand Up @@ -3286,7 +3286,7 @@ bool LayoutBox::ShouldBeConsideredAsReplaced() const {
// loaded algorithm.
bool LayoutBox::IsCustomItem() const {
NOT_DESTROYED();
auto* parent_layout_box = DynamicTo<LayoutNGCustom>(Parent());
auto* parent_layout_box = DynamicTo<LayoutCustom>(Parent());
return parent_layout_box && parent_layout_box->IsLoaded();
}

Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/layout/layout_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ LayoutObject* LayoutObject::CreateObject(Element* element,
return MakeGarbageCollected<LayoutNGMathMLBlock>(element);
case EDisplay::kLayoutCustom:
case EDisplay::kInlineLayoutCustom:
return MakeGarbageCollected<LayoutNGCustom>(element);
return MakeGarbageCollected<LayoutCustom>(element);
}

NOTREACHED();
Expand Down
6 changes: 3 additions & 3 deletions third_party/blink/renderer/core/layout/layout_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -956,9 +956,9 @@ class CORE_EXPORT LayoutObject : public GarbageCollected<LayoutObject>,
NOT_DESTROYED();
return IsOfType(kLayoutObjectButton);
}
bool IsLayoutNGCustom() const {
bool IsLayoutCustom() const {
NOT_DESTROYED();
return IsOfType(kLayoutObjectNGCustom);
return IsOfType(kLayoutObjectCustom);
}
bool IsLayoutNGGrid() const {
NOT_DESTROYED();
Expand Down Expand Up @@ -3468,6 +3468,7 @@ class CORE_EXPORT LayoutObject : public GarbageCollected<LayoutObject>,
kLayoutObjectButton,
kLayoutObjectCanvas,
kLayoutObjectCounter,
kLayoutObjectCustom,
kLayoutObjectCustomScrollbarPart,
kLayoutObjectEmbeddedObject,
kLayoutObjectFieldset,
Expand All @@ -3485,7 +3486,6 @@ class CORE_EXPORT LayoutObject : public GarbageCollected<LayoutObject>,
kLayoutObjectMultiColumnSet,
kLayoutObjectMultiColumnSpannerPlaceholder,
kLayoutObjectNGBlockFlow,
kLayoutObjectNGCustom,
kLayoutObjectNGFlexibleBox,
kLayoutObjectNGGrid,
kLayoutObjectOutsideListMarker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ void CustomLayoutWorkTask::RunLayoutFragmentTask(
builder.SetReplacedPercentageResolutionSize(percentage_size);
builder.SetIsFixedInlineSize(is_fixed_inline_size);
builder.SetIsFixedBlockSize(is_fixed_block_size);
if (child.IsLayoutNGCustom())
if (child.IsCustom()) {
builder.SetCustomLayoutData(std::move(constraint_data_));
}
auto space = builder.ToConstraintSpace();
auto* result =
To<NGBlockNode>(child).Layout(space, nullptr /* break_token */);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

namespace blink {

LayoutNGCustom::LayoutNGCustom(Element* element)
LayoutCustom::LayoutCustom(Element* element)
: LayoutNGBlockFlow(element), state_(kUnloaded) {
DCHECK(element);
}

void LayoutNGCustom::AddChild(LayoutObject* new_child,
LayoutObject* before_child) {
void LayoutCustom::AddChild(LayoutObject* new_child,
LayoutObject* before_child) {
// Only use the block-flow AddChild logic when we are unloaded, i.e. we
// should behave exactly like a block-flow.
if (state_ == kUnloaded) {
Expand All @@ -26,7 +26,7 @@ void LayoutNGCustom::AddChild(LayoutObject* new_child,
LayoutBlock::AddChild(new_child, before_child);
}

void LayoutNGCustom::RemoveChild(LayoutObject* child) {
void LayoutCustom::RemoveChild(LayoutObject* child) {
// Only use the block-flow RemoveChild logic when we are unloaded, i.e. we
// should behave exactly like a block-flow.
if (state_ == kUnloaded) {
Expand All @@ -36,8 +36,8 @@ void LayoutNGCustom::RemoveChild(LayoutObject* child) {
LayoutBlock::RemoveChild(child);
}

void LayoutNGCustom::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) {
void LayoutCustom::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) {
if (state_ == kUnloaded) {
const AtomicString& name = StyleRef().DisplayLayoutCustomName();
LayoutWorklet* worklet = LayoutWorklet::From(*GetDocument().domWindow());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ namespace blink {
// This class inherits from LayoutNGBlockFlow so that when a web developer's
// intrinsicSizes/layout callback fails, it can fallback onto the "default"
// block-flow layout algorithm.
class LayoutNGCustom final : public LayoutNGBlockFlow {
class LayoutCustom final : public LayoutNGBlockFlow {
public:
// NOTE: In the future there may be a third state "normal", this will mean
// that not everything is blockified, (e.g. root inline boxes, so that
// line-by-line layout can be performed).
enum State { kUnloaded, kBlock };

explicit LayoutNGCustom(Element*);
explicit LayoutCustom(Element*);

const char* GetName() const override {
NOT_DESTROYED();
return "LayoutNGCustom";
return "LayoutCustom";
}
bool CreatesNewFormattingContext() const override {
NOT_DESTROYED();
Expand All @@ -52,16 +52,16 @@ class LayoutNGCustom final : public LayoutNGBlockFlow {
private:
bool IsOfType(LayoutObjectType type) const override {
NOT_DESTROYED();
return type == kLayoutObjectNGCustom || LayoutNGBlockFlow::IsOfType(type);
return type == kLayoutObjectCustom || LayoutNGBlockFlow::IsOfType(type);
}

State state_;
};

template <>
struct DowncastTraits<LayoutNGCustom> {
struct DowncastTraits<LayoutCustom> {
static bool AllowFrom(const LayoutObject& object) {
return object.IsLayoutNGCustom();
return object.IsLayoutCustom();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

namespace blink {

NGCustomLayoutAlgorithm::NGCustomLayoutAlgorithm(
CustomLayoutAlgorithm::CustomLayoutAlgorithm(
const NGLayoutAlgorithmParams& params)
: NGLayoutAlgorithm(params), params_(params) {
DCHECK(params.space.IsNewFormattingContext());
}

MinMaxSizesResult NGCustomLayoutAlgorithm::ComputeMinMaxSizes(
MinMaxSizesResult CustomLayoutAlgorithm::ComputeMinMaxSizes(
const MinMaxSizesFloatInput& input) {
if (!Node().IsCustomLayoutLoaded())
return FallbackMinMaxSizes(input);
Expand Down Expand Up @@ -78,7 +78,7 @@ MinMaxSizesResult NGCustomLayoutAlgorithm::ComputeMinMaxSizes(
return MinMaxSizesResult(sizes, depends_on_block_constraints);
}

const NGLayoutResult* NGCustomLayoutAlgorithm::Layout() {
const NGLayoutResult* CustomLayoutAlgorithm::Layout() {
DCHECK(!IsBreakInside(BreakToken()));

if (!Node().IsCustomLayoutLoaded())
Expand Down Expand Up @@ -191,7 +191,7 @@ const NGLayoutResult* NGCustomLayoutAlgorithm::Layout() {
// OOF-positioned, adds them as a candidate, then proceeds to the next child.
//
// |child| will end up being the next inflow child, or empty.
void NGCustomLayoutAlgorithm::AddAnyOutOfFlowPositionedChildren(
void CustomLayoutAlgorithm::AddAnyOutOfFlowPositionedChildren(
NGLayoutInputNode* child) {
DCHECK(child);
while (*child && child->IsOutOfFlowPositioned()) {
Expand All @@ -201,12 +201,12 @@ void NGCustomLayoutAlgorithm::AddAnyOutOfFlowPositionedChildren(
}
}

MinMaxSizesResult NGCustomLayoutAlgorithm::FallbackMinMaxSizes(
MinMaxSizesResult CustomLayoutAlgorithm::FallbackMinMaxSizes(
const MinMaxSizesFloatInput& input) const {
return NGBlockLayoutAlgorithm(params_).ComputeMinMaxSizes(input);
}

const NGLayoutResult* NGCustomLayoutAlgorithm::FallbackLayout() {
const NGLayoutResult* CustomLayoutAlgorithm::FallbackLayout() {
return NGBlockLayoutAlgorithm(params_).Layout();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace blink {

class NGBlockBreakToken;

class CORE_EXPORT NGCustomLayoutAlgorithm
class CORE_EXPORT CustomLayoutAlgorithm
: public NGLayoutAlgorithm<NGBlockNode,
NGBoxFragmentBuilder,
NGBlockBreakToken> {
public:
NGCustomLayoutAlgorithm(const NGLayoutAlgorithmParams& params);
explicit CustomLayoutAlgorithm(const NGLayoutAlgorithmParams& params);

MinMaxSizesResult ComputeMinMaxSizes(const MinMaxSizesFloatInput&) override;
const NGLayoutResult* Layout() override;
Expand Down
7 changes: 3 additions & 4 deletions third_party/blink/renderer/core/layout/ng/ng_block_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ NOINLINE void DetermineAlgorithmAndRun(const NGLayoutAlgorithmParams& params,
CreateAlgorithmAndRun<NGTableRowLayoutAlgorithm>(params, callback);
} else if (box.IsTableSection()) {
CreateAlgorithmAndRun<NGTableSectionLayoutAlgorithm>(params, callback);
} else if (box.IsLayoutNGCustom()) {
CreateAlgorithmAndRun<NGCustomLayoutAlgorithm>(params, callback);
} else if (box.IsLayoutCustom()) {
CreateAlgorithmAndRun<CustomLayoutAlgorithm>(params, callback);
} else if (box.IsMathML()) {
DetermineMathMLAlgorithmAndRun(box, params, callback);
} else if (box.IsLayoutNGGrid()) {
Expand Down Expand Up @@ -1705,8 +1705,7 @@ bool NGBlockNode::HasNonVisibleBlockOverflow() const {
}

bool NGBlockNode::IsCustomLayoutLoaded() const {
DCHECK(box_->IsLayoutNGCustom());
return To<LayoutNGCustom>(box_.Get())->IsLoaded();
return To<LayoutCustom>(box_.Get())->IsLoaded();
}

MathScriptType NGBlockNode::ScriptType() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ class CORE_EXPORT NGLayoutInputNode {

bool IsBlockFlow() const { return IsBlock() && box_->IsLayoutBlockFlow(); }
bool IsBlockInInline() const { return box_->IsBlockInInline(); }
bool IsLayoutNGCustom() const {
return IsBlock() && box_->IsLayoutNGCustom();
}
bool IsCustom() const { return IsBlock() && box_->IsLayoutCustom(); }
bool IsColumnSpanAll() const { return IsBlock() && box_->IsColumnSpanAll(); }
bool IsFloating() const { return IsBlock() && box_->IsFloating(); }
bool IsOutOfFlowPositioned() const {
Expand Down
3 changes: 2 additions & 1 deletion third_party/blink/renderer/core/layout/ng/ng_layout_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ NGLayoutCacheStatus CalculateSizeBasedLayoutCacheStatusWithGeometry(

if (!is_block_size_equal) {
// Only block-flow supports changing the block-size for simplified layout.
if (!node.IsBlockFlow() || node.IsLayoutNGCustom())
if (!node.IsBlockFlow() || node.IsCustom()) {
return NGLayoutCacheStatus::kNeedsLayout;
}

// Fieldsets stretch their content to the final block-size, which might
// affect scrollbars.
Expand Down

0 comments on commit fcb0b0d

Please sign in to comment.