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

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

Issue 2629983003: Support control clipping for PaintLayers. (Closed)
Patch Set: none Created 3 years, 11 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 43dfa47027829975f6aeafcce8f838720ea4d7f1..4731fcc9e59e36a7275fe726f2cab87252c50ef4 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp
@@ -8,6 +8,7 @@
#include "core/layout/LayoutTestHelper.h"
#include "core/layout/LayoutView.h"
#include "core/paint/PaintLayer.h"
+#include "platform/LayoutTestSupport.h"
#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
#include "platform/testing/UnitTestHelpers.h"
@@ -21,6 +22,16 @@ class PaintLayerClipperTest : public ::testing::WithParamInterface<bool>,
: ScopedSlimmingPaintV2ForTest(GetParam()),
RenderingTest(EmptyFrameLoaderClient::create()) {}
+ void SetUp() override {
+ LayoutTestSupport::setMockThemeEnabledForTest(true);
+ RenderingTest::SetUp();
+ }
+
+ void TearDown() override {
+ LayoutTestSupport::setMockThemeEnabledForTest(false);
+ RenderingTest::TearDown();
+ }
+
bool geometryMapperCacheEmpty(const PaintLayerClipper& clipper) {
return clipper.m_geometryMapper->m_data.isEmpty();
}
@@ -55,6 +66,41 @@ TEST_P(PaintLayerClipperTest, LayoutSVGRoot) {
EXPECT_EQ(LayoutRect(8, 8, 200, 300), layerBounds);
}
+TEST_P(PaintLayerClipperTest, ControlClip) {
+ setBodyInnerHTML(
+ "<!DOCTYPE html>"
+ "<input id=target style='position:absolute; width: 200px; height: 300px'"
+ " type=button>");
+ Element* target = document().getElementById("target");
+ PaintLayer* targetPaintLayer =
+ toLayoutBoxModelObject(target->layoutObject())->layer();
+ ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects);
+ // When RLS is enabled, the LayoutView will have a composited scrolling layer,
+ // so don't apply an overflow clip.
+ if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
+ context.setIgnoreOverflowClip();
+ LayoutRect layerBounds;
+ ClipRect backgroundRect, foregroundRect;
+ targetPaintLayer->clipper().calculateRects(
+ context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds,
+ backgroundRect, foregroundRect);
+#if OS(MACOSX)
chrishtr 2017/01/18 21:12:30 Added OSX-specific expectations. I tried to make m
+ // If the PaintLayer clips overflow, the background rect is intersected with
+ // the PaintLayer bounds...
+ EXPECT_EQ(LayoutRect(3, 4, 210, 28), backgroundRect.rect());
chrishtr 2017/01/18 21:12:30 On Mac, input elements are forced into not being m
+ // and the foreground rect is intersected with the control clip in this case.
+ EXPECT_EQ(LayoutRect(8, 8, 200, 18), foregroundRect.rect());
+ EXPECT_EQ(LayoutRect(8, 8, 200, 18), layerBounds);
+#else
+ // If the PaintLayer clips overflow, the background rect is intersected with
+ // the PaintLayer bounds...
+ EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect());
+ // and the foreground rect is intersected with the control clip in this case.
+ EXPECT_EQ(LayoutRect(10, 10, 196, 296), foregroundRect.rect());
+ EXPECT_EQ(LayoutRect(8, 8, 200, 300), layerBounds);
+#endif
+}
+
TEST_P(PaintLayerClipperTest, LayoutSVGRootChild) {
setBodyInnerHTML(
"<svg width=200 height=300 style='position: relative'>"
« 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