Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(696)

Unified Diff: third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp

Issue 2856373002: [blink] Unify PaintLayerClipper behavior with kIgnoreOverflowClip (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698