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

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

Issue 12328104: Change new List(n) to return fixed length list. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head. Created 7 years, 9 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) 2012, the Dart project authors. Please see the AUTHORS file 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 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 // TODO(jacobr): use _Lists.dart to remove some of the duplicated 7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated
8 // functionality. 8 // functionality.
9 class _ChildrenElementList implements List { 9 class _ChildrenElementList implements List {
10 // Raw Element. 10 // Raw Element.
11 final Element _element; 11 final Element _element;
12 final HtmlCollection _childElements; 12 final HtmlCollection _childElements;
13 13
14 _ChildrenElementList._wrap(Element element) 14 _ChildrenElementList._wrap(Element element)
15 : _childElements = element.$dom_children, 15 : _childElements = element.$dom_children,
16 _element = element; 16 _element = element;
17 17
18 List<Element> toList() { 18 List<Element> toList({ bool growable: false }) {
19 final output = new List<Element>.fixedLength(_childElements.length); 19 final output;
20 if (growable) {
21 output = <Element>[];
22 output.length = _childElements.length;
23 } else {
24 output = new List<Element>(_childElements.length);
25 }
20 for (int i = 0, len = _childElements.length; i < len; i++) { 26 for (int i = 0, len = _childElements.length; i < len; i++) {
21 output[i] = _childElements[i]; 27 output[i] = _childElements[i];
22 } 28 }
23 return output; 29 return output;
24 } 30 }
25 31
26 Set<Element> toSet() { 32 Set<Element> toSet() {
27 final output = new Set<Element>(); 33 final output = new Set<Element>();
28 for (int i = 0, len = _childElements.length; i < len; i++) { 34 for (int i = 0, len = _childElements.length; i < len; i++) {
29 output.add(_childElements[i]); 35 output.add(_childElements[i]);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 311
306 bool any(bool f(Element element)) { 312 bool any(bool f(Element element)) {
307 for(Element element in this) { 313 for(Element element in this) {
308 if (f(element)) { 314 if (f(element)) {
309 return true; 315 return true;
310 } 316 }
311 }; 317 };
312 return false; 318 return false;
313 } 319 }
314 320
315 List<Element> toList() => new List<Element>.from(this); 321 List<Element> toList({ bool growable: false }) =>
322 new List<Element>.from(this, growable: growable);
316 Set<Element> toSet() => new Set<Element>.from(this); 323 Set<Element> toSet() => new Set<Element>.from(this);
317 324
318 Iterable<Element> take(int n) { 325 Iterable<Element> take(int n) {
319 return IterableMixinWorkaround.takeList(this, n); 326 return IterableMixinWorkaround.takeList(this, n);
320 } 327 }
321 328
322 Iterable<Element> takeWhile(bool test(Element value)) { 329 Iterable<Element> takeWhile(bool test(Element value)) {
323 return IterableMixinWorkaround.takeWhile(this, test); 330 return IterableMixinWorkaround.takeWhile(this, test);
324 } 331 }
325 332
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 const ScrollAlignment._internal(this._value); 1115 const ScrollAlignment._internal(this._value);
1109 toString() => 'ScrollAlignment.$_value'; 1116 toString() => 'ScrollAlignment.$_value';
1110 1117
1111 /// Attempt to align the element to the top of the scrollable area. 1118 /// Attempt to align the element to the top of the scrollable area.
1112 static const TOP = const ScrollAlignment._internal('TOP'); 1119 static const TOP = const ScrollAlignment._internal('TOP');
1113 /// Attempt to center the element in the scrollable area. 1120 /// Attempt to center the element in the scrollable area.
1114 static const CENTER = const ScrollAlignment._internal('CENTER'); 1121 static const CENTER = const ScrollAlignment._internal('CENTER');
1115 /// Attempt to align the element to the bottom of the scrollable area. 1122 /// Attempt to align the element to the bottom of the scrollable area.
1116 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 1123 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1117 } 1124 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698