struct-dom-13-f-isvalid.html (4751B)
1 <!DOCTYPE html> 2 <html lang='en'> 3 <head> 4 <title>struct-dom-13-f-manual.svg</title> 5 <meta charset='utf-8'> 6 </head> 7 <body> 8 <h1>Source SVG: struct-dom-13-f-manual.svg</h1> 9 <svg id="svg-root" width="100%" height="100%" 10 viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg" 11 xmlns:xlink="http://www.w3.org/1999/xlink" onload="test()"> 12 <!--======================================================================--> 13 <!--= Copyright 2008 World Wide Web Consortium, (Massachusetts =--> 14 <!--= Institute of Technology, European Research Consortium for =--> 15 <!--= Informatics and Mathematics (ERCIM), Keio University). =--> 16 <!--= All Rights Reserved. =--> 17 <!--= See http://www.w3.org/Consortium/Legal/. =--> 18 <!--======================================================================--> 19 20 <title id="test-title">$RCSfile: struct-dom-13-f.svg,v $</title> 21 <defs> 22 <font-face 23 font-family="SVGFreeSansASCII" 24 unicode-range="U+0-7F"> 25 <font-face-src> 26 <font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/> 27 </font-face-src> 28 </font-face> 29 </defs> 30 <g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18"> 31 <defs> 32 <style> 33 .passed { fill: lime } 34 .failed { fill: red } 35 .result { font: 9px monospace; fill: black } 36 </style> 37 </defs> 38 39 <g visibility="hidden"> 40 <circle id="c1" cx="40" cy="40" r="10" fill="blue" stroke="lime"/> 41 <circle id="c2" cx="10" cy="50" r="10" fill="red" stroke="lime"/> 42 <circle id="c3" cx="20" cy="20" r="20" fill="green" stroke="lime"/> 43 <line id="l1" x1="5" y1="5" x2="40" y2="20" stroke="black"/> 44 <line id="l2" x1="20" y1="20" x2="40" y2="30" stroke="red"/> 45 46 <rect id="r1" x="10" y="10" width="50" height="50" fill="none" stroke="red"/> 47 48 <circle id="c4" cx="80" cy="50" r="10" fill="yellow"/> 49 </g> 50 51 <script><![CDATA[ 52 var ypos = 100; 53 54 function verify(str, result) 55 { 56 var g = document.createElementNS("http://www.w3.org/2000/svg", "g"); 57 var r = document.createElementNS("http://www.w3.org/2000/svg", "rect"); 58 var t = document.createElementNS("http://www.w3.org/2000/svg", "text"); 59 t.textContent = str + ": " + (result ? "PASSED" : "FAILED"); 60 t.setAttribute("class", "result"); 61 t.setAttribute("x", "10"); 62 t.setAttribute("y", "7"); 63 r.setAttribute("y", "1"); 64 r.setAttribute("width", "5"); 65 r.setAttribute("height", "5"); 66 g.setAttribute("class", result ? "passed" : "failed"); 67 g.appendChild(r); 68 g.appendChild(t); 69 g.setAttribute("transform", "translate(280 " + ypos + ")"); 70 ypos += 10; 71 document.getElementById("test-body-content").appendChild(g); 72 } 73 74 function test() 75 { 76 var root = document.documentElement; //document.getElementById("test-root"); 77 var rect = root.createSVGRect(); 78 rect.x = 10; 79 rect.y = 10; 80 rect.width = 50; 81 rect.height = 50; 82 83 var tests = { "c1" : true, "c2" : true, "c3" : true, "l1" : true, "l2" : true, "r1" : true, "c4" : false }; 84 85 verify("checkIntersection", root.checkIntersection); 86 87 if(root.checkIntersection) 88 { 89 for(var test in tests) 90 { 91 try 92 { 93 var elm = document.getElementById(test); 94 var result = root.checkIntersection(elm, rect); 95 96 verify(test, result == tests[test]); 97 } 98 catch(e) 99 { 100 verify(test, false); 101 } 102 } 103 } 104 105 verify("getIntersectionList", root.getIntersectionList); 106 107 if(root.getIntersectionList) 108 { 109 var expected = [ "c1", "c2", "c3", "l1", "l2", "r1" ]; 110 try 111 { 112 var list = root.getIntersectionList(rect, null); 113 verify("call", true); 114 } 115 catch(e) 116 { 117 verify("call", false); 118 } 119 120 try 121 { 122 verify("length", expected.length == list.length); 123 } 124 catch(e) 125 { 126 verify("length", false); 127 } 128 129 for(var i = 0; i < expected.length; i++) 130 { 131 var elm = document.getElementById(expected[i]); 132 try 133 { 134 verify("has " + expected[i], elm === list.item(i)) 135 } 136 catch(e) 137 { 138 verify("has " + expected[i], false); 139 } 140 } 141 } 142 } 143 144 ]]></script> 145 </g> 146 <g font-family="SVGFreeSansASCII,sans-serif" font-size="32"> 147 <text id="revision" x="10" y="340" stroke="none" 148 fill="black">$Revision: 1.4 $</text> 149 </g> 150 <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/> 151 <!-- comment out this watermark once the test is approved --> 152 <g id="draft-watermark"> 153 <rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/> 154 <text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240" 155 text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text> 156 </g> 157 </svg> 158 </body> 159 </html>