OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
| 5 part of html; |
| 6 |
5 class _CustomEventFactoryProvider { | 7 class _CustomEventFactoryProvider { |
6 static CustomEvent createCustomEvent(String type, [bool canBubble = true, | 8 static CustomEvent createCustomEvent(String type, [bool canBubble = true, |
7 bool cancelable = true, Object detail = null]) { | 9 bool cancelable = true, Object detail = null]) { |
8 final CustomEvent e = document.$dom_createEvent("CustomEvent"); | 10 final CustomEvent e = document.$dom_createEvent("CustomEvent"); |
9 e.$dom_initCustomEvent(type, canBubble, cancelable, detail); | 11 e.$dom_initCustomEvent(type, canBubble, cancelable, detail); |
10 return e; | 12 return e; |
11 } | 13 } |
12 } | 14 } |
13 | 15 |
14 class _EventFactoryProvider { | 16 class _EventFactoryProvider { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // final fragment = new DocumentFragment(); | 64 // final fragment = new DocumentFragment(); |
63 // final e = new XMLElement.tag("xml"); | 65 // final e = new XMLElement.tag("xml"); |
64 // e.innerHTML = xml; | 66 // e.innerHTML = xml; |
65 // | 67 // |
66 // // Copy list first since we don't want liveness during iteration. | 68 // // Copy list first since we don't want liveness during iteration. |
67 // final List nodes = new List.from(e.nodes); | 69 // final List nodes = new List.from(e.nodes); |
68 // fragment.nodes.addAll(nodes); | 70 // fragment.nodes.addAll(nodes); |
69 // return fragment; | 71 // return fragment; |
70 // } | 72 // } |
71 | 73 |
72 static DocumentFragment createDocumentFragment_svg(String svg) { | 74 static DocumentFragment createDocumentFragment_svg(String svgContent) { |
73 final fragment = new DocumentFragment(); | 75 final fragment = new DocumentFragment(); |
74 final e = new SVGSVGElement(); | 76 final e = new svg.SVGSVGElement(); |
75 e.innerHTML = svg; | 77 e.innerHTML = svgContent; |
76 | 78 |
77 // Copy list first since we don't want liveness during iteration. | 79 // Copy list first since we don't want liveness during iteration. |
78 final List nodes = new List.from(e.nodes); | 80 final List nodes = new List.from(e.nodes); |
79 fragment.nodes.addAll(nodes); | 81 fragment.nodes.addAll(nodes); |
80 return fragment; | 82 return fragment; |
81 } | 83 } |
82 } | 84 } |
83 | |
84 class _SVGElementFactoryProvider { | |
85 static SVGElement createSVGElement_tag(String tag) { | |
86 final Element temp = | |
87 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag); | |
88 return temp; | |
89 } | |
90 | |
91 static SVGElement createSVGElement_svg(String svg) { | |
92 Element parentTag; | |
93 final match = _START_TAG_REGEXP.firstMatch(svg); | |
94 if (match != null && match.group(1).toLowerCase() == 'svg') { | |
95 parentTag = new Element.tag('div'); | |
96 } else { | |
97 parentTag = new SVGSVGElement(); | |
98 } | |
99 | |
100 parentTag.innerHTML = svg; | |
101 if (parentTag.elements.length == 1) return parentTag.elements.removeLast(); | |
102 | |
103 throw new ArgumentError( | |
104 'SVG had ${parentTag.elements.length} ' | |
105 'top-level elements but 1 expected'); | |
106 } | |
107 } | |
108 | |
109 class _SVGSVGElementFactoryProvider { | |
110 static SVGSVGElement createSVGSVGElement() { | |
111 final el = new SVGElement.tag("svg"); | |
112 // The SVG spec requires the version attribute to match the spec version | |
113 el.attributes['version'] = "1.1"; | |
114 return el; | |
115 } | |
116 } | |
OLD | NEW |