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_Element.darttemplate

Issue 12401002: Make List.from and Iterable.toList default to not growable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « tools/dom/src/WrappedList.dart ('k') | tools/dom/templates/html/impl/impl_Node.darttemplate » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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({ bool growable: false }) { 18 List<Element> toList({ bool growable: true }) {
19 List<Element> output; 19 List<Element> output;
20 if (growable) { 20 if (growable) {
21 output = <Element>[]; 21 output = <Element>[];
22 output.length = _childElements.length; 22 output.length = _childElements.length;
23 } else { 23 } else {
24 output = new List<Element>(_childElements.length); 24 output = new List<Element>(_childElements.length);
25 } 25 }
26 for (int i = 0, len = _childElements.length; i < len; i++) { 26 for (int i = 0, len = _childElements.length; i < len; i++) {
27 output[i] = _childElements[i]; 27 output[i] = _childElements[i];
28 } 28 }
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 bool any(bool f(Element element)) { 312 bool any(bool f(Element element)) {
313 for(Element element in this) { 313 for(Element element in this) {
314 if (f(element)) { 314 if (f(element)) {
315 return true; 315 return true;
316 } 316 }
317 }; 317 };
318 return false; 318 return false;
319 } 319 }
320 320
321 List<Element> toList({ bool growable: false }) => 321 List<Element> toList({ bool growable: true }) =>
322 new List<Element>.from(this, growable: growable); 322 new List<Element>.from(this, growable: growable);
323 Set<Element> toSet() => new Set<Element>.from(this); 323 Set<Element> toSet() => new Set<Element>.from(this);
324 324
325 Iterable<Element> take(int n) { 325 Iterable<Element> take(int n) {
326 return IterableMixinWorkaround.takeList(this, n); 326 return IterableMixinWorkaround.takeList(this, n);
327 } 327 }
328 328
329 Iterable<Element> takeWhile(bool test(Element value)) { 329 Iterable<Element> takeWhile(bool test(Element value)) {
330 return IterableMixinWorkaround.takeWhile(this, test); 330 return IterableMixinWorkaround.takeWhile(this, test);
331 } 331 }
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 const ScrollAlignment._internal(this._value); 1115 const ScrollAlignment._internal(this._value);
1116 toString() => 'ScrollAlignment.$_value'; 1116 toString() => 'ScrollAlignment.$_value';
1117 1117
1118 /// 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.
1119 static const TOP = const ScrollAlignment._internal('TOP'); 1119 static const TOP = const ScrollAlignment._internal('TOP');
1120 /// Attempt to center the element in the scrollable area. 1120 /// Attempt to center the element in the scrollable area.
1121 static const CENTER = const ScrollAlignment._internal('CENTER'); 1121 static const CENTER = const ScrollAlignment._internal('CENTER');
1122 /// 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.
1123 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 1123 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1124 } 1124 }
OLDNEW
« no previous file with comments | « tools/dom/src/WrappedList.dart ('k') | tools/dom/templates/html/impl/impl_Node.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698