layout/reftests/svg/pattern-transform-presence-01.svg

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 <?xml version="1.0"?>
     2 <svg xmlns="http://www.w3.org/2000/svg"
     3   xmlns:xlink="http://www.w3.org/1999/xlink"
     4   onload="addTransform()" viewBox="0 0 300 100" class="reftest-wait">
     5 <!-- Test that the presence/absence of a patternTransform is correctly detected.
     7      Details are below but, in summary, the first two squares should contain the
     8      same pattern (a diagonal checkerbox) whilst the third square should contain
     9      a different pattern (actually the same pattern but WITHOUT the rotation).
    10      -->
    11 <script>
    12 function addTransform()
    13 {
    14   var g = document.getElementById("patternBase");
    15   var list = g.patternTransform.baseVal;
    16   var t = document.documentElement.createSVGTransform();
    17   t.setRotate(45,50,50);
    18   list.appendItem(t);
    19   document.documentElement.removeAttribute("class");
    20 }
    21 </script>
    22 <defs>
    23   <!-- 1. The base pattern that will be referenced by others.
    24        When the document loads, script will add a patternTransform to this
    25        pattern. It does this using *only SVG DOM APIs* (i.e. not setAttribute)
    26        so that we can test that when a transform is not specified by markup but
    27        is added via the DOM we still correctly detect its presence. -->
    28   <pattern id="patternBase" width="1" height="1">
    29     <rect width="50" height="50" fill="blue"/>
    30     <rect x="50" width="50" height="50" fill="red"/>
    31     <rect y="50" width="50" height="50" fill="red"/>
    32     <rect x="50" y="50" width="50" height="50" fill="blue"/>
    33   </pattern>
    34   <!-- 2. References the base pattern and should detect the base pattern's
    35        patternTransform (added by script) and inherit it. (SVG 1.1 F2 13.3,
    36        xlink:href 'Any attributes which are defined on the referenced element
    37        which are not defined on this element are inherited by this element.').
    38        Hence this pattern should look IDENTICAL to patternBase. -->
    39   <pattern xlink:href="#patternBase" id="patternRefWithoutTransform"/>
    40   <!-- 3. References the base pattern but patternTransform is defined (although
    41        empty) and hence the patternTransform should NOT be inherited and this
    42        pattern should look DIFFERENT to patternBase. -->
    43   <pattern xlink:href="#patternBase" id="patternRefWithTransform"
    44     patternTransform=""/>
    45   <!-- The case of a patternTransform being supplied by animation is covered by
    46        SMIL reftest anim-pattern-attr-presence-01.svg -->
    47 </defs>
    48 <rect width="100" height="100" stroke="black"
    49   fill="url(#patternBase)"/>
    50 <g transform="translate(100)">
    51   <rect width="100" height="100" stroke="black"
    52     fill="url(#patternRefWithoutTransform)"/>
    53 </g>
    54 <g transform="translate(200)">
    55   <rect width="100" height="100" stroke="black"
    56     fill="url(#patternRefWithTransform)"/>
    57 </g>
    58 </svg>

mercurial