| Index: third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp b/third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp
|
| index 5d6d0ec152b6d3e9fa681cbbfa3e917a4e95a49f..20e0a27982c89dbc5f81124de48274d8ccf6afb2 100644
|
| --- a/third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp
|
| +++ b/third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp
|
| @@ -512,4 +512,114 @@ TEST_P(PaintLayerClipperTest, Filter) {
|
| EXPECT_EQ(LayoutRect(0, 0, 100, 200), foreground_rect.Rect());
|
| }
|
|
|
| +// Computed infinite clip rects may not match LayoutRect::InfiniteIntRect()
|
| +// due to floating point errors.
|
| +static bool IsInfinite(const LayoutRect& rect) {
|
| + return rect.X().Round() < -10000000 && rect.MaxX().Round() > 10000000
|
| + && rect.Y().Round() < -10000000 && rect.MaxY().Round() > 10000000;
|
| +}
|
| +
|
| +TEST_P(PaintLayerClipperTest, IgnoreRootLayerClipWithCSSClip) {
|
| + SetBodyInnerHTML(
|
| + "<style>"
|
| + " #root { "
|
| + " width: 400px; height: 400px;"
|
| + " position: absolute; clip: rect(0, 50px, 100px, 0);"
|
| + " }"
|
| + " #target {"
|
| + " position: relative;"
|
| + " }"
|
| + "</style>"
|
| + "<div id='root'>"
|
| + " <div id='target'></div>"
|
| + "</div>");
|
| +
|
| + PaintLayer* root =
|
| + ToLayoutBoxModelObject(GetLayoutObjectByElementId("root"))->Layer();
|
| + PaintLayer* target =
|
| + ToLayoutBoxModelObject(GetLayoutObjectByElementId("target"))->Layer();
|
| + ClipRectsContext context(root, kPaintingClipRectsIgnoringOverflowClip);
|
| + PaintLayer::GeometryMapperOption option = PaintLayer::kDoNotUseGeometryMapper;
|
| + if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
|
| + option = PaintLayer::kUseGeometryMapper;
|
| + LayoutRect infinite_rect(LayoutRect::InfiniteIntRect());
|
| + LayoutRect layer_bounds(infinite_rect);
|
| + ClipRect background_rect(infinite_rect);
|
| + ClipRect foreground_rect(infinite_rect);
|
| + target->Clipper(option).CalculateRects(context, infinite_rect, layer_bounds,
|
| + background_rect, foreground_rect);
|
| +
|
| + EXPECT_TRUE(IsInfinite(background_rect.Rect()));
|
| + EXPECT_TRUE(IsInfinite(foreground_rect.Rect()));
|
| +}
|
| +
|
| +TEST_P(PaintLayerClipperTest, IgnoreRootLayerClipWithOverflowClip) {
|
| + SetBodyInnerHTML(
|
| + "<style>"
|
| + " #root { "
|
| + " width: 400px; height: 400px;"
|
| + " overflow: hidden;"
|
| + " }"
|
| + " #target {"
|
| + " position: relative;"
|
| + " }"
|
| + "</style>"
|
| + "<div id='root'>"
|
| + " <div id='target'></div>"
|
| + "</div>");
|
| +
|
| + PaintLayer* root =
|
| + ToLayoutBoxModelObject(GetLayoutObjectByElementId("root"))->Layer();
|
| + PaintLayer* target =
|
| + ToLayoutBoxModelObject(GetLayoutObjectByElementId("target"))->Layer();
|
| + ClipRectsContext context(root, kPaintingClipRectsIgnoringOverflowClip);
|
| + PaintLayer::GeometryMapperOption option = PaintLayer::kDoNotUseGeometryMapper;
|
| + if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
|
| + option = PaintLayer::kUseGeometryMapper;
|
| + LayoutRect infinite_rect(LayoutRect::InfiniteIntRect());
|
| + LayoutRect layer_bounds(infinite_rect);
|
| + ClipRect background_rect(infinite_rect);
|
| + ClipRect foreground_rect(infinite_rect);
|
| + target->Clipper(option).CalculateRects(context, infinite_rect, layer_bounds,
|
| + background_rect, foreground_rect);
|
| +
|
| + EXPECT_TRUE(IsInfinite(background_rect.Rect()));
|
| + EXPECT_TRUE(IsInfinite(foreground_rect.Rect()));
|
| +}
|
| +
|
| +TEST_P(PaintLayerClipperTest, IgnoreRootLayerClipWithBothClip) {
|
| + SetBodyInnerHTML(
|
| + "<style>"
|
| + " #root { "
|
| + " width: 400px; height: 400px;"
|
| + " position: absolute; clip: rect(0, 50px, 100px, 0);"
|
| + " overflow: hidden;"
|
| + " }"
|
| + " #target {"
|
| + " position: relative;"
|
| + " }"
|
| + "</style>"
|
| + "<div id='root'>"
|
| + " <div id='target'></div>"
|
| + "</div>");
|
| +
|
| + PaintLayer* root =
|
| + ToLayoutBoxModelObject(GetLayoutObjectByElementId("root"))->Layer();
|
| + PaintLayer* target =
|
| + ToLayoutBoxModelObject(GetLayoutObjectByElementId("target"))->Layer();
|
| + ClipRectsContext context(root, kPaintingClipRectsIgnoringOverflowClip);
|
| + PaintLayer::GeometryMapperOption option = PaintLayer::kDoNotUseGeometryMapper;
|
| + if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
|
| + option = PaintLayer::kUseGeometryMapper;
|
| + LayoutRect infinite_rect(LayoutRect::InfiniteIntRect());
|
| + LayoutRect layer_bounds(infinite_rect);
|
| + ClipRect background_rect(infinite_rect);
|
| + ClipRect foreground_rect(infinite_rect);
|
| + target->Clipper(option).CalculateRects(context, infinite_rect, layer_bounds,
|
| + background_rect, foreground_rect);
|
| +
|
| + EXPECT_TRUE(IsInfinite(background_rect.Rect()));
|
| + EXPECT_TRUE(IsInfinite(foreground_rect.Rect()));
|
| +}
|
| +
|
| } // namespace blink
|
|
|