Commit 1cb0d64a authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Don't hit-test floats in a different layer.

Hit-testing should never enter a child that establishes a self-painting
layer.

Also added a couple of local variables to make it slightly easier to
read.

Change-Id: I2854cb1b677f8eb164befe1577e7de2740735538
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036104Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738493}
parent 6a8b54a9
...@@ -2010,21 +2010,25 @@ bool NGBoxFragmentPainter::HitTestFloatingChildren( ...@@ -2010,21 +2010,25 @@ bool NGBoxFragmentPainter::HitTestFloatingChildren(
DCHECK(container.HasFloatingDescendantsForPaint()); DCHECK(container.HasFloatingDescendantsForPaint());
auto children = container.Children(); auto children = container.Children();
for (const NGLink& child : base::Reversed(children)) { for (const NGLink& child : base::Reversed(children)) {
if (child->IsFloating()) { const NGPhysicalFragment& child_fragment = *child.fragment;
if (HitTestAllPhases(hit_test, *child, if (child_fragment.HasSelfPaintingLayer())
accumulated_offset + child.Offset())) continue;
const PhysicalOffset child_offset = accumulated_offset + child.offset;
if (child_fragment.IsFloating()) {
if (HitTestAllPhases(hit_test, child_fragment, child_offset))
return true; return true;
continue; continue;
} }
if (child->IsBlockFormattingContextRoot()) if (child_fragment.IsBlockFormattingContextRoot())
continue; continue;
if (const auto* child_container = if (const auto* child_container =
DynamicTo<NGPhysicalContainerFragment>(child.get())) { DynamicTo<NGPhysicalContainerFragment>(&child_fragment)) {
if (child_container->HasFloatingDescendantsForPaint() && if (child_container->HasFloatingDescendantsForPaint() &&
HitTestFloatingChildren(hit_test, *child_container, HitTestFloatingChildren(hit_test, *child_container, child_offset))
accumulated_offset + child.Offset()))
return true; return true;
} }
} }
......
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/CSS22/visuren.html#floats">
<link rel="help" href="https://www.w3.org/TR/CSS22/zindex.html">
<div id="target" style="width:100px; height:100px;">
<div id="error" style="float:left; position:relative; z-index:-1; width:100px; height:100px;"></div>
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(()=> {
var elm = document.elementFromPoint(50, 50);
assert_equals(elm.id, "target");
}, "Miss float below something else");
</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