OLD | NEW |
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 static Element getAndValidateNativeType(Type type, String tagName) { | 100 static Element getAndValidateNativeType(Type type, String tagName) { |
101 var element = new Element.tag(tagName); | 101 var element = new Element.tag(tagName); |
102 if (!isTypeSubclassOf(type, element.runtimeType)) { | 102 if (!isTypeSubclassOf(type, element.runtimeType)) { |
103 return null; | 103 return null; |
104 } | 104 } |
105 return element; | 105 return element; |
106 } | 106 } |
107 | 107 |
108 static window() => blink.Native_Utils_window(); | 108 static window() => _blink.Native_Utils_window(); |
109 static forwardingPrint(String message) => blink.Native_Utils_forwardingPrint(m
essage); | 109 static forwardingPrint(String message) => _blink.Native_Utils_forwardingPrint(
message); |
110 // TODO(vsm): Make this API compatible with spawnUri. It should also | 110 // TODO(vsm): Make this API compatible with spawnUri. It should also |
111 // return a Future<Isolate>. | 111 // return a Future<Isolate>. |
112 static spawnDomUri(String uri) => blink.Native_Utils_spawnDomUri(uri); | 112 static spawnDomUri(String uri) => _blink.Native_Utils_spawnDomUri(uri); |
113 | 113 |
114 // The following methods were added for debugger integration to make working | 114 // The following methods were added for debugger integration to make working |
115 // with the Dart C mirrors API simpler. | 115 // with the Dart C mirrors API simpler. |
116 // TODO(jacobr): consider moving them to a separate library. | 116 // TODO(jacobr): consider moving them to a separate library. |
117 // If Dart supported dynamic code injection, we would only inject this code | 117 // If Dart supported dynamic code injection, we would only inject this code |
118 // when the debugger is invoked. | 118 // when the debugger is invoked. |
119 | 119 |
120 /** | 120 /** |
121 * Strips the private secret prefix from member names of the form | 121 * Strips the private secret prefix from member names of the form |
122 * someName@hash. | 122 * someName@hash. |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 if (nativeClass.reflectedType != HtmlElement) { | 404 if (nativeClass.reflectedType != HtmlElement) { |
405 throw new UnsupportedError('Class must provide extendsTag if base ' | 405 throw new UnsupportedError('Class must provide extendsTag if base ' |
406 'native class is not HTMLElement'); | 406 'native class is not HTMLElement'); |
407 } | 407 } |
408 } | 408 } |
409 | 409 |
410 _register(document, tag, type, extendsTagName); | 410 _register(document, tag, type, extendsTagName); |
411 } | 411 } |
412 | 412 |
413 static void _register(Document document, String tag, Type customType, | 413 static void _register(Document document, String tag, Type customType, |
414 String extendsTagName) => blink.Native_Utils_register(document, tag, customT
ype, extendsTagName); | 414 String extendsTagName) => _blink.Native_Utils_register(document, tag, custom
Type, extendsTagName); |
415 | 415 |
416 static Element createElement(Document document, String tagName) => | 416 static Element createElement(Document document, String tagName) => |
417 blink.Native_Utils_createElement(document, tagName); | 417 _blink.Native_Utils_createElement(document, tagName); |
418 | 418 |
419 static void initializeCustomElement(HtmlElement element) => | 419 static void initializeCustomElement(HtmlElement element) => |
420 blink.Native_Utils_initializeCustomElement(element); | 420 _blink.Native_Utils_initializeCustomElement(element); |
421 | 421 |
422 static void changeElementWrapper(HtmlElement element, Type type) => | 422 static void changeElementWrapper(HtmlElement element, Type type) => |
423 blink.Native_Utils_changeElementWrapper(element, type); | 423 _blink.Native_Utils_changeElementWrapper(element, type); |
424 } | 424 } |
425 | 425 |
426 class _DOMWindowCrossFrame extends NativeFieldWrapperClass2 implements | 426 class _DOMWindowCrossFrame extends NativeFieldWrapperClass2 implements |
427 WindowBase { | 427 WindowBase { |
428 _DOMWindowCrossFrame.internal(); | 428 _DOMWindowCrossFrame.internal(); |
429 | 429 |
430 // Fields. | 430 // Fields. |
431 HistoryBase get history => blink.Native_DOMWindowCrossFrame_get_history(this); | 431 HistoryBase get history => _blink.Native_DOMWindowCrossFrame_get_history(this)
; |
432 LocationBase get location => blink.Native_DOMWindowCrossFrame_get_location(thi
s); | 432 LocationBase get location => _blink.Native_DOMWindowCrossFrame_get_location(th
is); |
433 bool get closed => blink.Native_DOMWindowCrossFrame_get_closed(this); | 433 bool get closed => _blink.Native_DOMWindowCrossFrame_get_closed(this); |
434 WindowBase get opener => blink.Native_DOMWindowCrossFrame_get_opener(this); | 434 WindowBase get opener => _blink.Native_DOMWindowCrossFrame_get_opener(this); |
435 WindowBase get parent => blink.Native_DOMWindowCrossFrame_get_parent(this); | 435 WindowBase get parent => _blink.Native_DOMWindowCrossFrame_get_parent(this); |
436 WindowBase get top => blink.Native_DOMWindowCrossFrame_get_top(this); | 436 WindowBase get top => _blink.Native_DOMWindowCrossFrame_get_top(this); |
437 | 437 |
438 // Methods. | 438 // Methods. |
439 void close() => blink.Native_DOMWindowCrossFrame_close(this); | 439 void close() => _blink.Native_DOMWindowCrossFrame_close(this); |
440 void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List
messagePorts]) => | 440 void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List
messagePorts]) => |
441 blink.Native_DOMWindowCrossFrame_postMessage(this, message, targetOrigin, me
ssagePorts); | 441 _blink.Native_DOMWindowCrossFrame_postMessage(this, message, targetOrigin, m
essagePorts); |
442 | 442 |
443 // Implementation support. | 443 // Implementation support. |
444 String get typeName => "Window"; | 444 String get typeName => "Window"; |
445 | 445 |
446 // TODO(efortuna): Remove this method. dartbug.com/16814 | 446 // TODO(efortuna): Remove this method. dartbug.com/16814 |
447 Events get on => throw new UnsupportedError( | 447 Events get on => throw new UnsupportedError( |
448 'You can only attach EventListeners to your own window.'); | 448 'You can only attach EventListeners to your own window.'); |
449 // TODO(efortuna): Remove this method. dartbug.com/16814 | 449 // TODO(efortuna): Remove this method. dartbug.com/16814 |
450 void addEventListener(String type, EventListener listener, [bool useCapture]) | 450 void addEventListener(String type, EventListener listener, [bool useCapture]) |
451 => throw new UnsupportedError( | 451 => throw new UnsupportedError( |
452 'You can only attach EventListeners to your own window.'); | 452 'You can only attach EventListeners to your own window.'); |
453 // TODO(efortuna): Remove this method. dartbug.com/16814 | 453 // TODO(efortuna): Remove this method. dartbug.com/16814 |
454 bool dispatchEvent(Event event) => throw new UnsupportedError( | 454 bool dispatchEvent(Event event) => throw new UnsupportedError( |
455 'You can only attach EventListeners to your own window.'); | 455 'You can only attach EventListeners to your own window.'); |
456 // TODO(efortuna): Remove this method. dartbug.com/16814 | 456 // TODO(efortuna): Remove this method. dartbug.com/16814 |
457 void removeEventListener(String type, EventListener listener, | 457 void removeEventListener(String type, EventListener listener, |
458 [bool useCapture]) => throw new UnsupportedError( | 458 [bool useCapture]) => throw new UnsupportedError( |
459 'You can only attach EventListeners to your own window.'); | 459 'You can only attach EventListeners to your own window.'); |
460 } | 460 } |
461 | 461 |
462 class _HistoryCrossFrame extends NativeFieldWrapperClass2 implements HistoryBase
{ | 462 class _HistoryCrossFrame extends NativeFieldWrapperClass2 implements HistoryBase
{ |
463 _HistoryCrossFrame.internal(); | 463 _HistoryCrossFrame.internal(); |
464 | 464 |
465 // Methods. | 465 // Methods. |
466 void back() => blink.Native_HistoryCrossFrame_back(this); | 466 void back() => _blink.Native_HistoryCrossFrame_back(this); |
467 void forward() => blink.Native_HistoryCrossFrame_forward(this); | 467 void forward() => _blink.Native_HistoryCrossFrame_forward(this); |
468 void go(int distance) => blink.Native_HistoryCrossFrame_go(this, distance); | 468 void go(int distance) => _blink.Native_HistoryCrossFrame_go(this, distance); |
469 | 469 |
470 // Implementation support. | 470 // Implementation support. |
471 String get typeName => "History"; | 471 String get typeName => "History"; |
472 } | 472 } |
473 | 473 |
474 class _LocationCrossFrame extends NativeFieldWrapperClass2 implements LocationBa
se { | 474 class _LocationCrossFrame extends NativeFieldWrapperClass2 implements LocationBa
se { |
475 _LocationCrossFrame.internal(); | 475 _LocationCrossFrame.internal(); |
476 | 476 |
477 // Fields. | 477 // Fields. |
478 void set href(String h) => blink.Native_LocationCrossFrame_set_href(this, h); | 478 void set href(String h) => _blink.Native_LocationCrossFrame_set_href(this, h); |
479 | 479 |
480 // Implementation support. | 480 // Implementation support. |
481 String get typeName => "Location"; | 481 String get typeName => "Location"; |
482 } | 482 } |
483 | 483 |
484 class _DOMStringMap extends NativeFieldWrapperClass2 implements Map<String, Stri
ng> { | 484 class _DOMStringMap extends NativeFieldWrapperClass2 implements Map<String, Stri
ng> { |
485 _DOMStringMap.internal(); | 485 _DOMStringMap.internal(); |
486 | 486 |
487 bool containsValue(String value) => Maps.containsValue(this, value); | 487 bool containsValue(String value) => Maps.containsValue(this, value); |
488 bool containsKey(String key) => blink.Native_DOMStringMap_containsKey(this, ke
y); | 488 bool containsKey(String key) => _blink.Native_DOMStringMap_containsKey(this, k
ey); |
489 String operator [](String key) => blink.Native_DOMStringMap_item(this, key); | 489 String operator [](String key) => _blink.Native_DOMStringMap_item(this, key); |
490 void operator []=(String key, String value) => blink.Native_DOMStringMap_setIt
em(this, key, value); | 490 void operator []=(String key, String value) => _blink.Native_DOMStringMap_setI
tem(this, key, value); |
491 String putIfAbsent(String key, String ifAbsent()) => Maps.putIfAbsent(this, ke
y, ifAbsent); | 491 String putIfAbsent(String key, String ifAbsent()) => Maps.putIfAbsent(this, ke
y, ifAbsent); |
492 String remove(String key) => blink.Native_DOMStringMap_remove(this, key); | 492 String remove(String key) => _blink.Native_DOMStringMap_remove(this, key); |
493 void clear() => Maps.clear(this); | 493 void clear() => Maps.clear(this); |
494 void forEach(void f(String key, String value)) => Maps.forEach(this, f); | 494 void forEach(void f(String key, String value)) => Maps.forEach(this, f); |
495 Iterable<String> get keys => blink.Native_DOMStringMap_get_keys(this, keys); | 495 Iterable<String> get keys => _blink.Native_DOMStringMap_get_keys(this, keys); |
496 Iterable<String> get values => Maps.getValues(this); | 496 Iterable<String> get values => Maps.getValues(this); |
497 int get length => Maps.length(this); | 497 int get length => Maps.length(this); |
498 bool get isEmpty => Maps.isEmpty(this); | 498 bool get isEmpty => Maps.isEmpty(this); |
499 bool get isNotEmpty => Maps.isNotEmpty(this); | 499 bool get isNotEmpty => Maps.isNotEmpty(this); |
500 void addAll(Map<String, String> other) { | 500 void addAll(Map<String, String> other) { |
501 other.forEach((key, value) => this[key] = value); | 501 other.forEach((key, value) => this[key] = value); |
502 } | 502 } |
503 } | 503 } |
504 | 504 |
505 final _printClosure = window.console.log; | 505 final _printClosure = window.console.log; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 _scheduleImmediateHelper._schedule(callback); | 599 _scheduleImmediateHelper._schedule(callback); |
600 }; | 600 }; |
601 | 601 |
602 get _pureIsolateScheduleImmediateClosure => ((void callback()) => | 602 get _pureIsolateScheduleImmediateClosure => ((void callback()) => |
603 throw new UnimplementedError("scheduleMicrotask in background isolates " | 603 throw new UnimplementedError("scheduleMicrotask in background isolates " |
604 "are not supported in the browser")); | 604 "are not supported in the browser")); |
605 | 605 |
606 void _initializeCustomElement(Element e) { | 606 void _initializeCustomElement(Element e) { |
607 _Utils.initializeCustomElement(e); | 607 _Utils.initializeCustomElement(e); |
608 } | 608 } |
OLD | NEW |