Commit 5553ca2e authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Cleanup how NGBlockNode sets/clears cached resluts and paint fragments

This patch cleans up how NGBlockNode sets/clears cached
results and paint fragments, reducing an "if" and avoiding
to clear paint fragment if we're going to update.

No behavior changes.

Bug: 714962
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I462a8d1632cb2bd6b2cef2fa4cb71493a97b4160
Reviewed-on: https://chromium-review.googlesource.com/1175749Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586655}
parent b87d6c9d
...@@ -233,35 +233,31 @@ void NGBlockNode::FinishLayout(const NGConstraintSpace& constraint_space, ...@@ -233,35 +233,31 @@ void NGBlockNode::FinishLayout(const NGConstraintSpace& constraint_space,
if (!IsBlockLayoutComplete(constraint_space, *layout_result)) if (!IsBlockLayoutComplete(constraint_space, *layout_result))
return; return;
// TODO(kojii): Even when we paint fragments, there seem to be some data we DCHECK(layout_result->PhysicalFragment());
// need to copy to LayoutBox. Review if we can minimize the copy.
LayoutBlockFlow* block_flow = if (box_->IsLayoutNGMixin()) {
box_->IsLayoutNGMixin() ? ToLayoutBlockFlow(box_) : nullptr; LayoutBlockFlow* block_flow = ToLayoutBlockFlow(box_);
if (block_flow) {
block_flow->SetCachedLayoutResult(constraint_space, break_token, block_flow->SetCachedLayoutResult(constraint_space, break_token,
layout_result); layout_result);
if (layout_result->Status() == NGLayoutResult::kSuccess &&
!constraint_space.IsIntermediateLayout())
block_flow->SetPaintFragment(break_token, nullptr);
}
DCHECK(layout_result->PhysicalFragment()); NGLayoutInputNode first_child = FirstChild();
if (first_child && first_child.IsInline()) {
NGLayoutInputNode first_child = FirstChild(); NGBoxStrut scrollbars = GetScrollbarSizes();
if (block_flow && first_child && first_child.IsInline()) { CopyFragmentDataToLayoutBoxForInlineChildren(
NGBoxStrut scrollbars = GetScrollbarSizes(); ToNGPhysicalBoxFragment(*layout_result->PhysicalFragment()),
CopyFragmentDataToLayoutBoxForInlineChildren( layout_result->PhysicalFragment()->Size().width -
ToNGPhysicalBoxFragment(*layout_result->PhysicalFragment()), scrollbars.block_start,
layout_result->PhysicalFragment()->Size().width - Style().IsFlippedBlocksWritingMode());
scrollbars.block_start,
Style().IsFlippedBlocksWritingMode()); block_flow->SetPaintFragment(break_token,
layout_result->PhysicalFragment());
block_flow->SetPaintFragment(break_token, } else {
layout_result->PhysicalFragment()); // We still need to clear paint fragments in case it had inline children,
// and thus had NGPaintFragment.
block_flow->SetPaintFragment(break_token, nullptr);
}
} }
// TODO(kojii): Even when we paint fragments, there seem to be some data we
// need to copy to LayoutBox. Review if we can minimize the copy.
CopyFragmentDataToLayoutBox(constraint_space, *layout_result); CopyFragmentDataToLayoutBox(constraint_space, *layout_result);
} }
......
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