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

Side by Side Diff: lib/dom/templates/html/impl/impl_Document.darttemplate

Issue 10448009: Apply html renames to native wrappers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 8 years, 6 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
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 class $CLASSNAME extends _NodeImpl 5 class $CLASSNAME extends _NodeImpl
6 implements Document 6 implements Document
7 $if FROG 7 $if FROG
8 native "*HTMLDocument" 8 native "*HTMLDocument"
9 $endif 9 $endif
10 { 10 {
11 11
12 $!MEMBERS 12 $!MEMBERS
13 // TODO(jacobr): implement all Element methods not on Document. 13 // TODO(jacobr): implement all Element methods not on Document.
14 14
15 _ElementImpl query(String selectors) { 15 _ElementImpl query(String selectors) {
16 // It is fine for our RegExp to detect element id query selectors to have 16 // It is fine for our RegExp to detect element id query selectors to have
17 // false negatives but not false positives. 17 // false negatives but not false positives.
18 if (const RegExp("^#[_a-zA-Z]\\w*\$").hasMatch(selectors)) { 18 if (const RegExp("^#[_a-zA-Z]\\w*\$").hasMatch(selectors)) {
19 return $dom_getElementById(selectors.substring(1)); 19 return $dom_getElementById(selectors.substring(1));
20 } 20 }
21 return $dom_querySelector(selectors); 21 return $dom_querySelector(selectors);
22 } 22 }
23 23
24 // TODO(jacobr): autogenerate this method. 24 // TODO(jacobr): autogenerate this method.
25 $if FROG 25 $if FROG
26 _ElementImpl $dom_querySelector(String selectors) native "return this.querySel ector(selectors);"; 26 _ElementImpl $dom_querySelector(String selectors) native "return this.querySel ector(selectors);";
27 $else 27 $else
28 _ElementImpl $dom_querySelector(String selectors) => 28 _ElementImpl $dom_querySelector(String selectors) =>
29 _wrap(_ptr.querySelector(selectors)); 29 _wrap(_ptr.query(selectors));
30 $endif 30 $endif
31 31
32 ElementList queryAll(String selectors) { 32 ElementList queryAll(String selectors) {
33 if (const RegExp("""^\\[name=["'][^'"]+['"]\\]\$""").hasMatch(selectors)) { 33 if (const RegExp("""^\\[name=["'][^'"]+['"]\\]\$""").hasMatch(selectors)) {
34 final mutableMatches = $dom_getElementsByName( 34 final mutableMatches = $dom_getElementsByName(
35 selectors.substring(7,selectors.length - 2)); 35 selectors.substring(7,selectors.length - 2));
36 int len = mutableMatches.length; 36 int len = mutableMatches.length;
37 final copyOfMatches = new List<Element>(len); 37 final copyOfMatches = new List<Element>(len);
38 for (int i = 0; i < len; ++i) { 38 for (int i = 0; i < len; ++i) {
39 copyOfMatches[i] = mutableMatches[i]; 39 copyOfMatches[i] = mutableMatches[i];
40 } 40 }
41 return new _FrozenElementList._wrap(copyOfMatches); 41 return new _FrozenElementList._wrap(copyOfMatches);
42 } else if (const RegExp("^[*a-zA-Z0-9]+\$").hasMatch(selectors)) { 42 } else if (const RegExp("^[*a-zA-Z0-9]+\$").hasMatch(selectors)) {
43 final mutableMatches = $dom_getElementsByTagName(selectors); 43 final mutableMatches = $dom_getElementsByTagName(selectors);
44 int len = mutableMatches.length; 44 int len = mutableMatches.length;
45 final copyOfMatches = new List<Element>(len); 45 final copyOfMatches = new List<Element>(len);
46 for (int i = 0; i < len; ++i) { 46 for (int i = 0; i < len; ++i) {
47 copyOfMatches[i] = mutableMatches[i]; 47 copyOfMatches[i] = mutableMatches[i];
48 } 48 }
49 return new _FrozenElementList._wrap(copyOfMatches); 49 return new _FrozenElementList._wrap(copyOfMatches);
50 } else { 50 } else {
51 return new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); 51 return new _FrozenElementList._wrap($dom_querySelectorAll(selectors));
52 } 52 }
53 } 53 }
54 } 54 }
OLDNEW
« no previous file with comments | « lib/dom/templates/html/dartium/impl_EventTarget.darttemplate ('k') | lib/html/frog/html_frog.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698