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

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
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.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/PaintPropertyTreeBuilderTest.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
index c783aacec1190156c35862aa5083e93f7dd3c439..ef1ebd9b43fb60a1da452d9030f7e4f005f88bc4 100644
--- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
@@ -898,9 +898,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_EXACT_VISUAL_RECT(clip, frameView->layoutView());
+// TODO(chrishtr): the old visual rect code is not able to apply CSS clip to fixed-position elements.
+// CHECK_EXACT_VISUAL_RECT(clip, frameView->layoutView());
LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties();
@@ -911,6 +910,52 @@ TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant)
CHECK_EXACT_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_EXACT_VISUAL_RECT(absolute, frameView->layoutView());
+}
+
TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared)
{
// This test is similar to CSSClipFixedPositionDescendant above, except that
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698