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

Unified Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp

Issue 2045253005: Re-implement SVG transform paint property nodes [spv2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months 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 1fcf8d2efa238de26b7d0d750ee73d9f5769784f..782f3c02e94041ff5f62d024d849dc71456c36c2 100644
--- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
@@ -417,8 +417,8 @@ TEST_F(PaintPropertyTreeBuilderTest, TransformNodesInSVG)
matrix.rotate(45);
// SVG's transform origin is baked into the transform.
matrix.applyTransformOrigin(50, 25, 0);
- EXPECT_EQ(matrix, rectWith2dTransformProperties->svgLocalTransform()->matrix());
- EXPECT_EQ(FloatPoint3D(0, 0, 0), rectWith2dTransformProperties->svgLocalTransform()->origin());
+ EXPECT_EQ(matrix, rectWith2dTransformProperties->transform()->matrix());
+ EXPECT_EQ(FloatPoint3D(0, 0, 0), rectWith2dTransformProperties->transform()->origin());
// SVG does not use paint offset.
EXPECT_EQ(nullptr, rectWith2dTransformProperties->paintOffsetTranslation());
}
@@ -445,13 +445,13 @@ TEST_F(PaintPropertyTreeBuilderTest, SVGViewBoxTransform)
LayoutObject& svgWithViewBox = *document().getElementById("svgWithViewBox")->layoutObject();
ObjectPaintProperties* svgWithViewBoxProperties = svgWithViewBox.objectPaintProperties();
EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithViewBoxProperties->transform()->matrix());
- EXPECT_EQ(TransformationMatrix().translate(-50, -50), svgWithViewBoxProperties->svgLocalTransform()->matrix());
- EXPECT_EQ(svgWithViewBoxProperties->svgLocalTransform()->parent(), svgWithViewBoxProperties->transform());
+ EXPECT_EQ(TransformationMatrix().translate(-50, -50), svgWithViewBoxProperties->svgLocalToBorderBoxTransform()->matrix());
+ EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform()->parent(), svgWithViewBoxProperties->transform());
LayoutObject& rect = *document().getElementById("rect")->layoutObject();
ObjectPaintProperties* rectProperties = rect.objectPaintProperties();
- EXPECT_EQ(TransformationMatrix().translate(100, 100), rectProperties->svgLocalTransform()->matrix());
- EXPECT_EQ(svgWithViewBoxProperties->svgLocalTransform(), rectProperties->svgLocalTransform()->parent());
+ EXPECT_EQ(TransformationMatrix().translate(100, 100), rectProperties->transform()->matrix());
+ EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), rectProperties->transform()->parent());
}
TEST_F(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode)
@@ -462,10 +462,26 @@ TEST_F(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode)
LayoutObject& svg = *document().getElementById("svg")->layoutObject();
ObjectPaintProperties* svgProperties = svg.objectPaintProperties();
- // Ensure that a paint offset transform is emitted for SVG, even without a CSS transform.
- EXPECT_EQ(nullptr, svgProperties->transform());
- EXPECT_EQ(TransformationMatrix().translate(50, 25), svgProperties->paintOffsetTranslation()->matrix());
- EXPECT_EQ(document().view()->scrollTranslation(), svgProperties->paintOffsetTranslation()->parent());
+ // Ensure that a paint offset transform is not unnecessarily emitted.
+ EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation());
+ EXPECT_EQ(TransformationMatrix().translate(50, 25), svgProperties->svgLocalToBorderBoxTransform()->matrix());
+ EXPECT_EQ(document().view()->scrollTranslation(), svgProperties->svgLocalToBorderBoxTransform()->parent());
+}
+
+TEST_F(PaintPropertyTreeBuilderTest, SVGRootLocalToBorderBoxTransformNode)
+{
+ setBodyInnerHTML(
+ "<style>body { margin: 0px; } </style>"
+ "<svg id='svg' style='transform: translate(2px, 3px); margin: 5px; border: 7px solid green; width: 100px; height: 100px;'/>");
+
+ LayoutObject& svg = *document().getElementById("svg")->layoutObject();
+ ObjectPaintProperties* svgProperties = svg.objectPaintProperties();
+ EXPECT_EQ(TransformationMatrix().translate(5, 5), svgProperties->paintOffsetTranslation()->matrix());
+ EXPECT_EQ(TransformationMatrix().translate(2, 3), svgProperties->transform()->matrix());
+ EXPECT_EQ(TransformationMatrix().translate(7, 7), svgProperties->svgLocalToBorderBoxTransform()->matrix());
+
+ EXPECT_EQ(svgProperties->paintOffsetTranslation(), svgProperties->transform()->parent());
+ EXPECT_EQ(svgProperties->transform(), svgProperties->svgLocalToBorderBoxTransform()->parent());
}
TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSVGHTMLBoundary)
@@ -511,14 +527,14 @@ TEST_F(PaintPropertyTreeBuilderTest, FixedTransformAncestorAcrossSVGHTMLBoundary
LayoutObject& container = *document().getElementById("container")->layoutObject();
ObjectPaintProperties* containerProperties = container.objectPaintProperties();
- EXPECT_EQ(TransformationMatrix().translate(20, 30), containerProperties->svgLocalTransform()->matrix());
- EXPECT_EQ(svgProperties->transform(), containerProperties->svgLocalTransform()->parent());
+ EXPECT_EQ(TransformationMatrix().translate(20, 30), containerProperties->transform()->matrix());
+ EXPECT_EQ(svgProperties->transform(), containerProperties->transform()->parent());
Element* fixed = document().getElementById("fixed");
ObjectPaintProperties* fixedProperties = fixed->layoutObject()->objectPaintProperties();
EXPECT_EQ(TransformationMatrix().translate(200, 150), fixedProperties->paintOffsetTranslation()->matrix());
// Ensure the fixed position element is rooted at the nearest transform container.
- EXPECT_EQ(containerProperties->svgLocalTransform(), fixedProperties->paintOffsetTranslation()->parent());
+ EXPECT_EQ(containerProperties->transform(), fixedProperties->paintOffsetTranslation()->parent());
}
TEST_F(PaintPropertyTreeBuilderTest, ControlClip)

Powered by Google App Engine
This is Rietveld 408576698