| 1 |
<svg id="svg-root" width="100%" height="100%" |
| 2 |
viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg" |
| 3 |
xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 4 |
<!--======================================================================--> |
| 5 |
<!--= Copyright 2008 World Wide Web Consortium, (Massachusetts =--> |
| 6 |
<!--= Institute of Technology, European Research Consortium for =--> |
| 7 |
<!--= Informatics and Mathematics (ERCIM), Keio University). =--> |
| 8 |
<!--= All Rights Reserved. =--> |
| 9 |
<!--= See http://www.w3.org/Consortium/Legal/. =--> |
| 10 |
<!--======================================================================--> |
| 11 |
<d:SVGTestCase xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/" |
| 12 |
template-version="1.3" reviewer="CL" author="CM" status="accepted" |
| 13 |
version="$Revision: 1.9 $" testname="$RCSfile: styling-pres-02-f.svg,v $"> |
| 14 |
<d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/styling.html#UsingPresentationAttributes"> |
| 15 |
<p> |
| 16 |
This tests that a presentation attribute that is not relevant |
| 17 |
to a given element which is otherwise stylable is correctly stored |
| 18 |
in the property collection for that element. In particular, |
| 19 |
it tests the following presentation attributes: |
| 20 |
</p> |
| 21 |
<ul> |
| 22 |
<li>fill on image</li> |
| 23 |
<li>stop-opacity on tspan</li> |
| 24 |
<li>font-size on rect</li> |
| 25 |
<li>font-style on circle</li> |
| 26 |
<li>stop-color on text</li> |
| 27 |
<li>font-variant on ellipse</li> |
| 28 |
<li>letter-spacing on polyline</li> |
| 29 |
<li>flood-color on tref</li> |
| 30 |
<li>flood-opacity on textPath</li> |
| 31 |
<li>color-interpolation-filters on altGlyph</li> |
| 32 |
<li>display on linearGradient</li> |
| 33 |
<li>fill-rule on stop</li> |
| 34 |
<li>visibility on radialGradient</li> |
| 35 |
<li>lighting-color on clipPath</li> |
| 36 |
</ul> |
| 37 |
</d:testDescription> |
| 38 |
<d:operatorScript xmlns="http://www.w3.org/1999/xhtml"> |
| 39 |
<p> |
| 40 |
The test comprises 14 sub-tests, each with a rectangle that indicates |
| 41 |
whether a given presentation attribute of the 14 listed in the test |
| 42 |
description affects the style of the element on which it is specified. A rectangle |
| 43 |
is black if the sub-test did not run, red if the sub-test failed and |
| 44 |
green if the sub-test succeeded. |
| 45 |
</p> |
| 46 |
</d:operatorScript> |
| 47 |
<d:passCriteria xmlns="http://www.w3.org/1999/xhtml"> |
| 48 |
<p> |
| 49 |
The test is passed if all 14 rectangles are green. |
| 50 |
</p> |
| 51 |
</d:passCriteria> |
| 52 |
</d:SVGTestCase> |
| 53 |
<title id="test-title">$RCSfile: styling-pres-02-f.svg,v $</title> |
| 54 |
<defs> |
| 55 |
<font-face |
| 56 |
font-family="SVGFreeSansASCII" |
| 57 |
unicode-range="U+0-7F"> |
| 58 |
<font-face-src> |
| 59 |
<font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/> |
| 60 |
</font-face-src> |
| 61 |
</font-face> |
| 62 |
</defs> |
| 63 |
<g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18"> |
| 64 |
<text x='10' y='20'>Testing inapplicable presentation attributes</text> |
| 65 |
|
| 66 |
<g visibility='hidden'> |
| 67 |
<path id="path" d="M0,0"/> |
| 68 |
<image id='image' xlink:href='../images/20x20.png' width='10' height='10' fill='rgb(0, 0, 255)'/> |
| 69 |
<rect id='rect' width='10' height='10' font-size='123px'/> |
| 70 |
<circle id='circle' r='10' font-style='italic'/> |
| 71 |
<ellipse id='ellipse' rx='10' ry='5' font-variant='small-caps'/> |
| 72 |
<polyline id='polyline' points='0,0 10,10' letter-spacing='20px'/> |
| 73 |
<text id='text' stop-color='rgb(0, 255, 0)'>a<tspan id='tspan' stop-opacity='0.5'>b</tspan><tref id='tref' xlink:href='#tspan' flood-color='rgb(255, 0, 0)'/><textPath id='textPath' xlink:href='#path' flood-opacity='0.25'/><altGlyph id='altGlyph' glyphRef='blah' color-interpolation-filters='auto'>c</altGlyph></text> |
| 74 |
<linearGradient id='linearGradient' display='block'><stop id='stop' offset='0' fill-rule='evenodd'/></linearGradient> |
| 75 |
<radialGradient id='radialGradient' visibility='hidden'><stop offset='0'/></radialGradient> |
| 76 |
<clipPath id='clipPath' lighting-color='rgb(255, 255, 255)'/> |
| 77 |
</g> |
| 78 |
|
| 79 |
<g font-size='14'> |
| 80 |
<rect id='r1' x='10' y='25' width='20' height='20'/> |
| 81 |
<text x='40' y='40'>fill on image</text> |
| 82 |
|
| 83 |
<rect id='r2' x='10' y='55' width='20' height='20'/> |
| 84 |
<text x='40' y='70'>stop-opacity on tspan</text> |
| 85 |
|
| 86 |
<rect id='r3' x='10' y='85' width='20' height='20'/> |
| 87 |
<text x='40' y='100'>font-size on rect</text> |
| 88 |
|
| 89 |
<rect id='r4' x='10' y='115' width='20' height='20'/> |
| 90 |
<text x='40' y='130'>font-style on circle</text> |
| 91 |
|
| 92 |
<rect id='r5' x='10' y='145' width='20' height='20'/> |
| 93 |
<text x='40' y='160'>stop-color on text</text> |
| 94 |
|
| 95 |
<rect id='r6' x='10' y='175' width='20' height='20'/> |
| 96 |
<text x='40' y='190'>font-variant on ellipse</text> |
| 97 |
|
| 98 |
<rect id='r7' x='10' y='205' width='20' height='20'/> |
| 99 |
<text x='40' y='220'>letter-spacing on polyline</text> |
| 100 |
|
| 101 |
<rect id='r11' x='250' y='25' width='20' height='20'/> |
| 102 |
<text x='280' y='40'>flood-color on tref</text> |
| 103 |
|
| 104 |
<rect id='r12' x='250' y='55' width='20' height='20'/> |
| 105 |
<text x='280' y='70'>flood-opacity on textPath</text> |
| 106 |
|
| 107 |
<rect id='r13' x='250' y='85' width='20' height='20'/> |
| 108 |
<text x='280' y='100'>clr-intp-filters on altGlyph</text> |
| 109 |
|
| 110 |
<rect id='r14' x='250' y='115' width='20' height='20'/> |
| 111 |
<text x='280' y='130'>display on linearGradient</text> |
| 112 |
|
| 113 |
<rect id='r15' x='250' y='145' width='20' height='20'/> |
| 114 |
<text x='280' y='160'>fill-rule on stop</text> |
| 115 |
|
| 116 |
<rect id='r16' x='250' y='175' width='20' height='20'/> |
| 117 |
<text x='280' y='190'>visibility on radialGradient</text> |
| 118 |
|
| 119 |
<rect id='r17' x='250' y='205' width='20' height='20'/> |
| 120 |
<text x='280' y='220'>lighting-color on clipPath</text> |
| 121 |
</g> |
| 122 |
|
| 123 |
<script><![CDATA[ |
| 124 |
function $(x) { return document.getElementById(x) } |
| 125 |
function decimalToHex(d) { |
| 126 |
var hex = Number(d).toString(16); |
| 127 |
while (hex.length < 2) { |
| 128 |
hex = "0" + hex; |
| 129 |
} |
| 130 |
return hex; |
| 131 |
} |
| 132 |
|
| 133 |
function checkSVGColor(e, p, r, g, b) { |
| 134 |
var v; |
| 135 |
try { |
| 136 |
var cssstyledecl = document.defaultView.getComputedStyle(e,null); |
| 137 |
var v = cssstyledecl.getPropertyValue(p); |
| 138 |
var longhex = "#" + decimalToHex(r) + decimalToHex(g) + decimalToHex(b); |
| 139 |
return v == "rgb(" + r + ", " + g + ", " + b + ")" || |
| 140 |
v == "rgba(" + r + ", " + g + ", " + b + ", 1)" || |
| 141 |
v == longhex || |
| 142 |
v == longhex.toUpperCase(); |
| 143 |
} catch (ex) { |
| 144 |
} |
| 145 |
return false; |
| 146 |
} |
| 147 |
|
| 148 |
function checkFloat(e, p, f) { |
| 149 |
var v; |
| 150 |
try { |
| 151 |
var cssstyledecl = document.defaultView.getComputedStyle(e,null); |
| 152 |
v = cssstyledecl.getPropertyValue(p); |
| 153 |
return parseFloat(v) == f; |
| 154 |
} catch (ex) { |
| 155 |
} |
| 156 |
return false; |
| 157 |
} |
| 158 |
|
| 159 |
function checkPx(e, p, f) { |
| 160 |
var v; |
| 161 |
try { |
| 162 |
var cssstyledecl = document.defaultView.getComputedStyle(e,null); |
| 163 |
v = cssstyledecl.getPropertyValue(p); |
| 164 |
return v == f; |
| 165 |
} catch (ex) { |
| 166 |
} |
| 167 |
return false; |
| 168 |
} |
| 169 |
|
| 170 |
function checkIdent(e, p, i) { |
| 171 |
var v; |
| 172 |
i = i.toLowerCase(); |
| 173 |
try { |
| 174 |
var cssstyledecl = document.defaultView.getComputedStyle(e,null); |
| 175 |
v = cssstyledecl.getPropertyValue(p); |
| 176 |
return v.toLowerCase() == i; |
| 177 |
} catch (ex) { |
| 178 |
} |
| 179 |
return false; |
| 180 |
} |
| 181 |
|
| 182 |
function report(n, b) { |
| 183 |
$('r' + n).setAttribute('fill', b ? 'green' : 'red'); |
| 184 |
} |
| 185 |
|
| 186 |
report(1, checkSVGColor($('image'), 'fill', 0, 0, 255)); |
| 187 |
report(2, checkFloat($('tspan'), 'stop-opacity', 0.5)); |
| 188 |
report(3, checkPx($('rect'), 'font-size', '123px')); |
| 189 |
report(4, checkIdent($('circle'), 'font-style', 'italic')); |
| 190 |
report(5, checkSVGColor($('text'), 'stop-color', 0, 255, 0)); |
| 191 |
report(6, checkIdent($('ellipse'), 'font-variant', 'small-caps')); |
| 192 |
report(7, checkPx($('polyline'), 'letter-spacing', '20px')); |
| 193 |
|
| 194 |
report(11, checkSVGColor($('tref'), 'flood-color', 255, 0, 0)); |
| 195 |
report(12, checkFloat($('textPath'), 'flood-opacity', 0.25)); |
| 196 |
report(13, checkIdent($('altGlyph'), 'color-interpolation-filters', 'auto')); |
| 197 |
report(14, checkIdent($('linearGradient'), 'display', 'block')); |
| 198 |
report(15, checkIdent($('stop'), 'fill-rule', 'evenodd')); |
| 199 |
report(16, checkIdent($('radialGradient'), 'visibility', 'hidden')); |
| 200 |
report(17, checkSVGColor($('clipPath'), 'lighting-color', 255, 255, 255)); |
| 201 |
]]></script> |
| 202 |
</g> |
| 203 |
<g font-family="SVGFreeSansASCII,sans-serif" font-size="32"> |
| 204 |
<text id="revision" x="10" y="340" stroke="none" |
| 205 |
fill="black">$Revision: 1.9 $</text> |
| 206 |
</g> |
| 207 |
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/> |
| 208 |
<!-- comment out this watermark once the test is approved --> |
| 209 |
<!-- |
| 210 |
<g id="draft-watermark"> |
| 211 |
<rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/> |
| 212 |
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240" |
| 213 |
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text> |
| 214 |
</g> |
| 215 |
--> |
| 216 |
</svg> |