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/layout/LayoutTestHelper.h" | 5 #include "core/layout/LayoutTestHelper.h" |
6 #include "core/layout/LayoutTreeAsText.h" | 6 #include "core/layout/LayoutTreeAsText.h" |
7 #include "core/layout/api/LayoutViewItem.h" | 7 #include "core/layout/api/LayoutViewItem.h" |
8 #include "core/paint/ObjectPaintProperties.h" | 8 #include "core/paint/ObjectPaintProperties.h" |
| 9 #include "core/paint/PaintLayer.h" |
9 #include "core/paint/PaintPropertyTreePrinter.h" | 10 #include "core/paint/PaintPropertyTreePrinter.h" |
10 #include "platform/graphics/paint/GeometryMapper.h" | 11 #include "platform/graphics/paint/GeometryMapper.h" |
11 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" | 12 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" |
12 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 13 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
13 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 14 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
14 #include "platform/testing/UnitTestHelpers.h" | 15 #include "platform/testing/UnitTestHelpers.h" |
15 #include "platform/text/TextStream.h" | 16 #include "platform/text/TextStream.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "wtf/HashMap.h" | 18 #include "wtf/HashMap.h" |
18 #include "wtf/Vector.h" | 19 #include "wtf/Vector.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 EXPECT_EQ(0.9f, transparentProperties->effect()->opacity()); | 146 EXPECT_EQ(0.9f, transparentProperties->effect()->opacity()); |
146 | 147 |
147 // Invalidate the opacity property. | 148 // Invalidate the opacity property. |
148 transparentElement->setAttribute(HTMLNames::classAttr, "opacityB"); | 149 transparentElement->setAttribute(HTMLNames::classAttr, "opacityB"); |
149 document().view()->updateAllLifecyclePhases(); | 150 document().view()->updateAllLifecyclePhases(); |
150 | 151 |
151 // The opacity should have changed. | 152 // The opacity should have changed. |
152 EXPECT_EQ(0.4f, transparentProperties->effect()->opacity()); | 153 EXPECT_EQ(0.4f, transparentProperties->effect()->opacity()); |
153 } | 154 } |
154 | 155 |
| 156 TEST_P(PrePaintTreeWalkTest, ClearSubsequenceCachingClipChange) { |
| 157 setBodyInnerHTML( |
| 158 "<style>" |
| 159 " .clip { overflow: hidden }" |
| 160 "</style>" |
| 161 "<div id='parent' style='transform: translateZ(0); width: 100px;" |
| 162 " height: 100px;'>" |
| 163 " <div id='child' style='isolation: isolate'>" |
| 164 " content" |
| 165 " </div>" |
| 166 "</div>"); |
| 167 |
| 168 auto* parent = document().getElementById("parent"); |
| 169 auto* child = document().getElementById("child"); |
| 170 auto* childPaintLayer = |
| 171 toLayoutBoxModelObject(child->layoutObject())->layer(); |
| 172 EXPECT_FALSE(childPaintLayer->needsRepaint()); |
| 173 EXPECT_FALSE(childPaintLayer->needsPaintPhaseFloat()); |
| 174 |
| 175 parent->setAttribute(HTMLNames::classAttr, "clip"); |
| 176 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 177 |
| 178 EXPECT_TRUE(childPaintLayer->needsRepaint()); |
| 179 } |
| 180 |
| 181 TEST_P(PrePaintTreeWalkTest, ClearSubsequenceCachingClipChange2DTransform) { |
| 182 setBodyInnerHTML( |
| 183 "<style>" |
| 184 " .clip { overflow: hidden }" |
| 185 "</style>" |
| 186 "<div id='parent' style='transform: translateX(0); width: 100px;" |
| 187 " height: 100px;'>" |
| 188 " <div id='child' style='isolation: isolate'>" |
| 189 " content" |
| 190 " </div>" |
| 191 "</div>"); |
| 192 |
| 193 auto* parent = document().getElementById("parent"); |
| 194 auto* child = document().getElementById("child"); |
| 195 auto* childPaintLayer = |
| 196 toLayoutBoxModelObject(child->layoutObject())->layer(); |
| 197 EXPECT_FALSE(childPaintLayer->needsRepaint()); |
| 198 EXPECT_FALSE(childPaintLayer->needsPaintPhaseFloat()); |
| 199 |
| 200 parent->setAttribute(HTMLNames::classAttr, "clip"); |
| 201 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 202 |
| 203 EXPECT_TRUE(childPaintLayer->needsRepaint()); |
| 204 } |
| 205 |
| 206 TEST_P(PrePaintTreeWalkTest, ClearSubsequenceCachingClipChangePosAbs) { |
| 207 setBodyInnerHTML( |
| 208 "<style>" |
| 209 " .clip { overflow: hidden }" |
| 210 "</style>" |
| 211 "<div id='parent' style='transform: translateZ(0); width: 100px;" |
| 212 " height: 100px; position: absolute'>" |
| 213 " <div id='child' style='overflow: hidden; z-index: 0; width: 50px;" |
| 214 " height: 50px'>" |
| 215 " content" |
| 216 " </div>" |
| 217 "</div>"); |
| 218 |
| 219 auto* parent = document().getElementById("parent"); |
| 220 auto* child = document().getElementById("child"); |
| 221 auto* childPaintLayer = |
| 222 toLayoutBoxModelObject(child->layoutObject())->layer(); |
| 223 EXPECT_FALSE(childPaintLayer->needsRepaint()); |
| 224 EXPECT_FALSE(childPaintLayer->needsPaintPhaseFloat()); |
| 225 |
| 226 // This changes clips for absolute-positioned descendants of "child" but not |
| 227 // normal-position ones, which are already clipped to 50x50. |
| 228 parent->setAttribute(HTMLNames::classAttr, "clip"); |
| 229 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 230 |
| 231 EXPECT_TRUE(childPaintLayer->needsRepaint()); |
| 232 } |
| 233 |
| 234 TEST_P(PrePaintTreeWalkTest, ClearSubsequenceCachingClipChangePosFixed) { |
| 235 setBodyInnerHTML( |
| 236 "<style>" |
| 237 " .clip { overflow: hidden }" |
| 238 "</style>" |
| 239 "<div id='parent' style='transform: translateZ(0); width: 100px;" |
| 240 " height: 100px; trans'>" |
| 241 " <div id='child' style='overflow: hidden; z-index: 0;" |
| 242 " position: absolute; width: 50px; height: 50px'>" |
| 243 " content" |
| 244 " </div>" |
| 245 "</div>"); |
| 246 |
| 247 auto* parent = document().getElementById("parent"); |
| 248 auto* child = document().getElementById("child"); |
| 249 auto* childPaintLayer = |
| 250 toLayoutBoxModelObject(child->layoutObject())->layer(); |
| 251 EXPECT_FALSE(childPaintLayer->needsRepaint()); |
| 252 EXPECT_FALSE(childPaintLayer->needsPaintPhaseFloat()); |
| 253 |
| 254 // This changes clips for absolute-positioned descendants of "child" but not |
| 255 // normal-position ones, which are already clipped to 50x50. |
| 256 parent->setAttribute(HTMLNames::classAttr, "clip"); |
| 257 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 258 |
| 259 EXPECT_TRUE(childPaintLayer->needsRepaint()); |
| 260 } |
| 261 |
155 } // namespace blink | 262 } // namespace blink |
OLD | NEW |