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

Side by Side Diff: tools/dom/src/native_DOMImplementation.dart

Issue 27222003: Dart changes for https://codereview.chromium.org/26571005/ (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | « tests/html/custom/document_register_type_extensions_test.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 html; 5 part of html;
6 6
7 class _ConsoleVariables { 7 class _ConsoleVariables {
8 Map<String, Object> _data = new Map<String, Object>(); 8 Map<String, Object> _data = new Map<String, Object>();
9 9
10 /** 10 /**
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (type == other) { 97 if (type == other) {
98 return true; 98 return true;
99 } 99 }
100 var superclass = reflectClass(type).superclass; 100 var superclass = reflectClass(type).superclass;
101 if (superclass != null) { 101 if (superclass != null) {
102 return isTypeSubclassOf(superclass.reflectedType, other); 102 return isTypeSubclassOf(superclass.reflectedType, other);
103 } 103 }
104 return false; 104 return false;
105 } 105 }
106 106
107 static bool isTypeSubclassOfTag(Type type, String tagName) {
108 var element = new Element.tag(tagName);
109 return isTypeSubclassOf(type, element.runtimeType);
110 }
111
107 static window() native "Utils_window"; 112 static window() native "Utils_window";
108 static forwardingPrint(String message) native "Utils_forwardingPrint"; 113 static forwardingPrint(String message) native "Utils_forwardingPrint";
109 static int _getNewIsolateId() native "Utils_getNewIsolateId"; 114 static int _getNewIsolateId() native "Utils_getNewIsolateId";
110 115
111 // The following methods were added for debugger integration to make working 116 // The following methods were added for debugger integration to make working
112 // with the Dart C mirrors API simpler. 117 // with the Dart C mirrors API simpler.
113 // TODO(jacobr): consider moving them to a separate library. 118 // TODO(jacobr): consider moving them to a separate library.
114 // If Dart supported dynamic code injection, we would only inject this code 119 // If Dart supported dynamic code injection, we would only inject this code
115 // when the debugger is invoked. 120 // when the debugger is invoked.
116 121
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 expression = expression.replaceFirst(_ENDING_SEMICOLONS, ""); 240 expression = expression.replaceFirst(_ENDING_SEMICOLONS, "");
236 } 241 }
237 242
238 if (locals != null) { 243 if (locals != null) {
239 for (int i = 0; i < locals.length; i+= 2) { 244 for (int i = 0; i < locals.length; i+= 2) {
240 addArg(locals[i], locals[i+1]); 245 addArg(locals[i], locals[i+1]);
241 } 246 }
242 } 247 }
243 // Inject all the already defined console variables. 248 // Inject all the already defined console variables.
244 _consoleTempVariables._data.forEach(addArg); 249 _consoleTempVariables._data.forEach(addArg);
245 250
246 // TODO(jacobr): remove the parentheses around the expresson once 251 // TODO(jacobr): remove the parentheses around the expresson once
247 // dartbug.com/13723 is fixed. Currently we wrap expression in parentheses 252 // dartbug.com/13723 is fixed. Currently we wrap expression in parentheses
248 // to ensure only valid Dart expressions are allowed. Otherwise the DartVM 253 // to ensure only valid Dart expressions are allowed. Otherwise the DartVM
249 // quietly ignores trailing Dart statements resulting in user confusion 254 // quietly ignores trailing Dart statements resulting in user confusion
250 // when part of an invalid expression they entered is ignored. 255 // when part of an invalid expression they entered is ignored.
251 sb..write(') => (\n$expression\n)'); 256 sb..write(') => (\n$expression\n)');
252 return [sb.toString(), args.values.toList(growable: false)]; 257 return [sb.toString(), args.values.toList(growable: false)];
253 } 258 }
254 259
255 /** 260 /**
256 * TODO(jacobr): this is a big hack to get around the fact that we are still 261 * TODO(jacobr): this is a big hack to get around the fact that we are still
257 * passing some JS expression to the evaluate method even when in a Dart 262 * passing some JS expression to the evaluate method even when in a Dart
258 * context. 263 * context.
259 */ 264 */
260 static bool isJsExpression(String expression) => 265 static bool isJsExpression(String expression) =>
261 expression.startsWith("(function getCompletions"); 266 expression.startsWith("(function getCompletions");
262 267
263 /** 268 /**
264 * Returns a list of completions to use if the receiver is o. 269 * Returns a list of completions to use if the receiver is o.
265 */ 270 */
266 static List<String> getCompletions(o) { 271 static List<String> getCompletions(o) {
267 MirrorSystem system = currentMirrorSystem(); 272 MirrorSystem system = currentMirrorSystem();
268 var completions = new Set<String>(); 273 var completions = new Set<String>();
269 addAll(Map<Symbol, dynamic> map, bool isStatic) { 274 addAll(Map<Symbol, dynamic> map, bool isStatic) {
270 map.forEach((symbol, mirror) { 275 map.forEach((symbol, mirror) {
271 if (mirror.isStatic == isStatic && !mirror.isPrivate) { 276 if (mirror.isStatic == isStatic && !mirror.isPrivate) {
272 var name = MirrorSystem.getName(symbol); 277 var name = MirrorSystem.getName(symbol);
273 if (mirror is MethodMirror && mirror.isSetter) 278 if (mirror is MethodMirror && mirror.isSetter)
274 name = name.substring(0, name.length - 1); 279 name = name.substring(0, name.length - 1);
275 completions.add(name); 280 completions.add(name);
276 } 281 }
277 }); 282 });
278 } 283 }
279 284
280 addForClass(ClassMirror mirror, bool isStatic) { 285 addForClass(ClassMirror mirror, bool isStatic) {
281 if (mirror == null) 286 if (mirror == null)
282 return; 287 return;
283 addAll(mirror.members, isStatic); 288 addAll(mirror.members, isStatic);
284 if (mirror.superclass != null) 289 if (mirror.superclass != null)
285 addForClass(mirror.superclass, isStatic); 290 addForClass(mirror.superclass, isStatic);
286 for (var interface in mirror.superinterfaces) { 291 for (var interface in mirror.superinterfaces) {
287 addForClass(interface, isStatic); 292 addForClass(interface, isStatic);
288 } 293 }
289 } 294 }
290 295
291 if (o is Type) { 296 if (o is Type) {
292 addForClass(reflectClass(o), true); 297 addForClass(reflectClass(o), true);
293 } else { 298 } else {
294 addForClass(reflect(o).type, false); 299 addForClass(reflect(o).type, false);
295 } 300 }
296 return completions.toList(growable: false); 301 return completions.toList(growable: false);
297 } 302 }
298 303
299 /** 304 /**
300 * Convenience helper to get the keys of a [Map] as a [List]. 305 * Convenience helper to get the keys of a [Map] as a [List].
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 }; 527 };
523 528
524 get _pureIsolateTimerFactoryClosure => 529 get _pureIsolateTimerFactoryClosure =>
525 ((int milliSeconds, void callback(Timer time), bool repeating) => 530 ((int milliSeconds, void callback(Timer time), bool repeating) =>
526 throw new UnimplementedError("Timers on background isolates " 531 throw new UnimplementedError("Timers on background isolates "
527 "are not supported in the browser")); 532 "are not supported in the browser"));
528 533
529 void _initializeCustomElement(Element e) { 534 void _initializeCustomElement(Element e) {
530 _Utils.initializeCustomElement(e); 535 _Utils.initializeCustomElement(e);
531 } 536 }
OLDNEW
« no previous file with comments | « tests/html/custom/document_register_type_extensions_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698