Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/PaintLayerTest.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/PaintLayerTest.cpp b/third_party/WebKit/Source/core/paint/PaintLayerTest.cpp |
| index 4e967a7c2a78746a4a97cc0c770f556b83ab0282..4896c132adc52e6317c47b69063d704aa2d44236 100644 |
| --- a/third_party/WebKit/Source/core/paint/PaintLayerTest.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PaintLayerTest.cpp |
| @@ -7,12 +7,36 @@ |
| #include "core/layout/LayoutBoxModelObject.h" |
| #include "core/layout/LayoutTestHelper.h" |
| #include "core/layout/LayoutView.h" |
| +#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| namespace blink { |
| -using PaintLayerTest = RenderingTest; |
| +typedef std::pair<bool, bool> SlimmingPaintAndRootLayerScrolling; |
| +class PaintLayerTest |
| + : public ::testing::WithParamInterface<SlimmingPaintAndRootLayerScrolling>, |
| + private ScopedSlimmingPaintV2ForTest, |
| + private ScopedRootLayerScrollingForTest, |
| + public RenderingTest { |
| + public: |
| + PaintLayerTest() |
| + : ScopedSlimmingPaintV2ForTest(GetParam().first), |
| + ScopedRootLayerScrollingForTest(GetParam().second), |
| + RenderingTest(SingleChildFrameLoaderClient::create()) {} |
| +}; |
| + |
| +SlimmingPaintAndRootLayerScrolling foo[] = { |
| + SlimmingPaintAndRootLayerScrolling(false, false), |
| + SlimmingPaintAndRootLayerScrolling(true, false), |
| + SlimmingPaintAndRootLayerScrolling(false, true), |
| + SlimmingPaintAndRootLayerScrolling(true, true)}; |
| + |
| +INSTANTIATE_TEST_CASE_P(All, PaintLayerTest, ::testing::ValuesIn(foo)); |
| + |
| +TEST_P(PaintLayerTest, CompositedBoundsAbsPosGrandchild) { |
| + // TODO(chrishtr): fix this test for SPv2 |
| + if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| + return; |
| -TEST_F(PaintLayerTest, CompositedBoundsAbsPosGrandchild) { |
| setBodyInnerHTML( |
| " <div id='parent'><div id='absposparent'><div id='absposchild'>" |
| " </div></div></div>" |
| @@ -32,7 +56,7 @@ TEST_F(PaintLayerTest, CompositedBoundsAbsPosGrandchild) { |
| parentLayer->boundingBoxForCompositing()); |
| } |
| -TEST_F(PaintLayerTest, PaintingExtentReflection) { |
| +TEST_P(PaintLayerTest, PaintingExtentReflection) { |
| setBodyInnerHTML( |
| "<div id='target' style='background-color: blue; position: absolute;" |
| " width: 110px; height: 120px; top: 40px; left: 60px;" |
| @@ -46,7 +70,7 @@ TEST_F(PaintLayerTest, PaintingExtentReflection) { |
| layer->paintingExtent(document().layoutView()->layer(), LayoutSize(), 0)); |
| } |
| -TEST_F(PaintLayerTest, PaintingExtentReflectionWithTransform) { |
| +TEST_P(PaintLayerTest, PaintingExtentReflectionWithTransform) { |
| setBodyInnerHTML( |
| "<div id='target' style='background-color: blue; position: absolute;" |
| " width: 110px; height: 120px; top: 40px; left: 60px;" |
| @@ -60,7 +84,60 @@ TEST_F(PaintLayerTest, PaintingExtentReflectionWithTransform) { |
| layer->paintingExtent(document().layoutView()->layer(), LayoutSize(), 0)); |
| } |
| -TEST_F(PaintLayerTest, CompositedScrollingNoNeedsRepaint) { |
| +TEST_P(PaintLayerTest, ScrollsWithViewportRelativePosition) { |
| + setBodyInnerHTML("<div id='target' style='position: relative'></div>"); |
| + |
| + PaintLayer* layer = |
| + toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); |
| + EXPECT_FALSE(layer->scrollsWithViewport()); |
| +} |
| + |
| +TEST_P(PaintLayerTest, ScrollsWithViewportFixedPosition) { |
| + setBodyInnerHTML("<div id='target' style='position: fixed'></div>"); |
| + |
| + PaintLayer* layer = |
| + toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); |
| + EXPECT_TRUE(layer->scrollsWithViewport()); |
| +} |
| + |
| +TEST_P(PaintLayerTest, ScrollsWithViewportFixedPositionInsideTransform) { |
| + setBodyInnerHTML( |
| + "<div style='transform: translateZ(0)'>" |
|
pdr.
2016/12/06 04:38:51
This isn't correct for spv2 because the viewport d
chrishtr
2016/12/06 23:56:06
Added here, and also added another test without sc
|
| + " <div id='target' style='position: fixed'></div>" |
| + "</div>"); |
| + |
| + PaintLayer* layer = |
| + toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); |
| + EXPECT_FALSE(layer->scrollsWithViewport()); |
| +} |
| + |
| +TEST_P(PaintLayerTest, ScrollsWithViewportStickyPosition) { |
| + setBodyInnerHTML( |
| + "<div style='transform: translateZ(0)'>" |
| + " <div id='target' style='position: sticky'></div>" |
| + "</div>"); |
| + |
| + PaintLayer* layer = |
| + toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); |
| + EXPECT_TRUE(layer->scrollsWithViewport()); |
| +} |
| + |
| +TEST_P(PaintLayerTest, ScrollsWithViewportStickyPositionInsideScroller) { |
| + setBodyInnerHTML( |
| + "<div style='overflow:scroll; width: 100px; height: 100px;'>" |
| + " <div id='target' style='position: sticky'></div>" |
| + " <div style='width: 50px; height: 1000px;'></div>" |
| + "</div>"); |
| + |
| + PaintLayer* layer = |
| + toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); |
| + EXPECT_FALSE(layer->scrollsWithViewport()); |
| +} |
| + |
| +TEST_P(PaintLayerTest, CompositedScrollingNoNeedsRepaint) { |
|
pdr.
2016/12/06 04:38:51
Nit: Can you file a bug for this and include it he
|
| + if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| + return; |
| + |
| enableCompositing(); |
| setBodyInnerHTML( |
| "<div id='scroll' style='width: 100px; height: 100px; overflow: scroll;" |
| @@ -87,7 +164,7 @@ TEST_F(PaintLayerTest, CompositedScrollingNoNeedsRepaint) { |
| document().view()->updateAllLifecyclePhases(); |
| } |
| -TEST_F(PaintLayerTest, NonCompositedScrollingNeedsRepaint) { |
| +TEST_P(PaintLayerTest, NonCompositedScrollingNeedsRepaint) { |
| setBodyInnerHTML( |
| "<div id='scroll' style='width: 100px; height: 100px; overflow: scroll'>" |
| " <div id='content' style='position: relative; background: blue;" |
| @@ -112,7 +189,7 @@ TEST_F(PaintLayerTest, NonCompositedScrollingNeedsRepaint) { |
| document().view()->updateAllLifecyclePhases(); |
| } |
| -TEST_F(PaintLayerTest, HasNonIsolatedDescendantWithBlendMode) { |
| +TEST_P(PaintLayerTest, HasNonIsolatedDescendantWithBlendMode) { |
| setBodyInnerHTML( |
| "<div id='stacking-grandparent' style='isolation: isolate'>" |
| " <div id='stacking-parent' style='isolation: isolate'>" |
| @@ -140,7 +217,7 @@ TEST_F(PaintLayerTest, HasNonIsolatedDescendantWithBlendMode) { |
| EXPECT_TRUE(parent->hasVisibleDescendant()); |
| } |
| -TEST_F(PaintLayerTest, HasDescendantWithClipPath) { |
| +TEST_P(PaintLayerTest, HasDescendantWithClipPath) { |
| setBodyInnerHTML( |
| "<div id='parent' style='position:relative'>" |
| " <div id='clip-path' style='clip-path: circle(50px at 0 100px)'>" |
| @@ -158,7 +235,7 @@ TEST_F(PaintLayerTest, HasDescendantWithClipPath) { |
| EXPECT_TRUE(parent->hasVisibleDescendant()); |
| } |
| -TEST_F(PaintLayerTest, HasVisibleDescendant) { |
| +TEST_P(PaintLayerTest, HasVisibleDescendant) { |
| enableCompositing(); |
| setBodyInnerHTML( |
| "<div id='invisible' style='position:relative'>" |