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' hide deprecated; | 5 import 'dart:_collection-dev' hide deprecated; |
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 5294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5359 } | 5331 } |
5360 | 5332 |
5361 void writeClasses(Set s) { | 5333 void writeClasses(Set s) { |
5362 _element.attributes['class'] = s.join(' '); | 5334 _element.attributes['class'] = s.join(' '); |
5363 } | 5335 } |
5364 } | 5336 } |
5365 | 5337 |
5366 @DomName('SVGElement') | 5338 @DomName('SVGElement') |
5367 @Unstable() | 5339 @Unstable() |
5368 class SvgElement extends Element { | 5340 class SvgElement extends Element { |
| 5341 static final _START_TAG_REGEXP = new RegExp('<(\\w+)'); |
| 5342 |
5369 factory SvgElement.tag(String tag) => | 5343 factory SvgElement.tag(String tag) => |
5370 _SvgElementFactoryProvider.createSvgElement_tag(tag); | 5344 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag); |
5371 factory SvgElement.svg(String svg) => | 5345 factory SvgElement.svg(String svg, |
5372 _SvgElementFactoryProvider.createSvgElement_svg(svg); | 5346 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { |
| 5347 |
| 5348 if (validator == null && treeSanitizer == null) { |
| 5349 validator = new NodeValidatorBuilder.common() |
| 5350 ..allowSvg(); |
| 5351 } |
| 5352 |
| 5353 final match = _START_TAG_REGEXP.firstMatch(svg); |
| 5354 var parentElement; |
| 5355 if (match != null && match.group(1).toLowerCase() == 'svg') { |
| 5356 parentElement = document.body; |
| 5357 } else { |
| 5358 parentElement = new SvgSvgElement(); |
| 5359 } |
| 5360 var fragment = parentElement.createFragment(svg, validator: validator, |
| 5361 treeSanitizer: treeSanitizer); |
| 5362 return fragment.nodes.where((e) => e is SvgElement).single; |
| 5363 } |
5373 | 5364 |
5374 _AttributeClassSet _cssClassSet; | 5365 _AttributeClassSet _cssClassSet; |
5375 CssClassSet get classes { | 5366 CssClassSet get classes { |
5376 if (_cssClassSet == null) { | 5367 if (_cssClassSet == null) { |
5377 _cssClassSet = new _AttributeClassSet(this); | 5368 _cssClassSet = new _AttributeClassSet(this); |
5378 } | 5369 } |
5379 return _cssClassSet; | 5370 return _cssClassSet; |
5380 } | 5371 } |
5381 | 5372 |
5382 List<Element> get children => new FilteredElementList<Element>(this); | 5373 List<Element> get children => new FilteredElementList<Element>(this); |
(...skipping 11 matching lines...) Expand all Loading... |
5394 return container.innerHtml; | 5385 return container.innerHtml; |
5395 } | 5386 } |
5396 | 5387 |
5397 String get innerHtml { | 5388 String get innerHtml { |
5398 final container = new Element.tag("div"); | 5389 final container = new Element.tag("div"); |
5399 final SvgElement cloned = this.clone(true); | 5390 final SvgElement cloned = this.clone(true); |
5400 container.children.addAll(cloned.children); | 5391 container.children.addAll(cloned.children); |
5401 return container.innerHtml; | 5392 return container.innerHtml; |
5402 } | 5393 } |
5403 | 5394 |
5404 void set innerHtml(String svg) { | 5395 DocumentFragment createFragment(String svg, |
5405 final container = new Element.tag("div"); | 5396 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { |
5406 // Wrap the SVG string in <svg> so that SvgElements are created, rather than | 5397 |
5407 // HTMLElements. | 5398 if (treeSanitizer == null) { |
5408 container.innerHtml = '<svg version="1.1">$svg</svg>'; | 5399 if (validator == null) { |
5409 this.children = container.children[0].children; | 5400 validator = new NodeValidatorBuilder.common() |
| 5401 ..allowSvg(); |
| 5402 } |
| 5403 treeSanitizer = new NodeTreeSanitizer(validator); |
| 5404 } |
| 5405 |
| 5406 // We create a fragment which will parse in the HTML parser |
| 5407 var html = '<svg version="1.1">$svg</svg>'; |
| 5408 var fragment = document.body.createFragment(html, |
| 5409 treeSanitizer: treeSanitizer); |
| 5410 |
| 5411 var svgFragment = new DocumentFragment(); |
| 5412 // The root is the <svg/> element, need to pull out the contents. |
| 5413 var root = fragment.nodes.single; |
| 5414 while (root.firstChild != null) { |
| 5415 svgFragment.append(root.firstChild); |
| 5416 } |
| 5417 return svgFragment; |
5410 } | 5418 } |
5411 | 5419 |
5412 // Unsupported methods inherited from Element. | 5420 // Unsupported methods inherited from Element. |
5413 | 5421 |
5414 @DomName('Element.insertAdjacentText') | 5422 @DomName('Element.insertAdjacentText') |
5415 void insertAdjacentText(String where, String text) { | 5423 void insertAdjacentText(String where, String text) { |
5416 throw new UnsupportedError("Cannot invoke insertAdjacentText on SVG."); | 5424 throw new UnsupportedError("Cannot invoke insertAdjacentText on SVG."); |
5417 } | 5425 } |
5418 | 5426 |
5419 @DomName('Element.insertAdjacentHTML') | 5427 @DomName('Element.insertAdjacentHTML') |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5493 | 5501 |
5494 } | 5502 } |
5495 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 5503 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
5496 // for details. All rights reserved. Use of this source code is governed by a | 5504 // for details. All rights reserved. Use of this source code is governed by a |
5497 // BSD-style license that can be found in the LICENSE file. | 5505 // BSD-style license that can be found in the LICENSE file. |
5498 | 5506 |
5499 | 5507 |
5500 @DomName('SVGSVGElement') | 5508 @DomName('SVGSVGElement') |
5501 @Unstable() | 5509 @Unstable() |
5502 class SvgSvgElement extends GraphicsElement implements FitToViewBox, ExternalRes
ourcesRequired, ZoomAndPan { | 5510 class SvgSvgElement extends GraphicsElement implements FitToViewBox, ExternalRes
ourcesRequired, ZoomAndPan { |
5503 factory SvgSvgElement() => _SvgSvgElementFactoryProvider.createSvgSvgElement()
; | 5511 factory SvgSvgElement() { |
| 5512 final el = new SvgElement.tag("svg"); |
| 5513 // The SVG spec requires the version attribute to match the spec version |
| 5514 el.attributes['version'] = "1.1"; |
| 5515 return el; |
| 5516 } |
5504 | 5517 |
5505 // To suppress missing implicit constructor warnings. | 5518 // To suppress missing implicit constructor warnings. |
5506 factory SvgSvgElement._() { throw new UnsupportedError("Not supported"); } | 5519 factory SvgSvgElement._() { throw new UnsupportedError("Not supported"); } |
5507 | 5520 |
5508 @DomName('SVGSVGElement.contentScriptType') | 5521 @DomName('SVGSVGElement.contentScriptType') |
5509 @DocsEditable() | 5522 @DocsEditable() |
5510 String get contentScriptType native "SVGSVGElement_contentScriptType_Getter"; | 5523 String get contentScriptType native "SVGSVGElement_contentScriptType_Getter"; |
5511 | 5524 |
5512 @DomName('SVGSVGElement.contentScriptType') | 5525 @DomName('SVGSVGElement.contentScriptType') |
5513 @DocsEditable() | 5526 @DocsEditable() |
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6897 @Unstable() | 6910 @Unstable() |
6898 abstract class _SVGVKernElement extends SvgElement { | 6911 abstract class _SVGVKernElement extends SvgElement { |
6899 // To suppress missing implicit constructor warnings. | 6912 // To suppress missing implicit constructor warnings. |
6900 factory _SVGVKernElement._() { throw new UnsupportedError("Not supported"); } | 6913 factory _SVGVKernElement._() { throw new UnsupportedError("Not supported"); } |
6901 | 6914 |
6902 @DomName('SVGVKernElement.SVGVKernElement') | 6915 @DomName('SVGVKernElement.SVGVKernElement') |
6903 @DocsEditable() | 6916 @DocsEditable() |
6904 factory _SVGVKernElement() => _SvgElementFactoryProvider.createSvgElement_tag(
"vkern"); | 6917 factory _SVGVKernElement() => _SvgElementFactoryProvider.createSvgElement_tag(
"vkern"); |
6905 | 6918 |
6906 } | 6919 } |
OLD | NEW |