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

Side by Side Diff: sdk/lib/svg/dartium/svg_dartium.dart

Issue 23523002: Revert "First rev of Safe DOM" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
« no previous file with comments | « sdk/lib/svg/dart2js/svg_dart2js.dart ('k') | tests/html/cssstyledeclaration_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:nativewrappers'; 8 import 'dart:nativewrappers';
9 // DO NOT EDIT 9 // DO NOT EDIT
10 // Auto-generated dart:svg library. 10 // Auto-generated dart:svg library.
11 11
12 12
13 13
14 14
15 15
16 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 16 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
17 // for details. All rights reserved. Use of this source code is governed by a 17 // for details. All rights reserved. Use of this source code is governed by a
18 // BSD-style license that can be found in the LICENSE file. 18 // BSD-style license that can be found in the LICENSE file.
19 19
20 20
21 final _START_TAG_REGEXP = new RegExp('<(\\w+)');
22
21 class _SvgElementFactoryProvider { 23 class _SvgElementFactoryProvider {
22 static SvgElement createSvgElement_tag(String tag) { 24 static SvgElement createSvgElement_tag(String tag) {
23 final Element temp = 25 final Element temp =
24 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag); 26 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag);
25 return temp; 27 return temp;
26 } 28 }
29
30 static SvgElement createSvgElement_svg(String svg) {
31 Element parentTag;
32 final match = _START_TAG_REGEXP.firstMatch(svg);
33 if (match != null && match.group(1).toLowerCase() == 'svg') {
34 parentTag = new Element.tag('div');
35 } else {
36 parentTag = new SvgSvgElement();
37 }
38
39 parentTag.innerHtml = svg;
40 if (parentTag.children.length == 1) return parentTag.children.removeLast();
41
42 throw new ArgumentError(
43 'SVG had ${parentTag.children.length} '
44 'top-level children but 1 expected');
45 }
46 }
47
48 class _SvgSvgElementFactoryProvider {
49 static SvgSvgElement createSvgSvgElement() {
50 final el = new SvgElement.tag("svg");
51 // The SVG spec requires the version attribute to match the spec version
52 el.attributes['version'] = "1.1";
53 return el;
54 }
27 } 55 }
28 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 56 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
29 // for details. All rights reserved. Use of this source code is governed by a 57 // for details. All rights reserved. Use of this source code is governed by a
30 // BSD-style license that can be found in the LICENSE file. 58 // BSD-style license that can be found in the LICENSE file.
31 59
32 // WARNING: Do not edit - generated code. 60 // WARNING: Do not edit - generated code.
33 61
34 62
35 @DocsEditable() 63 @DocsEditable()
36 @DomName('SVGAElement') 64 @DomName('SVGAElement')
(...skipping 5271 matching lines...) Expand 10 before | Expand all | Expand 10 after
5308 } 5336 }
5309 5337
5310 void writeClasses(Set s) { 5338 void writeClasses(Set s) {
5311 _element.attributes['class'] = s.join(' '); 5339 _element.attributes['class'] = s.join(' ');
5312 } 5340 }
5313 } 5341 }
5314 5342
5315 @DomName('SVGElement') 5343 @DomName('SVGElement')
5316 @Unstable() 5344 @Unstable()
5317 class SvgElement extends Element { 5345 class SvgElement extends Element {
5318 static final _START_TAG_REGEXP = new RegExp('<(\\w+)');
5319
5320 factory SvgElement.tag(String tag) => 5346 factory SvgElement.tag(String tag) =>
5321 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag); 5347 _SvgElementFactoryProvider.createSvgElement_tag(tag);
5322 factory SvgElement.svg(String svg, 5348 factory SvgElement.svg(String svg) =>
5323 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { 5349 _SvgElementFactoryProvider.createSvgElement_svg(svg);
5324
5325 if (validator == null && treeSanitizer == null) {
5326 validator = new NodeValidatorBuilder.common()..allowSvg();
5327 }
5328
5329 final match = _START_TAG_REGEXP.firstMatch(svg);
5330 var parentElement;
5331 if (match != null && match.group(1).toLowerCase() == 'svg') {
5332 parentElement = document.body;
5333 } else {
5334 parentElement = new SvgSvgElement();
5335 }
5336 var fragment = parentElement.createFragment(svg, validator: validator,
5337 treeSanitizer: treeSanitizer);
5338 return fragment.nodes.where((e) => e is SvgElement).single;
5339 }
5340 5350
5341 _AttributeClassSet _cssClassSet; 5351 _AttributeClassSet _cssClassSet;
5342 CssClassSet get classes { 5352 CssClassSet get classes {
5343 if (_cssClassSet == null) { 5353 if (_cssClassSet == null) {
5344 _cssClassSet = new _AttributeClassSet(this); 5354 _cssClassSet = new _AttributeClassSet(this);
5345 } 5355 }
5346 return _cssClassSet; 5356 return _cssClassSet;
5347 } 5357 }
5348 5358
5349 List<Element> get children => new FilteredElementList<Element>(this); 5359 List<Element> get children => new FilteredElementList<Element>(this);
(...skipping 11 matching lines...) Expand all
5361 return container.innerHtml; 5371 return container.innerHtml;
5362 } 5372 }
5363 5373
5364 String get innerHtml { 5374 String get innerHtml {
5365 final container = new Element.tag("div"); 5375 final container = new Element.tag("div");
5366 final SvgElement cloned = this.clone(true); 5376 final SvgElement cloned = this.clone(true);
5367 container.children.addAll(cloned.children); 5377 container.children.addAll(cloned.children);
5368 return container.innerHtml; 5378 return container.innerHtml;
5369 } 5379 }
5370 5380
5371 void set innerHtml(String value) { 5381 void set innerHtml(String svg) {
5372 this.setInnerHtml(value); 5382 final container = new Element.tag("div");
5373 } 5383 // Wrap the SVG string in <svg> so that SvgElements are created, rather than
5374 5384 // HTMLElements.
5375 DocumentFragment createFragment(String svg, 5385 container.innerHtml = '<svg version="1.1">$svg</svg>';
5376 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { 5386 this.children = container.children[0].children;
5377
5378 if (treeSanitizer == null) {
5379 if (validator == null) {
5380 validator = new NodeValidatorBuilder.common()
5381 ..allowSvg();
5382 }
5383 treeSanitizer = new NodeTreeSanitizer(validator);
5384 }
5385
5386 // We create a fragment which will parse in the HTML parser
5387 var html = '<svg version="1.1">$svg</svg>';
5388 var fragment = document.body.createFragment(html,
5389 treeSanitizer: treeSanitizer);
5390
5391 var svgFragment = new DocumentFragment();
5392 // The root is the <svg/> element, need to pull out the contents.
5393 var root = fragment.nodes.single;
5394 while (root.firstChild != null) {
5395 svgFragment.append(root.firstChild);
5396 }
5397 return svgFragment;
5398 } 5387 }
5399 5388
5400 // Unsupported methods inherited from Element. 5389 // Unsupported methods inherited from Element.
5401 5390
5402 @DomName('Element.insertAdjacentText') 5391 @DomName('Element.insertAdjacentText')
5403 void insertAdjacentText(String where, String text) { 5392 void insertAdjacentText(String where, String text) {
5404 throw new UnsupportedError("Cannot invoke insertAdjacentText on SVG."); 5393 throw new UnsupportedError("Cannot invoke insertAdjacentText on SVG.");
5405 } 5394 }
5406 5395
5407 @DomName('Element.insertAdjacentHTML') 5396 @DomName('Element.insertAdjacentHTML')
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
5483 5472
5484 } 5473 }
5485 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 5474 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
5486 // for details. All rights reserved. Use of this source code is governed by a 5475 // for details. All rights reserved. Use of this source code is governed by a
5487 // BSD-style license that can be found in the LICENSE file. 5476 // BSD-style license that can be found in the LICENSE file.
5488 5477
5489 5478
5490 @DomName('SVGSVGElement') 5479 @DomName('SVGSVGElement')
5491 @Unstable() 5480 @Unstable()
5492 class SvgSvgElement extends GraphicsElement implements FitToViewBox, ExternalRes ourcesRequired, ZoomAndPan { 5481 class SvgSvgElement extends GraphicsElement implements FitToViewBox, ExternalRes ourcesRequired, ZoomAndPan {
5493 factory SvgSvgElement() { 5482 factory SvgSvgElement() => _SvgSvgElementFactoryProvider.createSvgSvgElement() ;
5494 final el = new SvgElement.tag("svg");
5495 // The SVG spec requires the version attribute to match the spec version
5496 el.attributes['version'] = "1.1";
5497 return el;
5498 }
5499 5483
5500 // To suppress missing implicit constructor warnings. 5484 // To suppress missing implicit constructor warnings.
5501 factory SvgSvgElement._() { throw new UnsupportedError("Not supported"); } 5485 factory SvgSvgElement._() { throw new UnsupportedError("Not supported"); }
5502 5486
5503 @DomName('SVGSVGElement.contentScriptType') 5487 @DomName('SVGSVGElement.contentScriptType')
5504 @DocsEditable() 5488 @DocsEditable()
5505 String get contentScriptType native "SVGSVGElement_contentScriptType_Getter"; 5489 String get contentScriptType native "SVGSVGElement_contentScriptType_Getter";
5506 5490
5507 @DomName('SVGSVGElement.contentScriptType') 5491 @DomName('SVGSVGElement.contentScriptType')
5508 @DocsEditable() 5492 @DocsEditable()
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after
6892 @Unstable() 6876 @Unstable()
6893 abstract class _SVGVKernElement extends SvgElement { 6877 abstract class _SVGVKernElement extends SvgElement {
6894 // To suppress missing implicit constructor warnings. 6878 // To suppress missing implicit constructor warnings.
6895 factory _SVGVKernElement._() { throw new UnsupportedError("Not supported"); } 6879 factory _SVGVKernElement._() { throw new UnsupportedError("Not supported"); }
6896 6880
6897 @DomName('SVGVKernElement.SVGVKernElement') 6881 @DomName('SVGVKernElement.SVGVKernElement')
6898 @DocsEditable() 6882 @DocsEditable()
6899 factory _SVGVKernElement() => _SvgElementFactoryProvider.createSvgElement_tag( "vkern"); 6883 factory _SVGVKernElement() => _SvgElementFactoryProvider.createSvgElement_tag( "vkern");
6900 6884
6901 } 6885 }
OLDNEW
« no previous file with comments | « sdk/lib/svg/dart2js/svg_dart2js.dart ('k') | tests/html/cssstyledeclaration_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698