layout/svg/tests/example.xml

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="svg.css" type="text/css"?>
michael@0 3 <!DOCTYPE svg SYSTEM "SVG-20000202.dtd" >
michael@0 4 <!--<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 10 January 2000//EN" -->
michael@0 5 <!-- "http://www.w3.org/Graphics/SVG/SVG-19991203.dtd"> -->
michael@0 6 <svg xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.svg"
michael@0 7 xmlns:html="http://www.w3.org/1999/xhtml">
michael@0 8
michael@0 9 <html:script>
michael@0 10 <![CDATA[
michael@0 11
michael@0 12 var gIsInit = false;
michael@0 13 var barXPnts = new Array();
michael@0 14 var barYPnts = new Array();
michael@0 15
michael@0 16 var nodes = new Array();
michael@0 17 var gBarMax = 200;
michael@0 18 var gHeight = 80;
michael@0 19 var gBarCount = 10;
michael@0 20 var gBarDir = 1;
michael@0 21 var gGo = true;
michael@0 22
michael@0 23 function init()
michael@0 24 {
michael@0 25 dump("----------------\n");
michael@0 26 nodes[0] = findNode(document.documentElement, "bar21");
michael@0 27 nodes[1] = findNode(document.documentElement, "bar22");
michael@0 28 nodes[2] = findNode(document.documentElement, "bar23");
michael@0 29 nodes[3] = findNode(document.documentElement, "bargrid21");
michael@0 30 nodes[4] = findNode(document.documentElement, "bargrid22");
michael@0 31 nodes[5] = findNode(document.documentElement, "bargrid23");
michael@0 32 dump("----------------\n");
michael@0 33 gGo = true;
michael@0 34 setTimeout("moveit()", 100);
michael@0 35 }
michael@0 36 function stop()
michael@0 37 {
michael@0 38 gGo = false;
michael@0 39 }
michael@0 40 function ChangeBar(name, height)
michael@0 41 {
michael@0 42 today = new Date();
michael@0 43 stime = today.getMilliseconds();
michael@0 44 dump("----------------\n");
michael@0 45 str = name+"1";
michael@0 46 node = findNode(document.documentElement, str);
michael@0 47 //node = document.getElementById(str);
michael@0 48 today = new Date();
michael@0 49 etime = today.getMilliseconds();
michael@0 50 dump("1----------------"+(etime-stime)+"\n");
michael@0 51 attr = document.createAttribute("points");
michael@0 52 attr.value = "30 " + height + " 30 210 50 210 50 " + height;
michael@0 53 node.attributes.setNamedItem(attr);
michael@0 54 today = new Date();
michael@0 55 stime = today.getMilliseconds();
michael@0 56 dump("2----------------"+(stime-etime)+"\n");
michael@0 57
michael@0 58 str = name+"2";
michael@0 59 node = findNode(document.documentElement, str);
michael@0 60 dump("3----------------\n");
michael@0 61 attr.value = "30 " + height + " 50 " + height + " 60 " + (height-10) + " 40 " + (height-10);
michael@0 62 node.attributes.setNamedItem(attr);
michael@0 63 dump("4----------------\n");
michael@0 64
michael@0 65 str = name+"3";
michael@0 66 node = findNode(document.documentElement, str);
michael@0 67 dump("5----------------\n");
michael@0 68 attr.value = "50 " + height + " 60 " + (height-10) + " 60 200 50 210";
michael@0 69 node.attributes.setNamedItem(attr);
michael@0 70 dump("=================\n");
michael@0 71 }
michael@0 72
michael@0 73 function ChangeBarWithNodes(node1, node2, node3, height)
michael@0 74 {
michael@0 75 attr = document.createAttribute("points");
michael@0 76 attr.value = "30 " + height + " 30 210 50 210 50 " + height;
michael@0 77 node1.attributes.setNamedItem(attr);
michael@0 78
michael@0 79 attr.value = "30 " + height + " 50 " + height + " 60 " + (height-10) + " 40 " + (height-10);
michael@0 80 node2.attributes.setNamedItem(attr);
michael@0 81
michael@0 82 attr.value = "50 " + height + " 60 " + (height-10) + " 60 200 50 210";
michael@0 83 node3.attributes.setNamedItem(attr);
michael@0 84 }
michael@0 85
michael@0 86 function moveit()
michael@0 87 {
michael@0 88 //ChangeBar("bar2", 150);
michael@0 89 //ChangeBar("bargrid2", 150);
michael@0 90
michael@0 91 ChangeBarWithNodes(nodes[0], nodes[1], nodes[2], gHeight);
michael@0 92 ChangeBarWithNodes(nodes[3], nodes[4], nodes[5], gHeight);
michael@0 93
michael@0 94 gHeight += gBarDir;
michael@0 95 gBarCount--;
michael@0 96 //dump("gHeight: "+gHeight+" gBarCount: "+gBarCount+" gBarDir: "+gBarDir+"\n");
michael@0 97 if (gHeight > gBarMax || gHeight < 1) {
michael@0 98 gBarDir *= -1;
michael@0 99 gBarCount = (Math.random() * 15)+3;
michael@0 100 //dump("Changining directions: "+gBarDir+"\n");
michael@0 101 if (gHeight > gBarMax) {
michael@0 102 gHeight = gBarMax;
michael@0 103 } else {
michael@0 104 gHeight = 1;
michael@0 105 }
michael@0 106 } else {
michael@0 107 if (gBarCount < 1) {
michael@0 108 gBarDir *= -1;
michael@0 109 gBarCount = (Math.random() * 15)+3;
michael@0 110 //dump("----> "+gBarCount+"\n");
michael@0 111 }
michael@0 112 }
michael@0 113 if (gGo) {
michael@0 114 setTimeout("moveit()", 100);
michael@0 115 }
michael@0 116
michael@0 117 }
michael@0 118
michael@0 119 function findNode(node, nodename)
michael@0 120 {
michael@0 121 var type = node.nodeType;
michael@0 122 if (type == Node.ELEMENT_NODE) {
michael@0 123
michael@0 124 // open tag
michael@0 125 //dump("\<" + node.tagName);
michael@0 126
michael@0 127 // dump the attributes if any
michael@0 128 attributes = node.attributes;
michael@0 129 if (null != attributes) {
michael@0 130 var countAttrs = attributes.length;
michael@0 131 var index = 0;
michael@0 132 while(index < countAttrs) {
michael@0 133 att = attributes[index];
michael@0 134 if (null != att) {
michael@0 135 //dump(" " + att.name + "=" + att.value+" ["+nodename+"]\n");
michael@0 136 if (att.name == "id" && att.value == nodename) {
michael@0 137 //dump("Found it!\n");
michael@0 138 return node;
michael@0 139 }
michael@0 140 }
michael@0 141 index++;
michael@0 142 }
michael@0 143 }
michael@0 144
michael@0 145 // recursively dump the children
michael@0 146 if (node.hasChildNodes()) {
michael@0 147 // close tag
michael@0 148 //dump(">");
michael@0 149
michael@0 150 // get the children
michael@0 151 var children = node.childNodes;
michael@0 152 var length = children.length;
michael@0 153 var count = 0;
michael@0 154 while(count < length) {
michael@0 155 child = children[count];
michael@0 156 fndNode = findNode(child, nodename);
michael@0 157 if (fndNode != null) {
michael@0 158 return fndNode;
michael@0 159 }
michael@0 160 count++;
michael@0 161 }
michael@0 162 //dump("</" + node.tagName + ">");
michael@0 163 } else {
michael@0 164 // close tag
michael@0 165 //dump("/>");
michael@0 166 }
michael@0 167
michael@0 168
michael@0 169 }
michael@0 170 // if it's a piece of text just dump the text
michael@0 171 else if (type == Node.TEXT_NODE) {
michael@0 172 //dump(node.data);
michael@0 173 }
michael@0 174 return null;
michael@0 175 }
michael@0 176
michael@0 177 ]]>
michael@0 178 </html:script>
michael@0 179
michael@0 180 <g>
michael@0 181 <polyline x="55" y="10" id="bg" points="20 0 220 0 220 200 20 200"/>
michael@0 182 <polyline x="55" y="10" id="bg" points="20 0 20 200 0 220 0 20 0 20 20 0"/>
michael@0 183 <polyline x="55" y="10" id="bg" points="20 200 220 200 200 220 0 220"/>
michael@0 184
michael@0 185 <polyline x="55" y="10" id="grid" points="20 0 220 0 220 200 20 200"/>
michael@0 186 <polyline x="55" y="10" id="grid" points="20 0 20 200 0 220 0 20 0 20"/>
michael@0 187 <polyline x="55" y="10" id="grid" points="20 200 220 200 200 220 0 220"/>
michael@0 188
michael@0 189 <polyline x="55" y="10" id="grid" points="20 220 40 200 40 0"/>
michael@0 190 <polyline x="55" y="10" id="grid" points="40 220 60 200 60 0"/>
michael@0 191 <polyline x="55" y="10" id="grid" points="60 220 80 200 80 0"/>
michael@0 192 <polyline x="55" y="10" id="grid" points="80 220 100 200 100 0"/>
michael@0 193 <polyline x="55" y="10" id="grid" points="100 220 120 200 120 0"/>
michael@0 194 <polyline x="55" y="10" id="grid" points="120 220 140 200 140 0"/>
michael@0 195 <polyline x="55" y="10" id="grid" points="140 220 160 200 160 0"/>
michael@0 196 <polyline x="55" y="10" id="grid" points="160 220 180 200 180 0"/>
michael@0 197 <polyline x="55" y="10" id="grid" points="180 220 200 200 200 0"/>
michael@0 198
michael@0 199 <polygon x="55" y="10" id="bar1" points="30 60 30 210 50 210 50 60"/>
michael@0 200 <polygon x="55" y="10" id="bar1" points="30 60 50 60 60 50 40 50"/>
michael@0 201 <polygon x="55" y="10" id="bar1" points="50 60 60 50 60 200 50 210"/>
michael@0 202
michael@0 203 <polyline x="55" y="10" id="grid" points="30 60 30 210 50 210 50 60"/>
michael@0 204 <polyline x="55" y="10" id="grid" points="30 60 50 60 60 50 40 50"/>
michael@0 205 <polyline x="55" y="10" id="grid" points="50 60 60 50 60 200 50 210"/>
michael@0 206
michael@0 207
michael@0 208 <polygon x="95" y="10" id="bar21" points="30 80 30 210 50 210 50 80"/>
michael@0 209 <polygon x="95" y="10" id="bar22" points="30 80 50 80 60 70 40 70"/>
michael@0 210 <polygon x="95" y="10" id="bar23" points="50 80 60 70 60 200 50 210"/>
michael@0 211
michael@0 212 <polyline x="95" y="10" id="bargrid21" points="30 80 30 210 50 210 50 80"/>
michael@0 213 <polyline x="95" y="10" id="bargrid22" points="30 80 50 80 60 70 40 70"/>
michael@0 214 <polyline x="95" y="10" id="bargrid23" points="50 80 60 70 60 200 50 210"/>
michael@0 215
michael@0 216 <polygon x="400" y="20" id="rect" points="10 10 50 10 50 50"/>
michael@0 217 <polygon x="400" y="75" id="poly" points="10 10 50 10 50 50 45 70 32 32 80 20"/>
michael@0 218 <polyline x="400" y="150" id="poly" points="10 10 50 10 50 50 45 70 32 32 80 20"/>
michael@0 219
michael@0 220 </g>
michael@0 221 <foreignobject>
michael@0 222 <html:div style="position:absolute;top:5px;left:385px;">Simple Polygons</html:div>
michael@0 223 <html:div style="position:absolute;top:240px;left:115px;">A Simple Graph</html:div>
michael@0 224 <html:input type="button" style="position:absolute;top:260px;left:350px;" onclick="init();" value="Start"/>
michael@0 225 <html:input type="button" style="position:absolute;top:260px;left:390px;" onclick="stop();" value="Stop"/>
michael@0 226 </foreignobject>
michael@0 227 </svg>

mercurial