Chromium Code Reviews| Index: client/html/src/SVGElementWrappingImplementation.dart |
| diff --git a/client/html/src/SVGElementWrappingImplementation.dart b/client/html/src/SVGElementWrappingImplementation.dart |
| index 71203a4a513cb8d7a983d664f44e7dafb09f8ed1..d3c219d3cbde1eff7631cba725d5cf731766409c 100644 |
| --- a/client/html/src/SVGElementWrappingImplementation.dart |
| +++ b/client/html/src/SVGElementWrappingImplementation.dart |
| @@ -9,6 +9,22 @@ class SVGElementWrappingImplementation extends ElementWrappingImplementation imp |
| LevelDom.wrapSVGElement(dom.document.createElementNS( |
| "http://www.w3.org/2000/svg", tag)); |
| + factory SVGElementWrappingImplementation.svg(String svg) { |
| + Element parentTag; |
| + final match = _START_TAG_REGEXP.firstMatch(svg); |
| + if (match != null && match.group(1).toLowerCase() == 'svg') { |
| + parentTag = new Element.tag('div'); |
| + } else { |
| + parentTag = new SVGSVGElement(); |
| + } |
| + |
| + parentTag.innerHTML = svg; |
| + if (parentTag.elements.length == 1) return parentTag.elements[0]; |
| + |
| + throw new IllegalArgumentException('SVG had ${parentTag.elements.length} ' + |
| + 'top-level elements but 1 expected'); |
| + } |
| + |
| String get id() { return _ptr.id; } |
| void set id(String value) { _ptr.id = value; } |
| @@ -20,4 +36,38 @@ class SVGElementWrappingImplementation extends ElementWrappingImplementation imp |
| String get xmlbase() { return _ptr.xmlbase; } |
| void set xmlbase(String value) { _ptr.xmlbase = value; } |
| + |
| + ElementList get elements() { |
| + if (_elements == null) { |
| + _elements = new FilteredElementList(this); |
| + } |
| + return _elements; |
| + } |
| + |
| + // TODO: The type of value should be Collection<Element>. See http://b/5392897 |
| + void set elements(value) { |
| + final elements = this.elements; |
| + elements.clear(); |
| + elements.addAll(value); |
| + } |
| + |
| + String get outerHTML() { |
| + final container = new Element.tag("div"); |
| + container.elements.add(this.clone(true)); |
| + return container.innerHTML; |
| + } |
| + |
| + String get innerHTML() { |
| + final container = new Element.tag("div"); |
| + container.elements.addAll(this.clone(true).elements); |
|
sra1
2012/01/05 04:35:27
This breaks the build because the static type retu
Jacob
2012/01/05 16:39:48
The better fix is to define .clone on Element as w
|
| + return container.innerHTML; |
| + } |
| + |
| + void set innerHTML(String svg) { |
| + var container = new Element.tag("div"); |
| + // Wrap the SVG string in <svg> so that SVGElements are created, rather than |
| + // HTMLElements. |
| + container.innerHTML = '<svg version="1.1">$svg</svg>'; |
| + this.elements = container.elements.first.elements; |
| + } |
| } |