Chromium Code Reviews| 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 e26cf41e3a2d097351d87cdf022860060aed7535..64ce7da620a33f2d72bf7c64a50f5624ea20ae56 100644 |
| --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp |
| @@ -6,6 +6,7 @@ |
| #include "core/layout/LayoutTreeAsText.h" |
| #include "core/layout/api/LayoutViewItem.h" |
| #include "core/paint/ObjectPaintProperties.h" |
| +#include "core/paint/PaintPropertyTreePrinter.h" |
| #include "platform/graphics/paint/GeometryMapper.h" |
| #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| @@ -103,9 +104,9 @@ do { \ |
| FloatRect actual = geometryMapper.mapToVisualRectInDestinationSpace( \ |
| FloatRect(source), \ |
| (sourceLayoutObject)->objectPaintProperties()->localBorderBoxProperties()->propertyTreeState, \ |
| - (ancestorLayoutObject)->objectPaintProperties()->localBorderBoxProperties()->propertyTreeState, success); \ |
| + (ancestorLayoutObject)->objectPaintProperties()->contentsProperties(), success); \ |
| ASSERT_TRUE(success); \ |
| - EXPECT_EQ(expected, LayoutRect(actual)); \ |
| + EXPECT_EQ(expected, LayoutRect(actual)) << "GeometryMapper: expected: " << expected.toString() << ", actual: " << actual.toString(); \ |
| \ |
| if (slopFactor == LayoutUnit::max()) \ |
| break; \ |
| @@ -118,7 +119,7 @@ do { \ |
| EXPECT_TRUE(slowPathRect.contains(LayoutRect(actual))); \ |
| EXPECT_TRUE(inflatedActual.contains(slowPathRect)); \ |
| } else { \ |
| - EXPECT_EQ(slowPathRect, LayoutRect(actual)); \ |
| + EXPECT_EQ(expected, slowPathRect) << "Slow path: expected: " << slowPathRect.toString() << ", actual: " << actual.toString().ascii().data(); \ |
| } \ |
| } while (0) |
| @@ -1588,4 +1589,115 @@ TEST_P(PaintPropertyTreeBuilderTest, CachedProperties) |
| CHECK_EXACT_VISUAL_RECT(LayoutRect(114, 137, 10, 20), c->layoutObject(), frameView->layoutView()); |
| } |
| +TEST_P(PaintPropertyTreeBuilderTest, OverflowClipContentsProperties) |
| +{ |
| + // This test verifies the tree builder correctly computes and records the property tree context |
| + // for a (pseudo) stacking context that is scrolled by a containing block that is not one of |
| + // the painting ancestors. |
| + setBodyInnerHTML( |
| + "<style>body { margin: 0; }</style>" |
| + "<div id='clipper' style='overflow:hidden; width:400px; height:300px;'>" |
| + " <div id='child' style='position:relative; width:500px; height: 600px;'></div>" |
| + "</div>" |
| + ); |
| + |
| + LayoutBoxModelObject* clipper = toLayoutBoxModelObject(document().getElementById("clipper")->layoutObject()); |
| + const ObjectPaintProperties* clipProperties = clipper->objectPaintProperties(); |
| + LayoutObject* child = document().getElementById("child")->layoutObject(); |
| + const ObjectPaintProperties* childProperties = child->objectPaintProperties(); |
| + |
| + EXPECT_EQ(frameScrollTranslation(), clipProperties->localBorderBoxProperties()->propertyTreeState.transform); |
| + EXPECT_EQ(frameContentClip(), clipProperties->localBorderBoxProperties()->propertyTreeState.clip); |
| + |
| + EXPECT_EQ(frameScrollTranslation(), clipProperties->contentsProperties().transform); |
| + EXPECT_EQ(clipProperties->overflowClip(), clipProperties->contentsProperties().clip); |
| + |
| + EXPECT_EQ(frameScrollTranslation(), childProperties->localBorderBoxProperties()->propertyTreeState.transform); |
| + EXPECT_EQ(clipProperties->overflowClip(), childProperties->localBorderBoxProperties()->propertyTreeState.clip); |
| + |
| + EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTreeState.effect); |
| + CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 500, 600), child, clipper); |
| +} |
| + |
| +TEST_P(PaintPropertyTreeBuilderTest, OverflowScrollContentsProperties) |
| +{ |
| + // This test verifies the tree builder correctly computes and records the property tree context |
| + // for a (pseudo) stacking context that is scrolled by a containing block that is not one of |
| + // the painting ancestors. |
| + setBodyInnerHTML( |
| + "<style>body { margin: 0; }</style>" |
| + "<div id='clipper' style='overflow:scroll; width:400px; height:300px;'>" |
| + " <div id='child' style='position:relative; width:500px; height: 600px;'></div>" |
| + " <div style='width: 200px; height: 10000px'>" |
| + "</div>" |
| + ); |
| + |
| + LayoutBoxModelObject* clipper = toLayoutBoxModelObject(document().getElementById("clipper")->layoutObject()); |
|
szager1
2016/08/31 21:16:19
I'd like this test better if it had a call to docu
chrishtr
2016/09/01 16:56:22
Done.
|
| + const ObjectPaintProperties* clipProperties = clipper->objectPaintProperties(); |
| + LayoutObject* child = document().getElementById("child")->layoutObject(); |
| + const ObjectPaintProperties* childProperties = child->objectPaintProperties(); |
| + |
| + EXPECT_EQ(frameScrollTranslation(), clipProperties->localBorderBoxProperties()->propertyTreeState.transform); |
| + EXPECT_EQ(frameContentClip(), clipProperties->localBorderBoxProperties()->propertyTreeState.clip); |
| + |
| + EXPECT_EQ(clipProperties->scrollTranslation(), clipProperties->contentsProperties().transform); |
| + EXPECT_EQ(clipProperties->overflowClip(), clipProperties->contentsProperties().clip); |
| + |
| + EXPECT_EQ(clipProperties->scrollTranslation(), childProperties->localBorderBoxProperties()->propertyTreeState.transform); |
| + EXPECT_EQ(clipProperties->overflowClip(), childProperties->localBorderBoxProperties()->propertyTreeState.clip); |
| + |
| + CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 500, 600), child, clipper); |
| +} |
| + |
| +TEST_P(PaintPropertyTreeBuilderTest, CssClipContentsProperties) |
| +{ |
| + // This test verifies the tree builder correctly computes and records the property tree context |
| + // for a (pseudo) stacking context that is scrolled by a containing block that is not one of |
| + // the painting ancestors. |
| + setBodyInnerHTML( |
| + "<style>body { margin: 0; }</style>" |
| + "<div id='clipper' style='position: absolute; clip: rect(10px, 80px, 70px, 40px); width:400px; height:300px;'>" |
| + " <div id='child' style='position:relative; width:500px; height: 600px;'></div>" |
| + "</div>" |
| + ); |
| + |
| + LayoutBoxModelObject* clipper = toLayoutBoxModelObject(document().getElementById("clipper")->layoutObject()); |
| + const ObjectPaintProperties* clipProperties = clipper->objectPaintProperties(); |
| + LayoutObject* child = document().getElementById("child")->layoutObject(); |
| + |
| + EXPECT_EQ(frameScrollTranslation(), clipProperties->localBorderBoxProperties()->propertyTreeState.transform); |
| + // CSS clip on an element causes it to clip itself, not just descendants. |
| + EXPECT_EQ(clipProperties->cssClip(), clipProperties->localBorderBoxProperties()->propertyTreeState.clip); |
| + |
| + EXPECT_EQ(frameScrollTranslation(), clipProperties->contentsProperties().transform); |
| + EXPECT_EQ(clipProperties->cssClip(), clipProperties->contentsProperties().clip); |
| + |
| + CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 500, 600), child, clipper); |
| +} |
| + |
| +TEST_P(PaintPropertyTreeBuilderTest, SvgLocalToBorderBoxTransformContentsProperties) |
| +{ |
| + setBodyInnerHTML( |
| + "<style>" |
| + " body {" |
| + " margin: 0px;" |
| + " }" |
| + " svg {" |
| + " position: absolute;" |
| + " }" |
| + " rect {" |
| + " transform: translate(100px, 100px);" |
| + " }" |
| + "</style>" |
| + "<svg id='svgWithViewBox' width='100px' height='100px' viewBox='50 50 100 100'>" |
| + " <rect id='rect' width='100px' height='100px' />" |
| + "</svg>"); |
| + |
| + LayoutObject& svgWithViewBox = *document().getElementById("svgWithViewBox")->layoutObject(); |
| + const ObjectPaintProperties* svgWithViewBoxProperties = svgWithViewBox.objectPaintProperties(); |
| + |
| + EXPECT_EQ(frameScrollTranslation(), svgWithViewBoxProperties->localBorderBoxProperties()->propertyTreeState.transform); |
| + EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), svgWithViewBoxProperties->contentsProperties().transform); |
| +} |
| + |
| } // namespace blink |