Commit 78eb43f6 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Fix hit-testing culled inline for atomic inlines

This pathc fixes hit-testing [culled inline] in the following
conditions:
a. The first fragment does not fit, but it is an atomic
   inline that it cannot be truncated.
b. The atomic inline is within a culled inline.

The culled inline algorithm relies on fragments from a
|LayoutObject| appear in a row. Ellipsis for an atomic
inline has the same |LayoutObject| as the atomic inline,
but can appear at the top level.

This patch fixes this by eliminating ellipsis from
culled inline logic.

[culled inline]: https://chromium.googlesource.com/chromium/src/+/master/third_party/blink/renderer/core/layout/ng/inline/README.md#culled

Bug: 1104477
Change-Id: Ib0f7e5899e58c766554c78ddf45019deaf35ca96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2318887
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791691}
parent c3b9e3c9
...@@ -171,6 +171,10 @@ bool HitTestCulledInlineAncestors( ...@@ -171,6 +171,10 @@ bool HitTestCulledInlineAncestors(
const PhysicalOffset& physical_offset) { const PhysicalOffset& physical_offset) {
DCHECK(fragment.Parent()); DCHECK(fragment.Parent());
DCHECK(fragment.PhysicalFragment().IsInline()); DCHECK(fragment.PhysicalFragment().IsInline());
// Ellipsis can appear under a different parent from the ellipsized object
// that it can confuse culled inline logic.
if (UNLIKELY(fragment.IsEllipsis()))
return false;
const NGPaintFragment& parent = *fragment.Parent(); const NGPaintFragment& parent = *fragment.Parent();
// To be passed as |accumulated_offset| to LayoutInline::HitTestCulledInline, // To be passed as |accumulated_offset| to LayoutInline::HitTestCulledInline,
// where it equals the physical offset of the containing block in paint layer. // where it equals the physical offset of the containing block in paint layer.
...@@ -192,6 +196,10 @@ bool HitTestCulledInlineAncestors( ...@@ -192,6 +196,10 @@ bool HitTestCulledInlineAncestors(
const NGInlineCursorPosition& previous_sibling, const NGInlineCursorPosition& previous_sibling,
const HitTestLocation& hit_test_location, const HitTestLocation& hit_test_location,
const PhysicalOffset& physical_offset) { const PhysicalOffset& physical_offset) {
// Ellipsis can appear under a different parent from the ellipsized object
// that it can confuse culled inline logic.
if (UNLIKELY(item.IsEllipsis()))
return false;
// To be passed as |accumulated_offset| to LayoutInline::HitTestCulledInline, // To be passed as |accumulated_offset| to LayoutInline::HitTestCulledInline,
// where it equals the physical offset of the containing block in paint layer. // where it equals the physical offset of the containing block in paint layer.
const PhysicalOffset fallback_accumulated_offset = const PhysicalOffset fallback_accumulated_offset =
......
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-document-elementfrompoint" />
<link rel="author" title="Koji Ishii" href="mailto:kojii@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div style="width: 100px">
<div>
<span><span class="item" style="display: inline-block">XXXXXXXXXXXXXXXXXXXX</span></span>
</div>
<div class="ellipsis">
<span><span class="item" style="display: inline-block">XXXXXXXXXXXXXXXXXXXX</span></span>
</div>
<div class="ellipsis">
<span><span class="item" style="display: inline-flex;">XXXXXXXXXXXXXXXXXXXX</span></span>
</div>
</div>
<div id="log"></div>
<script>
for (const item of document.getElementsByClassName('item')) {
test(() => {
const bounds = item.getBoundingClientRect();
const result = document.elementFromPoint(bounds.x + 10, bounds.y + bounds.height / 2);
assert_equals(result, item);
});
}
</script>
</body>
</html>
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