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

Side by Side Diff: lib/dom/templates/html/interface/interface_Element.darttemplate

Issue 9732019: dart:html perf optimization based on runing Dromaeo benchmarks (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes Created 8 years, 8 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 // WARNING: Do not edit - generated code. 5 // WARNING: Do not edit - generated code.
6 6
7 /** 7 /**
8 * Provides a Map abstraction on top of data-* attributes, similar to the 8 * Provides a Map abstraction on top of data-* attributes, similar to the
9 * dataSet in the old DOM. 9 * dataSet in the old DOM.
10 */ 10 */
11 class _DataAttributeMap implements Map<String, String> { 11 class _DataAttributeMap implements Map<String, String> {
12 12
13 final Map<String, String> _attributes; 13 final Map<String, String> $dom_attributes;
14 14
15 _DataAttributeMap(this._attributes); 15 _DataAttributeMap(this.$dom_attributes);
16 16
17 // interface Map 17 // interface Map
18 18
19 // TODO: Use lazy iterator when it is available on Map. 19 // TODO: Use lazy iterator when it is available on Map.
20 bool containsValue(String value) => getValues().some((v) => v == value); 20 bool containsValue(String value) => getValues().some((v) => v == value);
21 21
22 bool containsKey(String key) => _attributes.containsKey(_attr(key)); 22 bool containsKey(String key) => $dom_attributes.containsKey(_attr(key));
23 23
24 String operator [](String key) => _attributes[_attr(key)]; 24 String operator [](String key) => $dom_attributes[_attr(key)];
25 25
26 void operator []=(String key, String value) { 26 void operator []=(String key, String value) {
27 _attributes[_attr(key)] = value; 27 $dom_attributes[_attr(key)] = value;
28 } 28 }
29 29
30 String putIfAbsent(String key, String ifAbsent()) { 30 String putIfAbsent(String key, String ifAbsent()) {
31 if (!containsKey(key)) { 31 if (!containsKey(key)) {
32 return this[key] = ifAbsent(); 32 return this[key] = ifAbsent();
33 } 33 }
34 return this[key]; 34 return this[key];
35 } 35 }
36 36
37 String remove(String key) => _attributes.remove(_attr(key)); 37 String remove(String key) => $dom_attributes.remove(_attr(key));
38 38
39 void clear() { 39 void clear() {
40 // Needs to operate on a snapshot since we are mutatiting the collection. 40 // Needs to operate on a snapshot since we are mutatiting the collection.
41 for (String key in getKeys()) { 41 for (String key in getKeys()) {
42 remove(key); 42 remove(key);
43 } 43 }
44 } 44 }
45 45
46 void forEach(void f(String key, String value)) { 46 void forEach(void f(String key, String value)) {
47 _attributes.forEach((String key, String value) { 47 $dom_attributes.forEach((String key, String value) {
48 if (_matches(key)) { 48 if (_matches(key)) {
49 f(_strip(key), value); 49 f(_strip(key), value);
50 } 50 }
51 }); 51 });
52 } 52 }
53 53
54 Collection<String> getKeys() { 54 Collection<String> getKeys() {
55 final keys = new List<String>(); 55 final keys = new List<String>();
56 _attributes.forEach((String key, String value) { 56 $dom_attributes.forEach((String key, String value) {
57 if (_matches(key)) { 57 if (_matches(key)) {
58 keys.add(_strip(key)); 58 keys.add(_strip(key));
59 } 59 }
60 }); 60 });
61 return keys; 61 return keys;
62 } 62 }
63 63
64 Collection<String> getValues() { 64 Collection<String> getValues() {
65 final values = new List<String>(); 65 final values = new List<String>();
66 _attributes.forEach((String key, String value) { 66 $dom_attributes.forEach((String key, String value) {
67 if (_matches(key)) { 67 if (_matches(key)) {
68 values.add(value); 68 values.add(value);
69 } 69 }
70 }); 70 });
71 return values; 71 return values;
72 } 72 }
73 73
74 int get length() => getKeys().length; 74 int get length() => getKeys().length;
75 75
76 // TODO: Use lazy iterator when it is available on Map. 76 // TODO: Use lazy iterator when it is available on Map.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 _write(s); 187 _write(s);
188 } 188 }
189 189
190 /** 190 /**
191 * Read the class names from the Element class property, 191 * Read the class names from the Element class property,
192 * and put them into a set (duplicates are discarded). 192 * and put them into a set (duplicates are discarded).
193 */ 193 */
194 Set<String> _read() { 194 Set<String> _read() {
195 // TODO(mattsh) simplify this once split can take regex. 195 // TODO(mattsh) simplify this once split can take regex.
196 Set<String> s = new Set<String>(); 196 Set<String> s = new Set<String>();
197 for (String name in _className().split(' ')) { 197 for (String name in $dom_className().split(' ')) {
198 String trimmed = name.trim(); 198 String trimmed = name.trim();
199 if (!trimmed.isEmpty()) { 199 if (!trimmed.isEmpty()) {
200 s.add(trimmed); 200 s.add(trimmed);
201 } 201 }
202 } 202 }
203 return s; 203 return s;
204 } 204 }
205 205
206 /** 206 /**
207 * Read the class names as a space-separated string. This is meant to be 207 * Read the class names as a space-separated string. This is meant to be
208 * overridden by subclasses. 208 * overridden by subclasses.
209 */ 209 */
210 String _className() => _element._className; 210 String $dom_className() => _element.$dom_className;
211 211
212 /** 212 /**
213 * Join all the elements of a set into one string and write 213 * Join all the elements of a set into one string and write
214 * back to the element. 214 * back to the element.
215 */ 215 */
216 void _write(Set s) { 216 void _write(Set s) {
217 _element._className = _formatSet(s); 217 _element.$dom_className = _formatSet(s);
218 } 218 }
219 219
220 String _formatSet(Set<String> s) { 220 String _formatSet(Set<String> s) {
221 // TODO(mattsh) should be able to pass Set to String.joins http:/b/5398605 221 // TODO(mattsh) should be able to pass Set to String.joins http:/b/5398605
222 List list = new List.from(s); 222 List list = new List.from(s);
223 return Strings.join(list, ' '); 223 return Strings.join(list, ' ');
224 } 224 }
225 } 225 }
226 226
227 interface ElementList extends List<Element> { 227 interface ElementList extends List<Element> {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 291
292 /** @domName Window.getComputedStyle */ 292 /** @domName Window.getComputedStyle */
293 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement); 293 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement);
294 294
295 Element clone(bool deep); 295 Element clone(bool deep);
296 296
297 Element get parent(); 297 Element get parent();
298 298
299 $!MEMBERS 299 $!MEMBERS
300 } 300 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698