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 class _SVGClassSet extends _CssClassSet { | 5 class _SVGClassSet extends _CssClassSet { |
6 _SVGClassSet(element) : super(element); | 6 _SVGClassSet(element) : super(element); |
7 | 7 |
8 String _className() => _element.className.baseVal; | 8 String _className() => _element.className.baseVal; |
9 | 9 |
10 void _write(Set s) { | 10 void _write(Set s) { |
(...skipping 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 parentTag.innerHTML = svg; | 31 parentTag.innerHTML = svg; |
32 if (parentTag.elements.length == 1) return parentTag.nodes.removeLast(); | 32 if (parentTag.elements.length == 1) return parentTag.nodes.removeLast(); |
33 | 33 |
34 throw new IllegalArgumentException( | 34 throw new IllegalArgumentException( |
35 'SVG had ${parentTag.elements.length} ' | 35 'SVG had ${parentTag.elements.length} ' |
36 'top-level elements but 1 expected'); | 36 'top-level elements but 1 expected'); |
37 } | 37 } |
38 | 38 |
39 CSSClassSet get classes() { | 39 CSSClassSet get classes { |
40 if (_cssClassSet === null) { | 40 if (_cssClassSet === null) { |
41 _cssClassSet = new _SVGClassSet(_ptr); | 41 _cssClassSet = new _SVGClassSet(_ptr); |
42 } | 42 } |
43 return _cssClassSet; | 43 return _cssClassSet; |
44 } | 44 } |
45 | 45 |
46 String get id() { return _ptr.id; } | 46 String get id { return _ptr.id; } |
47 | 47 |
48 void set id(String value) { _ptr.id = value; } | 48 void set id(String value) { _ptr.id = value; } |
49 | 49 |
50 SVGSVGElement get ownerSVGElement() { return LevelDom.wrapSVGSVGElement(_ptr.o
wnerSVGElement); } | 50 SVGSVGElement get ownerSVGElement { return LevelDom.wrapSVGSVGElement(_ptr.own
erSVGElement); } |
51 | 51 |
52 SVGElement get viewportElement() { return LevelDom.wrapSVGElement(_ptr.viewpor
tElement); } | 52 SVGElement get viewportElement { return LevelDom.wrapSVGElement(_ptr.viewportE
lement); } |
53 | 53 |
54 String get xmlbase() { return _ptr.xmlbase; } | 54 String get xmlbase { return _ptr.xmlbase; } |
55 | 55 |
56 void set xmlbase(String value) { _ptr.xmlbase = value; } | 56 void set xmlbase(String value) { _ptr.xmlbase = value; } |
57 | 57 |
58 ElementList get elements() { | 58 ElementList get elements { |
59 if (_elements == null) { | 59 if (_elements == null) { |
60 _elements = new FilteredElementList(this); | 60 _elements = new FilteredElementList(this); |
61 } | 61 } |
62 return _elements; | 62 return _elements; |
63 } | 63 } |
64 | 64 |
65 void set elements(Collection<Element> value) { | 65 void set elements(Collection<Element> value) { |
66 final elements = this.elements; | 66 final elements = this.elements; |
67 elements.clear(); | 67 elements.clear(); |
68 elements.addAll(value); | 68 elements.addAll(value); |
69 } | 69 } |
70 | 70 |
71 String get outerHTML() { | 71 String get outerHTML { |
72 final container = new Element.tag("div"); | 72 final container = new Element.tag("div"); |
73 container.elements.add(this.clone(true)); | 73 container.elements.add(this.clone(true)); |
74 return container.innerHTML; | 74 return container.innerHTML; |
75 } | 75 } |
76 | 76 |
77 String get innerHTML() { | 77 String get innerHTML { |
78 final container = new Element.tag("div"); | 78 final container = new Element.tag("div"); |
79 container.elements.addAll(this.clone(true).elements); | 79 container.elements.addAll(this.clone(true).elements); |
80 return container.innerHTML; | 80 return container.innerHTML; |
81 } | 81 } |
82 | 82 |
83 void set innerHTML(String svg) { | 83 void set innerHTML(String svg) { |
84 var container = new Element.tag("div"); | 84 var container = new Element.tag("div"); |
85 // Wrap the SVG string in <svg> so that SVGElements are created, rather than | 85 // Wrap the SVG string in <svg> so that SVGElements are created, rather than |
86 // HTMLElements. | 86 // HTMLElements. |
87 container.innerHTML = '<svg version="1.1">$svg</svg>'; | 87 container.innerHTML = '<svg version="1.1">$svg</svg>'; |
88 this.elements = container.elements.first.elements; | 88 this.elements = container.elements.first.elements; |
89 } | 89 } |
90 | 90 |
91 SVGElement clone(bool deep) => super.clone(deep); | 91 SVGElement clone(bool deep) => super.clone(deep); |
92 } | 92 } |
OLD | NEW |