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/html/HTMLIFrameElement.h" | 5 #include "core/html/HTMLIFrameElement.h" |
6 #include "core/paint/PaintPropertyTreeBuilderTest.h" | 6 #include "core/paint/PaintPropertyTreeBuilderTest.h" |
7 #include "core/paint/PaintPropertyTreePrinter.h" | 7 #include "core/paint/PaintPropertyTreePrinter.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 auto* iframeContainer = document().getElementById("iframeContainer"); | 438 auto* iframeContainer = document().getElementById("iframeContainer"); |
439 iframeContainer->setAttribute(HTMLNames::styleAttr, "visibility: hidden;"); | 439 iframeContainer->setAttribute(HTMLNames::styleAttr, "visibility: hidden;"); |
440 frameView->updateAllLifecyclePhases(); | 440 frameView->updateAllLifecyclePhases(); |
441 | 441 |
442 EXPECT_EQ(nullptr, frameScroll(frameView)); | 442 EXPECT_EQ(nullptr, frameScroll(frameView)); |
443 EXPECT_EQ(nullptr, frameScroll(childFrameView)); | 443 EXPECT_EQ(nullptr, frameScroll(childFrameView)); |
444 } | 444 } |
445 | 445 |
446 TEST_P(PaintPropertyTreeUpdateTest, | 446 TEST_P(PaintPropertyTreeUpdateTest, |
447 TransformNodeWithAnimationLosesNodeWhenAnimationRemoved) { | 447 TransformNodeWithAnimationLosesNodeWhenAnimationRemoved) { |
448 setBodyInnerHTML( | 448 loadTestData("transform-animation.html"); |
449 "<style>" | |
450 "@keyframes test {" | |
451 " 0% { transform: translate(1em, 1em) } " | |
452 " 100% { transform: translate(2em, 2em) } " | |
453 "} " | |
454 ".animate { " | |
455 " animation-name: test; " | |
456 " animation-duration: 1s " | |
457 "}" | |
458 "</style>" | |
459 "<div id='target' class='animate'></div>"); | |
460 Element* target = document().getElementById("target"); | 449 Element* target = document().getElementById("target"); |
461 const ObjectPaintProperties* properties = | 450 const ObjectPaintProperties* properties = |
462 target->layoutObject()->paintProperties(); | 451 target->layoutObject()->paintProperties(); |
463 EXPECT_TRUE(properties->transform()->hasDirectCompositingReasons()); | 452 EXPECT_TRUE(properties->transform()->hasDirectCompositingReasons()); |
464 | 453 |
465 // Removing the animation should remove the transform node. | 454 // Removing the animation should remove the transform node. |
466 target->removeAttribute(HTMLNames::classAttr); | 455 target->removeAttribute(HTMLNames::classAttr); |
467 document().view()->updateAllLifecyclePhases(); | 456 document().view()->updateAllLifecyclePhases(); |
468 EXPECT_EQ(nullptr, properties->transform()); | 457 EXPECT_EQ(nullptr, properties->transform()); |
469 } | 458 } |
470 | 459 |
471 TEST_P(PaintPropertyTreeUpdateTest, | 460 TEST_P(PaintPropertyTreeUpdateTest, |
472 EffectNodeWithAnimationLosesNodeWhenAnimationRemoved) { | 461 EffectNodeWithAnimationLosesNodeWhenAnimationRemoved) { |
473 setBodyInnerHTML( | 462 loadTestData("opacity-animation.html"); |
474 "<style>" | |
475 "div {" | |
476 " width: 100px;" | |
477 " height: 100px;" | |
478 " background-color: red;" | |
479 "} " | |
480 ".animate {" | |
481 " animation-name: test;" | |
482 " animation-duration: 4s;" | |
483 "}" | |
484 "@keyframes test {" | |
485 " from { opacity: 0.0;}" | |
486 " to { opacity: 1.0;}" | |
487 "}" | |
488 "</style>" | |
489 "<div id='target' class='animate'></div>"); | |
490 Element* target = document().getElementById("target"); | 463 Element* target = document().getElementById("target"); |
491 const ObjectPaintProperties* properties = | 464 const ObjectPaintProperties* properties = |
492 target->layoutObject()->paintProperties(); | 465 target->layoutObject()->paintProperties(); |
493 EXPECT_TRUE(properties->effect()->hasDirectCompositingReasons()); | 466 EXPECT_TRUE(properties->effect()->hasDirectCompositingReasons()); |
494 | 467 |
495 // Removing the animation should remove the effect node. | 468 // Removing the animation should remove the effect node. |
496 target->removeAttribute(HTMLNames::classAttr); | 469 target->removeAttribute(HTMLNames::classAttr); |
497 document().view()->updateAllLifecyclePhases(); | 470 document().view()->updateAllLifecyclePhases(); |
498 EXPECT_EQ(nullptr, properties->effect()); | 471 EXPECT_EQ(nullptr, properties->effect()); |
499 } | 472 } |
500 | 473 |
| 474 TEST_P(PaintPropertyTreeUpdateTest, |
| 475 TransformNodeLosesCompositorElementIdWhenAnimationRemoved) { |
| 476 loadTestData("transform-animation.html"); |
| 477 |
| 478 Element* target = document().getElementById("target"); |
| 479 target->setAttribute(HTMLNames::styleAttr, "transform: translateX(2em)"); |
| 480 document().view()->updateAllLifecyclePhases(); |
| 481 |
| 482 const ObjectPaintProperties* properties = |
| 483 target->layoutObject()->paintProperties(); |
| 484 EXPECT_NE(CompositorElementId(), |
| 485 properties->transform()->compositorElementId()); |
| 486 |
| 487 // Remove the animation but keep the transform on the element. |
| 488 target->removeAttribute(HTMLNames::classAttr); |
| 489 document().view()->updateAllLifecyclePhases(); |
| 490 EXPECT_EQ(CompositorElementId(), |
| 491 properties->transform()->compositorElementId()); |
| 492 } |
| 493 |
| 494 TEST_P(PaintPropertyTreeUpdateTest, |
| 495 EffectNodeLosesCompositorElementIdWhenAnimationRemoved) { |
| 496 loadTestData("opacity-animation.html"); |
| 497 |
| 498 Element* target = document().getElementById("target"); |
| 499 target->setAttribute(HTMLNames::styleAttr, "opacity: 0.2"); |
| 500 document().view()->updateAllLifecyclePhases(); |
| 501 |
| 502 const ObjectPaintProperties* properties = |
| 503 target->layoutObject()->paintProperties(); |
| 504 EXPECT_NE(CompositorElementId(), properties->effect()->compositorElementId()); |
| 505 |
| 506 target->removeAttribute(HTMLNames::classAttr); |
| 507 document().view()->updateAllLifecyclePhases(); |
| 508 EXPECT_EQ(CompositorElementId(), properties->effect()->compositorElementId()); |
| 509 } |
| 510 |
501 TEST_P(PaintPropertyTreeUpdateTest, PerspectiveOriginUpdatesOnSizeChanges) { | 511 TEST_P(PaintPropertyTreeUpdateTest, PerspectiveOriginUpdatesOnSizeChanges) { |
502 setBodyInnerHTML( | 512 setBodyInnerHTML( |
503 "<style>" | 513 "<style>" |
504 " body { margin: 0 }" | 514 " body { margin: 0 }" |
505 " #perspective {" | 515 " #perspective {" |
506 " position: absolute;" | 516 " position: absolute;" |
507 " perspective: 100px;" | 517 " perspective: 100px;" |
508 " width: 100px;" | 518 " width: 100px;" |
509 " perspective-origin: 50% 50% 0;" | 519 " perspective-origin: 50% 50% 0;" |
510 " }" | 520 " }" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 EXPECT_EQ(TransformationMatrix().translate3d(50, 100, 0), | 555 EXPECT_EQ(TransformationMatrix().translate3d(50, 100, 0), |
546 transformObject->paintProperties()->transform()->matrix()); | 556 transformObject->paintProperties()->transform()->matrix()); |
547 | 557 |
548 transform->setAttribute(HTMLNames::styleAttr, "width: 200px; height: 300px;"); | 558 transform->setAttribute(HTMLNames::styleAttr, "width: 200px; height: 300px;"); |
549 document().view()->updateAllLifecyclePhases(); | 559 document().view()->updateAllLifecyclePhases(); |
550 EXPECT_EQ(TransformationMatrix().translate3d(100, 150, 0), | 560 EXPECT_EQ(TransformationMatrix().translate3d(100, 150, 0), |
551 transformObject->paintProperties()->transform()->matrix()); | 561 transformObject->paintProperties()->transform()->matrix()); |
552 } | 562 } |
553 | 563 |
554 } // namespace blink | 564 } // namespace blink |
OLD | NEW |