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

Side by Side Diff: tools/dom/templates/html/impl/impl_DocumentFragment.darttemplate

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
OLDNEW
1 // Copyright (c) 2011, 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 part of $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { 7 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
8 factory $CLASSNAME() => document.createDocumentFragment(); 8 factory $CLASSNAME() => document.createDocumentFragment();
9 9
10 factory $CLASSNAME.html(String html, 10 factory $CLASSNAME.html(String html) {
11 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { 11 final fragment = new DocumentFragment();
12 12 fragment.innerHtml = html;
13 return document.body.createFragment(html, 13 return fragment;
14 validator: validator, treeSanitizer: treeSanitizer);
15 } 14 }
16 15
17 factory $CLASSNAME.svg(String svgContent, 16 factory $CLASSNAME.svg(String svgContent) {
18 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { 17 final fragment = new DocumentFragment();
18 final e = new svg.SvgSvgElement();
19 e.innerHtml = svgContent;
19 20
20 return new svg.SvgSvgElement().createFragment(svgContent, 21 // Copy list first since we don't want liveness during iteration.
21 validator: validator, treeSanitizer: treeSanitizer); 22 final List nodes = new List.from(e.nodes);
23 fragment.nodes.addAll(nodes);
24 return fragment;
22 } 25 }
23 26
24 $if DART2JS 27 $if DART2JS
25 // Native field is used only by Dart code so does not lead to instantiation 28 // Native field is used only by Dart code so does not lead to instantiation
26 // of native classes 29 // of native classes
27 @Creates('Null') 30 @Creates('Null')
28 $endif 31 $endif
29 List<Element> _children; 32 List<Element> _children;
30 33
31 List<Element> get children { 34 List<Element> get children {
(...skipping 15 matching lines...) Expand all
47 50
48 List<Element> queryAll(String selectors) => 51 List<Element> queryAll(String selectors) =>
49 new _FrozenElementList._wrap(_querySelectorAll(selectors)); 52 new _FrozenElementList._wrap(_querySelectorAll(selectors));
50 53
51 String get innerHtml { 54 String get innerHtml {
52 final e = new Element.tag("div"); 55 final e = new Element.tag("div");
53 e.append(this.clone(true)); 56 e.append(this.clone(true));
54 return e.innerHtml; 57 return e.innerHtml;
55 } 58 }
56 59
60 // TODO(nweiz): Do we want to support some variant of innerHtml for XML and/or
61 // SVG strings?
57 void set innerHtml(String value) { 62 void set innerHtml(String value) {
58 this.setInnerHtml(value); 63 this.nodes.clear();
59 }
60 64
61 void setInnerHtml(String html, 65 final e = new Element.tag("div");
62 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { 66 e.innerHtml = value;
63 67
64 this.nodes.clear(); 68 // Copy list first since we don't want liveness during iteration.
65 append(document.body.createFragment( 69 List nodes = new List.from(e.nodes, growable: false);
66 html, validator: validator, treeSanitizer: treeSanitizer)); 70 this.nodes.addAll(nodes);
67 } 71 }
68 72
69 /** 73 /**
70 * Adds the specified text as a text node after the last child of this 74 * Adds the specified text as a text node after the last child of this
71 * document fragment. 75 * document fragment.
72 */ 76 */
73 void appendText(String text) { 77 void appendText(String text) {
74 this.append(new Text(text)); 78 this.append(new Text(text));
75 } 79 }
76 80
77 81
78 /** 82 /**
79 * Parses the specified text as HTML and adds the resulting node after the 83 * Parses the specified text as HTML and adds the resulting node after the
80 * last child of this document fragment. 84 * last child of this document fragment.
81 */ 85 */
82 void appendHtml(String text) { 86 void appendHtml(String text) {
83 this.append(new DocumentFragment.html(text)); 87 this.append(new DocumentFragment.html(text));
84 } 88 }
85 89
86 $!MEMBERS 90 $!MEMBERS
87 } 91 }
OLDNEW
« no previous file with comments | « tools/dom/templates/html/dartium/html_dartium.darttemplate ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698