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

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

Issue 2241663002: Take CSS Clip and contain: paint into account when computing visual rects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: none Created 4 years, 4 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
Index: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
index 46b8c9c171d5586567f9c7bb04d81978a45b8da4..752fa46ca26ff52dd1fe122a98c08297105eb379 100644
--- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
@@ -894,9 +894,8 @@ TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant)
EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent());
EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTransformSpace());
EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->cssClip()->clipRect());
- // TODO(chrishtr): GeomeryMapper rports 40x60 size (i.e. including clip), whereas the old code reports 100x100 (unclipped).
- // Fix.
- // CHECK_VISUAL_RECT(clip, frameView->layoutView());
+// TODO(chrishtr): the old visual rect code is not able to apply CSS clip to fixed-position elements.
+// CHECK_VISUAL_RECT(clip, frameView->layoutView());
LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties();
@@ -907,6 +906,52 @@ TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant)
CHECK_VISUAL_RECT(fixed, frameView->layoutView());
}
+TEST_F(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant)
+{
+ // This test verifies that clip tree hierarchy being generated correctly for the hard case
+ // such that a fixed position element getting clipped by an absolute position CSS clip.
+ setBodyInnerHTML(
+ "<style>"
+ " #clip {"
+ " position: absolute;"
+ " left: 123px;"
+ " top: 456px;"
+ " clip: rect(10px, 80px, 70px, 40px);"
+ " width: 100px;"
+ " height: 100px;"
+ " }"
+ " #abs {"
+ " position: absolute;"
+ " left: 654px;"
+ " top: 321px;"
+ " width: 10px;"
+ " heght: 20px"
+ " }"
+ "</style>"
+ "<div id='clip'><div id='absolute'></div></div>"
+ );
+ LayoutRect localClipRect(40, 10, 40, 60);
+ LayoutRect absoluteClipRect = localClipRect;
+ absoluteClipRect.move(123, 456);
+
+ FrameView* frameView = document().view();
+
+ LayoutObject* clip = document().getElementById("clip")->layoutObject();
+ const ObjectPaintProperties* clipProperties = clip->objectPaintProperties();
+ EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent());
+ EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTransformSpace());
+ EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->cssClip()->clipRect());
+// TODO(chrishtr): the old visual rect code is not able to apply CSS clip to fixed-position elements.
+// CHECK_VISUAL_RECT(clip, frameView->layoutView());
+
+ LayoutObject* absolute = document().getElementById("absolute")->layoutObject();
+ const ObjectPaintProperties* absPosProperties = absolute->objectPaintProperties();
+ EXPECT_EQ(clipProperties->cssClip(), absPosProperties->localBorderBoxProperties()->propertyTreeState.clip);
+ EXPECT_EQ(frameView->preTranslation(), absPosProperties->localBorderBoxProperties()->propertyTreeState.transform->parent());
+ EXPECT_EQ(LayoutPoint(123, 456), absPosProperties->localBorderBoxProperties()->paintOffset);
+ CHECK_VISUAL_RECT(absolute, frameView->layoutView());
+}
+
TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared)
{
// This test is similar to CSSClipFixedPositionDescendant above, except that

Powered by Google App Engine
This is Rietveld 408576698