Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp

Issue 2571043002: Set a direct compositing reason for 3D transform & will-change property tree nodes (Closed)
Patch Set: none Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 inner->layoutObject()->paintProperties(); 327 inner->layoutObject()->paintProperties();
328 EXPECT_EQ(TransformationMatrix().translate(50, 100), 328 EXPECT_EQ(TransformationMatrix().translate(50, 100),
329 innerProperties->paintOffsetTranslation()->matrix()); 329 innerProperties->paintOffsetTranslation()->matrix());
330 EXPECT_EQ(perspectiveProperties->perspective(), 330 EXPECT_EQ(perspectiveProperties->perspective(),
331 innerProperties->paintOffsetTranslation()->parent()); 331 innerProperties->paintOffsetTranslation()->parent());
332 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 100, 200), inner->layoutObject(), 332 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 100, 200), inner->layoutObject(),
333 document().view()->layoutView()); 333 document().view()->layoutView());
334 } 334 }
335 335
336 TEST_P(PaintPropertyTreeBuilderTest, Transform) { 336 TEST_P(PaintPropertyTreeBuilderTest, Transform) {
337 loadTestData("transform.html"); 337 setBodyInnerHTML(
338 "<style> body { margin: 0 } </style>"
339 "<div id='transform' style='margin-left: 50px; margin-top: 100px;"
340 " width: 400px; height: 300px;"
341 " transform: translate3D(123px, 456px, 789px)'>"
342 "</div>");
338 343
339 Element* transform = document().getElementById("transform"); 344 Element* transform = document().getElementById("transform");
340 const ObjectPaintProperties* transformProperties = 345 const ObjectPaintProperties* transformProperties =
341 transform->layoutObject()->paintProperties(); 346 transform->layoutObject()->paintProperties();
342 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), 347 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789),
343 transformProperties->transform()->matrix()); 348 transformProperties->transform()->matrix());
344 EXPECT_EQ(FloatPoint3D(200, 150, 0), 349 EXPECT_EQ(FloatPoint3D(200, 150, 0),
345 transformProperties->transform()->origin()); 350 transformProperties->transform()->origin());
346 EXPECT_EQ(transformProperties->paintOffsetTranslation(), 351 EXPECT_EQ(transformProperties->paintOffsetTranslation(),
347 transformProperties->transform()->parent()); 352 transformProperties->transform()->parent());
348 EXPECT_EQ(TransformationMatrix().translate(50, 100), 353 EXPECT_EQ(TransformationMatrix().translate(50, 100),
349 transformProperties->paintOffsetTranslation()->matrix()); 354 transformProperties->paintOffsetTranslation()->matrix());
350 EXPECT_EQ(frameScrollTranslation(), 355 EXPECT_EQ(frameScrollTranslation(),
351 transformProperties->paintOffsetTranslation()->parent()); 356 transformProperties->paintOffsetTranslation()->parent());
357
358 EXPECT_TRUE(transformProperties->transform()->hasDirectCompositingReasons());
359 EXPECT_FALSE(frameScrollTranslation()->hasDirectCompositingReasons());
360
352 CHECK_EXACT_VISUAL_RECT(LayoutRect(173, 556, 400, 300), 361 CHECK_EXACT_VISUAL_RECT(LayoutRect(173, 556, 400, 300),
353 transform->layoutObject(), 362 transform->layoutObject(),
354 document().view()->layoutView()); 363 document().view()->layoutView());
364
365 transform->setAttribute(
366 HTMLNames::styleAttr,
367 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px;");
368 document().view()->updateAllLifecyclePhases();
369 EXPECT_EQ(nullptr, transform->layoutObject()->paintProperties()->transform());
370
371 transform->setAttribute(
372 HTMLNames::styleAttr,
373 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px; "
374 "transform: translate3D(123px, 456px, 789px)");
375 document().view()->updateAllLifecyclePhases();
376 EXPECT_EQ(
377 TransformationMatrix().translate3d(123, 456, 789),
378 transform->layoutObject()->paintProperties()->transform()->matrix());
379 }
380
381 TEST_P(PaintPropertyTreeBuilderTest, WillChangeTransform) {
382 setBodyInnerHTML(
383 "<style> body { margin: 0 } </style>"
384 "<div id='transform' style='margin-left: 50px; margin-top: 100px;"
385 " width: 400px; height: 300px;"
386 " will-change: transform'>"
387 "</div>");
388
389 Element* transform = document().getElementById("transform");
390 const ObjectPaintProperties* transformProperties =
391 transform->layoutObject()->paintProperties();
392
393 EXPECT_EQ(TransformationMatrix(), transformProperties->transform()->matrix());
394 EXPECT_EQ(FloatPoint3D(200, 150, 0),
395 transformProperties->transform()->origin());
396 EXPECT_EQ(nullptr, transformProperties->paintOffsetTranslation());
397 EXPECT_TRUE(transformProperties->transform()->hasDirectCompositingReasons());
398
399 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 400, 300),
400 transform->layoutObject(),
401 document().view()->layoutView());
402
403 transform->setAttribute(
404 HTMLNames::styleAttr,
405 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px;");
406 document().view()->updateAllLifecyclePhases();
407 EXPECT_EQ(nullptr, transform->layoutObject()->paintProperties()->transform());
408
409 transform->setAttribute(
410 HTMLNames::styleAttr,
411 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px; "
412 "will-change: transform");
413 document().view()->updateAllLifecyclePhases();
414 EXPECT_EQ(
415 TransformationMatrix(),
416 transform->layoutObject()->paintProperties()->transform()->matrix());
417 }
418
419 TEST_P(PaintPropertyTreeBuilderTest, WillChangeContents) {
420 setBodyInnerHTML(
421 "<style> body { margin: 0 } </style>"
422 "<div id='transform' style='margin-left: 50px; margin-top: 100px;"
423 " width: 400px; height: 300px;"
424 " will-change: transform, contents'>"
425 "</div>");
426
427 Element* transform = document().getElementById("transform");
428 const ObjectPaintProperties* transformProperties =
429 transform->layoutObject()->paintProperties();
430
431 EXPECT_EQ(nullptr, transformProperties->transform());
432 EXPECT_EQ(nullptr, transformProperties->paintOffsetTranslation());
433
434 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 400, 300),
435 transform->layoutObject(),
436 document().view()->layoutView());
355 } 437 }
356 438
357 TEST_P(PaintPropertyTreeBuilderTest, RelativePositionInline) { 439 TEST_P(PaintPropertyTreeBuilderTest, RelativePositionInline) {
358 loadTestData("relative-position-inline.html"); 440 loadTestData("relative-position-inline.html");
359 441
360 Element* inlineBlock = document().getElementById("inline-block"); 442 Element* inlineBlock = document().getElementById("inline-block");
361 const ObjectPaintProperties* inlineBlockProperties = 443 const ObjectPaintProperties* inlineBlockProperties =
362 inlineBlock->layoutObject()->paintProperties(); 444 inlineBlock->layoutObject()->paintProperties();
363 EXPECT_EQ(TransformationMatrix().translate(135, 490), 445 EXPECT_EQ(TransformationMatrix().translate(135, 490),
364 inlineBlockProperties->paintOffsetTranslation()->matrix()); 446 inlineBlockProperties->paintOffsetTranslation()->matrix());
(...skipping 2778 matching lines...) Expand 10 before | Expand all | Expand 10 after
3143 setBodyInnerHTML("<div id='div' style='background-color: blue'>DIV</div>"); 3225 setBodyInnerHTML("<div id='div' style='background-color: blue'>DIV</div>");
3144 auto* div = document().getElementById("div"); 3226 auto* div = document().getElementById("div");
3145 3227
3146 document().view()->updateAllLifecyclePhases(); 3228 document().view()->updateAllLifecyclePhases();
3147 div->setAttribute(HTMLNames::styleAttr, "background-color: green"); 3229 div->setAttribute(HTMLNames::styleAttr, "background-color: green");
3148 document().view()->updateLifecycleToLayoutClean(); 3230 document().view()->updateLifecycleToLayoutClean();
3149 EXPECT_FALSE(div->layoutObject()->needsPaintPropertyUpdate()); 3231 EXPECT_FALSE(div->layoutObject()->needsPaintPropertyUpdate());
3150 } 3232 }
3151 3233
3152 } // namespace blink 3234 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698