| 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 | |
| 26 class _SvgElementFactoryProvider { | 24 class _SvgElementFactoryProvider { |
| 27 static SvgElement createSvgElement_tag(String tag) { | 25 static SvgElement createSvgElement_tag(String tag) { |
| 28 final Element temp = | 26 final Element temp = |
| 29 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag); | 27 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag); |
| 30 return temp; | 28 return temp; |
| 31 } | 29 } |
| 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 } | |
| 58 } | 30 } |
| 59 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 31 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 60 // for details. All rights reserved. Use of this source code is governed by a | 32 // for details. All rights reserved. Use of this source code is governed by a |
| 61 // BSD-style license that can be found in the LICENSE file. | 33 // BSD-style license that can be found in the LICENSE file. |
| 62 | 34 |
| 63 | 35 |
| 64 @DocsEditable() | 36 @DocsEditable() |
| 65 @DomName('SVGAElement') | 37 @DomName('SVGAElement') |
| 66 @Unstable() | 38 @Unstable() |
| 67 class AElement extends GraphicsElement implements UriReference, ExternalResource
sRequired native "SVGAElement" { | 39 class AElement extends GraphicsElement implements UriReference, ExternalResource
sRequired native "SVGAElement" { |
| (...skipping 4700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4768 } | 4740 } |
| 4769 | 4741 |
| 4770 void writeClasses(Set s) { | 4742 void writeClasses(Set s) { |
| 4771 _element.attributes['class'] = s.join(' '); | 4743 _element.attributes['class'] = s.join(' '); |
| 4772 } | 4744 } |
| 4773 } | 4745 } |
| 4774 | 4746 |
| 4775 @DomName('SVGElement') | 4747 @DomName('SVGElement') |
| 4776 @Unstable() | 4748 @Unstable() |
| 4777 class SvgElement extends Element native "SVGElement" { | 4749 class SvgElement extends Element native "SVGElement" { |
| 4750 static final _START_TAG_REGEXP = new RegExp('<(\\w+)'); |
| 4751 |
| 4778 factory SvgElement.tag(String tag) => | 4752 factory SvgElement.tag(String tag) => |
| 4779 _SvgElementFactoryProvider.createSvgElement_tag(tag); | 4753 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag); |
| 4780 factory SvgElement.svg(String svg) => | 4754 factory SvgElement.svg(String svg, |
| 4781 _SvgElementFactoryProvider.createSvgElement_svg(svg); | 4755 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { |
| 4756 |
| 4757 if (validator == null && treeSanitizer == null) { |
| 4758 validator = new NodeValidatorBuilder.common() |
| 4759 ..allowSvg(); |
| 4760 } |
| 4761 |
| 4762 final match = _START_TAG_REGEXP.firstMatch(svg); |
| 4763 var parentElement; |
| 4764 if (match != null && match.group(1).toLowerCase() == 'svg') { |
| 4765 parentElement = document.body; |
| 4766 } else { |
| 4767 parentElement = new SvgSvgElement(); |
| 4768 } |
| 4769 var fragment = parentElement.createFragment(svg, validator: validator, |
| 4770 treeSanitizer: treeSanitizer); |
| 4771 return fragment.nodes.where((e) => e is SvgElement).single; |
| 4772 } |
| 4782 | 4773 |
| 4783 _AttributeClassSet _cssClassSet; | 4774 _AttributeClassSet _cssClassSet; |
| 4784 CssClassSet get classes { | 4775 CssClassSet get classes { |
| 4785 if (_cssClassSet == null) { | 4776 if (_cssClassSet == null) { |
| 4786 _cssClassSet = new _AttributeClassSet(this); | 4777 _cssClassSet = new _AttributeClassSet(this); |
| 4787 } | 4778 } |
| 4788 return _cssClassSet; | 4779 return _cssClassSet; |
| 4789 } | 4780 } |
| 4790 | 4781 |
| 4791 List<Element> get children => new FilteredElementList<Element>(this); | 4782 List<Element> get children => new FilteredElementList<Element>(this); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4803 return container.innerHtml; | 4794 return container.innerHtml; |
| 4804 } | 4795 } |
| 4805 | 4796 |
| 4806 String get innerHtml { | 4797 String get innerHtml { |
| 4807 final container = new Element.tag("div"); | 4798 final container = new Element.tag("div"); |
| 4808 final SvgElement cloned = this.clone(true); | 4799 final SvgElement cloned = this.clone(true); |
| 4809 container.children.addAll(cloned.children); | 4800 container.children.addAll(cloned.children); |
| 4810 return container.innerHtml; | 4801 return container.innerHtml; |
| 4811 } | 4802 } |
| 4812 | 4803 |
| 4813 void set innerHtml(String svg) { | 4804 DocumentFragment createFragment(String svg, |
| 4814 final container = new Element.tag("div"); | 4805 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { |
| 4815 // Wrap the SVG string in <svg> so that SvgElements are created, rather than | 4806 |
| 4816 // HTMLElements. | 4807 if (treeSanitizer == null) { |
| 4817 container.innerHtml = '<svg version="1.1">$svg</svg>'; | 4808 if (validator == null) { |
| 4818 this.children = container.children[0].children; | 4809 validator = new NodeValidatorBuilder.common() |
| 4810 ..allowSvg(); |
| 4811 } |
| 4812 treeSanitizer = new NodeTreeSanitizer(validator); |
| 4813 } |
| 4814 |
| 4815 // We create a fragment which will parse in the HTML parser |
| 4816 var html = '<svg version="1.1">$svg</svg>'; |
| 4817 var fragment = document.body.createFragment(html, |
| 4818 treeSanitizer: treeSanitizer); |
| 4819 |
| 4820 var svgFragment = new DocumentFragment(); |
| 4821 // The root is the <svg/> element, need to pull out the contents. |
| 4822 var root = fragment.nodes.single; |
| 4823 while (root.firstChild != null) { |
| 4824 svgFragment.append(root.firstChild); |
| 4825 } |
| 4826 return svgFragment; |
| 4819 } | 4827 } |
| 4820 | 4828 |
| 4821 // Unsupported methods inherited from Element. | 4829 // Unsupported methods inherited from Element. |
| 4822 | 4830 |
| 4823 @DomName('Element.insertAdjacentText') | 4831 @DomName('Element.insertAdjacentText') |
| 4824 void insertAdjacentText(String where, String text) { | 4832 void insertAdjacentText(String where, String text) { |
| 4825 throw new UnsupportedError("Cannot invoke insertAdjacentText on SVG."); | 4833 throw new UnsupportedError("Cannot invoke insertAdjacentText on SVG."); |
| 4826 } | 4834 } |
| 4827 | 4835 |
| 4828 @DomName('Element.insertAdjacentHTML') | 4836 @DomName('Element.insertAdjacentHTML') |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4888 | 4896 |
| 4889 } | 4897 } |
| 4890 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 4898 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 4891 // for details. All rights reserved. Use of this source code is governed by a | 4899 // for details. All rights reserved. Use of this source code is governed by a |
| 4892 // BSD-style license that can be found in the LICENSE file. | 4900 // BSD-style license that can be found in the LICENSE file. |
| 4893 | 4901 |
| 4894 | 4902 |
| 4895 @DomName('SVGSVGElement') | 4903 @DomName('SVGSVGElement') |
| 4896 @Unstable() | 4904 @Unstable() |
| 4897 class SvgSvgElement extends GraphicsElement implements FitToViewBox, ExternalRes
ourcesRequired, ZoomAndPan native "SVGSVGElement" { | 4905 class SvgSvgElement extends GraphicsElement implements FitToViewBox, ExternalRes
ourcesRequired, ZoomAndPan native "SVGSVGElement" { |
| 4898 factory SvgSvgElement() => _SvgSvgElementFactoryProvider.createSvgSvgElement()
; | 4906 factory SvgSvgElement() { |
| 4907 final el = new SvgElement.tag("svg"); |
| 4908 // The SVG spec requires the version attribute to match the spec version |
| 4909 el.attributes['version'] = "1.1"; |
| 4910 return el; |
| 4911 } |
| 4899 | 4912 |
| 4900 // To suppress missing implicit constructor warnings. | 4913 // To suppress missing implicit constructor warnings. |
| 4901 factory SvgSvgElement._() { throw new UnsupportedError("Not supported"); } | 4914 factory SvgSvgElement._() { throw new UnsupportedError("Not supported"); } |
| 4902 | 4915 |
| 4903 @DomName('SVGSVGElement.contentScriptType') | 4916 @DomName('SVGSVGElement.contentScriptType') |
| 4904 @DocsEditable() | 4917 @DocsEditable() |
| 4905 String contentScriptType; | 4918 String contentScriptType; |
| 4906 | 4919 |
| 4907 @DomName('SVGSVGElement.contentStyleType') | 4920 @DomName('SVGSVGElement.contentStyleType') |
| 4908 @DocsEditable() | 4921 @DocsEditable() |
| (...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6193 @DomName('SVGVKernElement') | 6206 @DomName('SVGVKernElement') |
| 6194 @Unstable() | 6207 @Unstable() |
| 6195 abstract class _SVGVKernElement extends SvgElement native "SVGVKernElement" { | 6208 abstract class _SVGVKernElement extends SvgElement native "SVGVKernElement" { |
| 6196 // To suppress missing implicit constructor warnings. | 6209 // To suppress missing implicit constructor warnings. |
| 6197 factory _SVGVKernElement._() { throw new UnsupportedError("Not supported"); } | 6210 factory _SVGVKernElement._() { throw new UnsupportedError("Not supported"); } |
| 6198 | 6211 |
| 6199 @DomName('SVGVKernElement.SVGVKernElement') | 6212 @DomName('SVGVKernElement.SVGVKernElement') |
| 6200 @DocsEditable() | 6213 @DocsEditable() |
| 6201 factory _SVGVKernElement() => _SvgElementFactoryProvider.createSvgElement_tag(
"vkern"); | 6214 factory _SVGVKernElement() => _SvgElementFactoryProvider.createSvgElement_tag(
"vkern"); |
| 6202 } | 6215 } |
| OLD | NEW |