Commit 145b4c7e authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[FragmentItem] Support hit-testing culled inline boxes

This patch supports hit-testing culled inline boxes by
leveraging |NGFragmentItem| generated for them by
<crrev.com/c/1774425>.

This patch recovers the most of regressions in the CL, in
addition to fixing ~70 failures.

Bug: 982194
Change-Id: I094a77440e5040fcd5a2d8f864c4d95d85925fd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1989727
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729662}
parent 02ed2f72
......@@ -1708,6 +1708,27 @@ bool NGBoxFragmentPainter::HitTestChildBoxFragment(
physical_offset, hit_test.action);
}
bool NGBoxFragmentPainter::HitTestChildBoxItem(
const HitTestContext& hit_test,
const NGFragmentItem& item,
const NGInlineBackwardCursor& cursor) {
DCHECK_EQ(&item, cursor.CurrentItem());
if (const NGPhysicalBoxFragment* child_fragment = item.BoxFragment()) {
const PhysicalOffset child_offset =
hit_test.inline_root_offset + item.Offset();
return HitTestChildBoxFragment(hit_test, *child_fragment, cursor,
child_offset);
}
DCHECK(item.GetLayoutObject()->IsLayoutInline());
DCHECK(!ToLayoutInline(item.GetLayoutObject())->ShouldCreateBoxFragment());
if (NGInlineCursor descendants = cursor.CursorForDescendants())
return HitTestItemsChildren(hit_test, descendants);
return false;
}
bool NGBoxFragmentPainter::HitTestChildren(
const HitTestContext& hit_test,
const PhysicalOffset& accumulated_offset) {
......@@ -1813,20 +1834,13 @@ bool NGBoxFragmentPainter::HitTestItemsChildren(
child_offset))
return true;
} else if (item->Type() == NGFragmentItem::kBox) {
if (const NGPhysicalBoxFragment* child_fragment = item->BoxFragment()) {
const PhysicalOffset child_offset =
hit_test.inline_root_offset + item->Offset();
if (HitTestChildBoxFragment(hit_test, *child_fragment, cursor,
child_offset))
return true;
}
if (HitTestChildBoxItem(hit_test, *item, cursor))
return true;
} else {
NOTREACHED();
}
cursor.MoveToPreviousSibling();
// TODO(kojii): Implement hit-testing culled inline box.
}
return false;
......
......@@ -210,6 +210,9 @@ class NGBoxFragmentPainter : public BoxPainterBase {
const NGPhysicalBoxFragment& fragment,
const NGInlineBackwardCursor& cursor,
const PhysicalOffset& physical_offset);
bool HitTestChildBoxItem(const HitTestContext& hit_test,
const NGFragmentItem& item,
const NGInlineBackwardCursor& cursor);
// Hit tests the given text fragment.
// @param physical_offset Physical offset of the text fragment in paint layer.
......
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