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

Unified Diff: third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp

Issue 1771833002: Add more SVG-related mapLocalToAncestor/mapAncestorToLocal tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp b/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp
index c4cf7c774f2e2aba8d6b153f3b646923b232497e..6008d5b5d880f26655424857156769ea46b6b41e 100644
--- a/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp
+++ b/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp
@@ -978,6 +978,42 @@ TEST_F(MapCoordinatesTest, SVGShapeWithViewBoxWithScale)
EXPECT_EQ(FloatPoint(), mappedPoint);
}
+TEST_F(MapCoordinatesTest, SVGShapeWithViewBoxWithNonZeroOffset)
+{
+ setBodyInnerHTML(
+ "<svg id='container' viewBox='100 100 200 200' width='400' height='200'>"
+ " <g transform='translate(100 50)'>"
+ " <rect id='target' transform='translate(100 100)' width='100' height='100'/>"
+ " </g>"
+ "</svg>");
+
+ LayoutObject* target = getLayoutObjectByElementId("target");
+ LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container"));
+
+ FloatPoint mappedPoint = mapLocalToAncestor(target, container, FloatPoint());
+ EXPECT_EQ(FloatPoint(200, 50), mappedPoint);
+ mappedPoint = mapAncestorToLocal(target, container, mappedPoint);
+ EXPECT_EQ(FloatPoint(), mappedPoint);
+}
+
+TEST_F(MapCoordinatesTest, SVGShapeWithViewBoxWithNonZeroOffsetAndScale)
+{
+ setBodyInnerHTML(
+ "<svg id='container' viewBox='100 100 100 100' width='400' height='200'>"
+ " <g transform='translate(50 50)'>"
+ " <rect id='target' transform='translate(100 100)' width='100' height='100'/>"
+ " </g>"
+ "</svg>");
+
+ LayoutObject* target = getLayoutObjectByElementId("target");
+ LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container"));
+
+ FloatPoint mappedPoint = mapLocalToAncestor(target, container, FloatPoint());
+ EXPECT_EQ(FloatPoint(200, 100), mappedPoint);
+ mappedPoint = mapAncestorToLocal(target, container, mappedPoint);
+ EXPECT_EQ(FloatPoint(), mappedPoint);
+}
+
TEST_F(MapCoordinatesTest, SVGForeignObject)
{
setBodyInnerHTML(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698