Bug 1106602 (Part 2) - Add tests for nonuniform scaling of SVG-as-image. r=dholbert
authorSeth Fowler <seth@mozilla.com>
Mon, 15 Dec 2014 15:44:16 -0800
changeset 219856 f9d56375d76f5df949f1bef555508efc3fc86230
parent 219855 a321e217332db2e170da519e8f5f566b6cb05048
child 219857 bc6e0cee432619e1dbd40cccac1cffd2695bc858
push id10419
push usercbook@mozilla.com
push dateTue, 16 Dec 2014 12:45:27 +0000
treeherderfx-team@ec87657146eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1106602
milestone37.0a1
Bug 1106602 (Part 2) - Add tests for nonuniform scaling of SVG-as-image. r=dholbert
layout/reftests/svg/as-image/blue-square-in-square-par-none.svg
layout/reftests/svg/as-image/blue-square-in-square.svg
layout/reftests/svg/as-image/nonuniform-scale-2d.html
layout/reftests/svg/as-image/nonuniform-scale-3d.html
layout/reftests/svg/as-image/nonuniform-scale-ref.html
layout/reftests/svg/as-image/reftest.list
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/as-image/blue-square-in-square-par-none.svg
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+<svg preserveAspectRatio="none" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
+<rect x="0" y="0" width="100" height="100" stroke-width="0" fill="blue"/>
+<rect x="10" y="10" width="80" height="80" stroke-width="0" fill="lightblue"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/as-image/blue-square-in-square.svg
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
+<rect x="0" y="0" width="100" height="100" stroke-width="0" fill="blue"/>
+<rect x="10" y="10" width="80" height="80" stroke-width="0" fill="lightblue"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/as-image/nonuniform-scale-2d.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+<head>
+  <style>
+    body {
+      border:  0px;
+      margin:  0px;
+      padding: 0px;
+    }
+    img {
+      width: 100px;
+      height: 100px;
+      transform-origin: 0 0 0;
+    }
+  </style>
+</head>
+<body>
+  <img src="blue-square-in-square.svg">
+
+  <script>
+    var scales = location.search.substring(1).split("&");
+    var xScale = scales[0];
+    var yScale = scales[1];
+
+    // Create a style representing a 2d transform.
+    var style = 'transform: matrix(' + xScale + ', 0,' +
+                                  '0, ' + yScale + ',' +
+                                  '0, 0);';
+
+    // Apply the style to the image.
+    var img = document.getElementsByTagName("img")[0];
+    img.style = style;
+  </script>
+</body>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/as-image/nonuniform-scale-3d.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+<head>
+  <style>
+    body {
+      border:  0px;
+      margin:  0px;
+      padding: 0px;
+    }
+    img {
+      width: 100px;
+      height: 100px;
+      transform-origin: 0 0 0;
+    }
+  </style>
+</head>
+<body>
+  <img src="blue-square-in-square.svg">
+
+  <script>
+    var scales = location.search.substring(1).split("&");
+    var xScale = scales[0];
+    var yScale = scales[1];
+    var zScale = scales[2];
+
+    // Create a style representing a 3d transform.
+    var style = 'transform: matrix3d(' + xScale + ', 0, 0, 0,' +
+                                     '0, ' + yScale + ', 0, 0,' +
+                                     '0, 0, ' + zScale + ', 0,' +
+                                     '0, 0, 0, 1);';
+
+    // Apply the style to the image.
+    var img = document.getElementsByTagName("img")[0];
+    img.style = style;
+  </script>
+</body>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/as-image/nonuniform-scale-ref.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+<head>
+  <style>
+    body {
+      border:  0px;
+      margin:  0px;
+      padding: 0px;
+    }
+  </style>
+</head>
+<body>
+  <img src="blue-square-in-square-par-none.svg">
+
+  <script>
+    var sizes = location.search.substring(1).split("&");
+
+    // Apply the size to the image.
+    var img = document.getElementsByTagName("img")[0];
+    img.width = sizes[0];
+    img.height = sizes[1];
+  </script>
+</body>
--- a/layout/reftests/svg/as-image/reftest.list
+++ b/layout/reftests/svg/as-image/reftest.list
@@ -221,8 +221,24 @@ skip-if(B2G) fuzzy(2,1) == svg-border-im
 != image-orientation-ref.html?0    image-orientation-ref.html?270
 != image-orientation-ref.html?90   image-orientation-ref.html?180
 != image-orientation-ref.html?90   image-orientation-ref.html?270
 != image-orientation-ref.html?180  image-orientation-ref.html?270
 != image-orientation-ref.html?0    image-orientation-ref.html?0&flip
 != image-orientation-ref.html?90   image-orientation-ref.html?90&flip
 != image-orientation-ref.html?180  image-orientation-ref.html?180&flip
 != image-orientation-ref.html?270  image-orientation-ref.html?270&flip
+
+# Tests that nonuniform scales work with SVG-as-image.
+== nonuniform-scale-2d.html?0.5&1.0  nonuniform-scale-ref.html?50&100
+== nonuniform-scale-2d.html?1.0&0.5  nonuniform-scale-ref.html?100&50
+== nonuniform-scale-3d.html?0.5&1.0&0.5  nonuniform-scale-ref.html?50&100
+== nonuniform-scale-3d.html?1.0&0.5&0.5  nonuniform-scale-ref.html?100&50
+
+# Sanity checks that nonuniform scales don't devolve to uniform scales.
+!= nonuniform-scale-2d.html?0.3&1.0  nonuniform-scale-2d.html?0.3&0.3
+!= nonuniform-scale-2d.html?0.3&1.0  nonuniform-scale-2d.html?1.0&1.0
+!= nonuniform-scale-2d.html?1.0&0.3  nonuniform-scale-2d.html?0.3&0.3
+!= nonuniform-scale-2d.html?1.0&0.3  nonuniform-scale-2d.html?1.0&1.0
+!= nonuniform-scale-3d.html?0.3&1.0&0.3  nonuniform-scale-3d.html?0.3&0.3&0.3
+!= nonuniform-scale-3d.html?0.3&1.0&0.3  nonuniform-scale-3d.html?1.0&1.0&1.0
+!= nonuniform-scale-3d.html?1.0&0.3&0.3  nonuniform-scale-3d.html?0.3&0.3&0.3
+!= nonuniform-scale-3d.html?1.0&0.3&0.3  nonuniform-scale-3d.html?1.0&1.0&1.0