Commit 9f9dc574 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[FragmentItem] Replace NGPaintFragment in HitTestCulledInline

This patch replaces |NGPaintFragment| with |NGInlineCursor|
in |LayoutInline::HitTestCulledInline|. The parent cursor
needed here is available up in the call stack, plumbing is
needed to pass it down.

This is in preparation to support culled inline box in
|NGFragmentItem|.

This patch has no behavior changes.

Bug: 982194
Change-Id: Ic06b4d0669ab47e01fbace9dd5071fa3806f9181
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2164365Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762696}
parent 12ddc921
...@@ -1101,12 +1101,11 @@ bool LayoutInline::NodeAtPoint(HitTestResult& result, ...@@ -1101,12 +1101,11 @@ bool LayoutInline::NodeAtPoint(HitTestResult& result,
hit_test_action); hit_test_action);
} }
bool LayoutInline::HitTestCulledInline( bool LayoutInline::HitTestCulledInline(HitTestResult& result,
HitTestResult& result, const HitTestLocation& hit_test_location,
const HitTestLocation& hit_test_location, const PhysicalOffset& accumulated_offset,
const PhysicalOffset& accumulated_offset, const NGInlineCursor* parent_cursor) {
const NGPaintFragment* container_fragment) { DCHECK(parent_cursor || !AlwaysCreateLineBoxes());
DCHECK(container_fragment || !AlwaysCreateLineBoxes());
if (!VisibleToHitTestRequest(result.GetHitTestRequest())) if (!VisibleToHitTestRequest(result.GetHitTestRequest()))
return false; return false;
...@@ -1124,13 +1123,9 @@ bool LayoutInline::HitTestCulledInline( ...@@ -1124,13 +1123,9 @@ bool LayoutInline::HitTestCulledInline(
// NG generates purely physical rectangles here, while legacy sets the block // NG generates purely physical rectangles here, while legacy sets the block
// offset on the rectangles relatively to the block-start. NG is doing the // offset on the rectangles relatively to the block-start. NG is doing the
// right thing. Legacy is wrong. // right thing. Legacy is wrong.
if (container_fragment) { if (parent_cursor) {
DCHECK(ContainingNGBlockFlow()); DCHECK(ContainingNGBlockFlow());
DCHECK(container_fragment->IsDescendantOfNotSelf( NGInlineCursor cursor(*parent_cursor);
*ContainingNGBlockFlow()->PaintFragment()));
DCHECK(container_fragment->PhysicalFragment().IsInline() ||
container_fragment->PhysicalFragment().IsLineBox());
NGInlineCursor cursor(*container_fragment);
for (cursor.MoveTo(*this); cursor; cursor.MoveToNextForSameLayoutObject()) for (cursor.MoveTo(*this); cursor; cursor.MoveToNextForSameLayoutObject())
yield(cursor.Current().RectInContainerBlock()); yield(cursor.Current().RectInContainerBlock());
} else { } else {
......
...@@ -34,7 +34,9 @@ ...@@ -34,7 +34,9 @@
namespace blink { namespace blink {
class LayoutBlockFlow; class LayoutBlockFlow;
class NGInlineCursor;
class NGPaintFragment; class NGPaintFragment;
// LayoutInline is the LayoutObject associated with display: inline. // LayoutInline is the LayoutObject associated with display: inline.
// This is called an "inline box" in CSS 2.1. // This is called an "inline box" in CSS 2.1.
// http://www.w3.org/TR/CSS2/visuren.html#inline-boxes // http://www.w3.org/TR/CSS2/visuren.html#inline-boxes
...@@ -235,7 +237,7 @@ class CORE_EXPORT LayoutInline : public LayoutBoxModelObject { ...@@ -235,7 +237,7 @@ class CORE_EXPORT LayoutInline : public LayoutBoxModelObject {
bool HitTestCulledInline(HitTestResult&, bool HitTestCulledInline(HitTestResult&,
const HitTestLocation&, const HitTestLocation&,
const PhysicalOffset& accumulated_offset, const PhysicalOffset& accumulated_offset,
const NGPaintFragment* parent_fragment = nullptr); const NGInlineCursor* parent_cursor = nullptr);
PhysicalOffset FirstLineBoxTopLeft() const { PhysicalOffset FirstLineBoxTopLeft() const {
return FirstLineBoxTopLeftInternal().value_or(PhysicalOffset()); return FirstLineBoxTopLeftInternal().value_or(PhysicalOffset());
......
...@@ -151,8 +151,9 @@ TEST_F(LayoutInlineTest, RegionHitTest) { ...@@ -151,8 +151,9 @@ TEST_F(LayoutInlineTest, RegionHitTest) {
const auto* div = To<LayoutBlockFlow>(lots_of_boxes->Parent()); const auto* div = To<LayoutBlockFlow>(lots_of_boxes->Parent());
for (const NGPaintFragment* line : div->PaintFragment()->Children()) { for (const NGPaintFragment* line : div->PaintFragment()->Children()) {
DCHECK(line->PhysicalFragment().IsLineBox()); DCHECK(line->PhysicalFragment().IsLineBox());
bool hit_outcome = lots_of_boxes->HitTestCulledInline(hit_result, location, NGInlineCursor line_cursor(*line);
hit_offset, line); bool hit_outcome = lots_of_boxes->HitTestCulledInline(
hit_result, location, hit_offset, &line_cursor);
EXPECT_FALSE(hit_outcome); EXPECT_FALSE(hit_outcome);
} }
// Make sure that the inline is hit // Make sure that the inline is hit
......
...@@ -97,6 +97,7 @@ bool FragmentVisibleToHitTestRequest(const NGPhysicalFragment& fragment, ...@@ -97,6 +97,7 @@ bool FragmentVisibleToHitTestRequest(const NGPhysicalFragment& fragment,
// box fragments. // box fragments.
// @param physical_offset Physical offset of |fragment| in the paint layer. // @param physical_offset Physical offset of |fragment| in the paint layer.
bool HitTestCulledInlineAncestors(HitTestResult& result, bool HitTestCulledInlineAncestors(HitTestResult& result,
const NGInlineCursor& parent_cursor,
const NGPaintFragment& fragment, const NGPaintFragment& fragment,
const NGPaintFragment* previous_sibling, const NGPaintFragment* previous_sibling,
const HitTestLocation& hit_test_location, const HitTestLocation& hit_test_location,
...@@ -137,7 +138,7 @@ bool HitTestCulledInlineAncestors(HitTestResult& result, ...@@ -137,7 +138,7 @@ bool HitTestCulledInlineAncestors(HitTestResult& result,
if (culled_parent->IsLayoutInline() && if (culled_parent->IsLayoutInline() &&
ToLayoutInline(culled_parent) ToLayoutInline(culled_parent)
->HitTestCulledInline(result, hit_test_location, ->HitTestCulledInline(result, hit_test_location,
fallback_accumulated_offset, &parent)) fallback_accumulated_offset, &parent_cursor))
return true; return true;
current_layout_object = culled_parent; current_layout_object = culled_parent;
...@@ -2121,9 +2122,9 @@ bool NGBoxFragmentPainter::HitTestPaintFragmentChildren( ...@@ -2121,9 +2122,9 @@ bool NGBoxFragmentPainter::HitTestPaintFragmentChildren(
// fragment. // fragment.
const NGPaintFragment* previous_sibling = const NGPaintFragment* previous_sibling =
cursor ? cursor.Current().PaintFragment() : nullptr; cursor ? cursor.Current().PaintFragment() : nullptr;
if (HitTestCulledInlineAncestors(*hit_test.result, *child_paint_fragment, if (HitTestCulledInlineAncestors(*hit_test.result, children,
previous_sibling, hit_test.location, *child_paint_fragment, previous_sibling,
child_offset)) hit_test.location, child_offset))
return true; return true;
} }
} }
......
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