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 f2e106bf825a08e3a09db0ab7131ffb9d3746b90..b1e76036eea5f1b41155b0104e98523127beeb6a 100644 |
| --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp |
| @@ -2980,10 +2980,10 @@ TEST_P(PaintPropertyTreeBuilderTest, SimpleFilter) { |
| "</div>"); |
| const ObjectPaintProperties* filterProperties = |
| getLayoutObjectByElementId("filter")->paintProperties(); |
| - EXPECT_TRUE(filterProperties->effect()->parent()->isRoot()); |
| + EXPECT_TRUE(filterProperties->filter()->parent()->isRoot()); |
| EXPECT_EQ(frameScrollTranslation(), |
| - filterProperties->effect()->localTransformSpace()); |
| - EXPECT_EQ(frameContentClip(), filterProperties->effect()->outputClip()); |
| + filterProperties->filter()->localTransformSpace()); |
| + EXPECT_EQ(frameContentClip(), filterProperties->filter()->outputClip()); |
| } |
| TEST_P(PaintPropertyTreeBuilderTest, FilterReparentClips) { |
| @@ -2997,11 +2997,11 @@ TEST_P(PaintPropertyTreeBuilderTest, FilterReparentClips) { |
| getLayoutObjectByElementId("clip")->paintProperties(); |
| const ObjectPaintProperties* filterProperties = |
| getLayoutObjectByElementId("filter")->paintProperties(); |
| - EXPECT_TRUE(filterProperties->effect()->parent()->isRoot()); |
| + EXPECT_TRUE(filterProperties->filter()->parent()->isRoot()); |
| EXPECT_EQ(frameScrollTranslation(), |
| - filterProperties->effect()->localTransformSpace()); |
| + filterProperties->filter()->localTransformSpace()); |
| EXPECT_EQ(clipProperties->overflowClip(), |
| - filterProperties->effect()->outputClip()); |
| + filterProperties->filter()->outputClip()); |
| const PropertyTreeState& childPaintState = |
| *getLayoutObjectByElementId("child") |
| @@ -3009,8 +3009,8 @@ TEST_P(PaintPropertyTreeBuilderTest, FilterReparentClips) { |
| ->localBorderBoxProperties(); |
| // This will change once we added clip expansion node. |
| - EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); |
| - EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); |
| + EXPECT_EQ(filterProperties->filter()->outputClip(), childPaintState.clip()); |
| + EXPECT_EQ(filterProperties->filter(), childPaintState.effect()); |
| } |
| TEST_P(PaintPropertyTreeBuilderTest, TransformOriginWithAndWithoutTransform) { |
| @@ -3174,4 +3174,114 @@ TEST_P(PaintPropertyTreeBuilderTest, ScrollTranslationHasCompositorElementId) { |
| properties->scrollTranslation()->compositorElementId()); |
| } |
| +TEST_P(PaintPropertyTreeBuilderTest, MaskSimple) { |
| + setBodyInnerHTML( |
| + "<div id='target' style='width:300px; height:200px; " |
| + "-webkit-mask:linear-gradient(red,red)'>" |
| + " Lorem ipsum" |
| + "</div>"); |
| + |
| + const ObjectPaintProperties* properties = paintPropertiesForElement("target"); |
| + const ClipPaintPropertyNode* outputClip = properties->maskClip(); |
| + |
| + EXPECT_EQ(outputClip, properties->localBorderBoxProperties()->clip()); |
| + EXPECT_EQ(frameContentClip(), outputClip->parent()); |
| + EXPECT_EQ(FloatRoundedRect(8, 8, 300, 200), outputClip->clipRect()); |
| + |
| + EXPECT_EQ(properties->effect(), |
| + properties->localBorderBoxProperties()->effect()); |
| + EXPECT_TRUE(properties->effect()->parent()->isRoot()); |
| + EXPECT_EQ(SkBlendMode::kSrcOver, properties->effect()->blendMode()); |
| + EXPECT_EQ(outputClip, properties->effect()->outputClip()); |
| + |
| + EXPECT_EQ(properties->effect(), properties->mask()->parent()); |
| + EXPECT_EQ(SkBlendMode::kDstIn, properties->mask()->blendMode()); |
| + EXPECT_EQ(outputClip, properties->mask()->outputClip()); |
| +} |
| + |
| +TEST_P(PaintPropertyTreeBuilderTest, MaskUnescapeClip) { |
|
chrishtr
2017/02/13 23:23:49
MaskEscapeClip?
trchen
2017/02/14 01:37:30
Done. Actually this test is not very good. I chang
|
| + // This test verifies an abs-pos element still escape the scroll of a |
| + // static-pos ancestor, but gets clipped due to the presence of a mask. |
| + setBodyInnerHTML( |
| + "<div id='target' style='width:300px; height:200px; overflow:scroll; " |
| + "-webkit-mask:linear-gradient(red,red)'>" |
| + " <div id='normal' style='position:relative; height:1000px;'>Lorem " |
| + "ipsum</div>" |
| + " <div id='absolute' style='position:absolute; left:0; top:0;'>Lorem " |
| + "ipsum</div>" |
| + "</div>"); |
| + |
| + const ObjectPaintProperties* properties = paintPropertiesForElement("target"); |
| + const ClipPaintPropertyNode* outputClip = properties->maskClip(); |
| + |
| + EXPECT_EQ(framePreTranslation(), |
| + properties->localBorderBoxProperties()->transform()); |
| + |
| + EXPECT_EQ(outputClip, properties->localBorderBoxProperties()->clip()); |
| + EXPECT_EQ(frameContentClip(), outputClip->parent()); |
| + EXPECT_EQ(FloatRoundedRect(8, 8, 300, 200), outputClip->clipRect()); |
| + |
| + EXPECT_EQ(properties->effect(), |
| + properties->localBorderBoxProperties()->effect()); |
| + EXPECT_TRUE(properties->effect()->parent()->isRoot()); |
| + EXPECT_EQ(SkBlendMode::kSrcOver, properties->effect()->blendMode()); |
| + EXPECT_EQ(outputClip, properties->effect()->outputClip()); |
| + |
| + EXPECT_EQ(properties->effect(), properties->mask()->parent()); |
| + EXPECT_EQ(SkBlendMode::kDstIn, properties->mask()->blendMode()); |
| + EXPECT_EQ(outputClip, properties->mask()->outputClip()); |
| + |
| + const ObjectPaintProperties* properties2 = |
| + paintPropertiesForElement("normal"); |
| + EXPECT_EQ(properties->scrollTranslation(), |
| + properties2->localBorderBoxProperties()->transform()); |
| + EXPECT_EQ(properties->overflowClip(), |
| + properties2->localBorderBoxProperties()->clip()); |
| + |
| + const ObjectPaintProperties* properties3 = |
| + paintPropertiesForElement("absolute"); |
| + EXPECT_EQ(framePreTranslation(), |
| + properties3->localBorderBoxProperties()->transform()); |
| + EXPECT_EQ(outputClip, properties3->localBorderBoxProperties()->clip()); |
| +} |
| + |
| +TEST_P(PaintPropertyTreeBuilderTest, MaskInline) { |
| + // This test verifies CSS mask applied on an inline element is clipped to |
| + // the line box of the said element. In this test the masked element has |
| + // only one box, and one of the child element overflows the box. |
| + setBodyInnerHTML( |
| + "<span style='display:inline-block; width:50px;'></span>" |
| + "<span id='target' style='-webkit-mask:linear-gradient(red,red); " |
| + "font-size:16px;'>" |
| + " <span style='display:inline-block; width:50px;'></span>" |
| + " <span id='overflowing' style='position:relative; font-size:32px;'>" |
| + " <span style='display:inline-block; width:50px;'></span>" |
| + " </span>" |
| + " <span style='display:inline-block; width:50px;'></span>" |
| + "</span>"); |
| + |
| + const ObjectPaintProperties* properties = paintPropertiesForElement("target"); |
| + const ClipPaintPropertyNode* outputClip = properties->maskClip(); |
| + |
| + EXPECT_EQ(outputClip, properties->localBorderBoxProperties()->clip()); |
| + EXPECT_EQ(frameContentClip(), outputClip->parent()); |
| + EXPECT_EQ(FloatRoundedRect(58, 23, 170, 19), outputClip->clipRect()); |
| + |
| + EXPECT_EQ(properties->effect(), |
| + properties->localBorderBoxProperties()->effect()); |
| + EXPECT_TRUE(properties->effect()->parent()->isRoot()); |
| + EXPECT_EQ(SkBlendMode::kSrcOver, properties->effect()->blendMode()); |
| + EXPECT_EQ(outputClip, properties->effect()->outputClip()); |
| + |
| + EXPECT_EQ(properties->effect(), properties->mask()->parent()); |
| + EXPECT_EQ(SkBlendMode::kDstIn, properties->mask()->blendMode()); |
| + EXPECT_EQ(outputClip, properties->mask()->outputClip()); |
| + |
| + const ObjectPaintProperties* properties2 = |
| + paintPropertiesForElement("overflowing"); |
| + EXPECT_EQ(outputClip, properties2->localBorderBoxProperties()->clip()); |
| + EXPECT_EQ(properties->effect(), |
| + properties2->localBorderBoxProperties()->effect()); |
| +} |
| + |
| } // namespace blink |