OLD | NEW |
---|---|
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 = growable |
20 ? (<Element>[]..length = _childElements.length) | |
floitsch
2013/02/26 13:54:19
I would prefer an if with 2 lines for the length.
Lasse Reichstein Nielsen
2013/02/26 15:26:00
Done.
| |
21 : new List<Element>(_childElements.length); | |
20 for (int i = 0, len = _childElements.length; i < len; i++) { | 22 for (int i = 0, len = _childElements.length; i < len; i++) { |
21 output[i] = _childElements[i]; | 23 output[i] = _childElements[i]; |
22 } | 24 } |
23 return output; | 25 return output; |
24 } | 26 } |
25 | 27 |
26 Set<Element> toSet() { | 28 Set<Element> toSet() { |
27 final output = new Set<Element>(); | 29 final output = new Set<Element>(); |
28 for (int i = 0, len = _childElements.length; i < len; i++) { | 30 for (int i = 0, len = _childElements.length; i < len; i++) { |
29 output.add(_childElements[i]); | 31 output.add(_childElements[i]); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 | 307 |
306 bool any(bool f(Element element)) { | 308 bool any(bool f(Element element)) { |
307 for(Element element in this) { | 309 for(Element element in this) { |
308 if (f(element)) { | 310 if (f(element)) { |
309 return true; | 311 return true; |
310 } | 312 } |
311 }; | 313 }; |
312 return false; | 314 return false; |
313 } | 315 } |
314 | 316 |
315 List<Element> toList() => new List<Element>.from(this); | 317 List<Element> toList({ bool growable: false }) => |
318 new List<Element>.from(this, growable: growable); | |
floitsch
2013/02/26 13:54:19
IterableMixinWorkaround.toListList(this, growable)
| |
316 Set<Element> toSet() => new Set<Element>.from(this); | 319 Set<Element> toSet() => new Set<Element>.from(this); |
317 | 320 |
318 Iterable<Element> take(int n) { | 321 Iterable<Element> take(int n) { |
319 return IterableMixinWorkaround.takeList(this, n); | 322 return IterableMixinWorkaround.takeList(this, n); |
320 } | 323 } |
321 | 324 |
322 Iterable<Element> takeWhile(bool test(Element value)) { | 325 Iterable<Element> takeWhile(bool test(Element value)) { |
323 return IterableMixinWorkaround.takeWhile(this, test); | 326 return IterableMixinWorkaround.takeWhile(this, test); |
324 } | 327 } |
325 | 328 |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1108 const ScrollAlignment._internal(this._value); | 1111 const ScrollAlignment._internal(this._value); |
1109 toString() => 'ScrollAlignment.$_value'; | 1112 toString() => 'ScrollAlignment.$_value'; |
1110 | 1113 |
1111 /// Attempt to align the element to the top of the scrollable area. | 1114 /// Attempt to align the element to the top of the scrollable area. |
1112 static const TOP = const ScrollAlignment._internal('TOP'); | 1115 static const TOP = const ScrollAlignment._internal('TOP'); |
1113 /// Attempt to center the element in the scrollable area. | 1116 /// Attempt to center the element in the scrollable area. |
1114 static const CENTER = const ScrollAlignment._internal('CENTER'); | 1117 static const CENTER = const ScrollAlignment._internal('CENTER'); |
1115 /// Attempt to align the element to the bottom of the scrollable area. | 1118 /// Attempt to align the element to the bottom of the scrollable area. |
1116 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); | 1119 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); |
1117 } | 1120 } |
OLD | NEW |