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

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

Issue 12391046: Add List.asMap(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. 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.
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 return first; 253 return first;
254 } 254 }
255 255
256 Element min([int compare(Element a, Element b)]) { 256 Element min([int compare(Element a, Element b)]) {
257 return IterableMixinWorkaround.min(this, compare); 257 return IterableMixinWorkaround.min(this, compare);
258 } 258 }
259 259
260 Element max([int compare(Element a, Element b)]) { 260 Element max([int compare(Element a, Element b)]) {
261 return IterableMixinWorkaround.max(this, compare); 261 return IterableMixinWorkaround.max(this, compare);
262 } 262 }
263
264 Map<int, Element> asMap() {
265 return IterableMixinWorkaround.asMapList(this);
266 }
263 } 267 }
264 268
265 // TODO(jacobr): this is an inefficient implementation but it is hard to see 269 // TODO(jacobr): this is an inefficient implementation but it is hard to see
266 // a better option given that we cannot quite force NodeList to be an 270 // a better option given that we cannot quite force NodeList to be an
267 // ElementList as there are valid cases where a NodeList JavaScript object 271 // ElementList as there are valid cases where a NodeList JavaScript object
268 // contains Node objects that are not Elements. 272 // contains Node objects that are not Elements.
269 class _FrozenElementList implements List { 273 class _FrozenElementList implements List {
270 final List<Node> _nodeList; 274 final List<Node> _nodeList;
271 275
272 _FrozenElementList._wrap(this._nodeList); 276 _FrozenElementList._wrap(this._nodeList);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 458
455 Element get single => _nodeList.single; 459 Element get single => _nodeList.single;
456 460
457 Element min([int compare(Element a, Element b)]) { 461 Element min([int compare(Element a, Element b)]) {
458 return IterableMixinWorkaround.min(this, compare); 462 return IterableMixinWorkaround.min(this, compare);
459 } 463 }
460 464
461 Element max([int compare(Element a, Element b)]) { 465 Element max([int compare(Element a, Element b)]) {
462 return IterableMixinWorkaround.max(this, compare); 466 return IterableMixinWorkaround.max(this, compare);
463 } 467 }
468
469 Map<int, Element> asMap() {
470 return IterableMixinWorkaround.asMapList(this);
471 }
464 } 472 }
465 473
466 class _FrozenElementListIterator implements Iterator<Element> { 474 class _FrozenElementListIterator implements Iterator<Element> {
467 final _FrozenElementList _list; 475 final _FrozenElementList _list;
468 int _index = -1; 476 int _index = -1;
469 Element _current; 477 Element _current;
470 478
471 _FrozenElementListIterator(this._list); 479 _FrozenElementListIterator(this._list);
472 480
473 /** 481 /**
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 const ScrollAlignment._internal(this._value); 1123 const ScrollAlignment._internal(this._value);
1116 toString() => 'ScrollAlignment.$_value'; 1124 toString() => 'ScrollAlignment.$_value';
1117 1125
1118 /// Attempt to align the element to the top of the scrollable area. 1126 /// Attempt to align the element to the top of the scrollable area.
1119 static const TOP = const ScrollAlignment._internal('TOP'); 1127 static const TOP = const ScrollAlignment._internal('TOP');
1120 /// Attempt to center the element in the scrollable area. 1128 /// Attempt to center the element in the scrollable area.
1121 static const CENTER = const ScrollAlignment._internal('CENTER'); 1129 static const CENTER = const ScrollAlignment._internal('CENTER');
1122 /// Attempt to align the element to the bottom of the scrollable area. 1130 /// Attempt to align the element to the bottom of the scrollable area.
1123 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 1131 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1124 } 1132 }
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