OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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) { |
11 _element.className.baseVal = _formatSet(s); | 11 _element.className.baseVal = _formatSet(s); |
(...skipping 25 matching lines...) Expand all Loading... |
37 | 37 |
38 Set<String> get classes() { | 38 Set<String> get classes() { |
39 if (_cssClassSet === null) { | 39 if (_cssClassSet === null) { |
40 _cssClassSet = new _SVGClassSet(_ptr); | 40 _cssClassSet = new _SVGClassSet(_ptr); |
41 } | 41 } |
42 return _cssClassSet; | 42 return _cssClassSet; |
43 } | 43 } |
44 | 44 |
45 String get id() { return _ptr.id; } | 45 String get id() { return _ptr.id; } |
46 | 46 |
47 void set id(String value) { | 47 void set id(String value) { _ptr.id = value; } |
48 assert(!_inMeasurementFrame || !_inDocument); | |
49 _ptr.id = value; | |
50 } | |
51 | 48 |
52 SVGSVGElement get ownerSVGElement() { return LevelDom.wrapSVGSVGElement(_ptr.o
wnerSVGElement); } | 49 SVGSVGElement get ownerSVGElement() { return LevelDom.wrapSVGSVGElement(_ptr.o
wnerSVGElement); } |
53 | 50 |
54 SVGElement get viewportElement() { return LevelDom.wrapSVGElement(_ptr.viewpor
tElement); } | 51 SVGElement get viewportElement() { return LevelDom.wrapSVGElement(_ptr.viewpor
tElement); } |
55 | 52 |
56 String get xmlbase() { return _ptr.xmlbase; } | 53 String get xmlbase() { return _ptr.xmlbase; } |
57 | 54 |
58 void set xmlbase(String value) { | 55 void set xmlbase(String value) { _ptr.xmlbase = value; } |
59 assert(!_inMeasurementFrame || !_inDocument); | |
60 _ptr.xmlbase = value; | |
61 } | |
62 | 56 |
63 ElementList get elements() { | 57 ElementList get elements() { |
64 if (_elements == null) { | 58 if (_elements == null) { |
65 _elements = new FilteredElementList(this); | 59 _elements = new FilteredElementList(this); |
66 } | 60 } |
67 return _elements; | 61 return _elements; |
68 } | 62 } |
69 | 63 |
70 // TODO: The type of value should be Collection<Element>. See http://b/5392897 | 64 // TODO: The type of value should be Collection<Element>. See http://b/5392897 |
71 void set elements(value) { | 65 void set elements(value) { |
72 assert(!_inMeasurementFrame || !_inDocument); | |
73 final elements = this.elements; | 66 final elements = this.elements; |
74 elements.clear(); | 67 elements.clear(); |
75 elements.addAll(value); | 68 elements.addAll(value); |
76 } | 69 } |
77 | 70 |
78 String get outerHTML() { | 71 String get outerHTML() { |
79 final container = new Element.tag("div"); | 72 final container = new Element.tag("div"); |
80 container.elements.add(this.clone(true)); | 73 container.elements.add(this.clone(true)); |
81 return container.innerHTML; | 74 return container.innerHTML; |
82 } | 75 } |
83 | 76 |
84 String get innerHTML() { | 77 String get innerHTML() { |
85 final container = new Element.tag("div"); | 78 final container = new Element.tag("div"); |
86 container.elements.addAll(this.clone(true).elements); | 79 container.elements.addAll(this.clone(true).elements); |
87 return container.innerHTML; | 80 return container.innerHTML; |
88 } | 81 } |
89 | 82 |
90 void set innerHTML(String svg) { | 83 void set innerHTML(String svg) { |
91 assert(!_inMeasurementFrame || !_inDocument); | |
92 var container = new Element.tag("div"); | 84 var container = new Element.tag("div"); |
93 // 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 |
94 // HTMLElements. | 86 // HTMLElements. |
95 container.innerHTML = '<svg version="1.1">$svg</svg>'; | 87 container.innerHTML = '<svg version="1.1">$svg</svg>'; |
96 this.elements = container.elements.first.elements; | 88 this.elements = container.elements.first.elements; |
97 } | 89 } |
98 | 90 |
99 SVGElement clone(bool deep) => super.clone(deep); | 91 SVGElement clone(bool deep) => super.clone(deep); |
100 } | 92 } |
OLD | NEW |