| 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:_js_helper' show Creates, Returns, JavaScriptIndexingBehavior, JSNa
me; | 8 import 'dart:_js_helper' show Creates, Returns, JavaScriptIndexingBehavior, JSNa
me; |
| 9 import 'dart:_foreign_helper' show JS; | 9 import 'dart:_foreign_helper' show JS; |
| 10 import 'dart:_interceptors' show Interceptor; | 10 import 'dart:_interceptors' show Interceptor; |
| 11 // DO NOT EDIT - unless you are editing documentation as per: | 11 // DO NOT EDIT - unless you are editing documentation as per: |
| 12 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation | 12 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation |
| 13 // Auto-generated dart:svg library. | 13 // Auto-generated dart:svg library. |
| 14 | 14 |
| 15 | 15 |
| 16 | 16 |
| 17 | 17 |
| 18 | 18 |
| 19 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 19 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 20 // for details. All rights reserved. Use of this source code is governed by a | 20 // for details. All rights reserved. Use of this source code is governed by a |
| 21 // BSD-style license that can be found in the LICENSE file. | 21 // BSD-style license that can be found in the LICENSE file. |
| 22 | 22 |
| 23 | 23 |
| 24 final _START_TAG_REGEXP = new RegExp('<(\\w+)'); |
| 25 |
| 24 class _SvgElementFactoryProvider { | 26 class _SvgElementFactoryProvider { |
| 25 static SvgElement createSvgElement_tag(String tag) { | 27 static SvgElement createSvgElement_tag(String tag) { |
| 26 final Element temp = | 28 final Element temp = |
| 27 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag); | 29 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag); |
| 28 return temp; | 30 return temp; |
| 29 } | 31 } |
| 32 |
| 33 static SvgElement createSvgElement_svg(String svg) { |
| 34 Element parentTag; |
| 35 final match = _START_TAG_REGEXP.firstMatch(svg); |
| 36 if (match != null && match.group(1).toLowerCase() == 'svg') { |
| 37 parentTag = new Element.tag('div'); |
| 38 } else { |
| 39 parentTag = new SvgSvgElement(); |
| 40 } |
| 41 |
| 42 parentTag.innerHtml = svg; |
| 43 if (parentTag.children.length == 1) return parentTag.children.removeLast(); |
| 44 |
| 45 throw new ArgumentError( |
| 46 'SVG had ${parentTag.children.length} ' |
| 47 'top-level children but 1 expected'); |
| 48 } |
| 49 } |
| 50 |
| 51 class _SvgSvgElementFactoryProvider { |
| 52 static SvgSvgElement createSvgSvgElement() { |
| 53 final el = new SvgElement.tag("svg"); |
| 54 // The SVG spec requires the version attribute to match the spec version |
| 55 el.attributes['version'] = "1.1"; |
| 56 return el; |
| 57 } |
| 30 } | 58 } |
| 31 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 59 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 32 // for details. All rights reserved. Use of this source code is governed by a | 60 // for details. All rights reserved. Use of this source code is governed by a |
| 33 // BSD-style license that can be found in the LICENSE file. | 61 // BSD-style license that can be found in the LICENSE file. |
| 34 | 62 |
| 35 | 63 |
| 36 @DocsEditable() | 64 @DocsEditable() |
| 37 @DomName('SVGAElement') | 65 @DomName('SVGAElement') |
| 38 @Unstable() | 66 @Unstable() |
| 39 class AElement extends GraphicsElement implements UriReference, ExternalResource
sRequired native "SVGAElement" { | 67 class AElement extends GraphicsElement implements UriReference, ExternalResource
sRequired native "SVGAElement" { |
| (...skipping 4682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4722 } | 4750 } |
| 4723 | 4751 |
| 4724 void writeClasses(Set s) { | 4752 void writeClasses(Set s) { |
| 4725 _element.attributes['class'] = s.join(' '); | 4753 _element.attributes['class'] = s.join(' '); |
| 4726 } | 4754 } |
| 4727 } | 4755 } |
| 4728 | 4756 |
| 4729 @DomName('SVGElement') | 4757 @DomName('SVGElement') |
| 4730 @Unstable() | 4758 @Unstable() |
| 4731 class SvgElement extends Element native "SVGElement" { | 4759 class SvgElement extends Element native "SVGElement" { |
| 4732 static final _START_TAG_REGEXP = new RegExp('<(\\w+)'); | |
| 4733 | |
| 4734 factory SvgElement.tag(String tag) => | 4760 factory SvgElement.tag(String tag) => |
| 4735 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag); | 4761 _SvgElementFactoryProvider.createSvgElement_tag(tag); |
| 4736 factory SvgElement.svg(String svg, | 4762 factory SvgElement.svg(String svg) => |
| 4737 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | 4763 _SvgElementFactoryProvider.createSvgElement_svg(svg); |
| 4738 | |
| 4739 if (validator == null && treeSanitizer == null) { | |
| 4740 validator = new NodeValidatorBuilder.common()..allowSvg(); | |
| 4741 } | |
| 4742 | |
| 4743 final match = _START_TAG_REGEXP.firstMatch(svg); | |
| 4744 var parentElement; | |
| 4745 if (match != null && match.group(1).toLowerCase() == 'svg') { | |
| 4746 parentElement = document.body; | |
| 4747 } else { | |
| 4748 parentElement = new SvgSvgElement(); | |
| 4749 } | |
| 4750 var fragment = parentElement.createFragment(svg, validator: validator, | |
| 4751 treeSanitizer: treeSanitizer); | |
| 4752 return fragment.nodes.where((e) => e is SvgElement).single; | |
| 4753 } | |
| 4754 | 4764 |
| 4755 _AttributeClassSet _cssClassSet; | 4765 _AttributeClassSet _cssClassSet; |
| 4756 CssClassSet get classes { | 4766 CssClassSet get classes { |
| 4757 if (_cssClassSet == null) { | 4767 if (_cssClassSet == null) { |
| 4758 _cssClassSet = new _AttributeClassSet(this); | 4768 _cssClassSet = new _AttributeClassSet(this); |
| 4759 } | 4769 } |
| 4760 return _cssClassSet; | 4770 return _cssClassSet; |
| 4761 } | 4771 } |
| 4762 | 4772 |
| 4763 List<Element> get children => new FilteredElementList<Element>(this); | 4773 List<Element> get children => new FilteredElementList<Element>(this); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4775 return container.innerHtml; | 4785 return container.innerHtml; |
| 4776 } | 4786 } |
| 4777 | 4787 |
| 4778 String get innerHtml { | 4788 String get innerHtml { |
| 4779 final container = new Element.tag("div"); | 4789 final container = new Element.tag("div"); |
| 4780 final SvgElement cloned = this.clone(true); | 4790 final SvgElement cloned = this.clone(true); |
| 4781 container.children.addAll(cloned.children); | 4791 container.children.addAll(cloned.children); |
| 4782 return container.innerHtml; | 4792 return container.innerHtml; |
| 4783 } | 4793 } |
| 4784 | 4794 |
| 4785 void set innerHtml(String value) { | 4795 void set innerHtml(String svg) { |
| 4786 this.setInnerHtml(value); | 4796 final container = new Element.tag("div"); |
| 4787 } | 4797 // Wrap the SVG string in <svg> so that SvgElements are created, rather than |
| 4788 | 4798 // HTMLElements. |
| 4789 DocumentFragment createFragment(String svg, | 4799 container.innerHtml = '<svg version="1.1">$svg</svg>'; |
| 4790 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | 4800 this.children = container.children[0].children; |
| 4791 | |
| 4792 if (treeSanitizer == null) { | |
| 4793 if (validator == null) { | |
| 4794 validator = new NodeValidatorBuilder.common() | |
| 4795 ..allowSvg(); | |
| 4796 } | |
| 4797 treeSanitizer = new NodeTreeSanitizer(validator); | |
| 4798 } | |
| 4799 | |
| 4800 // We create a fragment which will parse in the HTML parser | |
| 4801 var html = '<svg version="1.1">$svg</svg>'; | |
| 4802 var fragment = document.body.createFragment(html, | |
| 4803 treeSanitizer: treeSanitizer); | |
| 4804 | |
| 4805 var svgFragment = new DocumentFragment(); | |
| 4806 // The root is the <svg/> element, need to pull out the contents. | |
| 4807 var root = fragment.nodes.single; | |
| 4808 while (root.firstChild != null) { | |
| 4809 svgFragment.append(root.firstChild); | |
| 4810 } | |
| 4811 return svgFragment; | |
| 4812 } | 4801 } |
| 4813 | 4802 |
| 4814 // Unsupported methods inherited from Element. | 4803 // Unsupported methods inherited from Element. |
| 4815 | 4804 |
| 4816 @DomName('Element.insertAdjacentText') | 4805 @DomName('Element.insertAdjacentText') |
| 4817 void insertAdjacentText(String where, String text) { | 4806 void insertAdjacentText(String where, String text) { |
| 4818 throw new UnsupportedError("Cannot invoke insertAdjacentText on SVG."); | 4807 throw new UnsupportedError("Cannot invoke insertAdjacentText on SVG."); |
| 4819 } | 4808 } |
| 4820 | 4809 |
| 4821 @DomName('Element.insertAdjacentHTML') | 4810 @DomName('Element.insertAdjacentHTML') |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4880 | 4869 |
| 4881 } | 4870 } |
| 4882 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 4871 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 4883 // for details. All rights reserved. Use of this source code is governed by a | 4872 // for details. All rights reserved. Use of this source code is governed by a |
| 4884 // BSD-style license that can be found in the LICENSE file. | 4873 // BSD-style license that can be found in the LICENSE file. |
| 4885 | 4874 |
| 4886 | 4875 |
| 4887 @DomName('SVGSVGElement') | 4876 @DomName('SVGSVGElement') |
| 4888 @Unstable() | 4877 @Unstable() |
| 4889 class SvgSvgElement extends GraphicsElement implements FitToViewBox, ExternalRes
ourcesRequired, ZoomAndPan native "SVGSVGElement" { | 4878 class SvgSvgElement extends GraphicsElement implements FitToViewBox, ExternalRes
ourcesRequired, ZoomAndPan native "SVGSVGElement" { |
| 4890 factory SvgSvgElement() { | 4879 factory SvgSvgElement() => _SvgSvgElementFactoryProvider.createSvgSvgElement()
; |
| 4891 final el = new SvgElement.tag("svg"); | |
| 4892 // The SVG spec requires the version attribute to match the spec version | |
| 4893 el.attributes['version'] = "1.1"; | |
| 4894 return el; | |
| 4895 } | |
| 4896 | 4880 |
| 4897 // To suppress missing implicit constructor warnings. | 4881 // To suppress missing implicit constructor warnings. |
| 4898 factory SvgSvgElement._() { throw new UnsupportedError("Not supported"); } | 4882 factory SvgSvgElement._() { throw new UnsupportedError("Not supported"); } |
| 4899 | 4883 |
| 4900 @DomName('SVGSVGElement.contentScriptType') | 4884 @DomName('SVGSVGElement.contentScriptType') |
| 4901 @DocsEditable() | 4885 @DocsEditable() |
| 4902 String contentScriptType; | 4886 String contentScriptType; |
| 4903 | 4887 |
| 4904 @DomName('SVGSVGElement.contentStyleType') | 4888 @DomName('SVGSVGElement.contentStyleType') |
| 4905 @DocsEditable() | 4889 @DocsEditable() |
| (...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6190 @DomName('SVGVKernElement') | 6174 @DomName('SVGVKernElement') |
| 6191 @Unstable() | 6175 @Unstable() |
| 6192 abstract class _SVGVKernElement extends SvgElement native "SVGVKernElement" { | 6176 abstract class _SVGVKernElement extends SvgElement native "SVGVKernElement" { |
| 6193 // To suppress missing implicit constructor warnings. | 6177 // To suppress missing implicit constructor warnings. |
| 6194 factory _SVGVKernElement._() { throw new UnsupportedError("Not supported"); } | 6178 factory _SVGVKernElement._() { throw new UnsupportedError("Not supported"); } |
| 6195 | 6179 |
| 6196 @DomName('SVGVKernElement.SVGVKernElement') | 6180 @DomName('SVGVKernElement.SVGVKernElement') |
| 6197 @DocsEditable() | 6181 @DocsEditable() |
| 6198 factory _SVGVKernElement() => _SvgElementFactoryProvider.createSvgElement_tag(
"vkern"); | 6182 factory _SVGVKernElement() => _SvgElementFactoryProvider.createSvgElement_tag(
"vkern"); |
| 6199 } | 6183 } |
| OLD | NEW |