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

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

Issue 2598923002: Update transform paint property's transform-offset on element size changes (Closed)
Patch Set: Only create transform-origin when needed 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/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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 "<div id='transform' style='margin-left: 50px; margin-top: 100px;" 444 "<div id='transform' style='margin-left: 50px; margin-top: 100px;"
445 " width: 400px; height: 300px;" 445 " width: 400px; height: 300px;"
446 " will-change: transform'>" 446 " will-change: transform'>"
447 "</div>"); 447 "</div>");
448 448
449 Element* transform = document().getElementById("transform"); 449 Element* transform = document().getElementById("transform");
450 const ObjectPaintProperties* transformProperties = 450 const ObjectPaintProperties* transformProperties =
451 transform->layoutObject()->paintProperties(); 451 transform->layoutObject()->paintProperties();
452 452
453 EXPECT_EQ(TransformationMatrix(), transformProperties->transform()->matrix()); 453 EXPECT_EQ(TransformationMatrix(), transformProperties->transform()->matrix());
454 EXPECT_EQ(FloatPoint3D(200, 150, 0), 454 EXPECT_EQ(TransformationMatrix().translate(0, 0),
455 transformProperties->transform()->origin()); 455 transformProperties->transform()->matrix());
456 // The value is zero without a transform property that needs transform-offset.
457 EXPECT_EQ(FloatPoint3D(0, 0, 0), transformProperties->transform()->origin());
456 EXPECT_EQ(nullptr, transformProperties->paintOffsetTranslation()); 458 EXPECT_EQ(nullptr, transformProperties->paintOffsetTranslation());
457 EXPECT_TRUE(transformProperties->transform()->hasDirectCompositingReasons()); 459 EXPECT_TRUE(transformProperties->transform()->hasDirectCompositingReasons());
458 460
459 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 400, 300), 461 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 400, 300),
460 transform->layoutObject(), 462 transform->layoutObject(),
461 document().view()->layoutView()); 463 document().view()->layoutView());
462 464
463 transform->setAttribute( 465 transform->setAttribute(
464 HTMLNames::styleAttr, 466 HTMLNames::styleAttr,
465 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px;"); 467 "margin-left: 50px; margin-top: 100px; width: 400px; height: 300px;");
(...skipping 2598 matching lines...) Expand 10 before | Expand all | Expand 10 after
3064 childProperties->localBorderBoxProperties()->propertyTreeState; 3066 childProperties->localBorderBoxProperties()->propertyTreeState;
3065 EXPECT_EQ(framePreTranslation(), 3067 EXPECT_EQ(framePreTranslation(),
3066 childProperties->paintOffsetTranslation()->parent()); 3068 childProperties->paintOffsetTranslation()->parent());
3067 EXPECT_EQ(childProperties->paintOffsetTranslation(), 3069 EXPECT_EQ(childProperties->paintOffsetTranslation(),
3068 childPaintState.transform()); 3070 childPaintState.transform());
3069 // This will change once we added clip expansion node. 3071 // This will change once we added clip expansion node.
3070 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); 3072 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip());
3071 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); 3073 EXPECT_EQ(filterProperties->effect(), childPaintState.effect());
3072 } 3074 }
3073 3075
3076 TEST_P(PaintPropertyTreeBuilderTest, TransformOriginWithAndWithoutTransform) {
3077 setBodyInnerHTML(
3078 "<style>"
3079 " body { margin: 0 }"
3080 " div {"
3081 " width: 400px;"
3082 " height: 100px;"
3083 " }"
3084 " #transform {"
3085 " transform: translate(100px, 200px);"
3086 " transform-origin: 75% 75% 0;"
3087 " }"
3088 " #willChange {"
3089 " will-change: opacity;"
3090 " transform-origin: 75% 75% 0;"
3091 " }"
3092 "</style>"
3093 "<div id='transform'></div>"
3094 "<div id='willChange'></div>");
3095
3096 auto* transform = document().getElementById("transform")->layoutObject();
3097 EXPECT_EQ(TransformationMatrix().translate3d(100, 200, 0),
3098 transform->paintProperties()->transform()->matrix());
3099 EXPECT_EQ(FloatPoint3D(300, 75, 0),
3100 transform->paintProperties()->transform()->origin());
3101
3102 auto* willChange = document().getElementById("willChange")->layoutObject();
3103 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0),
3104 willChange->paintProperties()->transform()->matrix());
3105 EXPECT_EQ(FloatPoint3D(0, 0, 0),
3106 willChange->paintProperties()->transform()->origin());
3107 }
3108
3109 TEST_P(PaintPropertyTreeBuilderTest, TransformOriginWithAndWithoutMotionPath) {
3110 setBodyInnerHTML(
3111 "<style>"
3112 " body { margin: 0 }"
3113 " div {"
3114 " width: 100px;"
3115 " height: 100px;"
3116 " }"
3117 " #motionPath {"
3118 " position: absolute;"
3119 " motion-path: path('M0 0 L 200 400');"
3120 " motion-offset: 50%;"
3121 " motion-rotation: 0deg;"
3122 " transform-origin: 50% 50% 0;"
3123 " }"
3124 " #willChange {"
3125 " will-change: opacity;"
3126 " transform-origin: 50% 50% 0;"
3127 " }"
3128 "</style>"
3129 "<div id='motionPath'></div>"
3130 "<div id='willChange'></div>");
3131
3132 auto* motionPath = document().getElementById("motionPath")->layoutObject();
3133 EXPECT_EQ(TransformationMatrix().translate3d(50, 150, 0),
3134 motionPath->paintProperties()->transform()->matrix());
3135 EXPECT_EQ(FloatPoint3D(50, 50, 0),
3136 motionPath->paintProperties()->transform()->origin());
3137
3138 auto* willChange = document().getElementById("willChange")->layoutObject();
3139 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0),
3140 willChange->paintProperties()->transform()->matrix());
3141 EXPECT_EQ(FloatPoint3D(0, 0, 0),
3142 willChange->paintProperties()->transform()->origin());
3143 }
3144
3074 } // namespace blink 3145 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698