Commit f379945e authored by Koji Ishii's avatar Koji Ishii Committed by Chromium LUCI CQ

Eliminate |CurrentFragment| from |LayoutNGMixin|

Applies the same changes as |LayoutNGBlockFlowMixin|.

This patch should have no behavior changes.

Bug: 1061423
Change-Id: Id33a5fdda4c05dd3e4f16e8e16727a963da3a9cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2567055
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832329}
parent 621d7d12
...@@ -36,6 +36,14 @@ LayoutNGMixin<Base>::~LayoutNGMixin() = default; ...@@ -36,6 +36,14 @@ LayoutNGMixin<Base>::~LayoutNGMixin() = default;
template <typename Base> template <typename Base>
void LayoutNGMixin<Base>::Paint(const PaintInfo& paint_info) const { void LayoutNGMixin<Base>::Paint(const PaintInfo& paint_info) const {
// When |this| is NG block fragmented, the painter should traverse fragments
// instead of |LayoutObject|, because this function cannot handle block
// fragmented objects. We can come here only when |this| cannot traverse
// fragments, or the parent is legacy.
DCHECK(!Base::CanTraversePhysicalFragments() ||
!Base::Parent()->CanTraversePhysicalFragments());
DCHECK_LE(Base::PhysicalFragmentCount(), 1u);
// Avoid painting dirty objects because descendants maybe already destroyed. // Avoid painting dirty objects because descendants maybe already destroyed.
if (UNLIKELY(Base::NeedsLayout() && if (UNLIKELY(Base::NeedsLayout() &&
!Base::ChildLayoutBlockedByDisplayLock())) { !Base::ChildLayoutBlockedByDisplayLock())) {
...@@ -43,8 +51,11 @@ void LayoutNGMixin<Base>::Paint(const PaintInfo& paint_info) const { ...@@ -43,8 +51,11 @@ void LayoutNGMixin<Base>::Paint(const PaintInfo& paint_info) const {
return; return;
} }
if (const NGPhysicalBoxFragment* fragment = CurrentFragment()) if (Base::PhysicalFragmentCount()) {
const NGPhysicalBoxFragment* fragment = Base::GetPhysicalFragment(0);
DCHECK(fragment);
NGBoxFragmentPainter(*fragment).Paint(paint_info); NGBoxFragmentPainter(*fragment).Paint(paint_info);
}
} }
template <typename Base> template <typename Base>
...@@ -52,8 +63,14 @@ bool LayoutNGMixin<Base>::NodeAtPoint(HitTestResult& result, ...@@ -52,8 +63,14 @@ bool LayoutNGMixin<Base>::NodeAtPoint(HitTestResult& result,
const HitTestLocation& hit_test_location, const HitTestLocation& hit_test_location,
const PhysicalOffset& accumulated_offset, const PhysicalOffset& accumulated_offset,
HitTestAction action) { HitTestAction action) {
if (const NGPhysicalBoxFragment* fragment = CurrentFragment()) { // See |Paint()|.
DCHECK_EQ(Base::PhysicalFragmentCount(), 1u); DCHECK(!Base::CanTraversePhysicalFragments() ||
!Base::Parent()->CanTraversePhysicalFragments());
DCHECK_LE(Base::PhysicalFragmentCount(), 1u);
if (Base::PhysicalFragmentCount()) {
const NGPhysicalBoxFragment* fragment = Base::GetPhysicalFragment(0);
DCHECK(fragment);
return NGBoxFragmentPainter(*fragment).NodeAtPoint( return NGBoxFragmentPainter(*fragment).NodeAtPoint(
result, hit_test_location, accumulated_offset, action); result, hit_test_location, accumulated_offset, action);
} }
......
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