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

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

Issue 21607003: Add Event delegation to Elements and groups of elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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/EventStreamProvider.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 // Raw Element. 8 // Raw Element.
9 final Element _element; 9 final Element _element;
10 final HtmlCollection _childElements; 10 final HtmlCollection _childElements;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 * border + margin box in this list. 237 * border + margin box in this list.
238 * 238 *
239 * This returns a rectangle with the dimenions actually available for content 239 * This returns a rectangle with the dimenions actually available for content
240 * in this element, in pixels, regardless of this element's box-sizing 240 * in this element, in pixels, regardless of this element's box-sizing
241 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle 241 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
242 * will return the same numerical height if the element is hidden or not. This 242 * will return the same numerical height if the element is hidden or not. This
243 * can be used to retrieve jQuery's `outerHeight` value for an element. 243 * can be used to retrieve jQuery's `outerHeight` value for an element.
244 */ 244 */
245 @Experimental() 245 @Experimental()
246 CssRect get marginEdge; 246 CssRect get marginEdge;
247 $!STREAM_GETTER_SIGNATURES
247 } 248 }
248 249
249 // TODO(jacobr): this is an inefficient implementation but it is hard to see 250 // TODO(jacobr): this is an inefficient implementation but it is hard to see
250 // a better option given that we cannot quite force NodeList to be an 251 // a better option given that we cannot quite force NodeList to be an
251 // ElementList as there are valid cases where a NodeList JavaScript object 252 // ElementList as there are valid cases where a NodeList JavaScript object
252 // contains Node objects that are not Elements. 253 // contains Node objects that are not Elements.
253 class _FrozenElementList<T extends Element> extends ListBase<T> implements Eleme ntList { 254 class _FrozenElementList<T extends Element> extends ListBase<T> implements Eleme ntList {
254 final List<Node> _nodeList; 255 final List<Node> _nodeList;
255 // The subset of _nodeList that are Elements. 256 // The subset of _nodeList that are Elements.
256 List<Element> _elementList; 257 List<Element> _elementList;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 _elementList.forEach((e) => e.classes = value); 291 _elementList.forEach((e) => e.classes = value);
291 } 292 }
292 293
293 CssRect get contentEdge => new _ContentCssListRect(_elementList); 294 CssRect get contentEdge => new _ContentCssListRect(_elementList);
294 295
295 CssRect get paddingEdge => _elementList.first.paddingEdge; 296 CssRect get paddingEdge => _elementList.first.paddingEdge;
296 297
297 CssRect get borderEdge => _elementList.first.borderEdge; 298 CssRect get borderEdge => _elementList.first.borderEdge;
298 299
299 CssRect get marginEdge => _elementList.first.marginEdge; 300 CssRect get marginEdge => _elementList.first.marginEdge;
301 $!ELEMENT_STREAM_GETTERS
300 } 302 }
301 303
302 /** 304 /**
303 * An abstract class, which all HTML elements extend. 305 * An abstract class, which all HTML elements extend.
304 */ 306 */
305 $(ANNOTATIONS)abstract class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { 307 $(ANNOTATIONS)abstract class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
306 308
307 /** 309 /**
308 * Creates an HTML element from a valid fragment of HTML. 310 * Creates an HTML element from a valid fragment of HTML.
309 * 311 *
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 case 'afterend': 870 case 'afterend':
869 this.parentNode.insertBefore(node, this.nextNode); 871 this.parentNode.insertBefore(node, this.nextNode);
870 break; 872 break;
871 default: 873 default:
872 throw new ArgumentError("Invalid position ${where}"); 874 throw new ArgumentError("Invalid position ${where}");
873 } 875 }
874 } 876 }
875 877
876 /** 878 /**
877 * Checks if this element matches the CSS selectors. 879 * Checks if this element matches the CSS selectors.
880 *
881 * If `includeAncestors` is true, we examine all of this element's parent
882 * elements and also return true if any of its parent elements matches
883 * `selectors`.
878 */ 884 */
879 @Experimental() 885 @Experimental()
880 bool matches(String selectors) { 886 bool matches(String selectors, [includeAncestors = false]) {
881 if (JS('bool', '!!#.matches', this)) { 887 var elem = this;
882 return JS('bool', '#.matches(#)', this, selectors); 888 do {
883 } else if (JS('bool', '!!#.webkitMatchesSelector', this)) { 889 bool matches = false;
884 return JS('bool', '#.webkitMatchesSelector(#)', this, selectors); 890 if (JS('bool', '!!#.matches', elem)) {
885 } else if (JS('bool', '!!#.mozMatchesSelector', this)) { 891 matches = JS('bool', '#.matches(#)', elem, selectors);
886 return JS('bool', '#.mozMatchesSelector(#)', this, selectors); 892 } else if (JS('bool', '!!#.webkitMatchesSelector', elem)) {
887 } else if (JS('bool', '!!#.msMatchesSelector', this)) { 893 matches = JS('bool', '#.webkitMatchesSelector(#)', elem, selectors);
888 return JS('bool', '#.msMatchesSelector(#)', this, selectors); 894 } else if (JS('bool', '!!#.mozMatchesSelector', elem)) {
889 } 895 matches = JS('bool', '#.mozMatchesSelector(#)', elem, selectors);
890 throw new UnsupportedError("Not supported on this platform"); 896 } else if (JS('bool', '!!#.msMatchesSelector', elem)) {
897 matches = JS('bool', '#.msMatchesSelector(#)', elem, selectors);
898 } else {
899 throw new UnsupportedError("Not supported on this platform");
900 }
901 if (matches) return true;
902 elem = elem.parent;
903 } while(includeAncestors && elem != null);
904 return false;
891 } 905 }
892 $else 906 $else
893 $endif 907 $endif
894 908
895 $if DART2JS 909 $if DART2JS
896 @Creates('Null') // Set from Dart code; does not instantiate a native type. 910 @Creates('Null') // Set from Dart code; does not instantiate a native type.
897 $endif 911 $endif
898 Element _templateInstanceRef; 912 Element _templateInstanceRef;
899 913
900 // Note: only used if `this is! TemplateElement` 914 // Note: only used if `this is! TemplateElement`
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 throw new ArgumentError("Specified element is not a transitive offset " 1166 throw new ArgumentError("Specified element is not a transitive offset "
1153 "parent of this element."); 1167 "parent of this element.");
1154 } 1168 }
1155 Element parentOffset = current.offsetParent; 1169 Element parentOffset = current.offsetParent;
1156 Point p = Element._offsetToHelper(parentOffset, parent); 1170 Point p = Element._offsetToHelper(parentOffset, parent);
1157 return new Point(p.x + current.offsetLeft, p.y + current.offsetTop); 1171 return new Point(p.x + current.offsetLeft, p.y + current.offsetTop);
1158 } 1172 }
1159 $!MEMBERS 1173 $!MEMBERS
1160 } 1174 }
1161 1175
1162
1163 final _START_TAG_REGEXP = new RegExp('<(\\w+)'); 1176 final _START_TAG_REGEXP = new RegExp('<(\\w+)');
1164 class _ElementFactoryProvider { 1177 class _ElementFactoryProvider {
1165 static const _CUSTOM_PARENT_TAG_MAP = const { 1178 static const _CUSTOM_PARENT_TAG_MAP = const {
1166 'body' : 'html', 1179 'body' : 'html',
1167 'head' : 'html', 1180 'head' : 'html',
1168 'caption' : 'table', 1181 'caption' : 'table',
1169 'td': 'tr', 1182 'td': 'tr',
1170 'th': 'tr', 1183 'th': 'tr',
1171 'colgroup': 'table', 1184 'colgroup': 'table',
1172 'col' : 'colgroup', 1185 'col' : 'colgroup',
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 const ScrollAlignment._internal(this._value); 1309 const ScrollAlignment._internal(this._value);
1297 toString() => 'ScrollAlignment.$_value'; 1310 toString() => 'ScrollAlignment.$_value';
1298 1311
1299 /// Attempt to align the element to the top of the scrollable area. 1312 /// Attempt to align the element to the top of the scrollable area.
1300 static const TOP = const ScrollAlignment._internal('TOP'); 1313 static const TOP = const ScrollAlignment._internal('TOP');
1301 /// Attempt to center the element in the scrollable area. 1314 /// Attempt to center the element in the scrollable area.
1302 static const CENTER = const ScrollAlignment._internal('CENTER'); 1315 static const CENTER = const ScrollAlignment._internal('CENTER');
1303 /// Attempt to align the element to the bottom of the scrollable area. 1316 /// Attempt to align the element to the bottom of the scrollable area.
1304 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 1317 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1305 } 1318 }
OLDNEW
« no previous file with comments | « tools/dom/src/EventStreamProvider.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698