Commit 8a492e21 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Make |NGFragmentItems::DirtyLinesFromNeedsLayout| static

This patch changes |NGFragmentItems::DirtyLinesFromNeedsLayout|
to static, matching other |DirtyLines*| in crrev.com/c/2505262.

Also removes two calls to |FragmentItems|, which we need to
eliminate to support block fragmentation, in DCHECK and test.

This patch has no behavior changes.

Bug: 1061423
Change-Id: I13c8ad366935f0d7e2c37230030da8d649259b61
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2505707Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822592}
parent 17833a53
...@@ -62,7 +62,7 @@ class NGFragmentItemTest : public NGLayoutTest, ...@@ -62,7 +62,7 @@ class NGFragmentItemTest : public NGLayoutTest,
LayoutBlockFlow* block_flow = GetLayoutBlockFlowByElementId(id); LayoutBlockFlow* block_flow = GetLayoutBlockFlowByElementId(id);
const NGPhysicalBoxFragment* fragment = block_flow->GetPhysicalFragment(0); const NGPhysicalBoxFragment* fragment = block_flow->GetPhysicalFragment(0);
const NGFragmentItems* items = fragment->Items(); const NGFragmentItems* items = fragment->Items();
items->DirtyLinesFromNeedsLayout(block_flow); NGFragmentItems::DirtyLinesFromNeedsLayout(*block_flow);
const NGFragmentItem* end_reusable_item = const NGFragmentItem* end_reusable_item =
items->EndOfReusableItems(*fragment); items->EndOfReusableItems(*fragment);
......
...@@ -333,19 +333,25 @@ void NGFragmentItems::DirtyFirstItem(const LayoutBlockFlow& container) { ...@@ -333,19 +333,25 @@ void NGFragmentItems::DirtyFirstItem(const LayoutBlockFlow& container) {
} }
} }
// static
void NGFragmentItems::DirtyLinesFromNeedsLayout( void NGFragmentItems::DirtyLinesFromNeedsLayout(
const LayoutBlockFlow* container) const { const LayoutBlockFlow& container) {
DCHECK_EQ(this, container->FragmentItems()); DCHECK(std::any_of(container.PhysicalFragments().begin(),
container.PhysicalFragments().end(),
[](const NGPhysicalBoxFragment& fragment) {
return fragment.HasItems();
}));
// Mark dirty for the first top-level child that has |NeedsLayout|. // Mark dirty for the first top-level child that has |NeedsLayout|.
// //
// TODO(kojii): We could mark first descendant to increase reuse // TODO(kojii): We could mark first descendant to increase reuse
// opportunities. Doing this complicates the logic, especially when culled // opportunities. Doing this complicates the logic, especially when culled
// inline is involved, and common case is to append to large IFC. Choose // inline is involved, and common case is to append to large IFC. Choose
// simpler logic and faster to check over more reuse opportunities. // simpler logic and faster to check over more reuse opportunities.
for (LayoutObject* child = container->FirstChild(); child; for (LayoutObject* child = container.FirstChild(); child;
child = child->NextSibling()) { child = child->NextSibling()) {
if (child->NeedsLayout()) { if (child->NeedsLayout()) {
DirtyLinesFromChangedChild(*child, *container); DirtyLinesFromChangedChild(*child, container);
return; return;
} }
} }
......
...@@ -82,7 +82,7 @@ class CORE_EXPORT NGFragmentItems { ...@@ -82,7 +82,7 @@ class CORE_EXPORT NGFragmentItems {
const LayoutBlockFlow& container); const LayoutBlockFlow& container);
// Mark items dirty from |LayoutObject::NeedsLayout| flags. // Mark items dirty from |LayoutObject::NeedsLayout| flags.
void DirtyLinesFromNeedsLayout(const LayoutBlockFlow* block_flow) const; static void DirtyLinesFromNeedsLayout(const LayoutBlockFlow& block_flow);
// The byte size of this instance. // The byte size of this instance.
constexpr static wtf_size_t ByteSizeFor(wtf_size_t count) { constexpr static wtf_size_t ByteSizeFor(wtf_size_t count) {
......
...@@ -141,16 +141,23 @@ class NGInlineNodeTest : public NGLayoutTest { ...@@ -141,16 +141,23 @@ class NGInlineNodeTest : public NGLayoutTest {
return end_offsets; return end_offsets;
} }
void TestAnyItemsAreDirty(LayoutBlockFlow* block_flow, bool expected) { void TestAnyItemsAreDirty(const LayoutBlockFlow& block_flow, bool expected) {
const NGFragmentItems* items = block_flow->FragmentItems(); NGFragmentItems::DirtyLinesFromNeedsLayout(block_flow);
items->DirtyLinesFromNeedsLayout(block_flow); for (const NGPhysicalBoxFragment& fragment :
// Check |NGFragmentItem::IsDirty| directly without using block_flow.PhysicalFragments()) {
// |EndOfReusableItems|. This is different from the line cache logic, but if (const NGFragmentItems* items = fragment.Items()) {
// some items may not be reusable even if |!IsDirty()|. // Check |NGFragmentItem::IsDirty| directly without using
const bool is_any_items_dirty = // |EndOfReusableItems|. This is different from the line cache logic,
std::any_of(items->Items().begin(), items->Items().end(), // but some items may not be reusable even if |!IsDirty()|.
[](const NGFragmentItem& item) { return item.IsDirty(); }); for (const NGFragmentItem& item : items->Items()) {
EXPECT_EQ(is_any_items_dirty, expected); if (item.IsDirty()) {
EXPECT_TRUE(expected);
return;
}
}
}
}
EXPECT_FALSE(expected);
} }
scoped_refptr<const ComputedStyle> style_; scoped_refptr<const ComputedStyle> style_;
...@@ -686,7 +693,7 @@ TEST_P(StyleChangeTest, NeedsCollectInlinesOnStyle) { ...@@ -686,7 +693,7 @@ TEST_P(StyleChangeTest, NeedsCollectInlinesOnStyle) {
if (data.is_line_dirty && if (data.is_line_dirty &&
RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) { RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) {
TestAnyItemsAreDirty(To<LayoutBlockFlow>(container->GetLayoutObject()), TestAnyItemsAreDirty(*To<LayoutBlockFlow>(container->GetLayoutObject()),
*data.is_line_dirty); *data.is_line_dirty);
} }
......
...@@ -992,7 +992,9 @@ bool NGBlockLayoutAlgorithm::TryReuseFragmentsFromCache( ...@@ -992,7 +992,9 @@ bool NGBlockLayoutAlgorithm::TryReuseFragmentsFromCache(
DCHECK(previous_items); DCHECK(previous_items);
// Find reusable lines. Fail if no items are reusable. // Find reusable lines. Fail if no items are reusable.
previous_items->DirtyLinesFromNeedsLayout(inline_node.GetLayoutBlockFlow()); // TODO(kojii): |DirtyLinesFromNeedsLayout| is needed only once for a
// |LayoutBlockFlow|, not for every fragment.
NGFragmentItems::DirtyLinesFromNeedsLayout(*inline_node.GetLayoutBlockFlow());
const NGFragmentItem* end_item = const NGFragmentItem* end_item =
previous_items->EndOfReusableItems(previous_fragment); previous_items->EndOfReusableItems(previous_fragment);
DCHECK(end_item); DCHECK(end_item);
......
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