| 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/html/HTMLIFrameElement.h" | 5 #include "core/html/HTMLIFrameElement.h" |
| 6 #include "core/layout/LayoutTestHelper.h" | 6 #include "core/layout/LayoutTestHelper.h" |
| 7 #include "core/layout/LayoutTreeAsText.h" | 7 #include "core/layout/LayoutTreeAsText.h" |
| 8 #include "core/layout/api/LayoutViewItem.h" | 8 #include "core/layout/api/LayoutViewItem.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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 299 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 300 const auto* viewProperties = frameView->layoutView()->paintProperties(); | 300 const auto* viewProperties = frameView->layoutView()->paintProperties(); |
| 301 EXPECT_EQ(nullptr, viewProperties->scrollTranslation()); | 301 EXPECT_EQ(nullptr, viewProperties->scrollTranslation()); |
| 302 } | 302 } |
| 303 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 784, 10000), | 303 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 784, 10000), |
| 304 document().body()->layoutObject(), | 304 document().body()->layoutObject(), |
| 305 frameView->layoutView()); | 305 frameView->layoutView()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 TEST_P(PaintPropertyTreeBuilderTest, Perspective) { | 308 TEST_P(PaintPropertyTreeBuilderTest, Perspective) { |
| 309 loadTestData("perspective.html"); | 309 setBodyInnerHTML( |
| 310 | 310 "<style>" |
| 311 " #perspective { position: absolute; left: 50px; top: 100px;" |
| 312 " width: 400px; height: 300px; perspective: 100px }" |
| 313 " #inner { transform: translateZ(0); width: 100px; height: 200px; }" |
| 314 "</style>" |
| 315 "<div id='perspective'>" |
| 316 " <div id='inner'></div>" |
| 317 "</div>"); |
| 311 Element* perspective = document().getElementById("perspective"); | 318 Element* perspective = document().getElementById("perspective"); |
| 312 const ObjectPaintProperties* perspectiveProperties = | 319 const ObjectPaintProperties* perspectiveProperties = |
| 313 perspective->layoutObject()->paintProperties(); | 320 perspective->layoutObject()->paintProperties(); |
| 314 EXPECT_EQ(TransformationMatrix().applyPerspective(100), | 321 EXPECT_EQ(TransformationMatrix().applyPerspective(100), |
| 315 perspectiveProperties->perspective()->matrix()); | 322 perspectiveProperties->perspective()->matrix()); |
| 316 // The perspective origin is the center of the border box plus accumulated | 323 // The perspective origin is the center of the border box plus accumulated |
| 317 // paint offset. | 324 // paint offset. |
| 318 EXPECT_EQ(FloatPoint3D(250, 250, 0), | 325 EXPECT_EQ(FloatPoint3D(250, 250, 0), |
| 319 perspectiveProperties->perspective()->origin()); | 326 perspectiveProperties->perspective()->origin()); |
| 320 EXPECT_EQ(framePreTranslation(), | 327 EXPECT_EQ(framePreTranslation(), |
| 321 perspectiveProperties->perspective()->parent()); | 328 perspectiveProperties->perspective()->parent()); |
| 322 | 329 |
| 323 // Adding perspective doesn't clear paint offset. The paint offset will be | 330 // Adding perspective doesn't clear paint offset. The paint offset will be |
| 324 // passed down to children. | 331 // passed down to children. |
| 325 Element* inner = document().getElementById("inner"); | 332 Element* inner = document().getElementById("inner"); |
| 326 const ObjectPaintProperties* innerProperties = | 333 const ObjectPaintProperties* innerProperties = |
| 327 inner->layoutObject()->paintProperties(); | 334 inner->layoutObject()->paintProperties(); |
| 328 EXPECT_EQ(TransformationMatrix().translate(50, 100), | 335 EXPECT_EQ(TransformationMatrix().translate(50, 100), |
| 329 innerProperties->paintOffsetTranslation()->matrix()); | 336 innerProperties->paintOffsetTranslation()->matrix()); |
| 330 EXPECT_EQ(perspectiveProperties->perspective(), | 337 EXPECT_EQ(perspectiveProperties->perspective(), |
| 331 innerProperties->paintOffsetTranslation()->parent()); | 338 innerProperties->paintOffsetTranslation()->parent()); |
| 332 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 100, 200), inner->layoutObject(), | 339 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 100, 200), inner->layoutObject(), |
| 333 document().view()->layoutView()); | 340 document().view()->layoutView()); |
| 341 |
| 342 perspective->setAttribute(HTMLNames::styleAttr, "perspective: 200px"); |
| 343 document().view()->updateAllLifecyclePhases(); |
| 344 EXPECT_EQ(TransformationMatrix().applyPerspective(200), |
| 345 perspectiveProperties->perspective()->matrix()); |
| 346 EXPECT_EQ(FloatPoint3D(250, 250, 0), |
| 347 perspectiveProperties->perspective()->origin()); |
| 348 EXPECT_EQ(framePreTranslation(), |
| 349 perspectiveProperties->perspective()->parent()); |
| 350 |
| 351 perspective->setAttribute(HTMLNames::styleAttr, "perspective-origin: 5% 20%"); |
| 352 document().view()->updateAllLifecyclePhases(); |
| 353 EXPECT_EQ(TransformationMatrix().applyPerspective(100), |
| 354 perspectiveProperties->perspective()->matrix()); |
| 355 EXPECT_EQ(FloatPoint3D(70, 160, 0), |
| 356 perspectiveProperties->perspective()->origin()); |
| 357 EXPECT_EQ(framePreTranslation(), |
| 358 perspectiveProperties->perspective()->parent()); |
| 334 } | 359 } |
| 335 | 360 |
| 336 TEST_P(PaintPropertyTreeBuilderTest, Transform) { | 361 TEST_P(PaintPropertyTreeBuilderTest, Transform) { |
| 337 setBodyInnerHTML( | 362 setBodyInnerHTML( |
| 338 "<style> body { margin: 0 } </style>" | 363 "<style> body { margin: 0 } </style>" |
| 339 "<div id='transform' style='margin-left: 50px; margin-top: 100px;" | 364 "<div id='transform' style='margin-left: 50px; margin-top: 100px;" |
| 340 " width: 400px; height: 300px;" | 365 " width: 400px; height: 300px;" |
| 341 " transform: translate3D(123px, 456px, 789px)'>" | 366 " transform: translate3D(123px, 456px, 789px)'>" |
| 342 "</div>"); | 367 "</div>"); |
| 343 | 368 |
| (...skipping 2881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3225 setBodyInnerHTML("<div id='div' style='background-color: blue'>DIV</div>"); | 3250 setBodyInnerHTML("<div id='div' style='background-color: blue'>DIV</div>"); |
| 3226 auto* div = document().getElementById("div"); | 3251 auto* div = document().getElementById("div"); |
| 3227 | 3252 |
| 3228 document().view()->updateAllLifecyclePhases(); | 3253 document().view()->updateAllLifecyclePhases(); |
| 3229 div->setAttribute(HTMLNames::styleAttr, "background-color: green"); | 3254 div->setAttribute(HTMLNames::styleAttr, "background-color: green"); |
| 3230 document().view()->updateLifecycleToLayoutClean(); | 3255 document().view()->updateLifecycleToLayoutClean(); |
| 3231 EXPECT_FALSE(div->layoutObject()->needsPaintPropertyUpdate()); | 3256 EXPECT_FALSE(div->layoutObject()->needsPaintPropertyUpdate()); |
| 3232 } | 3257 } |
| 3233 | 3258 |
| 3234 } // namespace blink | 3259 } // namespace blink |
| OLD | NEW |