Commit abaa9a02 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Chromium LUCI CQ

Remove DCHECK from NGPhysicalBoxFragment::PositionForPoint().

We *should* indeed consider moving the code for handling hits outside of
atomic inlines, but NGPhysicalBoxFragment::PositionForPoint() isn't the
right place for it. If we have an inline-block with a child text node
that overflows it, and we hit such overflowing text, we'll perform
NGPhysicalBoxFragment::PositionForPoint() directly on the inline block
(from HitTestResult::GetPosition()), even if it's the text that we hit.
We cannot require that we are within the border box of the inline-block
in such cases. This check needs to be performed before entering
non-atomic inline children - probably in
NGInlineCursor::PositionForPointInChild(). At some point, that code
should stop calling LayoutObject::PositionForPoint(), and rather call
NGPhysicalBoxFragment::PositionForPoint(). That would be a good time to
clean up this.

Bug: 1155948
Change-Id: I0391f87d4bbf97c7cdd6a15ab2648aefa2d2abbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2577199Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834365}
parent 26e8adfe
......@@ -835,14 +835,6 @@ PositionWithAffinity NGPhysicalBoxFragment::PositionForPoint(
return layout_object_->PositionForPoint(point);
}
// TODO(layout-dev): Handle situations where we're near (but not within)
// atomic inlines here, rather than relying on it being taken care of by the
// layout object. This is currently handled in LayoutBlock and
// LayoutNGBlockFlowMixin - look for
// PositionForPointIfOutsideAtomicInlineLevel().
DCHECK(!IsAtomicInline() ||
PhysicalRect(PhysicalOffset(), Size()).Contains(point));
if (IsScrollContainer())
point += PhysicalOffset(PixelSnappedScrolledContentOffset());
......
<!DOCTYPE html>
<style>
body { margin:0; }
#ib { display:inline-block; width:100px; height:10px; line-height:50px; }
</style>
<div id="ib">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X</div>
<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>
<script>
test(()=> {
// At the beginning of the second line, which overflows #ib. Hit the 'X'.
assert_equals(document.caretRangeFromPoint(0, 75).startOffset, 41);
// At the end of the second line. Nothing there.
assert_equals(document.caretRangeFromPoint(90, 75).startOffset, 1);
assert_equals(document.caretRangeFromPoint(90, 75).startContainer, ib);
}, "Just outside an atomic inline");
</script>
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