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

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

Issue 802603002: Simplify _FrozenElementList (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | 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 class _ChildrenElementList extends ListBase<Element> 7 class _ChildrenElementList extends ListBase<Element>
8 implements NodeListWrapper { 8 implements NodeListWrapper {
9 // Raw Element. 9 // Raw Element.
10 final Element _element; 10 final Element _element;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 * in this element, in pixels, regardless of this element's box-sizing 246 * in this element, in pixels, regardless of this element's box-sizing
247 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle 247 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
248 * will return the same numerical height if the element is hidden or not. This 248 * will return the same numerical height if the element is hidden or not. This
249 * can be used to retrieve jQuery's `outerHeight` value for an element. 249 * can be used to retrieve jQuery's `outerHeight` value for an element.
250 */ 250 */
251 @Experimental() 251 @Experimental()
252 CssRect get marginEdge; 252 CssRect get marginEdge;
253 $!STREAM_GETTER_SIGNATURES 253 $!STREAM_GETTER_SIGNATURES
254 } 254 }
255 255
256 // TODO(jacobr): this is an inefficient implementation but it is hard to see 256 // Wrapper over an immutable NodeList to make it implement ElementList<Element>.
Jacob 2014/12/12 01:11:22 Tweak this comment as this class is no longer an E
257 // a better option given that we cannot quite force NodeList to be an 257 class _FrozenElementList extends ListBase
258 // ElementList as there are valid cases where a NodeList JavaScript object 258 implements ElementList, NodeListWrapper {
259 // contains Node objects that are not Elements.
260 class _FrozenElementList<T extends Element> extends ListBase<T>
261 implements ElementList<T>, NodeListWrapper {
262 final List<Node> _nodeList; 259 final List<Node> _nodeList;
263 // The subset of _nodeList that are Elements.
264 List<Element> _elementList;
265 260
266 _FrozenElementList._wrap(this._nodeList) { 261 _FrozenElementList._wrap(this._nodeList);
267 _elementList = _nodeList.where((e) => e is Element).toList();
268 }
269 262
270 int get length => _nodeList.length; 263 int get length => _nodeList.length;
271 264
272 Element operator [](int index) => _nodeList[index]; 265 Element operator [](int index) => _nodeList[index];
273 266
274 void operator []=(int index, Element value) { 267 void operator []=(int index, Element value) {
275 throw new UnsupportedError('Cannot modify list'); 268 throw new UnsupportedError('Cannot modify list');
276 } 269 }
277 270
278 void set length(int newLength) { 271 void set length(int newLength) {
279 throw new UnsupportedError('Cannot modify list'); 272 throw new UnsupportedError('Cannot modify list');
280 } 273 }
281 274
282 void sort([Comparator<Element> compare]) { 275 void sort([Comparator<Element> compare]) {
283 throw new UnsupportedError('Cannot sort list'); 276 throw new UnsupportedError('Cannot sort list');
284 } 277 }
285 278
286 void shuffle([Random random]) { 279 void shuffle([Random random]) {
287 throw new UnsupportedError('Cannot shuffle list'); 280 throw new UnsupportedError('Cannot shuffle list');
288 } 281 }
289 282
290 Element get first => _nodeList.first; 283 Element get first => _nodeList.first;
291 284
292 Element get last => _nodeList.last; 285 Element get last => _nodeList.last;
293 286
294 Element get single => _nodeList.single; 287 Element get single => _nodeList.single;
295 288
296 CssClassSet get classes => new _MultiElementCssClassSet(_elementList); 289 CssClassSet get classes => new _MultiElementCssClassSet(this);
297 290
298 CssStyleDeclarationBase get style => 291 CssStyleDeclarationBase get style =>
299 new _CssStyleDeclarationSet(_elementList); 292 new _CssStyleDeclarationSet(this);
300 293
301 void set classes(Iterable<String> value) { 294 void set classes(Iterable<String> value) {
302 _elementList.forEach((e) => e.classes = value); 295 _nodeList.forEach((e) => e.classes = value);
303 } 296 }
304 297
305 CssRect get contentEdge => new _ContentCssListRect(_elementList); 298 CssRect get contentEdge => new _ContentCssListRect(this);
306 299
307 CssRect get paddingEdge => _elementList.first.paddingEdge; 300 CssRect get paddingEdge => this.first.paddingEdge;
308 301
309 CssRect get borderEdge => _elementList.first.borderEdge; 302 CssRect get borderEdge => this.first.borderEdge;
310 303
311 CssRect get marginEdge => _elementList.first.marginEdge; 304 CssRect get marginEdge => this.first.marginEdge;
312 305
313 List<Node> get rawList => _nodeList; 306 List<Node> get rawList => _nodeList;
314 307
315 $!ELEMENT_STREAM_GETTERS 308 $!ELEMENT_STREAM_GETTERS
316 } 309 }
317 310
318 @DocsEditable() 311 @DocsEditable()
319 $(ANNOTATIONS)$(NATIVESPEC)abstract class $CLASSNAME$EXTENDS$IMPLEMENTS { 312 $(ANNOTATIONS)$(NATIVESPEC)abstract class $CLASSNAME$EXTENDS$IMPLEMENTS {
320 313
321 /** 314 /**
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 const ScrollAlignment._internal(this._value); 1475 const ScrollAlignment._internal(this._value);
1483 toString() => 'ScrollAlignment.$_value'; 1476 toString() => 'ScrollAlignment.$_value';
1484 1477
1485 /// Attempt to align the element to the top of the scrollable area. 1478 /// Attempt to align the element to the top of the scrollable area.
1486 static const TOP = const ScrollAlignment._internal('TOP'); 1479 static const TOP = const ScrollAlignment._internal('TOP');
1487 /// Attempt to center the element in the scrollable area. 1480 /// Attempt to center the element in the scrollable area.
1488 static const CENTER = const ScrollAlignment._internal('CENTER'); 1481 static const CENTER = const ScrollAlignment._internal('CENTER');
1489 /// Attempt to align the element to the bottom of the scrollable area. 1482 /// Attempt to align the element to the bottom of the scrollable area.
1490 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 1483 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1491 } 1484 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698