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

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

Issue 22529004: Add includeAncestors to dartium matches call. (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/scripts/htmlrenamer.py ('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 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 case 'afterend': 870 case 'afterend':
871 this.parentNode.insertBefore(node, this.nextNode); 871 this.parentNode.insertBefore(node, this.nextNode);
872 break; 872 break;
873 default: 873 default:
874 throw new ArgumentError("Invalid position ${where}"); 874 throw new ArgumentError("Invalid position ${where}");
875 } 875 }
876 } 876 }
877 877
878 /** 878 /**
879 * Checks if this element matches the CSS selectors. 879 * Checks if this element matches the CSS selectors.
880 */
881 @Experimental()
882 bool _matches(String selectors) {
883 if (JS('bool', '!!#.matches', this)) {
884 return JS('bool', '#.matches(#)', this, selectors);
885 } else if (JS('bool', '!!#.webkitMatchesSelector', this)) {
886 return JS('bool', '#.webkitMatchesSelector(#)', this, selectors);
887 } else if (JS('bool', '!!#.mozMatchesSelector', this)) {
888 return JS('bool', '#.mozMatchesSelector(#)', this, selectors);
889 } else if (JS('bool', '!!#.msMatchesSelector', this)) {
890 return matches = JS('bool', '#.msMatchesSelector(#)', this, selectors);
891 } else {
892 throw new UnsupportedError("Not supported on this platform");
893 }
894 return false;
895 }
896 $else
897 $endif
898
899 /**
900 * Checks if this element matches the CSS selectors.
880 * 901 *
881 * If `includeAncestors` is true, we examine all of this element's parent 902 * 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 903 * elements and also return true if any of its parent elements matches
883 * `selectors`. 904 * `selectors`.
884 */ 905 */
885 @Experimental() 906 @Experimental()
886 bool matches(String selectors, [includeAncestors = false]) { 907 bool matches(String selectors, [includeAncestors = false]) {
887 var elem = this; 908 var elem = this;
888 do { 909 do {
889 bool matches = false; 910 if (elem._matches(selectors)) return true;
890 if (JS('bool', '!!#.matches', elem)) {
891 matches = JS('bool', '#.matches(#)', elem, selectors);
892 } else if (JS('bool', '!!#.webkitMatchesSelector', elem)) {
893 matches = JS('bool', '#.webkitMatchesSelector(#)', elem, selectors);
894 } else if (JS('bool', '!!#.mozMatchesSelector', elem)) {
895 matches = JS('bool', '#.mozMatchesSelector(#)', elem, selectors);
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; 911 elem = elem.parent;
903 } while(includeAncestors && elem != null); 912 } while(includeAncestors && elem != null);
904 return false; 913 return false;
905 } 914 }
906 $else
907 $endif
908 915
909 $if DART2JS 916 $if DART2JS
910 @Creates('Null') // Set from Dart code; does not instantiate a native type. 917 @Creates('Null') // Set from Dart code; does not instantiate a native type.
911 $endif 918 $endif
912 Element _templateInstanceRef; 919 Element _templateInstanceRef;
913 920
914 // Note: only used if `this is! TemplateElement` 921 // Note: only used if `this is! TemplateElement`
915 $if DART2JS 922 $if DART2JS
916 @Creates('Null') // Set from Dart code; does not instantiate a native type. 923 @Creates('Null') // Set from Dart code; does not instantiate a native type.
917 $endif 924 $endif
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 const ScrollAlignment._internal(this._value); 1316 const ScrollAlignment._internal(this._value);
1310 toString() => 'ScrollAlignment.$_value'; 1317 toString() => 'ScrollAlignment.$_value';
1311 1318
1312 /// Attempt to align the element to the top of the scrollable area. 1319 /// Attempt to align the element to the top of the scrollable area.
1313 static const TOP = const ScrollAlignment._internal('TOP'); 1320 static const TOP = const ScrollAlignment._internal('TOP');
1314 /// Attempt to center the element in the scrollable area. 1321 /// Attempt to center the element in the scrollable area.
1315 static const CENTER = const ScrollAlignment._internal('CENTER'); 1322 static const CENTER = const ScrollAlignment._internal('CENTER');
1316 /// Attempt to align the element to the bottom of the scrollable area. 1323 /// Attempt to align the element to the bottom of the scrollable area.
1317 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 1324 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1318 } 1325 }
OLDNEW
« no previous file with comments | « tools/dom/scripts/htmlrenamer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698