Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: lib/html/src/SVGElementWrappingImplementation.dart

Issue 10910129: Remove stale files from lib/html/src. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 class _SVGClassSet extends _CssClassSet {
6 _SVGClassSet(element) : super(element);
7
8 String _className() => _element.className.baseVal;
9
10 void _write(Set s) {
11 _element.className.baseVal = _formatSet(s);
12 }
13 }
14
15 class SVGElementWrappingImplementation extends ElementWrappingImplementation imp lements SVGElement {
16 SVGElementWrappingImplementation._wrap(ptr) : super._wrap(ptr) {}
17
18 factory SVGElementWrappingImplementation.tag(String tag) =>
19 LevelDom.wrapSVGElement(dom.document.createElementNS(
20 "http://www.w3.org/2000/svg", tag));
21
22 factory SVGElementWrappingImplementation.svg(String svg) {
23 Element parentTag;
24 final match = _START_TAG_REGEXP.firstMatch(svg);
25 if (match != null && match.group(1).toLowerCase() == 'svg') {
26 parentTag = new Element.tag('div');
27 } else {
28 parentTag = new SVGSVGElement();
29 }
30
31 parentTag.innerHTML = svg;
32 if (parentTag.elements.length == 1) return parentTag.nodes.removeLast();
33
34 throw new IllegalArgumentException(
35 'SVG had ${parentTag.elements.length} '
36 'top-level elements but 1 expected');
37 }
38
39 CSSClassSet get classes() {
40 if (_cssClassSet === null) {
41 _cssClassSet = new _SVGClassSet(_ptr);
42 }
43 return _cssClassSet;
44 }
45
46 String get id() { return _ptr.id; }
47
48 void set id(String value) { _ptr.id = value; }
49
50 SVGSVGElement get ownerSVGElement() { return LevelDom.wrapSVGSVGElement(_ptr.o wnerSVGElement); }
51
52 SVGElement get viewportElement() { return LevelDom.wrapSVGElement(_ptr.viewpor tElement); }
53
54 String get xmlbase() { return _ptr.xmlbase; }
55
56 void set xmlbase(String value) { _ptr.xmlbase = value; }
57
58 ElementList get elements() {
59 if (_elements == null) {
60 _elements = new FilteredElementList(this);
61 }
62 return _elements;
63 }
64
65 void set elements(Collection<Element> value) {
66 final elements = this.elements;
67 elements.clear();
68 elements.addAll(value);
69 }
70
71 String get outerHTML() {
72 final container = new Element.tag("div");
73 container.elements.add(this.clone(true));
74 return container.innerHTML;
75 }
76
77 String get innerHTML() {
78 final container = new Element.tag("div");
79 container.elements.addAll(this.clone(true).elements);
80 return container.innerHTML;
81 }
82
83 void set innerHTML(String svg) {
84 var container = new Element.tag("div");
85 // Wrap the SVG string in <svg> so that SVGElements are created, rather than
86 // HTMLElements.
87 container.innerHTML = '<svg version="1.1">$svg</svg>';
88 this.elements = container.elements.first.elements;
89 }
90
91 SVGElement clone(bool deep) => super.clone(deep);
92 }
OLDNEW
« no previous file with comments | « lib/html/src/SVGElementInstanceWrappingImplementation.dart ('k') | lib/html/src/SVGSVGElement.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698