Bug 602759 part 16 - Reftest for detecting presence of transform lists; r=jwatt

This commit is contained in:
Brian Birtles 2011-09-25 22:04:47 +01:00
parent 45dbaa2bf0
commit d2271db96e
3 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,25 @@
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 100">
<defs>
<pattern id="patternRotated" width="1" height="1"
patternTransform="rotate(45 50 50)">
<rect width="50" height="50" fill="blue"/>
<rect x="50" width="50" height="50" fill="red"/>
<rect y="50" width="50" height="50" fill="red"/>
<rect x="50" y="50" width="50" height="50" fill="blue"/>
</pattern>
<pattern id="patternNotRotated" width="1" height="1">
<rect width="50" height="50" fill="blue"/>
<rect x="50" width="50" height="50" fill="red"/>
<rect y="50" width="50" height="50" fill="red"/>
<rect x="50" y="50" width="50" height="50" fill="blue"/>
</pattern>
</defs>
<rect width="100" height="100" stroke="black" fill="url(#patternRotated)"/>
<g transform="translate(100)">
<rect width="100" height="100" stroke="black" fill="url(#patternRotated)"/>
</g>
<g transform="translate(200)">
<rect width="100" height="100" stroke="black" fill="url(#patternNotRotated)"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1017 B

View File

@ -0,0 +1,58 @@
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
onload="addTransform()" viewBox="0 0 300 100" class="reftest-wait">
<!-- Test that the presence/absence of a patternTransform is correctly detected.
Details are below but, in summary, the first two squares should contain the
same pattern (a diagonal checkerbox) whilst the third square should contain
a different pattern (actually the same pattern but WITHOUT the rotation).
-->
<script>
function addTransform()
{
var g = document.getElementById("patternBase");
var list = g.patternTransform.baseVal;
var t = document.documentElement.createSVGTransform();
t.setRotate(45,50,50);
list.appendItem(t);
document.documentElement.removeAttribute("class");
}
</script>
<defs>
<!-- 1. The base pattern that will be referenced by others.
When the document loads, script will add a patternTransform to this
pattern. It does this using *only SVG DOM APIs* (i.e. not setAttribute)
so that we can test that when a transform is not specified by markup but
is added via the DOM we still correctly detect its presence. -->
<pattern id="patternBase" width="1" height="1">
<rect width="50" height="50" fill="blue"/>
<rect x="50" width="50" height="50" fill="red"/>
<rect y="50" width="50" height="50" fill="red"/>
<rect x="50" y="50" width="50" height="50" fill="blue"/>
</pattern>
<!-- 2. References the base pattern and should detect the base pattern's
patternTransform (added by script) and inherit it. (SVG 1.1 F2 13.3,
xlink:href 'Any attributes which are defined on the referenced element
which are not defined on this element are inherited by this element.').
Hence this pattern should look IDENTICAL to patternBase. -->
<pattern xlink:href="#patternBase" id="patternRefWithoutTransform"/>
<!-- 3. References the base pattern but patternTransform is defined (although
empty) and hence the patternTransform should NOT be inherited and this
pattern should look DIFFERENT to patternBase. -->
<pattern xlink:href="#patternBase" id="patternRefWithTransform"
patternTransform=""/>
<!-- The case of a patternTransform being supplied by animation is covered by
SMIL reftest anim-pattern-attr-presence-01.svg -->
</defs>
<rect width="100" height="100" stroke="black"
fill="url(#patternBase)"/>
<g transform="translate(100)">
<rect width="100" height="100" stroke="black"
fill="url(#patternRefWithoutTransform)"/>
</g>
<g transform="translate(200)">
<rect width="100" height="100" stroke="black"
fill="url(#patternRefWithTransform)"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -175,6 +175,7 @@ random-if(gtk2Widget) == objectBoundingBox-and-fePointLight-02.svg objectBoundin
== pattern-live-01a.svg pattern-live-01-ref.svg
== pattern-live-01b.svg pattern-live-01-ref.svg
== pattern-live-01c.svg pattern-live-01-ref.svg
== pattern-transform-presence-01.svg pattern-transform-presence-01-ref.svg
== polygon-marker-01.svg pass.svg
== polygon-points-negative-01.svg pass.svg
== polyline-points-invalid-01.svg pass.svg