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