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

Side by Side Diff: pkg/dev_compiler/tool/input_sdk/lib/html/html_common/filtered_element_list.dart

Issue 2752163002: Format all dart dev compiler files (Closed)
Patch Set: Created 3 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
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 html_common; 5 part of html_common;
6 6
7 /** 7 /**
8 * An indexable collection of a node's direct descendants in the document tree, 8 * An indexable collection of a node's direct descendants in the document tree,
9 * filtered so that only elements are in the collection. 9 * filtered so that only elements are in the collection.
10 */ 10 */
11 class FilteredElementList extends ListBase<Element> implements NodeListWrapper { 11 class FilteredElementList extends ListBase<Element> implements NodeListWrapper {
12 final Node _node; 12 final Node _node;
13 final List<Node> _childNodes; 13 final List<Node> _childNodes;
14 14
15 /** 15 /**
16 * Creates a collection of the elements that descend from a node. 16 * Creates a collection of the elements that descend from a node.
17 * 17 *
18 * Example usage: 18 * Example usage:
19 * 19 *
20 * var filteredElements = new FilteredElementList(query("#container")); 20 * var filteredElements = new FilteredElementList(query("#container"));
21 * // filteredElements is [a, b, c]. 21 * // filteredElements is [a, b, c].
22 */ 22 */
23 FilteredElementList(Node node) 23 FilteredElementList(Node node)
24 : _childNodes = node.nodes, 24 : _childNodes = node.nodes,
25 _node = node; 25 _node = node;
26 26
27 // We can't memoize this, since it's possible that children will be messed 27 // We can't memoize this, since it's possible that children will be messed
28 // with externally to this class. 28 // with externally to this class.
29 Iterable<Element> get _iterable => 29 Iterable<Element> get _iterable => _childNodes
30 _childNodes.where((n) => n is Element).map/*<Element>*/((n) => n as Elemen t); 30 .where((n) => n is Element)
31 .map/*<Element>*/((n) => n as Element);
31 List<Element> get _filtered => 32 List<Element> get _filtered =>
32 new List<Element>.from(_iterable, growable: false); 33 new List<Element>.from(_iterable, growable: false);
33 34
34 void forEach(void f(Element element)) { 35 void forEach(void f(Element element)) {
35 // This cannot use the iterator, because operations during iteration might 36 // This cannot use the iterator, because operations during iteration might
36 // modify the collection, e.g. addAll might append a node to another parent. 37 // modify the collection, e.g. addAll might append a node to another parent.
37 _filtered.forEach(f); 38 _filtered.forEach(f);
38 } 39 }
39 40
40 void operator []=(int index, Element value) { 41 void operator []=(int index, Element value) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 142 }
142 143
143 int get length => _iterable.length; 144 int get length => _iterable.length;
144 Element operator [](int index) => _iterable.elementAt(index); 145 Element operator [](int index) => _iterable.elementAt(index);
145 // This cannot use the iterator, because operations during iteration might 146 // This cannot use the iterator, because operations during iteration might
146 // modify the collection, e.g. addAll might append a node to another parent. 147 // modify the collection, e.g. addAll might append a node to another parent.
147 Iterator<Element> get iterator => _filtered.iterator; 148 Iterator<Element> get iterator => _filtered.iterator;
148 149
149 List<Node> get rawList => _node.childNodes; 150 List<Node> get rawList => _node.childNodes;
150 } 151 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698