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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
index 4e72e74dbf7a350bd3b5d5f934603e8b763333b5..73b29fea9f93ca566b493eb9c87702c865e9e58b 100644
--- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
@@ -451,8 +451,10 @@ TEST_P(PaintPropertyTreeBuilderTest, WillChangeTransform) {
transform->layoutObject()->paintProperties();
EXPECT_EQ(TransformationMatrix(), transformProperties->transform()->matrix());
- EXPECT_EQ(FloatPoint3D(200, 150, 0),
- transformProperties->transform()->origin());
+ EXPECT_EQ(TransformationMatrix().translate(0, 0),
+ transformProperties->transform()->matrix());
+ // The value is zero without a transform property that needs transform-offset.
+ EXPECT_EQ(FloatPoint3D(0, 0, 0), transformProperties->transform()->origin());
EXPECT_EQ(nullptr, transformProperties->paintOffsetTranslation());
EXPECT_TRUE(transformProperties->transform()->hasDirectCompositingReasons());
@@ -3071,4 +3073,73 @@ TEST_P(PaintPropertyTreeBuilderTest, FilterReparentClips) {
EXPECT_EQ(filterProperties->effect(), childPaintState.effect());
}
+TEST_P(PaintPropertyTreeBuilderTest, TransformOriginWithAndWithoutTransform) {
+ setBodyInnerHTML(
+ "<style>"
+ " body { margin: 0 }"
+ " div {"
+ " width: 400px;"
+ " height: 100px;"
+ " }"
+ " #transform {"
+ " transform: translate(100px, 200px);"
+ " transform-origin: 75% 75% 0;"
+ " }"
+ " #willChange {"
+ " will-change: opacity;"
+ " transform-origin: 75% 75% 0;"
+ " }"
+ "</style>"
+ "<div id='transform'></div>"
+ "<div id='willChange'></div>");
+
+ auto* transform = document().getElementById("transform")->layoutObject();
+ EXPECT_EQ(TransformationMatrix().translate3d(100, 200, 0),
+ transform->paintProperties()->transform()->matrix());
+ EXPECT_EQ(FloatPoint3D(300, 75, 0),
+ transform->paintProperties()->transform()->origin());
+
+ auto* willChange = document().getElementById("willChange")->layoutObject();
+ EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0),
+ willChange->paintProperties()->transform()->matrix());
+ EXPECT_EQ(FloatPoint3D(0, 0, 0),
+ willChange->paintProperties()->transform()->origin());
+}
+
+TEST_P(PaintPropertyTreeBuilderTest, TransformOriginWithAndWithoutMotionPath) {
+ setBodyInnerHTML(
+ "<style>"
+ " body { margin: 0 }"
+ " div {"
+ " width: 100px;"
+ " height: 100px;"
+ " }"
+ " #motionPath {"
+ " position: absolute;"
+ " motion-path: path('M0 0 L 200 400');"
+ " motion-offset: 50%;"
+ " motion-rotation: 0deg;"
+ " transform-origin: 50% 50% 0;"
+ " }"
+ " #willChange {"
+ " will-change: opacity;"
+ " transform-origin: 50% 50% 0;"
+ " }"
+ "</style>"
+ "<div id='motionPath'></div>"
+ "<div id='willChange'></div>");
+
+ auto* motionPath = document().getElementById("motionPath")->layoutObject();
+ EXPECT_EQ(TransformationMatrix().translate3d(50, 150, 0),
+ motionPath->paintProperties()->transform()->matrix());
+ EXPECT_EQ(FloatPoint3D(50, 50, 0),
+ motionPath->paintProperties()->transform()->origin());
+
+ auto* willChange = document().getElementById("willChange")->layoutObject();
+ EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0),
+ willChange->paintProperties()->transform()->matrix());
+ EXPECT_EQ(FloatPoint3D(0, 0, 0),
+ willChange->paintProperties()->transform()->origin());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698