| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 EXPECT_FALSE(FrameScrollTranslation()->HasDirectCompositingReasons()); | 371 EXPECT_FALSE(FrameScrollTranslation()->HasDirectCompositingReasons()); |
| 372 | 372 |
| 373 CHECK_EXACT_VISUAL_RECT(LayoutRect(173, 556, 400, 300), | 373 CHECK_EXACT_VISUAL_RECT(LayoutRect(173, 556, 400, 300), |
| 374 transform->GetLayoutObject(), | 374 transform->GetLayoutObject(), |
| 375 GetDocument().View()->GetLayoutView()); | 375 GetDocument().View()->GetLayoutView()); |
| 376 | 376 |
| 377 transform->setAttribute( | 377 transform->setAttribute( |
| 378 HTMLNames::styleAttr, | 378 HTMLNames::styleAttr, |
| 379 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px;"); | 379 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px;"); |
| 380 GetDocument().View()->UpdateAllLifecyclePhases(); | 380 GetDocument().View()->UpdateAllLifecyclePhases(); |
| 381 EXPECT_EQ(nullptr, | 381 EXPECT_EQ(nullptr, transform->GetLayoutObject()->PaintProperties()); |
| 382 transform->GetLayoutObject()->PaintProperties()->Transform()); | |
| 383 | 382 |
| 384 transform->setAttribute( | 383 transform->setAttribute( |
| 385 HTMLNames::styleAttr, | 384 HTMLNames::styleAttr, |
| 386 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px; " | 385 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px; " |
| 387 "transform: translate3d(123px, 456px, 789px)"); | 386 "transform: translate3d(123px, 456px, 789px)"); |
| 388 GetDocument().View()->UpdateAllLifecyclePhases(); | 387 GetDocument().View()->UpdateAllLifecyclePhases(); |
| 389 EXPECT_EQ( | 388 EXPECT_EQ( |
| 390 TransformationMatrix().Translate3d(123, 456, 789), | 389 TransformationMatrix().Translate3d(123, 456, 789), |
| 391 transform->GetLayoutObject()->PaintProperties()->Transform()->Matrix()); | 390 transform->GetLayoutObject()->PaintProperties()->Transform()->Matrix()); |
| 392 } | 391 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 EXPECT_TRUE(transform_properties->Transform()->HasDirectCompositingReasons()); | 471 EXPECT_TRUE(transform_properties->Transform()->HasDirectCompositingReasons()); |
| 473 | 472 |
| 474 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 400, 300), | 473 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 400, 300), |
| 475 transform->GetLayoutObject(), | 474 transform->GetLayoutObject(), |
| 476 GetDocument().View()->GetLayoutView()); | 475 GetDocument().View()->GetLayoutView()); |
| 477 | 476 |
| 478 transform->setAttribute( | 477 transform->setAttribute( |
| 479 HTMLNames::styleAttr, | 478 HTMLNames::styleAttr, |
| 480 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px;"); | 479 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px;"); |
| 481 GetDocument().View()->UpdateAllLifecyclePhases(); | 480 GetDocument().View()->UpdateAllLifecyclePhases(); |
| 482 EXPECT_EQ(nullptr, | 481 EXPECT_EQ(nullptr, transform->GetLayoutObject()->PaintProperties()); |
| 483 transform->GetLayoutObject()->PaintProperties()->Transform()); | |
| 484 | 482 |
| 485 transform->setAttribute( | 483 transform->setAttribute( |
| 486 HTMLNames::styleAttr, | 484 HTMLNames::styleAttr, |
| 487 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px; " | 485 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px; " |
| 488 "will-change: transform"); | 486 "will-change: transform"); |
| 489 GetDocument().View()->UpdateAllLifecyclePhases(); | 487 GetDocument().View()->UpdateAllLifecyclePhases(); |
| 490 EXPECT_EQ( | 488 EXPECT_EQ( |
| 491 TransformationMatrix(), | 489 TransformationMatrix(), |
| 492 transform->GetLayoutObject()->PaintProperties()->Transform()->Matrix()); | 490 transform->GetLayoutObject()->PaintProperties()->Transform()->Matrix()); |
| 493 } | 491 } |
| (...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1936 " <rect id='rect' transform='translate(1, 1)'/>" | 1934 " <rect id='rect' transform='translate(1, 1)'/>" |
| 1937 "</svg>"); | 1935 "</svg>"); |
| 1938 | 1936 |
| 1939 LayoutObject& svg_with_transform = | 1937 LayoutObject& svg_with_transform = |
| 1940 *GetDocument().GetElementById("svg")->GetLayoutObject(); | 1938 *GetDocument().GetElementById("svg")->GetLayoutObject(); |
| 1941 const ObjectPaintProperties* svg_with_transform_properties = | 1939 const ObjectPaintProperties* svg_with_transform_properties = |
| 1942 svg_with_transform.PaintProperties(); | 1940 svg_with_transform.PaintProperties(); |
| 1943 EXPECT_EQ(TransformationMatrix(), | 1941 EXPECT_EQ(TransformationMatrix(), |
| 1944 svg_with_transform_properties->Transform()->Matrix()); | 1942 svg_with_transform_properties->Transform()->Matrix()); |
| 1945 EXPECT_EQ(LayoutPoint(FloatPoint(0.1, 0)), svg_with_transform.PaintOffset()); | 1943 EXPECT_EQ(LayoutPoint(FloatPoint(0.1, 0)), svg_with_transform.PaintOffset()); |
| 1946 EXPECT_EQ(nullptr, | 1944 EXPECT_TRUE(svg_with_transform_properties->SvgLocalToBorderBoxTransform() == |
| 1947 svg_with_transform_properties->SvgLocalToBorderBoxTransform()); | 1945 nullptr); |
| 1948 | 1946 |
| 1949 LayoutObject& rect_with_transform = | 1947 LayoutObject& rect_with_transform = |
| 1950 *GetDocument().GetElementById("rect")->GetLayoutObject(); | 1948 *GetDocument().GetElementById("rect")->GetLayoutObject(); |
| 1951 const ObjectPaintProperties* rect_with_transform_properties = | 1949 const ObjectPaintProperties* rect_with_transform_properties = |
| 1952 rect_with_transform.PaintProperties(); | 1950 rect_with_transform.PaintProperties(); |
| 1953 EXPECT_EQ(TransformationMatrix().Translate(1, 1), | 1951 EXPECT_EQ(TransformationMatrix().Translate(1, 1), |
| 1954 rect_with_transform_properties->Transform()->Matrix()); | 1952 rect_with_transform_properties->Transform()->Matrix()); |
| 1955 | 1953 |
| 1956 // Ensure there is no PaintOffset transform between the rect and the svg's | 1954 // Ensure there is no PaintOffset transform between the rect and the svg's |
| 1957 // transform. | 1955 // transform. |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2328 | 2326 |
| 2329 // Remove transform from b. B's transform node should be removed from the | 2327 // Remove transform from b. B's transform node should be removed from the |
| 2330 // tree, and a and c's transform nodes should be unchanged (with c's parent | 2328 // tree, and a and c's transform nodes should be unchanged (with c's parent |
| 2331 // adjusted). | 2329 // adjusted). |
| 2332 b->setAttribute(HTMLNames::styleAttr, ""); | 2330 b->setAttribute(HTMLNames::styleAttr, ""); |
| 2333 GetDocument().View()->UpdateAllLifecyclePhases(); | 2331 GetDocument().View()->UpdateAllLifecyclePhases(); |
| 2334 | 2332 |
| 2335 EXPECT_EQ(a_properties, a->GetLayoutObject()->PaintProperties()); | 2333 EXPECT_EQ(a_properties, a->GetLayoutObject()->PaintProperties()); |
| 2336 EXPECT_EQ(a_transform_node, a_properties->Transform()); | 2334 EXPECT_EQ(a_transform_node, a_properties->Transform()); |
| 2337 | 2335 |
| 2338 EXPECT_EQ(b_properties, b->GetLayoutObject()->PaintProperties()); | 2336 EXPECT_EQ(nullptr, b->GetLayoutObject()->PaintProperties()); |
| 2339 EXPECT_EQ(nullptr, b_properties->Transform()); | |
| 2340 | 2337 |
| 2341 EXPECT_EQ(c_properties, c->GetLayoutObject()->PaintProperties()); | 2338 EXPECT_EQ(c_properties, c->GetLayoutObject()->PaintProperties()); |
| 2342 EXPECT_EQ(c_transform_node, c_properties->Transform()); | 2339 EXPECT_EQ(c_transform_node, c_properties->Transform()); |
| 2343 EXPECT_EQ(a_transform_node, c_transform_node->Parent()); | 2340 EXPECT_EQ(a_transform_node, c_transform_node->Parent()); |
| 2344 | 2341 |
| 2345 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->GetLayoutObject(), | 2342 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->GetLayoutObject(), |
| 2346 frame_view->GetLayoutView()); | 2343 frame_view->GetLayoutView()); |
| 2347 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 20), b->GetLayoutObject(), | 2344 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 20), b->GetLayoutObject(), |
| 2348 frame_view->GetLayoutView()); | 2345 frame_view->GetLayoutView()); |
| 2349 CHECK_EXACT_VISUAL_RECT(LayoutRect(110, 132, 10, 20), c->GetLayoutObject(), | 2346 CHECK_EXACT_VISUAL_RECT(LayoutRect(110, 132, 10, 20), c->GetLayoutObject(), |
| 2350 frame_view->GetLayoutView()); | 2347 frame_view->GetLayoutView()); |
| 2351 | 2348 |
| 2352 // Re-add transform to b. B's transform node should be inserted into the tree, | 2349 // Re-add transform to b. B's transform node should be inserted into the tree, |
| 2353 // and a and c's transform nodes should be unchanged (with c's parent | 2350 // and a and c's transform nodes should be unchanged (with c's parent |
| 2354 // adjusted). | 2351 // adjusted). |
| 2355 b->setAttribute(HTMLNames::styleAttr, "transform: translate(4px, 5px)"); | 2352 b->setAttribute(HTMLNames::styleAttr, "transform: translate(4px, 5px)"); |
| 2356 GetDocument().View()->UpdateAllLifecyclePhases(); | 2353 GetDocument().View()->UpdateAllLifecyclePhases(); |
| 2357 | 2354 |
| 2358 EXPECT_EQ(a_properties, a->GetLayoutObject()->PaintProperties()); | 2355 EXPECT_EQ(a_properties, a->GetLayoutObject()->PaintProperties()); |
| 2359 EXPECT_EQ(a_transform_node, a_properties->Transform()); | 2356 EXPECT_EQ(a_transform_node, a_properties->Transform()); |
| 2360 | 2357 |
| 2358 b_properties = b->GetLayoutObject()->PaintProperties(); |
| 2361 EXPECT_EQ(b_properties, b->GetLayoutObject()->PaintProperties()); | 2359 EXPECT_EQ(b_properties, b->GetLayoutObject()->PaintProperties()); |
| 2362 b_transform_node = b_properties->Transform(); | 2360 b_transform_node = b_properties->Transform(); |
| 2363 EXPECT_EQ(TransformationMatrix().Translate(4, 5), b_transform_node->Matrix()); | 2361 EXPECT_EQ(TransformationMatrix().Translate(4, 5), b_transform_node->Matrix()); |
| 2364 EXPECT_EQ(a_transform_node, b_transform_node->Parent()); | 2362 EXPECT_EQ(a_transform_node, b_transform_node->Parent()); |
| 2365 | 2363 |
| 2366 EXPECT_EQ(c_properties, c->GetLayoutObject()->PaintProperties()); | 2364 EXPECT_EQ(c_properties, c->GetLayoutObject()->PaintProperties()); |
| 2367 EXPECT_EQ(c_transform_node, c_properties->Transform()); | 2365 EXPECT_EQ(c_transform_node, c_properties->Transform()); |
| 2368 EXPECT_EQ(b_transform_node, c_transform_node->Parent()); | 2366 EXPECT_EQ(b_transform_node, c_transform_node->Parent()); |
| 2369 | 2367 |
| 2370 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->GetLayoutObject(), | 2368 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->GetLayoutObject(), |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3009 " <div id=absolute style='position: absolute'>absolute</div>" | 3007 " <div id=absolute style='position: absolute'>absolute</div>" |
| 3010 " </div>" | 3008 " </div>" |
| 3011 " </span>" | 3009 " </span>" |
| 3012 "</div>"); | 3010 "</div>"); |
| 3013 // There should be anonymous block created containing the inline "relative", | 3011 // There should be anonymous block created containing the inline "relative", |
| 3014 // serving as the container of "absolute". | 3012 // serving as the container of "absolute". |
| 3015 EXPECT_TRUE( | 3013 EXPECT_TRUE( |
| 3016 GetLayoutObjectByElementId("absolute")->Container()->IsLayoutBlock()); | 3014 GetLayoutObjectByElementId("absolute")->Container()->IsLayoutBlock()); |
| 3017 } | 3015 } |
| 3018 | 3016 |
| 3017 TEST_P(PaintPropertyTreeBuilderTest, Reflection) { |
| 3018 SetBodyInnerHTML( |
| 3019 "<div id='filter' style='-webkit-box-reflect: below; height:1000px;'>" |
| 3020 "</div>"); |
| 3021 const ObjectPaintProperties* filter_properties = |
| 3022 GetLayoutObjectByElementId("filter")->PaintProperties(); |
| 3023 EXPECT_TRUE(filter_properties->Filter()->Parent()->IsRoot()); |
| 3024 EXPECT_EQ(FrameScrollTranslation(), |
| 3025 filter_properties->Filter()->LocalTransformSpace()); |
| 3026 EXPECT_EQ(FrameContentClip(), filter_properties->Filter()->OutputClip()); |
| 3027 } |
| 3028 |
| 3019 TEST_P(PaintPropertyTreeBuilderTest, SimpleFilter) { | 3029 TEST_P(PaintPropertyTreeBuilderTest, SimpleFilter) { |
| 3020 SetBodyInnerHTML( | 3030 SetBodyInnerHTML( |
| 3021 "<div id='filter' style='filter:opacity(0.5); height:1000px;'>" | 3031 "<div id='filter' style='filter:opacity(0.5); height:1000px;'>" |
| 3022 "</div>"); | 3032 "</div>"); |
| 3023 const ObjectPaintProperties* filter_properties = | 3033 const ObjectPaintProperties* filter_properties = |
| 3024 GetLayoutObjectByElementId("filter")->PaintProperties(); | 3034 GetLayoutObjectByElementId("filter")->PaintProperties(); |
| 3025 EXPECT_TRUE(filter_properties->Filter()->Parent()->IsRoot()); | 3035 EXPECT_TRUE(filter_properties->Filter()->Parent()->IsRoot()); |
| 3026 EXPECT_EQ(FrameScrollTranslation(), | 3036 EXPECT_EQ(FrameScrollTranslation(), |
| 3027 filter_properties->Filter()->LocalTransformSpace()); | 3037 filter_properties->Filter()->LocalTransformSpace()); |
| 3028 EXPECT_EQ(FrameContentClip(), filter_properties->Filter()->OutputClip()); | 3038 EXPECT_EQ(FrameContentClip(), filter_properties->Filter()->OutputClip()); |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3460 | 3470 |
| 3461 LayoutObject& svg_root = | 3471 LayoutObject& svg_root = |
| 3462 *GetDocument().GetElementById("svgroot")->GetLayoutObject(); | 3472 *GetDocument().GetElementById("svgroot")->GetLayoutObject(); |
| 3463 const ObjectPaintProperties* svg_root_properties = svg_root.PaintProperties(); | 3473 const ObjectPaintProperties* svg_root_properties = svg_root.PaintProperties(); |
| 3464 EXPECT_TRUE(svg_root_properties->Effect()); | 3474 EXPECT_TRUE(svg_root_properties->Effect()); |
| 3465 EXPECT_EQ(EffectPaintPropertyNode::Root(), | 3475 EXPECT_EQ(EffectPaintPropertyNode::Root(), |
| 3466 svg_root_properties->Effect()->Parent()); | 3476 svg_root_properties->Effect()->Parent()); |
| 3467 } | 3477 } |
| 3468 | 3478 |
| 3469 } // namespace blink | 3479 } // namespace blink |
| OLD | NEW |