Bug 598798 patch 2: Create reftest directory for <svg:image> with more thorough tests. r=jwatt a=tests-only

--HG--
rename : layout/reftests/svg/image-fill-01.svg => layout/reftests/svg/image/image-fill-01.svg
rename : layout/reftests/svg/image-scaling-01.svg => layout/reftests/svg/image/image-scaling-01.svg
rename : layout/reftests/svg/image-scaling-02.svg => layout/reftests/svg/image/image-scaling-02.svg
This commit is contained in:
Daniel Holbert 2010-10-06 08:37:12 -07:00
parent 78ff1412b1
commit 588878ab46
29 changed files with 363 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

View File

@ -0,0 +1,6 @@
<!-- Helper SVG file used by some reftests -->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" id="root">
<rect x="0" y="0" width="10" height="10" fill="blue"/>
<rect x="1" y="1" width="8" height="8" fill="lightblue"/>
<rect x="1" y="1" width="8" height="4" fill="teal"/>
</svg>

After

Width:  |  Height:  |  Size: 297 B

View File

Before

Width:  |  Height:  |  Size: 823 B

After

Width:  |  Height:  |  Size: 823 B

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<use xlink:href="blueRect10x10.svg#root"
style="opacity: 0.3"/>
</svg>

After

Width:  |  Height:  |  Size: 169 B

View File

@ -0,0 +1,6 @@
<!-- Test to make sure "opacity" value is applied correctly on svg:image -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<image xlink:href="blueRect10x10.png" width="10" height="10"
style="opacity: 0.3"/>
</svg>

After

Width:  |  Height:  |  Size: 268 B

View File

@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<g style="opacity: 0.3">
<use xlink:href="blueRect10x10.svg#root"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 177 B

View File

@ -0,0 +1,7 @@
<!-- Test to make sure "opacity" value is applied correctly on svg:image -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<g style="opacity: 0.3">
<image xlink:href="blueRect10x10.png" width="10" height="10"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 274 B

View File

@ -0,0 +1,14 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
class="reftest-wait"
onload="go()">
<script xlink:href="util.js" type="text/javascript"/>
<script>
function go() {
var grid = generateSymbolGrid("blueRect10x10.svg#root", 20, 40);
grid.setAttribute("transform", "translate(10, 10)");
document.documentElement.appendChild(grid);
document.documentElement.removeAttribute("class");
}
</script>
</svg>

After

Width:  |  Height:  |  Size: 483 B

View File

@ -0,0 +1,18 @@
<!-- Test to make sure "preserveAspectRatio" value is applied correctly on
<image> tag, when the width:height ratio is less than the image's
nativeWidth:nativeHeight -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
class="reftest-wait"
onload="go()"
style="image-rendering: -moz-crisp-edges">
<script xlink:href="util.js" type="text/javascript"/>
<script>
function go() {
var grid = generateImageGrid("blueRect10x10.png", 20, 40);
grid.setAttribute("transform", "translate(10, 10)");
document.documentElement.appendChild(grid);
document.documentElement.removeAttribute("class");
}
</script>
</svg>

After

Width:  |  Height:  |  Size: 706 B

View File

@ -0,0 +1,14 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
class="reftest-wait"
onload="go()">
<script xlink:href="util.js" type="text/javascript"/>
<script>
function go() {
var grid = generateSymbolGrid("blueRect10x10.svg#root", 40, 20);
grid.setAttribute("transform", "translate(10, 10)");
document.documentElement.appendChild(grid);
document.documentElement.removeAttribute("class");
}
</script>
</svg>

After

Width:  |  Height:  |  Size: 483 B

View File

@ -0,0 +1,18 @@
<!-- Test to make sure "preserveAspectRatio" value is applied correctly on
<image> tag, when the width:height ratio is greater than the image's
nativeWidth:nativeHeight -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
class="reftest-wait"
onload="go()"
style="image-rendering: -moz-crisp-edges">
<script xlink:href="util.js" type="text/javascript"/>
<script>
function go() {
var grid = generateImageGrid("blueRect10x10.png", 40, 20);
grid.setAttribute("transform", "translate(10, 10)");
document.documentElement.appendChild(grid);
document.documentElement.removeAttribute("class");
}
</script>
</svg>

After

Width:  |  Height:  |  Size: 709 B

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<use xlink:href="blueRect10x10.svg#root"
transform="rotate(90 50 50)"/>
</svg>

After

Width:  |  Height:  |  Size: 177 B

View File

@ -0,0 +1,6 @@
<!-- Test to make sure "rotate" value is applied correctly on svg:image -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<image xlink:href="blueRect10x10.png" width="10" height="10"
transform="rotate(90 50 50)"/>
</svg>

After

Width:  |  Height:  |  Size: 275 B

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<use xlink:href="blueRect10x10.svg#root"
transform="translate(60, 80) rotate(180 40 40)"/>
</svg>

After

Width:  |  Height:  |  Size: 196 B

View File

@ -0,0 +1,6 @@
<!-- Test to make sure "rotate" value is applied correctly on svg:image -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<image xlink:href="blueRect10x10.png" width="10" height="10"
transform="translate(60, 80) rotate(180 40 40)"/>
</svg>

After

Width:  |  Height:  |  Size: 294 B

View File

@ -0,0 +1,7 @@
<!-- Test to make sure parent's "rotate" value is applied on svg:image -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<g transform="translate(60, 80) rotate(180 40 40)">
<image xlink:href="blueRect10x10.png" width="10" height="10"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 299 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<use xlink:href="blueRect10x10.svg#root"
transform="translate(60, 80)"/>
</svg>

After

Width:  |  Height:  |  Size: 178 B

View File

@ -0,0 +1,6 @@
<!-- Test to make sure transform value is applied correctly on svg:image -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<image xlink:href="blueRect10x10.png" width="10" height="10"
transform="translate(60, 80)"/>
</svg>

After

Width:  |  Height:  |  Size: 277 B

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<use xlink:href="blueRect10x10.svg#root"
x="123"/>
</svg>

After

Width:  |  Height:  |  Size: 156 B

View File

@ -0,0 +1,6 @@
<!-- Test to make sure "x" value is applied correctly on svg:image -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<image xlink:href="blueRect10x10.png" width="10" height="10"
x="123"/>
</svg>

After

Width:  |  Height:  |  Size: 249 B

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<use xlink:href="blueRect10x10.svg#root"
x="123" y="234"/>
</svg>

After

Width:  |  Height:  |  Size: 164 B

View File

@ -0,0 +1,7 @@
<!-- Test to make sure "x" and "y" value are simultaneously applied correctly
on svg:image -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<image xlink:href="blueRect10x10.png" width="10" height="10"
x="123" y="234"/>
</svg>

After

Width:  |  Height:  |  Size: 286 B

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<use xlink:href="blueRect10x10.svg#root"
y="123"/>
</svg>

After

Width:  |  Height:  |  Size: 156 B

View File

@ -0,0 +1,6 @@
<!-- Test to make sure "y" value is applied correctly on svg:image -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<image xlink:href="blueRect10x10.png" width="10" height="10"
y="123"/>
</svg>

After

Width:  |  Height:  |  Size: 249 B

View File

@ -0,0 +1,20 @@
# Tests of the SVG <image> element
== image-fill-01.svg ../pass.svg
== image-opacity-01.svg image-opacity-01-ref.svg
== image-opacity-02.svg image-opacity-02-ref.svg
== image-rotate-01.svg image-rotate-01-ref.svg
== image-rotate-02a.svg image-rotate-02-ref.svg
== image-rotate-02b.svg image-rotate-02-ref.svg
== image-scaling-01.svg ../pass.svg
== image-scaling-02.svg ../pass.svg
== image-translate-01.svg image-translate-01-ref.svg
== image-x-01.svg image-x-01-ref.svg
== image-xy-01.svg image-xy-01-ref.svg
== image-y-01.svg image-y-01-ref.svg
# Tests for <image> with preserveAspectRatio
# NOTE: The reference cases in the following tests trigger 20 assertions each
# (1 per <symbol> element), due to bug 563481.
asserts(20) == image-preserveAspectRatio-01.svg image-preserveAspectRatio-01-ref.svg
asserts(20) == image-preserveAspectRatio-02.svg image-preserveAspectRatio-02-ref.svg

View File

@ -0,0 +1,171 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is SVG Testing Code.
*
* The Initial Developer of the Original Code is
* the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Daniel Holbert <dholbert@mozilla.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// The possible values of the "align" component of preserveAspectRatio.
const ALIGN_VALS = ["none",
"xMinYMin", "xMinYMid", "xMinYMax",
"xMidYMin", "xMidYMid", "xMidYMax",
"xMaxYMin", "xMaxYMid", "xMaxYMax"];
// The possible values of the "meetOrSlice" component of preserveAspectRatio.
const MEETORSLICE_VALS = [ "meet", "slice" ];
const SVGNS = "http://www.w3.org/2000/svg";
const XLINKNS = "http://www.w3.org/1999/xlink";
// This is the separation between the x & y values of each <image> in a
// generated grid.
const IMAGE_OFFSET = 50;
function generateBorderRect(aX, aY, aWidth, aHeight) {
var rect = document.createElementNS(SVGNS, "rect");
rect.setAttribute("x", aX);
rect.setAttribute("y", aY);
rect.setAttribute("width", aWidth);
rect.setAttribute("height", aHeight);
rect.setAttribute("fill", "none");
rect.setAttribute("stroke", "black");
rect.setAttribute("stroke-width", "2");
rect.setAttribute("stroke-dasharray", "3 2");
return rect;
}
// Returns an SVG <image> element with the given xlink:href, width, height,
// and preserveAspectRatio=[aAlign aMeetOrSlice] attributes
function generateImageElementForParams(aX, aY, aWidth, aHeight,
aHref, aAlign, aMeetOrSlice) {
var image = document.createElementNS(SVGNS, "image");
image.setAttribute("x", aX);
image.setAttribute("y", aY);
image.setAttribute("width", aWidth);
image.setAttribute("height", aHeight);
image.setAttributeNS(XLINKNS, "href", aHref);
image.setAttribute("preserveAspectRatio", aAlign + " " + aMeetOrSlice);
return image;
}
// Returns a <g> element filled with a grid of <image> elements which each
// have the specified aWidth & aHeight and which use all possible values of
// preserveAspectRatio.
function generateImageGrid(aHref, aWidth, aHeight) {
var grid = document.createElementNS(SVGNS, "g");
var y = 0;
var x = 0;
for (var i = 0; i < ALIGN_VALS.length; i++) {
// Jump to next line of grid, for every other "i" value.
// (every fourth entry)
if (i && i % 2 == 0) {
y += IMAGE_OFFSET;
x = 0;
}
var alignVal = ALIGN_VALS[i];
for (var j = 0; j < MEETORSLICE_VALS.length; j++) {
var meetorsliceVal = MEETORSLICE_VALS[j];
var border = generateBorderRect(x, y, aWidth, aHeight);
var image = generateImageElementForParams(x, y, aWidth, aHeight,
aHref, alignVal,
meetorsliceVal);
grid.appendChild(border);
grid.appendChild(image);
x += IMAGE_OFFSET;
}
}
return grid;
}
// Returns an SVG <symbol> element that...
// (a) has the given ID
// (b) contains only a <use> element to the given URI
// (c) has a hardcoded viewBox="0 0 10 10" attribute
// (d) has the given preserveAspectRatio=[aAlign aMeetOrSlice] attribute
function generateSymbolElementForParams(aSymbolID, aHref,
aAlign, aMeetOrSlice) {
var use = document.createElementNS(SVGNS, "use");
use.setAttributeNS(XLINKNS, "href", aHref);
var symbol = document.createElementNS(SVGNS, "symbol");
symbol.setAttribute("id", aSymbolID);
symbol.setAttribute("viewBox", "0 0 10 10");
symbol.setAttribute("preserveAspectRatio", aAlign + " " + aMeetOrSlice);
symbol.appendChild(use);
return symbol;
}
function generateUseElementForParams(aTargetURI, aX, aY, aWidth, aHeight) {
var use = document.createElementNS(SVGNS, "use");
use.setAttributeNS(XLINKNS, "href", aTargetURI);
use.setAttribute("x", aX);
use.setAttribute("y", aY);
use.setAttribute("width", aWidth);
use.setAttribute("height", aHeight);
return use;
}
// Returns a <g> element filled with a grid of <use> elements which each
// have the specified aWidth & aHeight and which reference <symbol> elements
// with all possible values of preserveAspectRatio. Each <symbol> contains
// a <use> that links to the given URI, aHref.
function generateSymbolGrid(aHref, aWidth, aHeight) {
var grid = document.createElementNS(SVGNS, "g");
var y = 0;
var x = 0;
for (var i = 0; i < ALIGN_VALS.length; i++) {
// Jump to next line of grid, for every other "i" value.
// (every fourth entry)
if (i && i % 2 == 0) {
y += IMAGE_OFFSET;
x = 0;
}
var alignVal = ALIGN_VALS[i];
for (var j = 0; j < MEETORSLICE_VALS.length; j++) {
var meetorsliceVal = MEETORSLICE_VALS[j];
var border = generateBorderRect(x, y, aWidth, aHeight);
var symbolID = "symbol_" + alignVal + "_" + meetorsliceVal;
var symbol = generateSymbolElementForParams(symbolID, aHref,
alignVal, meetorsliceVal);
var use = generateUseElementForParams("#" + symbolID,
x, y, aWidth, aHeight);
grid.appendChild(symbol); // This isn't painted
grid.appendChild(border);
grid.appendChild(use);
x += IMAGE_OFFSET;
}
}
return grid;
}

View File

@ -1,9 +1,13 @@
# svg-as-an-image tests
include as-image/reftest.list
# <image> tests
include image/reftest.list
# sizing tests
include sizing/reftest.list
# filter tests
include filters/reftest.list
# smil / animation tests
@ -95,9 +99,6 @@ random == dynamic-use-nested-01.svg dynamic-use-nested-01-ref.svg # bug 467498
== gradient-live-01c.svg gradient-live-01-ref.svg
== gradient-live-01d.svg gradient-live-01-ref.svg
fails == inline-in-xul-basic-01.xul pass.svg
== image-fill-01.svg pass.svg
== image-scaling-01.svg pass.svg
== image-scaling-02.svg pass.svg
== invalid-text-01.svg pass.svg
== linearGradient-basic-01.svg pass.svg
== linearGradient-basic-02.svg pass.svg