| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/paint/PaintLayer.h" | 5 #include "core/paint/PaintLayer.h" |
| 6 | 6 |
| 7 #include "core/html/HTMLIFrameElement.h" | 7 #include "core/html/HTMLIFrameElement.h" |
| 8 #include "core/layout/LayoutBoxModelObject.h" | 8 #include "core/layout/LayoutBoxModelObject.h" |
| 9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
| 10 #include "core/layout/LayoutView.h" | 10 #include "core/layout/LayoutView.h" |
| 11 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 11 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| 12 #include "platform/testing/UnitTestHelpers.h" | 12 #include "platform/testing/UnitTestHelpers.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 typedef std::pair<bool, bool> SlimmingPaintAndRootLayerScrolling; | 16 typedef std::pair<bool, bool> SlimmingPaintAndRootLayerScrolling; |
| 17 class PaintLayerTest | 17 class PaintLayerTest |
| 18 : public ::testing::WithParamInterface<SlimmingPaintAndRootLayerScrolling>, | 18 : public ::testing::WithParamInterface<SlimmingPaintAndRootLayerScrolling>, |
| 19 private ScopedSlimmingPaintV2ForTest, | 19 private ScopedSlimmingPaintV2ForTest, |
| 20 private ScopedRootLayerScrollingForTest, | 20 private ScopedRootLayerScrollingForTest, |
| 21 public RenderingTest { | 21 public RenderingTest { |
| 22 public: | 22 public: |
| 23 PaintLayerTest() | 23 PaintLayerTest() |
| 24 : ScopedSlimmingPaintV2ForTest(GetParam().first), | 24 : ScopedSlimmingPaintV2ForTest(GetParam().first), |
| 25 ScopedRootLayerScrollingForTest(GetParam().second), | 25 ScopedRootLayerScrollingForTest(GetParam().second), |
| 26 RenderingTest(SingleChildLocalFrameClient::create()) {} | 26 RenderingTest(SingleChildLocalFrameClient::create()) {} |
| 27 |
| 28 protected: |
| 29 PaintLayer* getPaintLayerByElementId(const char* id) { |
| 30 return toLayoutBoxModelObject(getLayoutObjectByElementId(id))->layer(); |
| 31 } |
| 27 }; | 32 }; |
| 28 | 33 |
| 29 SlimmingPaintAndRootLayerScrolling foo[] = { | 34 SlimmingPaintAndRootLayerScrolling foo[] = { |
| 30 SlimmingPaintAndRootLayerScrolling(false, false), | 35 SlimmingPaintAndRootLayerScrolling(false, false), |
| 31 SlimmingPaintAndRootLayerScrolling(true, false), | 36 SlimmingPaintAndRootLayerScrolling(true, false), |
| 32 SlimmingPaintAndRootLayerScrolling(false, true), | 37 SlimmingPaintAndRootLayerScrolling(false, true), |
| 33 SlimmingPaintAndRootLayerScrolling(true, true)}; | 38 SlimmingPaintAndRootLayerScrolling(true, true)}; |
| 34 | 39 |
| 35 INSTANTIATE_TEST_CASE_P(All, PaintLayerTest, ::testing::ValuesIn(foo)); | 40 INSTANTIATE_TEST_CASE_P(All, PaintLayerTest, ::testing::ValuesIn(foo)); |
| 36 | 41 |
| 37 TEST_P(PaintLayerTest, ChildWithoutPaintLayer) { | 42 TEST_P(PaintLayerTest, ChildWithoutPaintLayer) { |
| 38 setBodyInnerHTML( | 43 setBodyInnerHTML( |
| 39 "<div id='target' style='width: 200px; height: 200px;'></div>"); | 44 "<div id='target' style='width: 200px; height: 200px;'></div>"); |
| 40 | 45 |
| 41 Element* element = document().getElementById("target"); | 46 PaintLayer* paintLayer = getPaintLayerByElementId("target"); |
| 42 PaintLayer* paintLayer = | |
| 43 toLayoutBoxModelObject(element->layoutObject())->layer(); | |
| 44 PaintLayer* rootLayer = layoutView().layer(); | 47 PaintLayer* rootLayer = layoutView().layer(); |
| 45 | 48 |
| 46 EXPECT_EQ(nullptr, paintLayer); | 49 EXPECT_EQ(nullptr, paintLayer); |
| 47 EXPECT_NE(nullptr, rootLayer); | 50 EXPECT_NE(nullptr, rootLayer); |
| 48 } | 51 } |
| 49 | 52 |
| 50 TEST_P(PaintLayerTest, CompositedBoundsAbsPosGrandchild) { | 53 TEST_P(PaintLayerTest, CompositedBoundsAbsPosGrandchild) { |
| 51 setBodyInnerHTML( | 54 setBodyInnerHTML( |
| 52 " <div id='parent'><div id='absposparent'><div id='absposchild'>" | 55 " <div id='parent'><div id='absposparent'><div id='absposchild'>" |
| 53 " </div></div></div>" | 56 " </div></div></div>" |
| 54 "<style>" | 57 "<style>" |
| 55 " #parent { position: absolute; z-index: 0; overflow: hidden;" | 58 " #parent { position: absolute; z-index: 0; overflow: hidden;" |
| 56 " background: lightgray; width: 150px; height: 150px;" | 59 " background: lightgray; width: 150px; height: 150px;" |
| 57 " will-change: transform; }" | 60 " will-change: transform; }" |
| 58 " #absposparent { position: absolute; z-index: 0; }" | 61 " #absposparent { position: absolute; z-index: 0; }" |
| 59 " #absposchild { position: absolute; top: 0px; left: 0px; height: 200px;" | 62 " #absposchild { position: absolute; top: 0px; left: 0px; height: 200px;" |
| 60 " width: 200px; background: lightblue; }</style>"); | 63 " width: 200px; background: lightblue; }</style>"); |
| 61 | 64 |
| 62 PaintLayer* parentLayer = | 65 PaintLayer* parentLayer = getPaintLayerByElementId("parent"); |
| 63 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); | |
| 64 // Since "absposchild" is clipped by "parent", it should not expand the | 66 // Since "absposchild" is clipped by "parent", it should not expand the |
| 65 // composited bounds for "parent" beyond its intrinsic size of 150x150. | 67 // composited bounds for "parent" beyond its intrinsic size of 150x150. |
| 66 EXPECT_EQ(LayoutRect(0, 0, 150, 150), | 68 EXPECT_EQ(LayoutRect(0, 0, 150, 150), |
| 67 parentLayer->boundingBoxForCompositing()); | 69 parentLayer->boundingBoxForCompositing()); |
| 68 } | 70 } |
| 69 | 71 |
| 70 TEST_P(PaintLayerTest, CompositedBoundsTransformedChild) { | 72 TEST_P(PaintLayerTest, CompositedBoundsTransformedChild) { |
| 71 // TODO(chrishtr): fix this test for SPv2 | 73 // TODO(chrishtr): fix this test for SPv2 |
| 72 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 74 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 73 return; | 75 return; |
| 74 | 76 |
| 75 setBodyInnerHTML( | 77 setBodyInnerHTML( |
| 76 "<div id=parent style='overflow: scroll; will-change: transform'>" | 78 "<div id=parent style='overflow: scroll; will-change: transform'>" |
| 77 " <div class='target'" | 79 " <div class='target'" |
| 78 " style='position: relative; transform: skew(-15deg);'>" | 80 " style='position: relative; transform: skew(-15deg);'>" |
| 79 " </div>" | 81 " </div>" |
| 80 " <div style='width: 1000px; height: 500px; background: lightgray'>" | 82 " <div style='width: 1000px; height: 500px; background: lightgray'>" |
| 81 " </div>" | 83 " </div>" |
| 82 "</div>"); | 84 "</div>"); |
| 83 | 85 |
| 84 PaintLayer* parentLayer = | 86 PaintLayer* parentLayer = getPaintLayerByElementId("parent"); |
| 85 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); | |
| 86 EXPECT_EQ(LayoutRect(0, 0, 784, 500), | 87 EXPECT_EQ(LayoutRect(0, 0, 784, 500), |
| 87 parentLayer->boundingBoxForCompositing()); | 88 parentLayer->boundingBoxForCompositing()); |
| 88 } | 89 } |
| 89 | 90 |
| 90 TEST_P(PaintLayerTest, RootLayerCompositedBounds) { | 91 TEST_P(PaintLayerTest, RootLayerCompositedBounds) { |
| 91 setBodyInnerHTML( | 92 setBodyInnerHTML( |
| 92 "<style> body { width: 1000px; height: 1000px; margin: 0 } </style>"); | 93 "<style> body { width: 1000px; height: 1000px; margin: 0 } </style>"); |
| 93 EXPECT_EQ(RuntimeEnabledFeatures::rootLayerScrollingEnabled() | 94 EXPECT_EQ(RuntimeEnabledFeatures::rootLayerScrollingEnabled() |
| 94 ? LayoutRect(0, 0, 800, 600) | 95 ? LayoutRect(0, 0, 800, 600) |
| 95 : LayoutRect(0, 0, 1000, 1000), | 96 : LayoutRect(0, 0, 1000, 1000), |
| 96 layoutView().layer()->boundingBoxForCompositing()); | 97 layoutView().layer()->boundingBoxForCompositing()); |
| 97 } | 98 } |
| 98 | 99 |
| 99 TEST_P(PaintLayerTest, PaintingExtentReflection) { | 100 TEST_P(PaintLayerTest, PaintingExtentReflection) { |
| 100 setBodyInnerHTML( | 101 setBodyInnerHTML( |
| 101 "<div id='target' style='background-color: blue; position: absolute;" | 102 "<div id='target' style='background-color: blue; position: absolute;" |
| 102 " width: 110px; height: 120px; top: 40px; left: 60px;" | 103 " width: 110px; height: 120px; top: 40px; left: 60px;" |
| 103 " -webkit-box-reflect: below 3px'>" | 104 " -webkit-box-reflect: below 3px'>" |
| 104 "</div>"); | 105 "</div>"); |
| 105 | 106 |
| 106 PaintLayer* layer = | 107 PaintLayer* layer = getPaintLayerByElementId("target"); |
| 107 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); | |
| 108 EXPECT_EQ( | 108 EXPECT_EQ( |
| 109 LayoutRect(60, 40, 110, 243), | 109 LayoutRect(60, 40, 110, 243), |
| 110 layer->paintingExtent(document().layoutView()->layer(), LayoutSize(), 0)); | 110 layer->paintingExtent(document().layoutView()->layer(), LayoutSize(), 0)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 TEST_P(PaintLayerTest, PaintingExtentReflectionWithTransform) { | 113 TEST_P(PaintLayerTest, PaintingExtentReflectionWithTransform) { |
| 114 setBodyInnerHTML( | 114 setBodyInnerHTML( |
| 115 "<div id='target' style='background-color: blue; position: absolute;" | 115 "<div id='target' style='background-color: blue; position: absolute;" |
| 116 " width: 110px; height: 120px; top: 40px; left: 60px;" | 116 " width: 110px; height: 120px; top: 40px; left: 60px;" |
| 117 " -webkit-box-reflect: below 3px; transform: translateX(30px)'>" | 117 " -webkit-box-reflect: below 3px; transform: translateX(30px)'>" |
| 118 "</div>"); | 118 "</div>"); |
| 119 | 119 |
| 120 PaintLayer* layer = | 120 PaintLayer* layer = getPaintLayerByElementId("target"); |
| 121 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); | |
| 122 EXPECT_EQ( | 121 EXPECT_EQ( |
| 123 LayoutRect(90, 40, 110, 243), | 122 LayoutRect(90, 40, 110, 243), |
| 124 layer->paintingExtent(document().layoutView()->layer(), LayoutSize(), 0)); | 123 layer->paintingExtent(document().layoutView()->layer(), LayoutSize(), 0)); |
| 125 } | 124 } |
| 126 | 125 |
| 127 TEST_P(PaintLayerTest, ScrollsWithViewportRelativePosition) { | 126 TEST_P(PaintLayerTest, ScrollsWithViewportRelativePosition) { |
| 128 setBodyInnerHTML("<div id='target' style='position: relative'></div>"); | 127 setBodyInnerHTML("<div id='target' style='position: relative'></div>"); |
| 129 | 128 |
| 130 PaintLayer* layer = | 129 PaintLayer* layer = getPaintLayerByElementId("target"); |
| 131 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); | |
| 132 EXPECT_FALSE(layer->sticksToViewport()); | 130 EXPECT_FALSE(layer->sticksToViewport()); |
| 133 } | 131 } |
| 134 | 132 |
| 135 TEST_P(PaintLayerTest, ScrollsWithViewportFixedPosition) { | 133 TEST_P(PaintLayerTest, ScrollsWithViewportFixedPosition) { |
| 136 setBodyInnerHTML("<div id='target' style='position: fixed'></div>"); | 134 setBodyInnerHTML("<div id='target' style='position: fixed'></div>"); |
| 137 | 135 |
| 138 PaintLayer* layer = | 136 PaintLayer* layer = getPaintLayerByElementId("target"); |
| 139 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); | |
| 140 EXPECT_TRUE(layer->sticksToViewport()); | 137 EXPECT_TRUE(layer->sticksToViewport()); |
| 141 } | 138 } |
| 142 | 139 |
| 143 TEST_P(PaintLayerTest, ScrollsWithViewportFixedPositionInsideTransform) { | 140 TEST_P(PaintLayerTest, ScrollsWithViewportFixedPositionInsideTransform) { |
| 144 // We don't intend to launch SPv2 without root layer scrolling, so skip this | 141 // We don't intend to launch SPv2 without root layer scrolling, so skip this |
| 145 // test in that configuration because it's broken. | 142 // test in that configuration because it's broken. |
| 146 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && | 143 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 147 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | 144 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
| 148 return; | 145 return; |
| 149 setBodyInnerHTML( | 146 setBodyInnerHTML( |
| 150 "<div style='transform: translateZ(0)'>" | 147 "<div style='transform: translateZ(0)'>" |
| 151 " <div id='target' style='position: fixed'></div>" | 148 " <div id='target' style='position: fixed'></div>" |
| 152 "</div>" | 149 "</div>" |
| 153 "<div style='width: 10px; height: 1000px'></div>"); | 150 "<div style='width: 10px; height: 1000px'></div>"); |
| 154 PaintLayer* layer = | 151 PaintLayer* layer = getPaintLayerByElementId("target"); |
| 155 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); | |
| 156 EXPECT_FALSE(layer->sticksToViewport()); | 152 EXPECT_FALSE(layer->sticksToViewport()); |
| 157 } | 153 } |
| 158 | 154 |
| 159 TEST_P(PaintLayerTest, | 155 TEST_P(PaintLayerTest, |
| 160 ScrollsWithViewportFixedPositionInsideTransformNoScroll) { | 156 ScrollsWithViewportFixedPositionInsideTransformNoScroll) { |
| 161 setBodyInnerHTML( | 157 setBodyInnerHTML( |
| 162 "<div style='transform: translateZ(0)'>" | 158 "<div style='transform: translateZ(0)'>" |
| 163 " <div id='target' style='position: fixed'></div>" | 159 " <div id='target' style='position: fixed'></div>" |
| 164 "</div>"); | 160 "</div>"); |
| 165 PaintLayer* layer = | 161 PaintLayer* layer = getPaintLayerByElementId("target"); |
| 166 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); | |
| 167 | 162 |
| 168 // In SPv2 mode, we correctly determine that the frame doesn't scroll at all, | 163 // In SPv2 mode, we correctly determine that the frame doesn't scroll at all, |
| 169 // and so return true. | 164 // and so return true. |
| 170 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 165 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 171 EXPECT_TRUE(layer->sticksToViewport()); | 166 EXPECT_TRUE(layer->sticksToViewport()); |
| 172 else | 167 else |
| 173 EXPECT_FALSE(layer->sticksToViewport()); | 168 EXPECT_FALSE(layer->sticksToViewport()); |
| 174 } | 169 } |
| 175 | 170 |
| 176 TEST_P(PaintLayerTest, ScrollsWithViewportStickyPosition) { | 171 TEST_P(PaintLayerTest, ScrollsWithViewportStickyPosition) { |
| 177 setBodyInnerHTML( | 172 setBodyInnerHTML( |
| 178 "<div style='transform: translateZ(0)'>" | 173 "<div style='transform: translateZ(0)'>" |
| 179 " <div id='target' style='position: sticky'></div>" | 174 " <div id='target' style='position: sticky'></div>" |
| 180 "</div>" | 175 "</div>" |
| 181 "<div style='width: 10px; height: 1000px'></div>"); | 176 "<div style='width: 10px; height: 1000px'></div>"); |
| 182 | 177 |
| 183 PaintLayer* layer = | 178 PaintLayer* layer = getPaintLayerByElementId("target"); |
| 184 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); | |
| 185 EXPECT_TRUE(layer->sticksToViewport()); | 179 EXPECT_TRUE(layer->sticksToViewport()); |
| 186 } | 180 } |
| 187 | 181 |
| 188 TEST_P(PaintLayerTest, ScrollsWithViewportStickyPositionNoScroll) { | 182 TEST_P(PaintLayerTest, ScrollsWithViewportStickyPositionNoScroll) { |
| 189 setBodyInnerHTML( | 183 setBodyInnerHTML( |
| 190 "<div style='transform: translateZ(0)'>" | 184 "<div style='transform: translateZ(0)'>" |
| 191 " <div id='target' style='position: sticky'></div>" | 185 " <div id='target' style='position: sticky'></div>" |
| 192 "</div>"); | 186 "</div>"); |
| 193 | 187 |
| 194 PaintLayer* layer = | 188 PaintLayer* layer = getPaintLayerByElementId("target"); |
| 195 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); | |
| 196 EXPECT_TRUE(layer->sticksToViewport()); | 189 EXPECT_TRUE(layer->sticksToViewport()); |
| 197 } | 190 } |
| 198 | 191 |
| 199 TEST_P(PaintLayerTest, ScrollsWithViewportStickyPositionInsideScroller) { | 192 TEST_P(PaintLayerTest, ScrollsWithViewportStickyPositionInsideScroller) { |
| 200 setBodyInnerHTML( | 193 setBodyInnerHTML( |
| 201 "<div style='overflow:scroll; width: 100px; height: 100px;'>" | 194 "<div style='overflow:scroll; width: 100px; height: 100px;'>" |
| 202 " <div id='target' style='position: sticky'></div>" | 195 " <div id='target' style='position: sticky'></div>" |
| 203 " <div style='width: 50px; height: 1000px;'></div>" | 196 " <div style='width: 50px; height: 1000px;'></div>" |
| 204 "</div>"); | 197 "</div>"); |
| 205 | 198 |
| 206 PaintLayer* layer = | 199 PaintLayer* layer = getPaintLayerByElementId("target"); |
| 207 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); | |
| 208 EXPECT_FALSE(layer->sticksToViewport()); | 200 EXPECT_FALSE(layer->sticksToViewport()); |
| 209 } | 201 } |
| 210 | 202 |
| 211 TEST_P(PaintLayerTest, CompositedScrollingNoNeedsRepaint) { | 203 TEST_P(PaintLayerTest, CompositedScrollingNoNeedsRepaint) { |
| 212 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 204 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 213 return; | 205 return; |
| 214 | 206 |
| 215 enableCompositing(); | 207 enableCompositing(); |
| 216 setBodyInnerHTML( | 208 setBodyInnerHTML( |
| 217 "<div id='scroll' style='width: 100px; height: 100px; overflow: scroll;" | 209 "<div id='scroll' style='width: 100px; height: 100px; overflow: scroll;" |
| 218 " will-change: transform'>" | 210 " will-change: transform'>" |
| 219 " <div id='content' style='position: relative; background: blue;" | 211 " <div id='content' style='position: relative; background: blue;" |
| 220 " width: 2000px; height: 2000px'></div>" | 212 " width: 2000px; height: 2000px'></div>" |
| 221 "</div>"); | 213 "</div>"); |
| 222 | 214 |
| 223 PaintLayer* scrollLayer = | 215 PaintLayer* scrollLayer = getPaintLayerByElementId("scroll"); |
| 224 toLayoutBoxModelObject(getLayoutObjectByElementId("scroll"))->layer(); | |
| 225 EXPECT_EQ(PaintsIntoOwnBacking, scrollLayer->compositingState()); | 216 EXPECT_EQ(PaintsIntoOwnBacking, scrollLayer->compositingState()); |
| 226 | 217 |
| 227 PaintLayer* contentLayer = | 218 PaintLayer* contentLayer = getPaintLayerByElementId("content"); |
| 228 toLayoutBoxModelObject(getLayoutObjectByElementId("content"))->layer(); | |
| 229 EXPECT_EQ(NotComposited, contentLayer->compositingState()); | 219 EXPECT_EQ(NotComposited, contentLayer->compositingState()); |
| 230 EXPECT_EQ(LayoutPoint(), contentLayer->location()); | 220 EXPECT_EQ(LayoutPoint(), contentLayer->location()); |
| 231 | 221 |
| 232 scrollLayer->getScrollableArea()->setScrollOffset(ScrollOffset(1000, 1000), | 222 scrollLayer->getScrollableArea()->setScrollOffset(ScrollOffset(1000, 1000), |
| 233 ProgrammaticScroll); | 223 ProgrammaticScroll); |
| 234 document().view()->updateAllLifecyclePhasesExceptPaint(); | 224 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 235 EXPECT_EQ(LayoutPoint(-1000, -1000), contentLayer->location()); | 225 EXPECT_EQ(LayoutPoint(-1000, -1000), contentLayer->location()); |
| 236 EXPECT_FALSE(contentLayer->needsRepaint()); | 226 EXPECT_FALSE(contentLayer->needsRepaint()); |
| 237 EXPECT_FALSE(scrollLayer->needsRepaint()); | 227 EXPECT_FALSE(scrollLayer->needsRepaint()); |
| 238 document().view()->updateAllLifecyclePhases(); | 228 document().view()->updateAllLifecyclePhases(); |
| 239 } | 229 } |
| 240 | 230 |
| 241 TEST_P(PaintLayerTest, NonCompositedScrollingNeedsRepaint) { | 231 TEST_P(PaintLayerTest, NonCompositedScrollingNeedsRepaint) { |
| 242 setBodyInnerHTML( | 232 setBodyInnerHTML( |
| 243 "<div id='scroll' style='width: 100px; height: 100px; overflow: scroll'>" | 233 "<div id='scroll' style='width: 100px; height: 100px; overflow: scroll'>" |
| 244 " <div id='content' style='position: relative; background: blue;" | 234 " <div id='content' style='position: relative; background: blue;" |
| 245 " width: 2000px; height: 2000px'></div>" | 235 " width: 2000px; height: 2000px'></div>" |
| 246 "</div>"); | 236 "</div>"); |
| 247 | 237 |
| 248 PaintLayer* scrollLayer = | 238 PaintLayer* scrollLayer = getPaintLayerByElementId("scroll"); |
| 249 toLayoutBoxModelObject(getLayoutObjectByElementId("scroll"))->layer(); | |
| 250 EXPECT_EQ(NotComposited, scrollLayer->compositingState()); | 239 EXPECT_EQ(NotComposited, scrollLayer->compositingState()); |
| 251 | 240 |
| 252 PaintLayer* contentLayer = | 241 PaintLayer* contentLayer = getPaintLayerByElementId("content"); |
| 253 toLayoutBoxModelObject(getLayoutObjectByElementId("content"))->layer(); | |
| 254 EXPECT_EQ(NotComposited, scrollLayer->compositingState()); | 242 EXPECT_EQ(NotComposited, scrollLayer->compositingState()); |
| 255 EXPECT_EQ(LayoutPoint(), contentLayer->location()); | 243 EXPECT_EQ(LayoutPoint(), contentLayer->location()); |
| 256 | 244 |
| 257 scrollLayer->getScrollableArea()->setScrollOffset(ScrollOffset(1000, 1000), | 245 scrollLayer->getScrollableArea()->setScrollOffset(ScrollOffset(1000, 1000), |
| 258 ProgrammaticScroll); | 246 ProgrammaticScroll); |
| 259 document().view()->updateAllLifecyclePhasesExceptPaint(); | 247 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 260 EXPECT_EQ(LayoutPoint(-1000, -1000), contentLayer->location()); | 248 EXPECT_EQ(LayoutPoint(-1000, -1000), contentLayer->location()); |
| 261 EXPECT_TRUE(contentLayer->needsRepaint()); | 249 EXPECT_TRUE(contentLayer->needsRepaint()); |
| 262 EXPECT_TRUE(scrollLayer->needsRepaint()); | 250 EXPECT_TRUE(scrollLayer->needsRepaint()); |
| 263 document().view()->updateAllLifecyclePhases(); | 251 document().view()->updateAllLifecyclePhases(); |
| 264 } | 252 } |
| 265 | 253 |
| 266 TEST_P(PaintLayerTest, HasNonIsolatedDescendantWithBlendMode) { | 254 TEST_P(PaintLayerTest, HasNonIsolatedDescendantWithBlendMode) { |
| 267 setBodyInnerHTML( | 255 setBodyInnerHTML( |
| 268 "<div id='stacking-grandparent' style='isolation: isolate'>" | 256 "<div id='stacking-grandparent' style='isolation: isolate'>" |
| 269 " <div id='stacking-parent' style='isolation: isolate'>" | 257 " <div id='stacking-parent' style='isolation: isolate'>" |
| 270 " <div id='non-stacking-parent' style='position:relative'>" | 258 " <div id='non-stacking-parent' style='position:relative'>" |
| 271 " <div id='blend-mode' style='mix-blend-mode: overlay'>" | 259 " <div id='blend-mode' style='mix-blend-mode: overlay'>" |
| 272 " </div>" | 260 " </div>" |
| 273 " </div>" | 261 " </div>" |
| 274 " </div>" | 262 " </div>" |
| 275 "</div>"); | 263 "</div>"); |
| 276 PaintLayer* stackingGrandparent = | 264 PaintLayer* stackingGrandparent = |
| 277 toLayoutBoxModelObject(getLayoutObjectByElementId("stacking-grandparent")) | 265 getPaintLayerByElementId("stacking-grandparent"); |
| 278 ->layer(); | 266 PaintLayer* stackingParent = getPaintLayerByElementId("stacking-parent"); |
| 279 PaintLayer* stackingParent = | 267 PaintLayer* parent = getPaintLayerByElementId("non-stacking-parent"); |
| 280 toLayoutBoxModelObject(getLayoutObjectByElementId("stacking-parent")) | |
| 281 ->layer(); | |
| 282 PaintLayer* parent = | |
| 283 toLayoutBoxModelObject(getLayoutObjectByElementId("non-stacking-parent")) | |
| 284 ->layer(); | |
| 285 | 268 |
| 286 EXPECT_TRUE(parent->hasNonIsolatedDescendantWithBlendMode()); | 269 EXPECT_TRUE(parent->hasNonIsolatedDescendantWithBlendMode()); |
| 287 EXPECT_TRUE(stackingParent->hasNonIsolatedDescendantWithBlendMode()); | 270 EXPECT_TRUE(stackingParent->hasNonIsolatedDescendantWithBlendMode()); |
| 288 EXPECT_FALSE(stackingGrandparent->hasNonIsolatedDescendantWithBlendMode()); | 271 EXPECT_FALSE(stackingGrandparent->hasNonIsolatedDescendantWithBlendMode()); |
| 289 | 272 |
| 290 EXPECT_FALSE(parent->hasDescendantWithClipPath()); | 273 EXPECT_FALSE(parent->hasDescendantWithClipPath()); |
| 291 EXPECT_TRUE(parent->hasVisibleDescendant()); | 274 EXPECT_TRUE(parent->hasVisibleDescendant()); |
| 292 } | 275 } |
| 293 | 276 |
| 294 TEST_P(PaintLayerTest, HasDescendantWithClipPath) { | 277 TEST_P(PaintLayerTest, HasDescendantWithClipPath) { |
| 295 setBodyInnerHTML( | 278 setBodyInnerHTML( |
| 296 "<div id='parent' style='position:relative'>" | 279 "<div id='parent' style='position:relative'>" |
| 297 " <div id='clip-path' style='clip-path: circle(50px at 0 100px)'>" | 280 " <div id='clip-path' style='clip-path: circle(50px at 0 100px)'>" |
| 298 " </div>" | 281 " </div>" |
| 299 "</div>"); | 282 "</div>"); |
| 300 PaintLayer* parent = | 283 PaintLayer* parent = getPaintLayerByElementId("parent"); |
| 301 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); | 284 PaintLayer* clipPath = getPaintLayerByElementId("clip-path"); |
| 302 PaintLayer* clipPath = | |
| 303 toLayoutBoxModelObject(getLayoutObjectByElementId("clip-path"))->layer(); | |
| 304 | 285 |
| 305 EXPECT_TRUE(parent->hasDescendantWithClipPath()); | 286 EXPECT_TRUE(parent->hasDescendantWithClipPath()); |
| 306 EXPECT_FALSE(clipPath->hasDescendantWithClipPath()); | 287 EXPECT_FALSE(clipPath->hasDescendantWithClipPath()); |
| 307 | 288 |
| 308 EXPECT_FALSE(parent->hasNonIsolatedDescendantWithBlendMode()); | 289 EXPECT_FALSE(parent->hasNonIsolatedDescendantWithBlendMode()); |
| 309 EXPECT_TRUE(parent->hasVisibleDescendant()); | 290 EXPECT_TRUE(parent->hasVisibleDescendant()); |
| 310 } | 291 } |
| 311 | 292 |
| 312 TEST_P(PaintLayerTest, HasVisibleDescendant) { | 293 TEST_P(PaintLayerTest, HasVisibleDescendant) { |
| 313 enableCompositing(); | 294 enableCompositing(); |
| 314 setBodyInnerHTML( | 295 setBodyInnerHTML( |
| 315 "<div id='invisible' style='position:relative'>" | 296 "<div id='invisible' style='position:relative'>" |
| 316 " <div id='visible' style='visibility: visible; position: relative'>" | 297 " <div id='visible' style='visibility: visible; position: relative'>" |
| 317 " </div>" | 298 " </div>" |
| 318 "</div>"); | 299 "</div>"); |
| 319 PaintLayer* invisible = | 300 PaintLayer* invisible = getPaintLayerByElementId("invisible"); |
| 320 toLayoutBoxModelObject(getLayoutObjectByElementId("invisible"))->layer(); | 301 PaintLayer* visible = getPaintLayerByElementId("visible"); |
| 321 PaintLayer* visible = | |
| 322 toLayoutBoxModelObject(getLayoutObjectByElementId("visible"))->layer(); | |
| 323 | 302 |
| 324 EXPECT_TRUE(invisible->hasVisibleDescendant()); | 303 EXPECT_TRUE(invisible->hasVisibleDescendant()); |
| 325 EXPECT_FALSE(visible->hasVisibleDescendant()); | 304 EXPECT_FALSE(visible->hasVisibleDescendant()); |
| 326 | 305 |
| 327 EXPECT_FALSE(invisible->hasNonIsolatedDescendantWithBlendMode()); | 306 EXPECT_FALSE(invisible->hasNonIsolatedDescendantWithBlendMode()); |
| 328 EXPECT_FALSE(invisible->hasDescendantWithClipPath()); | 307 EXPECT_FALSE(invisible->hasDescendantWithClipPath()); |
| 329 } | 308 } |
| 330 | 309 |
| 331 TEST_P(PaintLayerTest, Has3DTransformedDescendant) { | 310 TEST_P(PaintLayerTest, Has3DTransformedDescendant) { |
| 332 enableCompositing(); | 311 enableCompositing(); |
| 333 setBodyInnerHTML( | 312 setBodyInnerHTML( |
| 334 "<div id='parent' style='position:relative; z-index: 0'>" | 313 "<div id='parent' style='position:relative; z-index: 0'>" |
| 335 " <div id='child' style='transform: translateZ(1px)'>" | 314 " <div id='child' style='transform: translateZ(1px)'>" |
| 336 " </div>" | 315 " </div>" |
| 337 "</div>"); | 316 "</div>"); |
| 338 PaintLayer* parent = | 317 PaintLayer* parent = getPaintLayerByElementId("parent"); |
| 339 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); | 318 PaintLayer* child = getPaintLayerByElementId("child"); |
| 340 PaintLayer* child = | |
| 341 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); | |
| 342 | 319 |
| 343 EXPECT_TRUE(parent->has3DTransformedDescendant()); | 320 EXPECT_TRUE(parent->has3DTransformedDescendant()); |
| 344 EXPECT_FALSE(child->has3DTransformedDescendant()); | 321 EXPECT_FALSE(child->has3DTransformedDescendant()); |
| 345 } | 322 } |
| 346 | 323 |
| 347 TEST_P(PaintLayerTest, Has3DTransformedDescendantChangeStyle) { | 324 TEST_P(PaintLayerTest, Has3DTransformedDescendantChangeStyle) { |
| 348 enableCompositing(); | 325 enableCompositing(); |
| 349 setBodyInnerHTML( | 326 setBodyInnerHTML( |
| 350 "<div id='parent' style='position:relative; z-index: 0'>" | 327 "<div id='parent' style='position:relative; z-index: 0'>" |
| 351 " <div id='child' style='position:relative '>" | 328 " <div id='child' style='position:relative '>" |
| 352 " </div>" | 329 " </div>" |
| 353 "</div>"); | 330 "</div>"); |
| 354 PaintLayer* parent = | 331 PaintLayer* parent = getPaintLayerByElementId("parent"); |
| 355 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); | 332 PaintLayer* child = getPaintLayerByElementId("child"); |
| 356 PaintLayer* child = | |
| 357 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); | |
| 358 | 333 |
| 359 EXPECT_FALSE(parent->has3DTransformedDescendant()); | 334 EXPECT_FALSE(parent->has3DTransformedDescendant()); |
| 360 EXPECT_FALSE(child->has3DTransformedDescendant()); | 335 EXPECT_FALSE(child->has3DTransformedDescendant()); |
| 361 | 336 |
| 362 document().getElementById("child")->setAttribute( | 337 document().getElementById("child")->setAttribute( |
| 363 HTMLNames::styleAttr, "transform: translateZ(1px)"); | 338 HTMLNames::styleAttr, "transform: translateZ(1px)"); |
| 364 document().view()->updateAllLifecyclePhases(); | 339 document().view()->updateAllLifecyclePhases(); |
| 365 | 340 |
| 366 EXPECT_TRUE(parent->has3DTransformedDescendant()); | 341 EXPECT_TRUE(parent->has3DTransformedDescendant()); |
| 367 EXPECT_FALSE(child->has3DTransformedDescendant()); | 342 EXPECT_FALSE(child->has3DTransformedDescendant()); |
| 368 } | 343 } |
| 369 | 344 |
| 370 TEST_P(PaintLayerTest, Has3DTransformedDescendantNotStacking) { | 345 TEST_P(PaintLayerTest, Has3DTransformedDescendantNotStacking) { |
| 371 enableCompositing(); | 346 enableCompositing(); |
| 372 setBodyInnerHTML( | 347 setBodyInnerHTML( |
| 373 "<div id='parent' style='position:relative;'>" | 348 "<div id='parent' style='position:relative;'>" |
| 374 " <div id='child' style='transform: translateZ(1px)'>" | 349 " <div id='child' style='transform: translateZ(1px)'>" |
| 375 " </div>" | 350 " </div>" |
| 376 "</div>"); | 351 "</div>"); |
| 377 PaintLayer* parent = | 352 PaintLayer* parent = getPaintLayerByElementId("parent"); |
| 378 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); | 353 PaintLayer* child = getPaintLayerByElementId("child"); |
| 379 PaintLayer* child = | |
| 380 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); | |
| 381 | 354 |
| 382 // |child| is not a stacking child of |parent|, so it has no 3D transformed | 355 // |child| is not a stacking child of |parent|, so it has no 3D transformed |
| 383 // descendant. | 356 // descendant. |
| 384 EXPECT_FALSE(parent->has3DTransformedDescendant()); | 357 EXPECT_FALSE(parent->has3DTransformedDescendant()); |
| 385 EXPECT_FALSE(child->has3DTransformedDescendant()); | 358 EXPECT_FALSE(child->has3DTransformedDescendant()); |
| 386 } | 359 } |
| 387 | 360 |
| 388 TEST_P(PaintLayerTest, Has3DTransformedGrandchildWithPreserve3d) { | 361 TEST_P(PaintLayerTest, Has3DTransformedGrandchildWithPreserve3d) { |
| 389 enableCompositing(); | 362 enableCompositing(); |
| 390 setBodyInnerHTML( | 363 setBodyInnerHTML( |
| 391 "<div id='parent' style='position:relative; z-index: 0'>" | 364 "<div id='parent' style='position:relative; z-index: 0'>" |
| 392 " <div id='child' style='transform-style: preserve-3d'>" | 365 " <div id='child' style='transform-style: preserve-3d'>" |
| 393 " <div id='grandchild' style='transform: translateZ(1px)'>" | 366 " <div id='grandchild' style='transform: translateZ(1px)'>" |
| 394 " </div>" | 367 " </div>" |
| 395 " </div>" | 368 " </div>" |
| 396 "</div>"); | 369 "</div>"); |
| 397 PaintLayer* parent = | 370 PaintLayer* parent = getPaintLayerByElementId("parent"); |
| 398 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); | 371 PaintLayer* child = getPaintLayerByElementId("child"); |
| 399 PaintLayer* child = | 372 PaintLayer* grandchild = getPaintLayerByElementId("grandchild"); |
| 400 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); | |
| 401 PaintLayer* grandchild = | |
| 402 toLayoutBoxModelObject(getLayoutObjectByElementId("grandchild"))->layer(); | |
| 403 | 373 |
| 404 EXPECT_TRUE(parent->has3DTransformedDescendant()); | 374 EXPECT_TRUE(parent->has3DTransformedDescendant()); |
| 405 EXPECT_TRUE(child->has3DTransformedDescendant()); | 375 EXPECT_TRUE(child->has3DTransformedDescendant()); |
| 406 EXPECT_FALSE(grandchild->has3DTransformedDescendant()); | 376 EXPECT_FALSE(grandchild->has3DTransformedDescendant()); |
| 407 } | 377 } |
| 408 | 378 |
| 409 TEST_P(PaintLayerTest, DescendantDependentFlagsStopsAtThrottledFrames) { | 379 TEST_P(PaintLayerTest, DescendantDependentFlagsStopsAtThrottledFrames) { |
| 410 enableCompositing(); | 380 enableCompositing(); |
| 411 setBodyInnerHTML( | 381 setBodyInnerHTML( |
| 412 "<style>body { margin: 0; }</style>" | 382 "<style>body { margin: 0; }</style>" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 EXPECT_EQ(LayoutRect(0, 30, 50, 10), contentLayer->visualRect()); | 479 EXPECT_EQ(LayoutRect(0, 30, 50, 10), contentLayer->visualRect()); |
| 510 EXPECT_EQ(LayoutRect(0, 30, 50, 5), content->visualRect()); | 480 EXPECT_EQ(LayoutRect(0, 30, 50, 5), content->visualRect()); |
| 511 | 481 |
| 512 scroller->getScrollableArea()->setScrollOffset(ScrollOffset(0, 20), | 482 scroller->getScrollableArea()->setScrollOffset(ScrollOffset(0, 20), |
| 513 ProgrammaticScroll); | 483 ProgrammaticScroll); |
| 514 document().view()->updateAllLifecyclePhases(); | 484 document().view()->updateAllLifecyclePhases(); |
| 515 EXPECT_EQ(LayoutRect(0, 30, 50, 10), contentLayer->visualRect()); | 485 EXPECT_EQ(LayoutRect(0, 30, 50, 10), contentLayer->visualRect()); |
| 516 EXPECT_EQ(LayoutRect(0, 30, 50, 5), content->visualRect()); | 486 EXPECT_EQ(LayoutRect(0, 30, 50, 5), content->visualRect()); |
| 517 } | 487 } |
| 518 | 488 |
| 519 TEST_P(PaintLayerTest, CompositingContainerFloat) { | 489 TEST_P(PaintLayerTest, CompositingContainerStackedFloatUnderStackingInline) { |
| 520 enableCompositing(); | 490 enableCompositing(); |
| 521 setBodyInnerHTML( | 491 setBodyInnerHTML( |
| 522 "<div id='compositedContainer' style='position: relative;" | 492 "<div id='compositedContainer' style='position: relative;" |
| 523 " will-change: transform'>" | 493 " will-change: transform'>" |
| 524 " <div id='containingBlock' style='position: relative; z-index: 0'>" | 494 " <div id='containingBlock' style='position: relative; z-index: 0'>" |
| 525 " <div style='backface-visibility: hidden'></div>" | 495 " <span id='span' style='opacity: 0.9'>" |
| 526 " <span id='span'" | |
| 527 " style='clip-path: polygon(0px 15px, 0px 54px, 100px 0px)'>" | |
| 528 " <div id='target' style='float: right; position: relative'></div>" | 496 " <div id='target' style='float: right; position: relative'></div>" |
| 529 " </span>" | 497 " </span>" |
| 530 " </div>" | 498 " </div>" |
| 531 "</div>"); | 499 "</div>"); |
| 532 | 500 |
| 533 PaintLayer* target = | 501 PaintLayer* target = getPaintLayerByElementId("target"); |
| 534 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); | 502 EXPECT_EQ(getPaintLayerByElementId("span"), target->compositingContainer()); |
| 535 PaintLayer* span = | 503 |
| 536 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); | 504 // enclosingLayerWithCompositedLayerMapping is not needed or applicable to |
| 505 // SPv2. |
| 506 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 507 EXPECT_EQ(getPaintLayerByElementId("compositedContainer"), |
| 508 target->enclosingLayerWithCompositedLayerMapping(ExcludeSelf)); |
| 509 } |
| 510 } |
| 511 |
| 512 TEST_P(PaintLayerTest, |
| 513 CompositingContainerStackedFloatUnderStackingCompositedInline) { |
| 514 enableCompositing(); |
| 515 setBodyInnerHTML( |
| 516 "<div id='compositedContainer' style='position: relative;" |
| 517 " will-change: transform'>" |
| 518 " <div id='containingBlock' style='position: relative; z-index: 0'>" |
| 519 " <span id='span' style='opacity: 0.9; will-change: transform'>" |
| 520 " <div id='target' style='float: right; position: relative'></div>" |
| 521 " </span>" |
| 522 " </div>" |
| 523 "</div>"); |
| 524 |
| 525 PaintLayer* target = getPaintLayerByElementId("target"); |
| 526 PaintLayer* span = getPaintLayerByElementId("span"); |
| 537 EXPECT_EQ(span, target->compositingContainer()); | 527 EXPECT_EQ(span, target->compositingContainer()); |
| 538 PaintLayer* compositedContainer = | 528 |
| 539 toLayoutBoxModelObject(getLayoutObjectByElementId("compositedContainer")) | 529 // enclosingLayerWithCompositedLayerMapping is not needed or applicable to |
| 540 ->layer(); | 530 // SPv2. |
| 541 | 531 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 542 // enclosingLayerWithCompositedLayerMapping is not needed or applicable to | 532 EXPECT_EQ(span, |
| 543 // SPv2. | 533 target->enclosingLayerWithCompositedLayerMapping(ExcludeSelf)); |
| 544 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 534 } |
| 545 EXPECT_EQ(compositedContainer, | 535 } |
| 546 target->enclosingLayerWithCompositedLayerMapping(ExcludeSelf)); | 536 |
| 547 } | 537 TEST_P(PaintLayerTest, CompositingContainerNonStackedFloatUnderStackingInline) { |
| 548 } | 538 enableCompositing(); |
| 539 setBodyInnerHTML( |
| 540 "<div id='compositedContainer' style='position: relative;" |
| 541 " will-change: transform'>" |
| 542 " <div id='containingBlock' style='position: relative; z-index: 0'>" |
| 543 " <span id='span' style='opacity: 0.9'>" |
| 544 " <div id='target' style='float: right; overflow: hidden'</div>" |
| 545 " </span>" |
| 546 " </div>" |
| 547 "</div>"); |
| 548 |
| 549 PaintLayer* target = getPaintLayerByElementId("target"); |
| 550 EXPECT_EQ(getPaintLayerByElementId("containingBlock"), |
| 551 target->compositingContainer()); |
| 552 |
| 553 // enclosingLayerWithCompositedLayerMapping is not needed or applicable to |
| 554 // SPv2. |
| 555 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 556 EXPECT_EQ(getPaintLayerByElementId("compositedContainer"), |
| 557 target->enclosingLayerWithCompositedLayerMapping(ExcludeSelf)); |
| 558 } |
| 559 } |
| 560 |
| 561 TEST_P(PaintLayerTest, |
| 562 CompositingContainerNonStackedFloatUnderStackingCompositedInline) { |
| 563 enableCompositing(); |
| 564 setBodyInnerHTML( |
| 565 "<div id='compositedContainer' style='position: relative;" |
| 566 " will-change: transform'>" |
| 567 " <div id='containingBlock' style='position: relative; z-index: 0'>" |
| 568 " <span id='span' style='opacity: 0.9; will-change: transform'>" |
| 569 " <div id='target' style='float: right; overflow: hidden'</div>" |
| 570 " </span>" |
| 571 " </div>" |
| 572 "</div>"); |
| 573 |
| 574 PaintLayer* target = getPaintLayerByElementId("target"); |
| 575 EXPECT_EQ(getPaintLayerByElementId("containingBlock"), |
| 576 target->compositingContainer()); |
| 577 |
| 578 // enclosingLayerWithCompositedLayerMapping is not needed or applicable to |
| 579 // SPv2. |
| 580 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 581 EXPECT_EQ(getPaintLayerByElementId("compositedContainer"), |
| 582 target->enclosingLayerWithCompositedLayerMapping(ExcludeSelf)); |
| 583 } |
| 584 } |
| 585 |
| 586 TEST_P(PaintLayerTest, |
| 587 CompositingContainerStackedUnderFloatUnderStackingInline) { |
| 588 enableCompositing(); |
| 589 setBodyInnerHTML( |
| 590 "<div id='compositedContainer' style='position: relative;" |
| 591 " will-change: transform'>" |
| 592 " <div id='containingBlock' style='position: relative; z-index: 0'>" |
| 593 " <span id='span' style='opacity: 0.9'>" |
| 594 " <div style='float: right'>" |
| 595 " <div id='target' style='position: relative'></div>" |
| 596 " </div>" |
| 597 " </span>" |
| 598 " </div>" |
| 599 "</div>"); |
| 600 |
| 601 PaintLayer* target = getPaintLayerByElementId("target"); |
| 602 EXPECT_EQ(getPaintLayerByElementId("span"), target->compositingContainer()); |
| 603 |
| 604 // enclosingLayerWithCompositedLayerMapping is not needed or applicable to |
| 605 // SPv2. |
| 606 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 607 EXPECT_EQ(getPaintLayerByElementId("compositedContainer"), |
| 608 target->enclosingLayerWithCompositedLayerMapping(ExcludeSelf)); |
| 609 } |
| 610 } |
| 611 |
| 612 TEST_P(PaintLayerTest, |
| 613 CompositingContainerStackedUnderFloatUnderStackingCompositedInline) { |
| 614 enableCompositing(); |
| 615 setBodyInnerHTML( |
| 616 "<div id='compositedContainer' style='position: relative;" |
| 617 " will-change: transform'>" |
| 618 " <div id='containingBlock' style='position: relative; z-index: 0'>" |
| 619 " <span id='span' style='opacity: 0.9; will-change: transform'>" |
| 620 " <div style='float: right'>" |
| 621 " <div id='target' style='position: relative'></div>" |
| 622 " </div>" |
| 623 " </span>" |
| 624 " </div>" |
| 625 "</div>"); |
| 626 |
| 627 PaintLayer* target = getPaintLayerByElementId("target"); |
| 628 PaintLayer* span = getPaintLayerByElementId("span"); |
| 629 EXPECT_EQ(span, target->compositingContainer()); |
| 630 |
| 631 // enclosingLayerWithCompositedLayerMapping is not needed or applicable to |
| 632 // SPv2. |
| 633 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 634 EXPECT_EQ(span, |
| 635 target->enclosingLayerWithCompositedLayerMapping(ExcludeSelf)); |
| 636 } |
| 637 } |
| 638 |
| 639 TEST_P(PaintLayerTest, |
| 640 CompositingContainerNonStackedUnderFloatUnderStackingInline) { |
| 641 enableCompositing(); |
| 642 setBodyInnerHTML( |
| 643 "<div id='compositedContainer' style='position: relative;" |
| 644 " will-change: transform'>" |
| 645 " <div id='containingBlock' style='position: relative; z-index: 0'>" |
| 646 " <span id='span' style='opacity: 0.9'>" |
| 647 " <div style='float: right'>" |
| 648 " <div id='target' style='overflow: hidden'></div>" |
| 649 " </div>" |
| 650 " </span>" |
| 651 " </div>" |
| 652 "</div>"); |
| 653 |
| 654 PaintLayer* target = getPaintLayerByElementId("target"); |
| 655 EXPECT_EQ(getPaintLayerByElementId("containingBlock"), |
| 656 target->compositingContainer()); |
| 657 |
| 658 // enclosingLayerWithCompositedLayerMapping is not needed or applicable to |
| 659 // SPv2. |
| 660 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 661 EXPECT_EQ(getPaintLayerByElementId("compositedContainer"), |
| 662 target->enclosingLayerWithCompositedLayerMapping(ExcludeSelf)); |
| 663 } |
| 664 } |
| 665 |
| 666 TEST_P(PaintLayerTest, |
| 667 CompositingContainerNonStackedUnderFloatUnderStackingCompositedInline) { |
| 668 enableCompositing(); |
| 669 setBodyInnerHTML( |
| 670 "<div id='compositedContainer' style='position: relative;" |
| 671 " will-change: transform'>" |
| 672 " <div id='containingBlock' style='position: relative; z-index: 0'>" |
| 673 " <span id='span' style='opacity: 0.9; will-change: transform'>" |
| 674 " <div style='float: right'>" |
| 675 " <div id='target' style='overflow: hidden'></div>" |
| 676 " </div>" |
| 677 " </span>" |
| 678 " </div>" |
| 679 "</div>"); |
| 680 |
| 681 PaintLayer* target = getPaintLayerByElementId("target"); |
| 682 EXPECT_EQ(getPaintLayerByElementId("containingBlock"), |
| 683 target->compositingContainer()); |
| 684 |
| 685 // enclosingLayerWithCompositedLayerMapping is not needed or applicable to |
| 686 // SPv2. |
| 687 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 688 EXPECT_EQ(getPaintLayerByElementId("compositedContainer"), |
| 689 target->enclosingLayerWithCompositedLayerMapping(ExcludeSelf)); |
| 690 } |
| 691 } |
| 549 | 692 |
| 550 TEST_P(PaintLayerTest, FloatLayerAndAbsoluteUnderInlineLayer) { | 693 TEST_P(PaintLayerTest, FloatLayerAndAbsoluteUnderInlineLayer) { |
| 551 setBodyInnerHTML( | 694 setBodyInnerHTML( |
| 552 "<div id='container' style='position: absolute; top: 20px; left: 20px'>" | 695 "<div id='container' style='position: absolute; top: 20px; left: 20px'>" |
| 553 " <div style='margin: 33px'>" | 696 " <div style='margin: 33px'>" |
| 554 " <span id='span' style='position: relative; top: 100px; left: 100px'>" | 697 " <span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 555 " <div id='floating'" | 698 " <div id='floating'" |
| 556 " style='float: left; position: relative; top: 50px; left: 50px'>" | 699 " style='float: left; position: relative; top: 50px; left: 50px'>" |
| 557 " </div>" | 700 " </div>" |
| 558 " <div id='absolute'" | 701 " <div id='absolute'" |
| 559 " style='position: absolute; top: 50px; left: 50px'>" | 702 " style='position: absolute; top: 50px; left: 50px'>" |
| 560 " </div>" | 703 " </div>" |
| 561 " </span>" | 704 " </span>" |
| 562 " </div>" | 705 " </div>" |
| 563 "</div>"); | 706 "</div>"); |
| 564 | 707 |
| 565 PaintLayer* floating = | 708 PaintLayer* floating = getPaintLayerByElementId("floating"); |
| 566 toLayoutBoxModelObject(getLayoutObjectByElementId("floating"))->layer(); | 709 PaintLayer* absolute = getPaintLayerByElementId("absolute"); |
| 567 PaintLayer* absolute = | 710 PaintLayer* span = getPaintLayerByElementId("span"); |
| 568 toLayoutBoxModelObject(getLayoutObjectByElementId("absolute"))->layer(); | 711 PaintLayer* container = getPaintLayerByElementId("container"); |
| 569 PaintLayer* span = | |
| 570 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); | |
| 571 PaintLayer* container = | |
| 572 toLayoutBoxModelObject(getLayoutObjectByElementId("container"))->layer(); | |
| 573 | 712 |
| 574 EXPECT_EQ(span, floating->parent()); | 713 EXPECT_EQ(span, floating->parent()); |
| 575 EXPECT_EQ(container, floating->containingLayer()); | 714 EXPECT_EQ(container, floating->containingLayer()); |
| 576 EXPECT_EQ(span, absolute->parent()); | 715 EXPECT_EQ(span, absolute->parent()); |
| 577 EXPECT_EQ(span, absolute->containingLayer()); | 716 EXPECT_EQ(span, absolute->containingLayer()); |
| 578 EXPECT_EQ(container, span->parent()); | 717 EXPECT_EQ(container, span->parent()); |
| 579 EXPECT_EQ(container, span->containingLayer()); | 718 EXPECT_EQ(container, span->containingLayer()); |
| 580 | 719 |
| 581 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); | 720 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); |
| 582 EXPECT_EQ(LayoutPoint(50, 50), absolute->location()); | 721 EXPECT_EQ(LayoutPoint(50, 50), absolute->location()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 594 setBodyInnerHTML( | 733 setBodyInnerHTML( |
| 595 "<div id='container' style='overflow: scroll; width: 50px; height: 50px'>" | 734 "<div id='container' style='overflow: scroll; width: 50px; height: 50px'>" |
| 596 " <span id='span' style='position: relative; top: 100px; left: 100px'>" | 735 " <span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 597 " <div id='floating'" | 736 " <div id='floating'" |
| 598 " style='float: left; position: relative; top: 50px; left: 50px'>" | 737 " style='float: left; position: relative; top: 50px; left: 50px'>" |
| 599 " </div>" | 738 " </div>" |
| 600 " </span>" | 739 " </span>" |
| 601 " <div style='height: 1000px'></div>" | 740 " <div style='height: 1000px'></div>" |
| 602 "</div>"); | 741 "</div>"); |
| 603 | 742 |
| 604 PaintLayer* floating = | 743 PaintLayer* floating = getPaintLayerByElementId("floating"); |
| 605 toLayoutBoxModelObject(getLayoutObjectByElementId("floating"))->layer(); | 744 PaintLayer* span = getPaintLayerByElementId("span"); |
| 606 PaintLayer* span = | 745 PaintLayer* container = getPaintLayerByElementId("container"); |
| 607 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); | |
| 608 PaintLayer* container = | |
| 609 toLayoutBoxModelObject(getLayoutObjectByElementId("container"))->layer(); | |
| 610 container->getScrollableArea()->setScrollOffset(ScrollOffset(0, 400), | 746 container->getScrollableArea()->setScrollOffset(ScrollOffset(0, 400), |
| 611 ProgrammaticScroll); | 747 ProgrammaticScroll); |
| 612 | 748 |
| 613 EXPECT_EQ(span, floating->parent()); | 749 EXPECT_EQ(span, floating->parent()); |
| 614 EXPECT_EQ(container, floating->containingLayer()); | 750 EXPECT_EQ(container, floating->containingLayer()); |
| 615 EXPECT_EQ(container, span->parent()); | 751 EXPECT_EQ(container, span->parent()); |
| 616 EXPECT_EQ(container, span->containingLayer()); | 752 EXPECT_EQ(container, span->containingLayer()); |
| 617 | 753 |
| 618 EXPECT_EQ(LayoutPoint(50, -350), floating->location()); | 754 EXPECT_EQ(LayoutPoint(50, -350), floating->location()); |
| 619 EXPECT_EQ(LayoutPoint(100, -300), span->location()); | 755 EXPECT_EQ(LayoutPoint(100, -300), span->location()); |
| 620 | 756 |
| 621 EXPECT_EQ(LayoutPoint(-50, -50), floating->visualOffsetFromAncestor(span)); | 757 EXPECT_EQ(LayoutPoint(-50, -50), floating->visualOffsetFromAncestor(span)); |
| 622 EXPECT_EQ(LayoutPoint(50, -350), | 758 EXPECT_EQ(LayoutPoint(50, -350), |
| 623 floating->visualOffsetFromAncestor(container)); | 759 floating->visualOffsetFromAncestor(container)); |
| 624 } | 760 } |
| 625 | 761 |
| 626 TEST_P(PaintLayerTest, FloatLayerUnderBlockUnderInlineLayer) { | 762 TEST_P(PaintLayerTest, FloatLayerUnderBlockUnderInlineLayer) { |
| 627 setBodyInnerHTML( | 763 setBodyInnerHTML( |
| 628 "<style>body {margin: 0}</style>" | 764 "<style>body {margin: 0}</style>" |
| 629 "<span id='span' style='position: relative; top: 100px; left: 100px'>" | 765 "<span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 630 " <div style='display: inline-block; margin: 33px'>" | 766 " <div style='display: inline-block; margin: 33px'>" |
| 631 " <div id='floating'" | 767 " <div id='floating'" |
| 632 " style='float: left; position: relative; top: 50px; left: 50px'>" | 768 " style='float: left; position: relative; top: 50px; left: 50px'>" |
| 633 " </div>" | 769 " </div>" |
| 634 " </div>" | 770 " </div>" |
| 635 "</span>"); | 771 "</span>"); |
| 636 | 772 |
| 637 PaintLayer* floating = | 773 PaintLayer* floating = getPaintLayerByElementId("floating"); |
| 638 toLayoutBoxModelObject(getLayoutObjectByElementId("floating"))->layer(); | 774 PaintLayer* span = getPaintLayerByElementId("span"); |
| 639 PaintLayer* span = | |
| 640 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); | |
| 641 | 775 |
| 642 EXPECT_EQ(span, floating->parent()); | 776 EXPECT_EQ(span, floating->parent()); |
| 643 EXPECT_EQ(span, floating->containingLayer()); | 777 EXPECT_EQ(span, floating->containingLayer()); |
| 644 | 778 |
| 645 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); | 779 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); |
| 646 EXPECT_EQ(LayoutPoint(100, 100), span->location()); | 780 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 647 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor(span)); | 781 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor(span)); |
| 648 EXPECT_EQ(LayoutPoint(183, 183), floating->visualOffsetFromAncestor( | 782 EXPECT_EQ(LayoutPoint(183, 183), floating->visualOffsetFromAncestor( |
| 649 document().layoutView()->layer())); | 783 document().layoutView()->layer())); |
| 650 } | 784 } |
| 651 | 785 |
| 652 TEST_P(PaintLayerTest, FloatLayerUnderFloatUnderInlineLayer) { | 786 TEST_P(PaintLayerTest, FloatLayerUnderFloatUnderInlineLayer) { |
| 653 setBodyInnerHTML( | 787 setBodyInnerHTML( |
| 654 "<style>body {margin: 0}</style>" | 788 "<style>body {margin: 0}</style>" |
| 655 "<span id='span' style='position: relative; top: 100px; left: 100px'>" | 789 "<span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 656 " <div style='float: left; margin: 33px'>" | 790 " <div style='float: left; margin: 33px'>" |
| 657 " <div id='floating'" | 791 " <div id='floating'" |
| 658 " style='float: left; position: relative; top: 50px; left: 50px'>" | 792 " style='float: left; position: relative; top: 50px; left: 50px'>" |
| 659 " </div>" | 793 " </div>" |
| 660 " </div>" | 794 " </div>" |
| 661 "</span>"); | 795 "</span>"); |
| 662 | 796 |
| 663 PaintLayer* floating = | 797 PaintLayer* floating = getPaintLayerByElementId("floating"); |
| 664 toLayoutBoxModelObject(getLayoutObjectByElementId("floating"))->layer(); | 798 PaintLayer* span = getPaintLayerByElementId("span"); |
| 665 PaintLayer* span = | |
| 666 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); | |
| 667 | 799 |
| 668 EXPECT_EQ(span, floating->parent()); | 800 EXPECT_EQ(span, floating->parent()); |
| 669 EXPECT_EQ(span->parent(), floating->containingLayer()); | 801 EXPECT_EQ(span->parent(), floating->containingLayer()); |
| 670 | 802 |
| 671 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); | 803 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); |
| 672 EXPECT_EQ(LayoutPoint(100, 100), span->location()); | 804 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 673 EXPECT_EQ(LayoutPoint(-17, -17), floating->visualOffsetFromAncestor(span)); | 805 EXPECT_EQ(LayoutPoint(-17, -17), floating->visualOffsetFromAncestor(span)); |
| 674 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor( | 806 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor( |
| 675 document().layoutView()->layer())); | 807 document().layoutView()->layer())); |
| 676 } | 808 } |
| 677 | 809 |
| 678 TEST_P(PaintLayerTest, FloatLayerUnderFloatLayerUnderInlineLayer) { | 810 TEST_P(PaintLayerTest, FloatLayerUnderFloatLayerUnderInlineLayer) { |
| 679 setBodyInnerHTML( | 811 setBodyInnerHTML( |
| 680 "<style>body {margin: 0}</style>" | 812 "<style>body {margin: 0}</style>" |
| 681 "<span id='span' style='position: relative; top: 100px; left: 100px'>" | 813 "<span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 682 " <div id='floatingParent'" | 814 " <div id='floatingParent'" |
| 683 " style='float: left; position: relative; margin: 33px'>" | 815 " style='float: left; position: relative; margin: 33px'>" |
| 684 " <div id='floating'" | 816 " <div id='floating'" |
| 685 " style='float: left; position: relative; top: 50px; left: 50px'>" | 817 " style='float: left; position: relative; top: 50px; left: 50px'>" |
| 686 " </div>" | 818 " </div>" |
| 687 " </div>" | 819 " </div>" |
| 688 "</span>"); | 820 "</span>"); |
| 689 | 821 |
| 690 PaintLayer* floating = | 822 PaintLayer* floating = getPaintLayerByElementId("floating"); |
| 691 toLayoutBoxModelObject(getLayoutObjectByElementId("floating"))->layer(); | 823 PaintLayer* floatingParent = getPaintLayerByElementId("floatingParent"); |
| 692 PaintLayer* floatingParent = | 824 PaintLayer* span = getPaintLayerByElementId("span"); |
| 693 toLayoutBoxModelObject(getLayoutObjectByElementId("floatingParent")) | |
| 694 ->layer(); | |
| 695 PaintLayer* span = | |
| 696 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); | |
| 697 | 825 |
| 698 EXPECT_EQ(floatingParent, floating->parent()); | 826 EXPECT_EQ(floatingParent, floating->parent()); |
| 699 EXPECT_EQ(floatingParent, floating->containingLayer()); | 827 EXPECT_EQ(floatingParent, floating->containingLayer()); |
| 700 EXPECT_EQ(span, floatingParent->parent()); | 828 EXPECT_EQ(span, floatingParent->parent()); |
| 701 EXPECT_EQ(span->parent(), floatingParent->containingLayer()); | 829 EXPECT_EQ(span->parent(), floatingParent->containingLayer()); |
| 702 | 830 |
| 703 EXPECT_EQ(LayoutPoint(50, 50), floating->location()); | 831 EXPECT_EQ(LayoutPoint(50, 50), floating->location()); |
| 704 EXPECT_EQ(LayoutPoint(33, 33), floatingParent->location()); | 832 EXPECT_EQ(LayoutPoint(33, 33), floatingParent->location()); |
| 705 EXPECT_EQ(LayoutPoint(100, 100), span->location()); | 833 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 706 EXPECT_EQ(LayoutPoint(-17, -17), floating->visualOffsetFromAncestor(span)); | 834 EXPECT_EQ(LayoutPoint(-17, -17), floating->visualOffsetFromAncestor(span)); |
| 707 EXPECT_EQ(LayoutPoint(-67, -67), | 835 EXPECT_EQ(LayoutPoint(-67, -67), |
| 708 floatingParent->visualOffsetFromAncestor(span)); | 836 floatingParent->visualOffsetFromAncestor(span)); |
| 709 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor( | 837 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor( |
| 710 document().layoutView()->layer())); | 838 document().layoutView()->layer())); |
| 711 } | 839 } |
| 712 | 840 |
| 713 TEST_P(PaintLayerTest, LayerUnderFloatUnderInlineLayer) { | 841 TEST_P(PaintLayerTest, LayerUnderFloatUnderInlineLayer) { |
| 714 setBodyInnerHTML( | 842 setBodyInnerHTML( |
| 715 "<style>body {margin: 0}</style>" | 843 "<style>body {margin: 0}</style>" |
| 716 "<span id='span' style='position: relative; top: 100px; left: 100px'>" | 844 "<span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 717 " <div style='float: left; margin: 33px'>" | 845 " <div style='float: left; margin: 33px'>" |
| 718 " <div>" | 846 " <div>" |
| 719 " <div id='child' style='position: relative; top: 50px; left: 50px'>" | 847 " <div id='child' style='position: relative; top: 50px; left: 50px'>" |
| 720 " </div>" | 848 " </div>" |
| 721 " </div>" | 849 " </div>" |
| 722 " </div>" | 850 " </div>" |
| 723 "</span>"); | 851 "</span>"); |
| 724 | 852 |
| 725 PaintLayer* child = | 853 PaintLayer* child = getPaintLayerByElementId("child"); |
| 726 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); | 854 PaintLayer* span = getPaintLayerByElementId("span"); |
| 727 PaintLayer* span = | |
| 728 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); | |
| 729 | 855 |
| 730 EXPECT_EQ(span, child->parent()); | 856 EXPECT_EQ(span, child->parent()); |
| 731 EXPECT_EQ(span->parent(), child->containingLayer()); | 857 EXPECT_EQ(span->parent(), child->containingLayer()); |
| 732 | 858 |
| 733 EXPECT_EQ(LayoutPoint(83, 83), child->location()); | 859 EXPECT_EQ(LayoutPoint(83, 83), child->location()); |
| 734 EXPECT_EQ(LayoutPoint(100, 100), span->location()); | 860 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 735 EXPECT_EQ(LayoutPoint(-17, -17), child->visualOffsetFromAncestor(span)); | 861 EXPECT_EQ(LayoutPoint(-17, -17), child->visualOffsetFromAncestor(span)); |
| 736 EXPECT_EQ(LayoutPoint(83, 83), | 862 EXPECT_EQ(LayoutPoint(83, 83), |
| 737 child->visualOffsetFromAncestor(document().layoutView()->layer())); | 863 child->visualOffsetFromAncestor(document().layoutView()->layer())); |
| 738 } | 864 } |
| 739 | 865 |
| 740 TEST_P(PaintLayerTest, CompositingContainerFloatingIframe) { | 866 TEST_P(PaintLayerTest, CompositingContainerFloatingIframe) { |
| 741 enableCompositing(); | 867 enableCompositing(); |
| 742 setBodyInnerHTML( | 868 setBodyInnerHTML( |
| 743 "<div id='compositedContainer' style='position: relative;" | 869 "<div id='compositedContainer' style='position: relative;" |
| 744 " will-change: transform'>" | 870 " will-change: transform'>" |
| 745 " <div id='containingBlock' style='position: relative; z-index: 0'>" | 871 " <div id='containingBlock' style='position: relative; z-index: 0'>" |
| 746 " <div style='backface-visibility: hidden'></div>" | 872 " <div style='backface-visibility: hidden'></div>" |
| 747 " <span id='span'" | 873 " <span id='span'" |
| 748 " style='clip-path: polygon(0px 15px, 0px 54px, 100px 0px)'>" | 874 " style='clip-path: polygon(0px 15px, 0px 54px, 100px 0px)'>" |
| 749 " <iframe srcdoc='foo' id='target' style='float: right'></iframe>" | 875 " <iframe srcdoc='foo' id='target' style='float: right'></iframe>" |
| 750 " </span>" | 876 " </span>" |
| 751 " </div>" | 877 " </div>" |
| 752 "</div>"); | 878 "</div>"); |
| 753 | 879 |
| 754 PaintLayer* target = | 880 PaintLayer* target = getPaintLayerByElementId("target"); |
| 755 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); | |
| 756 | 881 |
| 757 // A non-positioned iframe still gets a PaintLayer because PaintLayers are | 882 // A non-positioned iframe still gets a PaintLayer because PaintLayers are |
| 758 // forced for all LayoutPart objects. However, such PaintLayers are not | 883 // forced for all LayoutPart objects. However, such PaintLayers are not |
| 759 // stacked. | 884 // stacked. |
| 760 PaintLayer* containingBlock = | 885 PaintLayer* containingBlock = getPaintLayerByElementId("containingBlock"); |
| 761 toLayoutBoxModelObject(getLayoutObjectByElementId("containingBlock")) | |
| 762 ->layer(); | |
| 763 EXPECT_EQ(containingBlock, target->compositingContainer()); | 886 EXPECT_EQ(containingBlock, target->compositingContainer()); |
| 764 PaintLayer* compositedContainer = | 887 PaintLayer* compositedContainer = |
| 765 toLayoutBoxModelObject(getLayoutObjectByElementId("compositedContainer")) | 888 getPaintLayerByElementId("compositedContainer"); |
| 766 ->layer(); | |
| 767 | 889 |
| 768 // enclosingLayerWithCompositedLayerMapping is not needed or applicable to | 890 // enclosingLayerWithCompositedLayerMapping is not needed or applicable to |
| 769 // SPv2. | 891 // SPv2. |
| 770 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 892 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 771 EXPECT_EQ(compositedContainer, | 893 EXPECT_EQ(compositedContainer, |
| 772 target->enclosingLayerWithCompositedLayerMapping(ExcludeSelf)); | 894 target->enclosingLayerWithCompositedLayerMapping(ExcludeSelf)); |
| 773 } | 895 } |
| 774 } | 896 } |
| 775 | 897 |
| 776 TEST_P(PaintLayerTest, CompositingContainerSelfPaintingNonStackedFloat) { | 898 TEST_P(PaintLayerTest, CompositingContainerSelfPaintingNonStackedFloat) { |
| 777 setBodyInnerHTML( | 899 setBodyInnerHTML( |
| 778 "<div id='container' style='position: relative'>" | 900 "<div id='container' style='position: relative'>" |
| 779 " <span id='span' style='opacity: 0.9'>" | 901 " <span id='span' style='opacity: 0.9'>" |
| 780 " <div id='target' style='columns: 1; float: left'></div>" | 902 " <div id='target' style='columns: 1; float: left'></div>" |
| 781 " </span>" | 903 " </span>" |
| 782 "</div>"); | 904 "</div>"); |
| 783 | 905 |
| 784 // The target layer is self-painting, but not stacked. | 906 // The target layer is self-painting, but not stacked. |
| 785 PaintLayer* target = | 907 PaintLayer* target = getPaintLayerByElementId("target"); |
| 786 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); | |
| 787 EXPECT_TRUE(target->isSelfPaintingLayer()); | 908 EXPECT_TRUE(target->isSelfPaintingLayer()); |
| 788 EXPECT_FALSE(target->stackingNode()->isStacked()); | 909 EXPECT_FALSE(target->stackingNode()->isStacked()); |
| 789 | 910 |
| 790 PaintLayer* container = | 911 PaintLayer* container = getPaintLayerByElementId("container"); |
| 791 toLayoutBoxModelObject(getLayoutObjectByElementId("container"))->layer(); | 912 PaintLayer* span = getPaintLayerByElementId("span"); |
| 792 PaintLayer* span = | |
| 793 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); | |
| 794 EXPECT_EQ(container, target->containingLayer()); | 913 EXPECT_EQ(container, target->containingLayer()); |
| 795 EXPECT_EQ(span, target->compositingContainer()); | 914 EXPECT_EQ(span, target->compositingContainer()); |
| 796 } | 915 } |
| 797 | 916 |
| 798 TEST_P(PaintLayerTest, ColumnSpanLayerUnderExtraLayerScrolled) { | 917 TEST_P(PaintLayerTest, ColumnSpanLayerUnderExtraLayerScrolled) { |
| 799 setBodyInnerHTML( | 918 setBodyInnerHTML( |
| 800 "<div id='columns' style='overflow: hidden; width: 80px; height: 80px; " | 919 "<div id='columns' style='overflow: hidden; width: 80px; height: 80px; " |
| 801 " columns: 2; column-gap: 0'>" | 920 " columns: 2; column-gap: 0'>" |
| 802 " <div id='extraLayer'" | 921 " <div id='extraLayer'" |
| 803 " style='position: relative; top: 100px; left: 100px'>" | 922 " style='position: relative; top: 100px; left: 100px'>" |
| 804 " <div id='spanner' style='column-span: all; position: relative; " | 923 " <div id='spanner' style='column-span: all; position: relative; " |
| 805 " top: 50px; left: 50px'>" | 924 " top: 50px; left: 50px'>" |
| 806 " </div>" | 925 " </div>" |
| 807 " </div>" | 926 " </div>" |
| 808 " <div style='height: 1000px'></div>" | 927 " <div style='height: 1000px'></div>" |
| 809 "</div>"); | 928 "</div>"); |
| 810 | 929 |
| 811 PaintLayer* spanner = | 930 PaintLayer* spanner = getPaintLayerByElementId("spanner"); |
| 812 toLayoutBoxModelObject(getLayoutObjectByElementId("spanner"))->layer(); | 931 PaintLayer* extraLayer = getPaintLayerByElementId("extraLayer"); |
| 813 PaintLayer* extraLayer = | 932 PaintLayer* columns = getPaintLayerByElementId("columns"); |
| 814 toLayoutBoxModelObject(getLayoutObjectByElementId("extraLayer"))->layer(); | |
| 815 PaintLayer* columns = | |
| 816 toLayoutBoxModelObject(getLayoutObjectByElementId("columns"))->layer(); | |
| 817 columns->getScrollableArea()->setScrollOffset(ScrollOffset(200, 0), | 933 columns->getScrollableArea()->setScrollOffset(ScrollOffset(200, 0), |
| 818 ProgrammaticScroll); | 934 ProgrammaticScroll); |
| 819 | 935 |
| 820 EXPECT_EQ(extraLayer, spanner->parent()); | 936 EXPECT_EQ(extraLayer, spanner->parent()); |
| 821 EXPECT_EQ(columns, spanner->containingLayer()); | 937 EXPECT_EQ(columns, spanner->containingLayer()); |
| 822 EXPECT_EQ(columns, extraLayer->parent()->parent()); | 938 EXPECT_EQ(columns, extraLayer->parent()->parent()); |
| 823 EXPECT_EQ(columns, extraLayer->containingLayer()->parent()); | 939 EXPECT_EQ(columns, extraLayer->containingLayer()->parent()); |
| 824 | 940 |
| 825 EXPECT_EQ(LayoutPoint(-150, 50), spanner->location()); | 941 EXPECT_EQ(LayoutPoint(-150, 50), spanner->location()); |
| 826 EXPECT_EQ(LayoutPoint(100, 100), extraLayer->location()); | 942 EXPECT_EQ(LayoutPoint(100, 100), extraLayer->location()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 842 RefPtr<ComputedStyle> oldStyle = | 958 RefPtr<ComputedStyle> oldStyle = |
| 843 ComputedStyle::clone(targetObject->styleRef()); | 959 ComputedStyle::clone(targetObject->styleRef()); |
| 844 ComputedStyle* newStyle = targetObject->mutableStyle(); | 960 ComputedStyle* newStyle = targetObject->mutableStyle(); |
| 845 newStyle->setHasCurrentTransformAnimation(); | 961 newStyle->setHasCurrentTransformAnimation(); |
| 846 targetPaintLayer->updateTransform(oldStyle.get(), *newStyle); | 962 targetPaintLayer->updateTransform(oldStyle.get(), *newStyle); |
| 847 | 963 |
| 848 EXPECT_NE(nullptr, targetPaintLayer->transform()); | 964 EXPECT_NE(nullptr, targetPaintLayer->transform()); |
| 849 } | 965 } |
| 850 | 966 |
| 851 } // namespace blink | 967 } // namespace blink |
| OLD | NEW |