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 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 Loading... |
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. |
257 // a better option given that we cannot quite force NodeList to be an | 257 // |
258 // ElementList as there are valid cases where a NodeList JavaScript object | 258 // Clients are {`Document`, `DocumentFragment`}.`querySelectorAll` which are |
259 // contains Node objects that are not Elements. | 259 // declared to return `ElementList`. This provides all the static analysis |
260 class _FrozenElementList<T extends Element> extends ListBase<T> | 260 // benefit so there is no need for this class have a constrained type parameter. |
261 implements ElementList<T>, NodeListWrapper { | 261 // |
| 262 class _FrozenElementList extends ListBase |
| 263 implements ElementList, NodeListWrapper { |
262 final List<Node> _nodeList; | 264 final List<Node> _nodeList; |
263 // The subset of _nodeList that are Elements. | |
264 List<Element> _elementList; | |
265 | 265 |
266 _FrozenElementList._wrap(this._nodeList) { | 266 _FrozenElementList._wrap(this._nodeList); |
267 _elementList = _nodeList.where((e) => e is Element).toList(); | |
268 } | |
269 | 267 |
270 int get length => _nodeList.length; | 268 int get length => _nodeList.length; |
271 | 269 |
272 Element operator [](int index) => _nodeList[index]; | 270 Element operator [](int index) => _nodeList[index]; |
273 | 271 |
274 void operator []=(int index, Element value) { | 272 void operator []=(int index, Element value) { |
275 throw new UnsupportedError('Cannot modify list'); | 273 throw new UnsupportedError('Cannot modify list'); |
276 } | 274 } |
277 | 275 |
278 void set length(int newLength) { | 276 void set length(int newLength) { |
279 throw new UnsupportedError('Cannot modify list'); | 277 throw new UnsupportedError('Cannot modify list'); |
280 } | 278 } |
281 | 279 |
282 void sort([Comparator<Element> compare]) { | 280 void sort([Comparator<Element> compare]) { |
283 throw new UnsupportedError('Cannot sort list'); | 281 throw new UnsupportedError('Cannot sort list'); |
284 } | 282 } |
285 | 283 |
286 void shuffle([Random random]) { | 284 void shuffle([Random random]) { |
287 throw new UnsupportedError('Cannot shuffle list'); | 285 throw new UnsupportedError('Cannot shuffle list'); |
288 } | 286 } |
289 | 287 |
290 Element get first => _nodeList.first; | 288 Element get first => _nodeList.first; |
291 | 289 |
292 Element get last => _nodeList.last; | 290 Element get last => _nodeList.last; |
293 | 291 |
294 Element get single => _nodeList.single; | 292 Element get single => _nodeList.single; |
295 | 293 |
296 CssClassSet get classes => new _MultiElementCssClassSet(_elementList); | 294 CssClassSet get classes => new _MultiElementCssClassSet(this); |
297 | 295 |
298 CssStyleDeclarationBase get style => | 296 CssStyleDeclarationBase get style => |
299 new _CssStyleDeclarationSet(_elementList); | 297 new _CssStyleDeclarationSet(this); |
300 | 298 |
301 void set classes(Iterable<String> value) { | 299 void set classes(Iterable<String> value) { |
302 _elementList.forEach((e) => e.classes = value); | 300 _nodeList.forEach((e) => e.classes = value); |
303 } | 301 } |
304 | 302 |
305 CssRect get contentEdge => new _ContentCssListRect(_elementList); | 303 CssRect get contentEdge => new _ContentCssListRect(this); |
306 | 304 |
307 CssRect get paddingEdge => _elementList.first.paddingEdge; | 305 CssRect get paddingEdge => this.first.paddingEdge; |
308 | 306 |
309 CssRect get borderEdge => _elementList.first.borderEdge; | 307 CssRect get borderEdge => this.first.borderEdge; |
310 | 308 |
311 CssRect get marginEdge => _elementList.first.marginEdge; | 309 CssRect get marginEdge => this.first.marginEdge; |
312 | 310 |
313 List<Node> get rawList => _nodeList; | 311 List<Node> get rawList => _nodeList; |
314 | 312 |
315 $!ELEMENT_STREAM_GETTERS | 313 $!ELEMENT_STREAM_GETTERS |
316 } | 314 } |
317 | 315 |
318 @DocsEditable() | 316 @DocsEditable() |
319 $(ANNOTATIONS)$(NATIVESPEC)abstract class $CLASSNAME$EXTENDS$IMPLEMENTS { | 317 $(ANNOTATIONS)$(NATIVESPEC)abstract class $CLASSNAME$EXTENDS$IMPLEMENTS { |
320 | 318 |
321 /** | 319 /** |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1482 const ScrollAlignment._internal(this._value); | 1480 const ScrollAlignment._internal(this._value); |
1483 toString() => 'ScrollAlignment.$_value'; | 1481 toString() => 'ScrollAlignment.$_value'; |
1484 | 1482 |
1485 /// Attempt to align the element to the top of the scrollable area. | 1483 /// Attempt to align the element to the top of the scrollable area. |
1486 static const TOP = const ScrollAlignment._internal('TOP'); | 1484 static const TOP = const ScrollAlignment._internal('TOP'); |
1487 /// Attempt to center the element in the scrollable area. | 1485 /// Attempt to center the element in the scrollable area. |
1488 static const CENTER = const ScrollAlignment._internal('CENTER'); | 1486 static const CENTER = const ScrollAlignment._internal('CENTER'); |
1489 /// Attempt to align the element to the bottom of the scrollable area. | 1487 /// Attempt to align the element to the bottom of the scrollable area. |
1490 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); | 1488 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); |
1491 } | 1489 } |
OLD | NEW |