| 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.4" reviewer="ED" author="CM" status="accepted" |
| 13 |
version="$Revision: 1.5 $" testname="$RCSfile: struct-dom-11-f.svg,v $"> |
| 14 |
<d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGSVGElement"> |
| 15 |
<p> |
| 16 |
This tests that the getIntersectionList() and getEnclosureList() |
| 17 |
methods return NodeLists that are not live. |
| 18 |
</p> |
| 19 |
<p> |
| 20 |
After loading the test, two rectangles will be presented. The |
| 21 |
upper rectangle indicates the result of testing whether |
| 22 |
getIntersectionList() returns a non-live NodeList, while the |
| 23 |
lower rectangle indicates so for getEnclosureList(). |
| 24 |
</p> |
| 25 |
</d:testDescription> |
| 26 |
<d:operatorScript xmlns="http://www.w3.org/1999/xhtml"> |
| 27 |
<p> |
| 28 |
Run the test. No interaction required. |
| 29 |
</p> |
| 30 |
</d:operatorScript> |
| 31 |
<d:passCriteria xmlns="http://www.w3.org/1999/xhtml"> |
| 32 |
<p> |
| 33 |
The test is passed if both rectangles are green. |
| 34 |
</p> |
| 35 |
</d:passCriteria> |
| 36 |
</d:SVGTestCase> |
| 37 |
<title id="test-title">$RCSfile: struct-dom-11-f.svg,v $</title> |
| 38 |
<defs> |
| 39 |
<font-face |
| 40 |
font-family="SVGFreeSansASCII" |
| 41 |
unicode-range="U+0-7F"> |
| 42 |
<font-face-src> |
| 43 |
<font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/> |
| 44 |
</font-face-src> |
| 45 |
</font-face> |
| 46 |
</defs> |
| 47 |
<g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18"> |
| 48 |
|
| 49 |
<text x='10' y='40' font-size='13'>Test getIntersectionList and getEnclosureList return value liveness</text> |
| 50 |
|
| 51 |
<rect id='r1' x='10' y='70' width='50' height='50' fill='black'/> |
| 52 |
<text x='70' y='100'>getIntersectionList</text> |
| 53 |
|
| 54 |
<rect id='r2' x='10' y='130' width='50' height='50' fill='black'/> |
| 55 |
<text x='70' y='160'>getEnclosureList</text> |
| 56 |
|
| 57 |
<g id="g1" visibility="hidden" pointer-events="painted"> |
| 58 |
<circle id='c1' cx='305' cy='100' r='5'/> |
| 59 |
<circle id='c2' cx='305' cy='150' r='5'/> |
| 60 |
</g> |
| 61 |
|
| 62 |
<script><![CDATA[ |
| 63 |
function userspace2viewport(elm, r) |
| 64 |
{ |
| 65 |
var ctm = elm.getCTM(); |
| 66 |
|
| 67 |
var corners = []; |
| 68 |
for(var i = 0; i < 4; i++) |
| 69 |
corners.push(svg.createSVGPoint()); |
| 70 |
|
| 71 |
corners[0].x = r.x; |
| 72 |
corners[0].y = r.y; |
| 73 |
corners[1].x = r.x + r.width; |
| 74 |
corners[1].y = r.y; |
| 75 |
corners[2].x = r.x + r.width; |
| 76 |
corners[2].y = r.y + r.height; |
| 77 |
corners[3].x = r.x; |
| 78 |
corners[3].y = r.y + r.height; |
| 79 |
|
| 80 |
for(var i = 0; i < 4; i++) |
| 81 |
corners[i] = corners[i].matrixTransform(ctm); |
| 82 |
|
| 83 |
var min = svg.createSVGPoint(); |
| 84 |
var max = svg.createSVGPoint(); |
| 85 |
min.x = corners[0].x; |
| 86 |
min.y = corners[0].y; |
| 87 |
max.x = corners[0].x; |
| 88 |
max.y = corners[0].y; |
| 89 |
|
| 90 |
for(var i = 1; i < 4; i++) |
| 91 |
{ |
| 92 |
var x = corners[i].x; |
| 93 |
var y = corners[i].y; |
| 94 |
|
| 95 |
if(x < min.x) |
| 96 |
min.x = x; |
| 97 |
else if(x > max.x) |
| 98 |
max.x = x; |
| 99 |
|
| 100 |
if(y < min.y) |
| 101 |
min.y = y; |
| 102 |
else if(y > max.y) |
| 103 |
max.y = y; |
| 104 |
} |
| 105 |
|
| 106 |
var res = svg.createSVGRect(); |
| 107 |
res.x = min.x; |
| 108 |
res.y = min.y; |
| 109 |
res.width = max.x - min.x; |
| 110 |
res.height = max.y - min.y; |
| 111 |
return res; |
| 112 |
} |
| 113 |
|
| 114 |
var svg = document.documentElement, |
| 115 |
c = document.getElementById('c'), |
| 116 |
r1 = document.getElementById('r1'), |
| 117 |
r2 = document.getElementById('r2'), |
| 118 |
c1 = document.getElementById('c1'), |
| 119 |
c2 = document.getElementById('c2'), |
| 120 |
g1 = document.getElementById('g1'), |
| 121 |
r = svg.createSVGRect(), |
| 122 |
nl; |
| 123 |
|
| 124 |
try { |
| 125 |
r.x = 300; |
| 126 |
r.y = 95; |
| 127 |
r.width = 5; |
| 128 |
r.height = 5; |
| 129 |
|
| 130 |
r = userspace2viewport(g1, r); |
| 131 |
|
| 132 |
nl = svg.getIntersectionList(r, null); |
| 133 |
if (nl && nl.length == 1) { |
| 134 |
c1.parentNode.removeChild(c1); |
| 135 |
r1.setAttribute('fill', nl.length == 1 ? 'lime' : 'red'); |
| 136 |
} |
| 137 |
} catch (e) { |
| 138 |
} |
| 139 |
|
| 140 |
try { |
| 141 |
r.x = 290; |
| 142 |
r.y = 135; |
| 143 |
r.width = 20; |
| 144 |
r.height = 20; |
| 145 |
|
| 146 |
r = userspace2viewport(g1, r); |
| 147 |
|
| 148 |
nl = svg.getEnclosureList(r, null); |
| 149 |
if (nl && nl.length == 1) { |
| 150 |
c2.parentNode.removeChild(c2); |
| 151 |
r2.setAttribute('fill', nl.length == 1 ? 'lime' : 'red'); |
| 152 |
} |
| 153 |
} catch (e) { |
| 154 |
} |
| 155 |
]]></script> |
| 156 |
</g> |
| 157 |
<g font-family="SVGFreeSansASCII,sans-serif" font-size="32"> |
| 158 |
<text id="revision" x="10" y="340" stroke="none" |
| 159 |
fill="black">$Revision: 1.5 $</text> |
| 160 |
</g> |
| 161 |
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/> |
| 162 |
<!-- comment out this watermark once the test is approved --> |
| 163 |
<!--<g id="draft-watermark"> |
| 164 |
<rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/> |
| 165 |
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240" |
| 166 |
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text> |
| 167 |
</g>--> |
| 168 |
</svg> |