1 <html xmlns=
"http://www.w3.org/1999/xhtml">
11 #transformOriginRect {
13 transform: rotate(
90deg);
18 Test for bug 79068 - SVG should support transform-origin and relative values.
20 You should see 9 green 20x20 rectangles. Each green rectangle is actually one of a set of about 6, each one
21 with a different but equivalent value for the CSS transform-origin property.
25 <svg id=
"svgRoot" xmlns=
"http://www.w3.org/2000/svg"></svg>
28 var svgNS
= "http://www.w3.org/2000/svg";
30 function addTransformOriginRect(x
, y
, s
)
32 var rect
= document
.createElementNS(svgNS
, "rect");
33 var transformOrigin
= (typeof(s
) == "string") ? s
: (x
+ s
[0]) + " " + (y
+ s
[1]);
34 rect
.setAttribute("id", "transformOriginRect");
35 rect
.setAttribute("x", x
);
36 rect
.setAttribute("y", y
);
37 rect
.setAttribute("width", 30);
38 rect
.setAttribute("height", 30);
39 rect
.setAttribute("style", "-webkit-transform-origin: " + transformOrigin
+ ";");
40 document
.getElementById("svgRoot").appendChild(rect
);
43 var equivalentTransformOrigins
= [
44 ["50% 50%", "center 50%", "50% center", "center", "center center", [15, 15]],
45 ["0% 0%", "left 0%", "0% top", "left top", "top left", [0, 0]],
46 ["0% 50%", "left 50%", "0% center", "left", "left center", "center left", [0, 15]],
47 ["100% 0%", "right 0%", "100% top", "right top", "top right", [30, 0]],
48 ["0% 50%", "left 50%", "0% center", "left center", "center left", [0, 15]],
49 ["100% 50%", "right 50%", "100% center", "right center", "center right", [30, 15]],
50 ["0% 100%", "left 100%", "0% bottom", "left bottom", "left bottom", [0, 30]],
51 ["50% 100%", "center 100%", "50% bottom", "bottom", "center bottom", "bottom center", [15, 30]],
52 ["100% 100%", "right 100%", "100% bottom", "right bottom", "bottom right", [30, 30]]
55 for (var i
= 0; i
< equivalentTransformOrigins
.length
; i
++) {
56 var x
= 60 + (i
% 4) * 60;
57 var y
= 60 + Math
.floor(i
/ 4) * 60;
58 equivalentTransformOrigins
[i
].map( function(s
) { addTransformOriginRect(x
, y
, s
); } );