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

[FragmentItem] Implement LayoutInline::NodeAtPoint

This patch implements |LayoutInline::NodeAtPoint| by
replacing |NGPaintFragment::InlineFragmentsFor| with
|NGInlineCursor|.

Fixes ~6 tests.

Bug: 982194
Change-Id: Id327810033008499593e27553b225e4e3758e84c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2022447Reviewed-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@{#735719}
parent a1f57882
...@@ -1046,14 +1046,31 @@ bool LayoutInline::NodeAtPoint(HitTestResult& result, ...@@ -1046,14 +1046,31 @@ bool LayoutInline::NodeAtPoint(HitTestResult& result,
// PaintLayer::HitTestContents() without going through any ancestor, in // PaintLayer::HitTestContents() without going through any ancestor, in
// which case the element must have self painting layer. // which case the element must have self painting layer.
DCHECK(HasSelfPaintingLayer()); DCHECK(HasSelfPaintingLayer());
for (const NGPaintFragment* fragment : NGInlineCursor cursor;
NGPaintFragment::InlineFragmentsFor(this)) { for (cursor.MoveTo(*this); cursor; cursor.MoveToNextForSameLayoutObject()) {
if (const NGPaintFragment* paint_fragment =
cursor.Current().PaintFragment()) {
// NGBoxFragmentPainter::NodeAtPoint() takes an offset that is
// accumulated up to the fragment itself. Compute this offset.
const PhysicalOffset child_offset =
accumulated_offset + paint_fragment->InlineOffsetToContainerBox();
if (NGBoxFragmentPainter(*paint_fragment)
.NodeAtPoint(result, hit_test_location, child_offset,
hit_test_action))
return true;
continue;
}
DCHECK(cursor.Current().Item());
const NGFragmentItem& item = *cursor.Current().Item();
const NGPhysicalBoxFragment* box_fragment = item.BoxFragment();
DCHECK(box_fragment);
NGInlineCursor descendants = cursor.CursorForDescendants();
// NGBoxFragmentPainter::NodeAtPoint() takes an offset that is accumulated // NGBoxFragmentPainter::NodeAtPoint() takes an offset that is accumulated
// up to the fragment itself. Compute this offset. // up to the fragment itself. Compute this offset.
PhysicalOffset adjusted_location = const PhysicalOffset child_offset = accumulated_offset + item.Offset();
accumulated_offset + fragment->InlineOffsetToContainerBox(); if (NGBoxFragmentPainter(item, *box_fragment, &descendants)
if (NGBoxFragmentPainter(*fragment).NodeAtPoint( .NodeAtPoint(result, hit_test_location, child_offset,
result, hit_test_location, adjusted_location, hit_test_action)) hit_test_action))
return true; return true;
} }
return false; return false;
......
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