Commit 0f6f00ac authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Restore "same layer" check in CalculateRectsWithGeometryMapper

If the root layer and the "current" layer are the same, we can't really
guarantee that the "pre"-transform is the same as the "local border
box"-transform - for example in the case where we're performing a hit-
test from/under a foreignObject element which has a 'transform' applied.

Bug: 908570
Change-Id: Icbaf3c15ca7b483f8209d5d0cc8b4613d80d49ce
Reviewed-on: https://chromium-review.googlesource.com/c/1355184
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612643}
parent 561c9646
...@@ -281,12 +281,16 @@ void PaintLayerClipper::CalculateRectsWithGeometryMapper( ...@@ -281,12 +281,16 @@ void PaintLayerClipper::CalculateRectsWithGeometryMapper(
layer_bounds.SetLocation(*offset_from_root); layer_bounds.SetLocation(*offset_from_root);
} else { } else {
layer_bounds.SetLocation(LayoutPoint(context.sub_pixel_accumulation)); layer_bounds.SetLocation(LayoutPoint(context.sub_pixel_accumulation));
layer_bounds.MoveBy(fragment_data.PaintOffset()); if (&layer_ == context.root_layer) {
GeometryMapper::SourceToDestinationRect( DCHECK_EQ(&fragment_data, context.root_fragment);
fragment_data.PreTransform(), } else {
context.root_fragment->LocalBorderBoxProperties().Transform(), layer_bounds.MoveBy(fragment_data.PaintOffset());
layer_bounds); GeometryMapper::SourceToDestinationRect(
layer_bounds.MoveBy(-context.root_fragment->PaintOffset()); fragment_data.PreTransform(),
context.root_fragment->LocalBorderBoxProperties().Transform(),
layer_bounds);
layer_bounds.MoveBy(-context.root_fragment->PaintOffset());
}
} }
CalculateBackgroundClipRectWithGeometryMapper( CalculateBackgroundClipRectWithGeometryMapper(
......
...@@ -877,10 +877,6 @@ TEST_F(PaintLayerClipperTest, ScrollbarClipBehaviorParent) { ...@@ -877,10 +877,6 @@ TEST_F(PaintLayerClipperTest, ScrollbarClipBehaviorParent) {
PaintLayer* parent_paint_layer = PaintLayer* parent_paint_layer =
ToLayoutBoxModelObject(parent->GetLayoutObject())->Layer(); ToLayoutBoxModelObject(parent->GetLayoutObject())->Layer();
Element* child = GetDocument().getElementById("child");
PaintLayer* child_paint_layer =
ToLayoutBoxModelObject(child->GetLayoutObject())->Layer();
ClipRectsContext context( ClipRectsContext context(
parent_paint_layer, parent_paint_layer,
&parent_paint_layer->GetLayoutObject().FirstFragment(), &parent_paint_layer->GetLayoutObject().FirstFragment(),
...@@ -890,7 +886,7 @@ TEST_F(PaintLayerClipperTest, ScrollbarClipBehaviorParent) { ...@@ -890,7 +886,7 @@ TEST_F(PaintLayerClipperTest, ScrollbarClipBehaviorParent) {
ClipRect background_rect, foreground_rect; ClipRect background_rect, foreground_rect;
parent_paint_layer->Clipper(PaintLayer::kUseGeometryMapper) parent_paint_layer->Clipper(PaintLayer::kUseGeometryMapper)
.CalculateRects(context, .CalculateRects(context,
&child_paint_layer->GetLayoutObject().FirstFragment(), &parent_paint_layer->GetLayoutObject().FirstFragment(),
nullptr, layer_bounds, background_rect, foreground_rect); nullptr, layer_bounds, background_rect, foreground_rect);
// Only the foreground is clipped by the scrollbar size, because we // Only the foreground is clipped by the scrollbar size, because we
......
<!DOCTYPE html>
<title>Hit-test on contents of transformed foreignObject</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<svg>
<foreignObject width="100" height="100" transform="translate(100, 0)">
<div id="target" style="width: 100px; height: 100px; background-color: blue"></div>
</foreignObject>
</svg>
<script>
test(function() {
assert_equals(document.elementFromPoint(150, 50), target);
});
</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