Commit d5522e36 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Fix hit testing culled inline when text is fragmented

This patch fixes hit testing culled inline when a text node
(or LayoutText) is fragmented. This can happen for trailing
spaces, `::first-letter`, and a few other cases.

|HitTestCulledInlineAncestors| checks if the current fragment
is the first one in the line, but only by checking
|LayoutObject|, so it fails when a |LayoutObject| is
fragmented. This patch adds check if the current fragment is
from the same |LayoutObject| as the previous sibling.

Bug: 1009042
Change-Id: Id9cd8b834528bda999fb557e0a6f0d2aeec69e4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2262401Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781846}
parent 4e7b9db5
......@@ -280,6 +280,34 @@ TEST_P(ParameterizedLayoutInlineTest, MultilineRelativePositionedHitTest) {
}
}
TEST_P(ParameterizedLayoutInlineTest, HitTestCulledInlinePreWrap) {
SetBodyInnerHTML(R"HTML(
<style>
html, body { margin: 0; }
body {
width: 250px;
}
span {
white-space: pre-wrap;
font: 30px serif;
}
</style>
<div id="container">
<span id="span">The quick brown fox jumps over the lazy dog.</span>
</div>
)HTML");
HitTestRequest hit_request(HitTestRequest::kReadOnly);
PhysicalOffset hit_location(100, 15);
HitTestLocation location(hit_location);
HitTestResult hit_result(hit_request, location);
LayoutObject* container = GetLayoutObjectByElementId("container");
container->HitTestAllPhases(hit_result, location, PhysicalOffset());
Element* span = GetElementById("span");
Node* text_node = span->firstChild();
EXPECT_EQ(hit_result.InnerNode(), text_node);
}
TEST_P(ParameterizedLayoutInlineTest, VisualRectInDocument) {
LoadAhem();
SetBodyInnerHTML(R"HTML(
......
......@@ -125,6 +125,11 @@ bool HitTestCulledInlineAncestors(
const HitTestLocation& hit_test_location,
const PhysicalOffset fallback_accumulated_offset) {
DCHECK(current != limit && current->IsDescendantOf(limit));
// Check ancestors only when |current| is the first fragment in this line.
if (previous_sibling && current == previous_sibling.GetLayoutObject())
return false;
for (LayoutObject* parent = current->Parent(); parent && parent != limit;
current = parent, parent = parent->Parent()) {
// |culled_parent| is a culled inline element to be hit tested, since it's
......
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