File: svg-deep-clone-to-new-doc.html

package info (click to toggle)
qtwebkit 2.3.4.dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 290,116 kB
  • ctags: 272,544
  • sloc: cpp: 1,417,496; python: 85,048; ansic: 39,353; perl: 38,858; ruby: 10,313; objc: 9,505; xml: 8,679; asm: 3,864; yacc: 2,458; sh: 1,237; lex: 813; makefile: 592; java: 228; php: 79
file content (56 lines) | stat: -rw-r--r-- 1,778 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />

  <!-- To run this test: Open this page, close the window, and (hopefully) don't crash.-->

  <script>    
    function gc()
    {
        if (window.GCController)
            GCController.collect();
        else
            for (var i = 0; i < 10000; ++i) // Allocate a sufficient number of objects to force a GC.
                ({});
    }
    window.onload = init;
    
    function init() {
      var iframe = document.getElementById("iframe");
      var thesvgdiv = document.getElementById('thediv');
      var theclone = thesvgdiv.cloneNode(true);
      iframe.contentDocument.body.appendChild(theclone);
      setTimeout(function() {
        iframe.style.display = 'none';
        iframe.parentNode.removeChild(iframe);
        gc();
        window.close();
      }, 500);
    }
  </script>
</head>

<body>
  <div>
    <div id="thediv">
      <svg id="thesvg" width="12cm" height="3.6cm" viewBox="0 0 1000 300">  
          <defs>
            <lineargradient id="orange_red" x2="0" y2="1" >
              <stop stop-color="yellow" />
              <stop offset="1" stop-color="red" />
            </lineargradient>
          </defs>
          <path id="MyPath" d="M 100 200  C 200 100 300   0 400 100   C 500 200 600 300 700 200  C 800 100 900 100 900 100" fill="none" stroke="red" />  
          <text font-family="Verdana" font-size="72.5" fill="url(#orange_red)" >    
            <textpath xlink:href="#MyPath"> Look mom, SVG in HTML! </textpath>  
          </text>
          (If you had an HTML5 compliant browser, the previous text would be colored and on a path.)
      </svg>
    </div>
    <div>
      <iframe id="iframe" width="50%" height="50%"></iframe>
    </div>
  </div>
</body>
</html>