Commit 0fed0254 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Reland "[LayoutNG] Snap bounds rect to pixel before hit testing inline boxes"

This is a reland of f2dd14b6

The original patch snapped bounds for inline box, text run,
and line box. Snapping inlne box matches to legacy, but it
missed that legacy doesn't snap text run, and doing so
regressed following test on Mac:
  external/wpt/intersection-observer/v2/inline-occlusion.html

This patch limits the snapping only to inline box.

Original change's description:
> [LayoutNG] Snap bounds rect to pixel before hit testing inline boxes
>
> This patch fixes inline hit-testing by snapping bounds rect
> only for inline boxes. The behavior matches to legacy.
>
> Bug: 976606
> Change-Id: I2532fd3d3439ec5e0bc3f73408b9cdc9b5454a7d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1676564
> Commit-Queue: Koji Ishii <kojii@chromium.org>
> Reviewed-by: Emil A Eklund <eae@chromium.org>
> Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#672419}

TBR=eae@chromium.org, wangxianzhu@chromium.org

Bug: 976606
Change-Id: I4fb6d08db01d736eb3e229f4e3054e401518448b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1677350Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672469}
parent 4de815ef
...@@ -986,6 +986,7 @@ bool NGBoxFragmentPainter::NodeAtPoint(HitTestResult& result, ...@@ -986,6 +986,7 @@ bool NGBoxFragmentPainter::NodeAtPoint(HitTestResult& result,
const HitTestLocation& hit_test_location, const HitTestLocation& hit_test_location,
const PhysicalOffset& physical_offset, const PhysicalOffset& physical_offset,
HitTestAction action) { HitTestAction action) {
const NGPhysicalBoxFragment& fragment = PhysicalFragment();
const PhysicalSize& size = box_fragment_.Size(); const PhysicalSize& size = box_fragment_.Size();
const ComputedStyle& style = box_fragment_.Style(); const ComputedStyle& style = box_fragment_.Style();
...@@ -1039,6 +1040,10 @@ bool NGBoxFragmentPainter::NodeAtPoint(HitTestResult& result, ...@@ -1039,6 +1040,10 @@ bool NGBoxFragmentPainter::NodeAtPoint(HitTestResult& result,
bounds_rect = box_fragment_.SelfInkOverflow(); bounds_rect = box_fragment_.SelfInkOverflow();
bounds_rect.Move(physical_offset); bounds_rect.Move(physical_offset);
} }
// TODO(kojii): Don't have good explanation why only inline box needs to
// snap, but matches to legacy and fixes crbug.com/976606.
if (fragment.IsInlineBox())
bounds_rect = PhysicalRect(PixelSnappedIntRect(bounds_rect));
if (hit_test_location.Intersects(bounds_rect)) { if (hit_test_location.Intersects(bounds_rect)) {
Node* node = box_fragment_.NodeForHitTest(); Node* node = box_fragment_.NodeForHitTest();
if (!result.InnerNode() && node) { if (!result.InnerNode() && node) {
......
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