Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/PaintPropertyTreeBuilderTest.h" | 5 #include "core/paint/PaintPropertyTreeBuilderTest.h" |
| 6 | 6 |
| 7 #include "core/html/HTMLIFrameElement.h" | 7 #include "core/html/HTMLIFrameElement.h" |
| 8 #include "core/layout/LayoutTreeAsText.h" | 8 #include "core/layout/LayoutTreeAsText.h" |
| 9 #include "core/paint/ObjectPaintProperties.h" | 9 #include "core/paint/ObjectPaintProperties.h" |
| 10 #include "core/paint/PaintPropertyTreePrinter.h" | 10 #include "core/paint/PaintPropertyTreePrinter.h" |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 transform->setAttribute( | 387 transform->setAttribute( |
| 388 HTMLNames::styleAttr, | 388 HTMLNames::styleAttr, |
| 389 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px; " | 389 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px; " |
| 390 "transform: translate3d(123px, 456px, 789px)"); | 390 "transform: translate3d(123px, 456px, 789px)"); |
| 391 document().view()->updateAllLifecyclePhases(); | 391 document().view()->updateAllLifecyclePhases(); |
| 392 EXPECT_EQ( | 392 EXPECT_EQ( |
| 393 TransformationMatrix().translate3d(123, 456, 789), | 393 TransformationMatrix().translate3d(123, 456, 789), |
| 394 transform->layoutObject()->paintProperties()->transform()->matrix()); | 394 transform->layoutObject()->paintProperties()->transform()->matrix()); |
| 395 } | 395 } |
| 396 | 396 |
| 397 namespace { | |
| 398 | |
| 399 const char* kSimpleTransformAnimationHTML = | |
| 400 "<style>" | |
| 401 "@keyframes test {" | |
| 402 " 0% { transform: translate(1em, 1em) } " | |
| 403 " 100% { transform: translate(2em, 2em) } " | |
| 404 "} " | |
| 405 ".animate { " | |
| 406 " animation-name: test; " | |
| 407 " animation-duration: 1s " | |
| 408 "}" | |
| 409 "</style>" | |
| 410 "<div id='target' class='animate'></div>"; | |
| 411 | |
| 412 } // namespace | |
| 413 | |
| 397 TEST_P(PaintPropertyTreeBuilderTest, | 414 TEST_P(PaintPropertyTreeBuilderTest, |
| 398 TransformNodeWithActiveAnimationHasDirectCompositingReason) { | 415 TransformNodeWithActiveAnimationHasDirectCompositingReason) { |
| 416 setBodyInnerHTML(kSimpleTransformAnimationHTML); | |
| 417 Element* target = document().getElementById("target"); | |
| 418 const ObjectPaintProperties* properties = | |
| 419 target->layoutObject()->paintProperties(); | |
| 420 EXPECT_TRUE(properties->transform()->hasDirectCompositingReasons()); | |
| 421 } | |
| 422 | |
| 423 TEST_P(PaintPropertyTreeBuilderTest, | |
| 424 TransformNodeWithAnimationLosesNodeWhenAnimationRemoved) { | |
|
pdr.
2016/12/21 19:00:06
Nit: can you move this test to PaintPropertyTreeUp
wkorman
2016/12/21 19:20:53
Done.
| |
| 425 setBodyInnerHTML(kSimpleTransformAnimationHTML); | |
| 426 Element* target = document().getElementById("target"); | |
| 427 const ObjectPaintProperties* properties = | |
| 428 target->layoutObject()->paintProperties(); | |
| 429 EXPECT_TRUE(properties->transform()->hasDirectCompositingReasons()); | |
| 430 | |
| 431 // Removing the animation should remove the transform node. | |
| 432 target->removeAttribute(HTMLNames::classAttr); | |
| 433 document().view()->updateAllLifecyclePhases(); | |
| 434 EXPECT_EQ(nullptr, properties->transform()); | |
| 435 } | |
| 436 | |
| 437 TEST_P(PaintPropertyTreeBuilderTest, | |
| 438 OpacityAnimationDoesNotCreateTransformNode) { | |
| 399 setBodyInnerHTML( | 439 setBodyInnerHTML( |
| 400 "<style>" | 440 "<style>" |
| 401 "@keyframes test {" | 441 "div {" |
| 402 " 0% { transform: translate(1em, 1em) } " | 442 " width: 100px;" |
| 403 " 100% { transform: translate(2em, 2em) } " | 443 " height: 100px;" |
| 404 "} " | 444 " background-color: red;" |
| 445 " animation-name: example;" | |
| 446 " animation-duration: 4s;" | |
| 447 "}" | |
| 448 "@keyframes example {" | |
| 449 " from { opacity: 0.0;}" | |
| 450 " to { opacity: 1.0;}" | |
| 451 "}" | |
| 405 "</style>" | 452 "</style>" |
| 406 "<div id='transform'" | 453 "<div id='target'></div>"); |
| 407 " style='animation-name: test; animation-duration: 1s'>" | |
| 408 "</div>"); | |
| 409 | 454 |
| 410 Element* transform = document().getElementById("transform"); | 455 Element* target = document().getElementById("target"); |
| 411 const ObjectPaintProperties* transformProperties = | 456 const ObjectPaintProperties* properties = |
| 412 transform->layoutObject()->paintProperties(); | 457 target->layoutObject()->paintProperties(); |
| 413 EXPECT_TRUE(transformProperties->transform()->hasDirectCompositingReasons()); | 458 EXPECT_EQ(nullptr, properties->transform()); |
| 414 } | 459 } |
| 415 | 460 |
| 416 TEST_P(PaintPropertyTreeBuilderTest, WillChangeTransform) { | 461 TEST_P(PaintPropertyTreeBuilderTest, WillChangeTransform) { |
| 417 setBodyInnerHTML( | 462 setBodyInnerHTML( |
| 418 "<style> body { margin: 0 } </style>" | 463 "<style> body { margin: 0 } </style>" |
| 419 "<div id='transform' style='margin-left: 50px; margin-top: 100px;" | 464 "<div id='transform' style='margin-left: 50px; margin-top: 100px;" |
| 420 " width: 400px; height: 300px;" | 465 " width: 400px; height: 300px;" |
| 421 " will-change: transform'>" | 466 " will-change: transform'>" |
| 422 "</div>"); | 467 "</div>"); |
| 423 | 468 |
| (...skipping 2616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3040 EXPECT_EQ(framePreTranslation(), | 3085 EXPECT_EQ(framePreTranslation(), |
| 3041 childProperties->paintOffsetTranslation()->parent()); | 3086 childProperties->paintOffsetTranslation()->parent()); |
| 3042 EXPECT_EQ(childProperties->paintOffsetTranslation(), | 3087 EXPECT_EQ(childProperties->paintOffsetTranslation(), |
| 3043 childPaintState.transform()); | 3088 childPaintState.transform()); |
| 3044 // This will change once we added clip expansion node. | 3089 // This will change once we added clip expansion node. |
| 3045 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); | 3090 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); |
| 3046 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); | 3091 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); |
| 3047 } | 3092 } |
| 3048 | 3093 |
| 3049 } // namespace blink | 3094 } // namespace blink |
| OLD | NEW |