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" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 PaintLayer* visible = | 283 PaintLayer* visible = |
284 toLayoutBoxModelObject(getLayoutObjectByElementId("visible"))->layer(); | 284 toLayoutBoxModelObject(getLayoutObjectByElementId("visible"))->layer(); |
285 | 285 |
286 EXPECT_TRUE(invisible->hasVisibleDescendant()); | 286 EXPECT_TRUE(invisible->hasVisibleDescendant()); |
287 EXPECT_FALSE(visible->hasVisibleDescendant()); | 287 EXPECT_FALSE(visible->hasVisibleDescendant()); |
288 | 288 |
289 EXPECT_FALSE(invisible->hasNonIsolatedDescendantWithBlendMode()); | 289 EXPECT_FALSE(invisible->hasNonIsolatedDescendantWithBlendMode()); |
290 EXPECT_FALSE(invisible->hasDescendantWithClipPath()); | 290 EXPECT_FALSE(invisible->hasDescendantWithClipPath()); |
291 } | 291 } |
292 | 292 |
| 293 TEST_P(PaintLayerTest, Has3DTransformedDescendant) { |
| 294 enableCompositing(); |
| 295 setBodyInnerHTML( |
| 296 "<div id='parent' style='position:relative; z-index: 0'>" |
| 297 " <div id='child' style='transform: translateZ(1px)'>" |
| 298 " </div>" |
| 299 "</div>"); |
| 300 PaintLayer* parent = |
| 301 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); |
| 302 PaintLayer* child = |
| 303 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); |
| 304 |
| 305 EXPECT_TRUE(parent->has3DTransformedDescendant()); |
| 306 EXPECT_FALSE(child->has3DTransformedDescendant()); |
| 307 } |
| 308 |
| 309 TEST_P(PaintLayerTest, Has3DTransformedDescendantChangeStyle) { |
| 310 enableCompositing(); |
| 311 setBodyInnerHTML( |
| 312 "<div id='parent' style='position:relative; z-index: 0'>" |
| 313 " <div id='child' style='position:relative '>" |
| 314 " </div>" |
| 315 "</div>"); |
| 316 PaintLayer* parent = |
| 317 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); |
| 318 PaintLayer* child = |
| 319 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); |
| 320 |
| 321 EXPECT_FALSE(parent->has3DTransformedDescendant()); |
| 322 EXPECT_FALSE(child->has3DTransformedDescendant()); |
| 323 |
| 324 document().getElementById("child")->setAttribute( |
| 325 HTMLNames::styleAttr, "transform: translateZ(1px)"); |
| 326 document().view()->updateAllLifecyclePhases(); |
| 327 |
| 328 EXPECT_TRUE(parent->has3DTransformedDescendant()); |
| 329 EXPECT_FALSE(child->has3DTransformedDescendant()); |
| 330 } |
| 331 |
| 332 TEST_P(PaintLayerTest, Has3DTransformedDescendantNotStacking) { |
| 333 enableCompositing(); |
| 334 setBodyInnerHTML( |
| 335 "<div id='parent' style='position:relative;'>" |
| 336 " <div id='child' style='transform: translateZ(1px)'>" |
| 337 " </div>" |
| 338 "</div>"); |
| 339 PaintLayer* parent = |
| 340 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); |
| 341 PaintLayer* child = |
| 342 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); |
| 343 |
| 344 // |child| is not a stacking child of |parent|, so it has no 3D transformed |
| 345 // descendant. |
| 346 EXPECT_FALSE(parent->has3DTransformedDescendant()); |
| 347 EXPECT_FALSE(child->has3DTransformedDescendant()); |
| 348 } |
| 349 |
| 350 TEST_P(PaintLayerTest, Has3DTransformedGrandchildWithPreserve3d) { |
| 351 enableCompositing(); |
| 352 setBodyInnerHTML( |
| 353 "<div id='parent' style='position:relative; z-index: 0'>" |
| 354 " <div id='child' style='transform-style: preserve-3d'>" |
| 355 " <div id='grandchild' style='transform: translateZ(1px)'>" |
| 356 " </div>" |
| 357 " </div>" |
| 358 "</div>"); |
| 359 PaintLayer* parent = |
| 360 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); |
| 361 PaintLayer* child = |
| 362 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); |
| 363 PaintLayer* grandchild = |
| 364 toLayoutBoxModelObject(getLayoutObjectByElementId("grandchild"))->layer(); |
| 365 |
| 366 EXPECT_TRUE(parent->has3DTransformedDescendant()); |
| 367 EXPECT_TRUE(child->has3DTransformedDescendant()); |
| 368 EXPECT_FALSE(grandchild->has3DTransformedDescendant()); |
| 369 } |
| 370 |
293 TEST_P(PaintLayerTest, DescendantDependentFlagsStopsAtThrottledFrames) { | 371 TEST_P(PaintLayerTest, DescendantDependentFlagsStopsAtThrottledFrames) { |
294 enableCompositing(); | 372 enableCompositing(); |
295 setBodyInnerHTML( | 373 setBodyInnerHTML( |
296 "<style>body { margin: 0; }</style>" | 374 "<style>body { margin: 0; }</style>" |
297 "<div id='transform' style='transform: translate3d(4px, 5px, 6px);'>" | 375 "<div id='transform' style='transform: translate3d(4px, 5px, 6px);'>" |
298 "</div>" | 376 "</div>" |
299 "<iframe id='iframe' sandbox></iframe>"); | 377 "<iframe id='iframe' sandbox></iframe>"); |
300 setChildFrameHTML( | 378 setChildFrameHTML( |
301 "<style>body { margin: 0; }</style>" | 379 "<style>body { margin: 0; }</style>" |
302 "<div id='iframeTransform'" | 380 "<div id='iframeTransform'" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 EXPECT_EQ(LayoutRect(0, 30, 50, 5), content->visualRect()); | 472 EXPECT_EQ(LayoutRect(0, 30, 50, 5), content->visualRect()); |
395 | 473 |
396 scroller->getScrollableArea()->setScrollOffset(ScrollOffset(0, 20), | 474 scroller->getScrollableArea()->setScrollOffset(ScrollOffset(0, 20), |
397 ProgrammaticScroll); | 475 ProgrammaticScroll); |
398 document().view()->updateAllLifecyclePhases(); | 476 document().view()->updateAllLifecyclePhases(); |
399 EXPECT_EQ(LayoutRect(0, 30, 50, 10), contentLayer->visualRect()); | 477 EXPECT_EQ(LayoutRect(0, 30, 50, 10), contentLayer->visualRect()); |
400 EXPECT_EQ(LayoutRect(0, 30, 50, 5), content->visualRect()); | 478 EXPECT_EQ(LayoutRect(0, 30, 50, 5), content->visualRect()); |
401 } | 479 } |
402 | 480 |
403 } // namespace blink | 481 } // namespace blink |
OLD | NEW |