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..d63909bbdf533bb7db55949545326606b7608f8e 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,100 @@ TEST_P(PaintPropertyTreeBuilderTest, CachedProperties) |
| CHECK_EXACT_VISUAL_RECT(LayoutRect(114, 137, 10, 20), c->layoutObject(), frameView->layoutView()); |
| } |
| +TEST_P(PaintPropertyTreeBuilderTest, OverflowClipContentsProperties) |
|
pdr.
2016/08/31 04:48:52
Can you add a test for SVG with svgLocalToBorderBo
chrishtr
2016/08/31 17:43:30
Done.
|
| +{ |
| + // 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()); |
| + 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); |
| + |
| + showTransformPropertyTree(*document().view()); |
| + |
| + 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); |
| + |
| + EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTreeState.effect); |
| + 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>" |
| + ); |
| + |
| + showClipPropertyTree(*document().view()); |
| + |
| + 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); |
| + // 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); |
| + |
| + EXPECT_EQ(frameScrollTranslation(), childProperties->localBorderBoxProperties()->propertyTreeState.transform); |
| + EXPECT_EQ(clipProperties->cssClip(), childProperties->localBorderBoxProperties()->propertyTreeState.clip); |
| + |
| + EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTreeState.effect); |
| + CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 500, 600), child, clipper); |
| +} |
| + |
| } // namespace blink |