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

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

Issue 46433003: Exposing raw DOM lists from wrappers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 class _ChildrenElementList extends ListBase<Element> { 7 class _ChildrenElementList extends ListBase<Element>
8 implements NodeListWrapper {
8 // Raw Element. 9 // Raw Element.
9 final Element _element; 10 final Element _element;
10 final HtmlCollection _childElements; 11 final HtmlCollection _childElements;
11 12
12 _ChildrenElementList._wrap(Element element) 13 _ChildrenElementList._wrap(Element element)
13 : _childElements = element._children, 14 : _childElements = element._children,
14 _element = element; 15 _element = element;
15 16
16 bool contains(Object element) => _childElements.contains(element); 17 bool contains(Object element) => _childElements.contains(element);
17 18
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 Element get last { 151 Element get last {
151 Element result = _element._lastElementChild; 152 Element result = _element._lastElementChild;
152 if (result == null) throw new StateError("No elements"); 153 if (result == null) throw new StateError("No elements");
153 return result; 154 return result;
154 } 155 }
155 156
156 Element get single { 157 Element get single {
157 if (length > 1) throw new StateError("More than one element"); 158 if (length > 1) throw new StateError("More than one element");
158 return first; 159 return first;
159 } 160 }
161
162 List<Node> get rawList => _element._childElements;
justinfagnani 2013/10/26 01:32:26 why isn't this just => _childElements ?
blois 2013/10/26 17:55:17 Done.
160 } 163 }
161 164
162 /** 165 /**
163 * An immutable list containing HTML elements. This list contains some 166 * An immutable list containing HTML elements. This list contains some
164 * additional methods when compared to regular lists for ease of CSS 167 * additional methods when compared to regular lists for ease of CSS
165 * manipulation on a group of elements. 168 * manipulation on a group of elements.
166 */ 169 */
167 abstract class ElementList<T extends Element> extends ListBase<T> { 170 abstract class ElementList<T extends Element> extends ListBase<T> {
168 /** 171 /**
169 * The union of all CSS classes applied to the elements in this list. 172 * The union of all CSS classes applied to the elements in this list.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 */ 251 */
249 @Experimental() 252 @Experimental()
250 CssRect get marginEdge; 253 CssRect get marginEdge;
251 $!STREAM_GETTER_SIGNATURES 254 $!STREAM_GETTER_SIGNATURES
252 } 255 }
253 256
254 // TODO(jacobr): this is an inefficient implementation but it is hard to see 257 // TODO(jacobr): this is an inefficient implementation but it is hard to see
255 // a better option given that we cannot quite force NodeList to be an 258 // a better option given that we cannot quite force NodeList to be an
256 // ElementList as there are valid cases where a NodeList JavaScript object 259 // ElementList as there are valid cases where a NodeList JavaScript object
257 // contains Node objects that are not Elements. 260 // contains Node objects that are not Elements.
258 class _FrozenElementList<T extends Element> extends ListBase<T> implements Eleme ntList { 261 class _FrozenElementList<T extends Element> extends ListBase<T>
262 implements ElementList, NodeListWrapper {
259 final List<Node> _nodeList; 263 final List<Node> _nodeList;
260 // The subset of _nodeList that are Elements. 264 // The subset of _nodeList that are Elements.
261 List<Element> _elementList; 265 List<Element> _elementList;
262 266
263 _FrozenElementList._wrap(this._nodeList) { 267 _FrozenElementList._wrap(this._nodeList) {
264 _elementList = _nodeList.where((e) => e is Element).toList(); 268 _elementList = _nodeList.where((e) => e is Element).toList();
265 } 269 }
266 270
267 int get length => _nodeList.length; 271 int get length => _nodeList.length;
268 272
(...skipping 30 matching lines...) Expand all
299 _elementList.forEach((e) => e.classes = value); 303 _elementList.forEach((e) => e.classes = value);
300 } 304 }
301 305
302 CssRect get contentEdge => new _ContentCssListRect(_elementList); 306 CssRect get contentEdge => new _ContentCssListRect(_elementList);
303 307
304 CssRect get paddingEdge => _elementList.first.paddingEdge; 308 CssRect get paddingEdge => _elementList.first.paddingEdge;
305 309
306 CssRect get borderEdge => _elementList.first.borderEdge; 310 CssRect get borderEdge => _elementList.first.borderEdge;
307 311
308 CssRect get marginEdge => _elementList.first.marginEdge; 312 CssRect get marginEdge => _elementList.first.marginEdge;
313
314 List<Node> get rawList => _nodeList;
315
309 $!ELEMENT_STREAM_GETTERS 316 $!ELEMENT_STREAM_GETTERS
310 } 317 }
311 318
312 @DocsEditable() 319 @DocsEditable()
313 $(ANNOTATIONS)abstract class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { 320 $(ANNOTATIONS)abstract class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
314 321
315 /** 322 /**
316 * Creates an HTML element from a valid fragment of HTML. 323 * Creates an HTML element from a valid fragment of HTML.
317 * 324 *
318 * var element = new Element.html('<div class="foo">content</div>'); 325 * var element = new Element.html('<div class="foo">content</div>');
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 const ScrollAlignment._internal(this._value); 1289 const ScrollAlignment._internal(this._value);
1283 toString() => 'ScrollAlignment.$_value'; 1290 toString() => 'ScrollAlignment.$_value';
1284 1291
1285 /// Attempt to align the element to the top of the scrollable area. 1292 /// Attempt to align the element to the top of the scrollable area.
1286 static const TOP = const ScrollAlignment._internal('TOP'); 1293 static const TOP = const ScrollAlignment._internal('TOP');
1287 /// Attempt to center the element in the scrollable area. 1294 /// Attempt to center the element in the scrollable area.
1288 static const CENTER = const ScrollAlignment._internal('CENTER'); 1295 static const CENTER = const ScrollAlignment._internal('CENTER');
1289 /// Attempt to align the element to the bottom of the scrollable area. 1296 /// Attempt to align the element to the bottom of the scrollable area.
1290 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 1297 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1291 } 1298 }
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