Commit dc9f9f49 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[FlexNG] Update hittest with flexbox if we hit an anon flex-item.

Previously if we hit an anonymous flex-item we wouldn't update the
hit-test result with the flexbox itself.

This updates the hit-test with the flexbox if no node is set yet.

Bug: 1097654
Change-Id: I4b9d1754061aae14dd8fa6a9f33d8d065c838db6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2264017Reviewed-by: default avatarDavid Grogan <dgrogan@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782059}
parent 72f9045d
......@@ -2212,25 +2212,26 @@ bool NGBoxFragmentPainter::HitTestBlockChildren(
const PhysicalOffset child_offset = accumulated_offset + child.offset;
if (block_child.IsPaintedAtomically()) {
if (HitTestAllPhasesInFragment(block_child, hit_test_location,
child_offset, &result)) {
if (const LayoutObject* child_object = block_child.GetLayoutObject()) {
child_object->UpdateHitTestResult(
result, hit_test_location.Point() - accumulated_offset);
}
return true;
}
continue;
}
if (NodeAtPointInFragment(block_child, hit_test_location, child_offset,
action, &result)) {
bool hit_child =
block_child.IsPaintedAtomically()
? HitTestAllPhasesInFragment(block_child, hit_test_location,
child_offset, &result)
: NodeAtPointInFragment(block_child, hit_test_location,
child_offset, action, &result);
if (hit_child) {
if (const LayoutObject* child_object = block_child.GetLayoutObject()) {
child_object->UpdateHitTestResult(
result, hit_test_location.Point() - accumulated_offset);
}
// Our child may have been an anonymous-block, update the hit-test node
// to include our node if needed.
if (const LayoutObject* object = box_fragment_.GetLayoutObject()) {
object->UpdateHitTestResult(
result, hit_test_location.Point() - accumulated_offset);
}
return true;
}
}
......
<!DOCTYPE html>
<link rel="help" href="https://crbug.com/1097654" />
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#target {
font: 20px/1 Ahem;
display: flex;
flex-direction: column;
border: 2px solid black;
width: 100px;
height: 100px;
}
</style>
<div id=target>X</div>
<script>
test(function(t) {
const target = document.getElementById('target');
assert_equals(target, document.elementFromPoint(30, 10));
}, 'Hit-testing within an anonymous flex-item should return the flexbox as the hittest result.');
</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