OLD | NEW |
1 library dart.dom.svg; | 1 library dart.dom.svg; |
2 | 2 |
3 import 'dart:async'; | 3 import 'dart:async'; |
4 import 'dart:collection'; | 4 import 'dart:collection'; |
5 import 'dart:_collection-dev'; | 5 import 'dart:_collection-dev'; |
6 import 'dart:html'; | 6 import 'dart:html'; |
7 import 'dart:html_common'; | 7 import 'dart:html_common'; |
8 import 'dart:nativewrappers'; | 8 import 'dart:nativewrappers'; |
9 // DO NOT EDIT | 9 // DO NOT EDIT |
10 // Auto-generated dart:svg library. | 10 // Auto-generated dart:svg library. |
11 | 11 |
12 | 12 |
13 | 13 |
14 | 14 |
15 | 15 |
16 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 16 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
17 // for details. All rights reserved. Use of this source code is governed by a | 17 // for details. All rights reserved. Use of this source code is governed by a |
18 // BSD-style license that can be found in the LICENSE file. | 18 // BSD-style license that can be found in the LICENSE file. |
19 | 19 |
20 | 20 |
21 final _START_TAG_REGEXP = new RegExp('<(\\w+)'); | |
22 | |
23 class _SvgElementFactoryProvider { | 21 class _SvgElementFactoryProvider { |
24 static SvgElement createSvgElement_tag(String tag) { | 22 static SvgElement createSvgElement_tag(String tag) { |
25 final Element temp = | 23 final Element temp = |
26 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag); | 24 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag); |
27 return temp; | 25 return temp; |
28 } | 26 } |
29 | |
30 static SvgElement createSvgElement_svg(String svg) { | |
31 Element parentTag; | |
32 final match = _START_TAG_REGEXP.firstMatch(svg); | |
33 if (match != null && match.group(1).toLowerCase() == 'svg') { | |
34 parentTag = new Element.tag('div'); | |
35 } else { | |
36 parentTag = new SvgSvgElement(); | |
37 } | |
38 | |
39 parentTag.innerHtml = svg; | |
40 if (parentTag.children.length == 1) return parentTag.children.removeLast(); | |
41 | |
42 throw new ArgumentError( | |
43 'SVG had ${parentTag.children.length} ' | |
44 'top-level children but 1 expected'); | |
45 } | |
46 } | |
47 | |
48 class _SvgSvgElementFactoryProvider { | |
49 static SvgSvgElement createSvgSvgElement() { | |
50 final el = new SvgElement.tag("svg"); | |
51 // The SVG spec requires the version attribute to match the spec version | |
52 el.attributes['version'] = "1.1"; | |
53 return el; | |
54 } | |
55 } | 27 } |
56 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 28 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
57 // for details. All rights reserved. Use of this source code is governed by a | 29 // for details. All rights reserved. Use of this source code is governed by a |
58 // BSD-style license that can be found in the LICENSE file. | 30 // BSD-style license that can be found in the LICENSE file. |
59 | 31 |
60 // WARNING: Do not edit - generated code. | 32 // WARNING: Do not edit - generated code. |
61 | 33 |
62 | 34 |
63 @DocsEditable | 35 @DocsEditable |
64 @DomName('SVGAElement') | 36 @DomName('SVGAElement') |
(...skipping 6139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6204 } | 6176 } |
6205 | 6177 |
6206 void writeClasses(Set s) { | 6178 void writeClasses(Set s) { |
6207 _element.attributes['class'] = s.join(' '); | 6179 _element.attributes['class'] = s.join(' '); |
6208 } | 6180 } |
6209 } | 6181 } |
6210 | 6182 |
6211 @DomName('SVGElement') | 6183 @DomName('SVGElement') |
6212 @Unstable | 6184 @Unstable |
6213 class SvgElement extends Element { | 6185 class SvgElement extends Element { |
| 6186 static final _START_TAG_REGEXP = new RegExp('<(\\w+)'); |
| 6187 |
6214 factory SvgElement.tag(String tag) => | 6188 factory SvgElement.tag(String tag) => |
6215 _SvgElementFactoryProvider.createSvgElement_tag(tag); | 6189 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag); |
6216 factory SvgElement.svg(String svg) => | 6190 |
6217 _SvgElementFactoryProvider.createSvgElement_svg(svg); | 6191 factory SvgElement.svg(String svg, |
| 6192 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { |
| 6193 |
| 6194 if (validator == null && treeSanitizer == null) { |
| 6195 validator = new NodeValidatorBuilder.common() |
| 6196 ..allowSvg(); |
| 6197 } |
| 6198 |
| 6199 final match = _START_TAG_REGEXP.firstMatch(svg); |
| 6200 var parentElement; |
| 6201 if (match != null && match.group(1).toLowerCase() == 'svg') { |
| 6202 parentElement = document.body; |
| 6203 } else { |
| 6204 parentElement = new SvgSvgElement(); |
| 6205 } |
| 6206 var fragment = parentElement.createFragment(svg, validator: validator, |
| 6207 treeSanitizer: treeSanitizer); |
| 6208 return fragment.nodes.where((e) => e is SvgElement).single; |
| 6209 } |
6218 | 6210 |
6219 _AttributeClassSet _cssClassSet; | 6211 _AttributeClassSet _cssClassSet; |
6220 CssClassSet get classes { | 6212 CssClassSet get classes { |
6221 if (_cssClassSet == null) { | 6213 if (_cssClassSet == null) { |
6222 _cssClassSet = new _AttributeClassSet(this); | 6214 _cssClassSet = new _AttributeClassSet(this); |
6223 } | 6215 } |
6224 return _cssClassSet; | 6216 return _cssClassSet; |
6225 } | 6217 } |
6226 | 6218 |
6227 List<Element> get children => new FilteredElementList<Element>(this); | 6219 List<Element> get children => new FilteredElementList<Element>(this); |
(...skipping 11 matching lines...) Expand all Loading... |
6239 return container.innerHtml; | 6231 return container.innerHtml; |
6240 } | 6232 } |
6241 | 6233 |
6242 String get innerHtml { | 6234 String get innerHtml { |
6243 final container = new Element.tag("div"); | 6235 final container = new Element.tag("div"); |
6244 final SvgElement cloned = this.clone(true); | 6236 final SvgElement cloned = this.clone(true); |
6245 container.children.addAll(cloned.children); | 6237 container.children.addAll(cloned.children); |
6246 return container.innerHtml; | 6238 return container.innerHtml; |
6247 } | 6239 } |
6248 | 6240 |
6249 void set innerHtml(String svg) { | 6241 DocumentFragment createFragment(String svg, |
6250 final container = new Element.tag("div"); | 6242 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { |
6251 // Wrap the SVG string in <svg> so that SvgElements are created, rather than | 6243 |
6252 // HTMLElements. | 6244 if (treeSanitizer == null) { |
6253 container.innerHtml = '<svg version="1.1">$svg</svg>'; | 6245 if (validator == null) { |
6254 this.children = container.children[0].children; | 6246 validator = new NodeValidatorBuilder.common() |
| 6247 ..allowSvg(); |
| 6248 } |
| 6249 treeSanitizer = new NodeTreeSanitizer(validator); |
| 6250 } |
| 6251 |
| 6252 // We create a fragment which will parse in the HTML parser |
| 6253 var html = '<svg version="1.1">$svg</svg>'; |
| 6254 var fragment = document.body.createFragment(html, |
| 6255 treeSanitizer: treeSanitizer); |
| 6256 |
| 6257 var svgFragment = new DocumentFragment(); |
| 6258 // The root is the <svg/> element, need to pull out the contents. |
| 6259 var root = fragment.nodes.single; |
| 6260 while (root.$dom_firstChild != null) { |
| 6261 svgFragment.append(root.$dom_firstChild); |
| 6262 } |
| 6263 return svgFragment; |
6255 } | 6264 } |
6256 | 6265 |
6257 // Unsupported methods inherited from Element. | 6266 // Unsupported methods inherited from Element. |
6258 | 6267 |
6259 @DomName('Element.insertAdjacentText') | 6268 @DomName('Element.insertAdjacentText') |
6260 void insertAdjacentText(String where, String text) { | 6269 void insertAdjacentText(String where, String text) { |
6261 throw new UnsupportedError("Cannot invoke insertAdjacentText on SVG."); | 6270 throw new UnsupportedError("Cannot invoke insertAdjacentText on SVG."); |
6262 } | 6271 } |
6263 | 6272 |
6264 @DomName('Element.insertAdjacentHTML') | 6273 @DomName('Element.insertAdjacentHTML') |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6361 | 6370 |
6362 } | 6371 } |
6363 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 6372 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
6364 // for details. All rights reserved. Use of this source code is governed by a | 6373 // for details. All rights reserved. Use of this source code is governed by a |
6365 // BSD-style license that can be found in the LICENSE file. | 6374 // BSD-style license that can be found in the LICENSE file. |
6366 | 6375 |
6367 | 6376 |
6368 @DomName('SVGSVGElement') | 6377 @DomName('SVGSVGElement') |
6369 @Unstable | 6378 @Unstable |
6370 class SvgSvgElement extends StyledElement implements FitToViewBox, Transformable
, Tests, ExternalResourcesRequired, ZoomAndPan, LangSpace { | 6379 class SvgSvgElement extends StyledElement implements FitToViewBox, Transformable
, Tests, ExternalResourcesRequired, ZoomAndPan, LangSpace { |
6371 factory SvgSvgElement() => _SvgSvgElementFactoryProvider.createSvgSvgElement()
; | 6380 factory SvgSvgElement() { |
6372 | 6381 final el = new SvgElement.tag("svg"); |
| 6382 // The SVG spec requires the version attribute to match the spec version |
| 6383 el.attributes['version'] = "1.1"; |
| 6384 return el; |
| 6385 } |
6373 SvgSvgElement.internal() : super.internal(); | 6386 SvgSvgElement.internal() : super.internal(); |
6374 | 6387 |
6375 @DomName('SVGSVGElement.contentScriptType') | 6388 @DomName('SVGSVGElement.contentScriptType') |
6376 @DocsEditable | 6389 @DocsEditable |
6377 String get contentScriptType native "SVGSVGElement_contentScriptType_Getter"; | 6390 String get contentScriptType native "SVGSVGElement_contentScriptType_Getter"; |
6378 | 6391 |
6379 @DomName('SVGSVGElement.contentScriptType') | 6392 @DomName('SVGSVGElement.contentScriptType') |
6380 @DocsEditable | 6393 @DocsEditable |
6381 void set contentScriptType(String value) native "SVGSVGElement_contentScriptTy
pe_Setter"; | 6394 void set contentScriptType(String value) native "SVGSVGElement_contentScriptTy
pe_Setter"; |
6382 | 6395 |
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8039 @DomName('SVGVKernElement') | 8052 @DomName('SVGVKernElement') |
8040 @Unstable | 8053 @Unstable |
8041 abstract class _SVGVKernElement extends SvgElement { | 8054 abstract class _SVGVKernElement extends SvgElement { |
8042 _SVGVKernElement.internal() : super.internal(); | 8055 _SVGVKernElement.internal() : super.internal(); |
8043 | 8056 |
8044 @DomName('SVGVKernElement.SVGVKernElement') | 8057 @DomName('SVGVKernElement.SVGVKernElement') |
8045 @DocsEditable | 8058 @DocsEditable |
8046 factory _SVGVKernElement() => _SvgElementFactoryProvider.createSvgElement_tag(
"vkern"); | 8059 factory _SVGVKernElement() => _SvgElementFactoryProvider.createSvgElement_tag(
"vkern"); |
8047 | 8060 |
8048 } | 8061 } |
OLD | NEW |