Bug 1106602 (Part 2) - Add tests for nonuniform scaling of SVG-as-image. r=dholbert

This commit is contained in:
Seth Fowler 2014-12-15 15:44:16 -08:00
Родитель 350888d88d
Коммит 3872008abd
6 изменённых файлов: 126 добавлений и 0 удалений

Просмотреть файл

@ -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>

После

Ширина:  |  Высота:  |  Размер: 385 B

Просмотреть файл

@ -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>

После

Ширина:  |  Высота:  |  Размер: 358 B

Просмотреть файл

@ -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>

Просмотреть файл

@ -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>

Просмотреть файл

@ -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>

Просмотреть файл

@ -226,3 +226,19 @@ skip-if(B2G) fuzzy(2,1) == svg-border-image-repaint-1.html svg-border-image-repa
!= 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