Chromium Code Reviews| 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/compositing/CompositingReasonFinder.h" | 5 #include "core/layout/compositing/CompositingReasonFinder.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/layout/LayoutBlock.h" | 8 #include "core/layout/LayoutBlock.h" |
| 9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
| 10 #include "core/paint/PaintLayer.h" | 10 #include "core/paint/PaintLayer.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 | 296 |
| 297 Element* innerSticky = document().getElementById("innerSticky"); | 297 Element* innerSticky = document().getElementById("innerSticky"); |
| 298 PaintLayer* innerStickyLayer = | 298 PaintLayer* innerStickyLayer = |
| 299 toLayoutBoxModelObject(innerSticky->layoutObject())->layer(); | 299 toLayoutBoxModelObject(innerSticky->layoutObject())->layer(); |
| 300 ASSERT_TRUE(innerStickyLayer); | 300 ASSERT_TRUE(innerStickyLayer); |
| 301 | 301 |
| 302 EXPECT_EQ(PaintsIntoOwnBacking, outerStickyLayer->compositingState()); | 302 EXPECT_EQ(PaintsIntoOwnBacking, outerStickyLayer->compositingState()); |
| 303 EXPECT_EQ(NotComposited, innerStickyLayer->compositingState()); | 303 EXPECT_EQ(NotComposited, innerStickyLayer->compositingState()); |
| 304 } | 304 } |
| 305 | 305 |
| 306 TEST_F(CompositingReasonFinderTest, CompositeSkewWithPromotedSkewedAncestor) { | |
| 307 setBodyInnerHTML( | |
| 308 "<style>div.skew { transform: skew(20deg);}" | |
| 309 "div.skew > div { transform: skew(-20deg); }" | |
| 310 "div.composited { will-change: transform; }</style>" | |
| 311 "<div class='skew'>" | |
| 312 " <div id='non-composited'></div>" | |
| 313 "</div>" | |
| 314 "<div id='skew' class='skew'>" | |
| 315 " <div id='should-composite'></div>" | |
| 316 " <div id='composited' class='composited'></div>" | |
| 317 "</div>"); | |
| 318 document().view()->updateAllLifecyclePhases(); | |
| 319 | |
| 320 // Skewed element is not composited automatically. | |
| 321 Element* nonComposited = document().getElementById("non-composited"); | |
| 322 PaintLayer* nonCompositedLayer = | |
| 323 toLayoutBoxModelObject(nonComposited->layoutObject())->layer(); | |
| 324 ASSERT_TRUE(nonCompositedLayer); | |
| 325 EXPECT_EQ(NotComposited, nonCompositedLayer->compositingState()); | |
| 326 | |
| 327 // Composite as it has composited descendant. | |
| 328 Element* compositedElement = document().getElementById("skew"); | |
| 329 PaintLayer* compositedLayer = | |
| 330 toLayoutBoxModelObject(compositedElement->layoutObject())->layer(); | |
| 331 ASSERT_TRUE(compositedLayer); | |
| 332 EXPECT_EQ(PaintsIntoOwnBacking, compositedLayer->compositingState()); | |
|
flackr
2017/02/28 21:40:14
This should not automatically be composited, it's
| |
| 333 | |
| 334 // Skewed element with promoted skewed ancestor gets promoted as well. | |
| 335 compositedElement = document().getElementById("should-composite"); | |
| 336 compositedLayer = | |
| 337 toLayoutBoxModelObject(compositedElement->layoutObject())->layer(); | |
| 338 ASSERT_TRUE(compositedLayer); | |
| 339 EXPECT_EQ(PaintsIntoOwnBacking, compositedLayer->compositingState()); | |
| 340 | |
| 341 // Skewed element without promoted ancestor does not composite. | |
| 342 document().getElementById("composited")->removeAttribute("class"); | |
| 343 document().view()->updateAllLifecyclePhases(); | |
| 344 ASSERT_TRUE(compositedLayer); | |
| 345 EXPECT_EQ(NotComposited, compositedLayer->compositingState()); | |
| 346 | |
| 347 // Skewed element with promoted ancestor which is not skewed does not | |
| 348 // composite. | |
| 349 document() | |
| 350 .getElementById("composited") | |
| 351 ->setAttribute(HTMLNames::classAttr, "composited"); | |
| 352 document().getElementById("skew")->removeAttribute("class"); | |
| 353 document().view()->updateAllLifecyclePhases(); | |
| 354 ASSERT_TRUE(compositedLayer); | |
| 355 EXPECT_EQ(NotComposited, compositedLayer->compositingState()); | |
| 356 } | |
| 357 | |
| 306 } // namespace blink | 358 } // namespace blink |
| OLD | NEW |