| 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 class _Utils { | 5 class _Utils { |
| 6 static List convertToList(List list) { | 6 static List convertToList(List list) { |
| 7 // FIXME: [possible optimization]: do not copy the array if Dart_IsArray is
fine w/ it. | 7 // FIXME: [possible optimization]: do not copy the array if Dart_IsArray is
fine w/ it. |
| 8 final length = list.length; | 8 final length = list.length; |
| 9 List result = new List(length); | 9 List result = new List(length); |
| 10 result.setRange(0, length, list); | 10 result.setRange(0, length, list); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 | 33 |
| 34 static window() native "Utils_window"; | 34 static window() native "Utils_window"; |
| 35 static print(String message) native "Utils_print"; | 35 static print(String message) native "Utils_print"; |
| 36 static SendPort spawnDomFunctionImpl(Function topLevelFunction) native "Utils_
spawnDomFunction"; | 36 static SendPort spawnDomFunctionImpl(Function topLevelFunction) native "Utils_
spawnDomFunction"; |
| 37 static int _getNewIsolateId() native "Utils_getNewIsolateId"; | 37 static int _getNewIsolateId() native "Utils_getNewIsolateId"; |
| 38 static bool shadowRootSupported(Document document) native "Utils_shadowRootSup
ported"; | 38 static bool shadowRootSupported(Document document) native "Utils_shadowRootSup
ported"; |
| 39 } | 39 } |
| 40 | 40 |
| 41 class _NPObject extends NativeFieldWrapperClass1 { | 41 class _NPObject extends NativeFieldWrapperClass1 { |
| 42 _NPObject(); | 42 _NPObject.internal(); |
| 43 static _NPObject retrieve(String key) native "NPObject_retrieve"; | 43 static _NPObject retrieve(String key) native "NPObject_retrieve"; |
| 44 property(String propertyName) native "NPObject_property"; | 44 property(String propertyName) native "NPObject_property"; |
| 45 invoke(String methodName, [List args = null]) native "NPObject_invoke"; | 45 invoke(String methodName, [List args = null]) native "NPObject_invoke"; |
| 46 } | 46 } |
| 47 | 47 |
| 48 class _DOMWindowCrossFrameImpl extends NativeFieldWrapperClass1 implements Windo
w { | 48 class _DOMWindowCrossFrame extends NativeFieldWrapperClass1 implements Window { |
| 49 _DOMWindowCrossFrameImpl(); | 49 _DOMWindowCrossFrame.internal(); |
| 50 | 50 |
| 51 // Fields. | 51 // Fields. |
| 52 History get history() native "DOMWindow_history_cross_frame_Getter"; | 52 History get history() native "DOMWindow_history_cross_frame_Getter"; |
| 53 Location get location() native "DOMWindow_location_cross_frame_Getter"; | 53 Location get location() native "DOMWindow_location_cross_frame_Getter"; |
| 54 bool get closed() native "DOMWindow_closed_Getter"; | 54 bool get closed() native "DOMWindow_closed_Getter"; |
| 55 int get length() native "DOMWindow_length_Getter"; | 55 int get length() native "DOMWindow_length_Getter"; |
| 56 Window get opener() native "DOMWindow_opener_Getter"; | 56 Window get opener() native "DOMWindow_opener_Getter"; |
| 57 Window get parent() native "DOMWindow_parent_Getter"; | 57 Window get parent() native "DOMWindow_parent_Getter"; |
| 58 Window get top() native "DOMWindow_top_Getter"; | 58 Window get top() native "DOMWindow_top_Getter"; |
| 59 | 59 |
| 60 // Methods. | 60 // Methods. |
| 61 void focus() native "DOMWindow_focus_Callback"; | 61 void focus() native "DOMWindow_focus_Callback"; |
| 62 void blur() native "DOMWindow_blur_Callback"; | 62 void blur() native "DOMWindow_blur_Callback"; |
| 63 void close() native "DOMWindow_close_Callback"; | 63 void close() native "DOMWindow_close_Callback"; |
| 64 void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List
messagePorts]) native "DOMWindow_postMessage_Callback"; | 64 void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List
messagePorts]) native "DOMWindow_postMessage_Callback"; |
| 65 | 65 |
| 66 // Implementation support. | 66 // Implementation support. |
| 67 String get typeName => "DOMWindow"; | 67 String get typeName => "DOMWindow"; |
| 68 } | 68 } |
| 69 | 69 |
| 70 class _HistoryCrossFrameImpl extends NativeFieldWrapperClass1 implements History
{ | 70 class _HistoryCrossFrame extends NativeFieldWrapperClass1 implements History { |
| 71 _HistoryCrossFrameImpl(); | 71 _HistoryCrossFrame.internal(); |
| 72 | 72 |
| 73 // Methods. | 73 // Methods. |
| 74 void back() native "History_back_Callback"; | 74 void back() native "History_back_Callback"; |
| 75 void forward() native "History_forward_Callback"; | 75 void forward() native "History_forward_Callback"; |
| 76 void go(int distance) native "History_go_Callback"; | 76 void go(int distance) native "History_go_Callback"; |
| 77 | 77 |
| 78 // Implementation support. | 78 // Implementation support. |
| 79 String get typeName => "History"; | 79 String get typeName => "History"; |
| 80 } | 80 } |
| 81 | 81 |
| 82 class _LocationCrossFrameImpl extends NativeFieldWrapperClass1 implements Locati
on { | 82 class _LocationCrossFrame extends NativeFieldWrapperClass1 implements Location { |
| 83 _LocationCrossFrameImpl(); | 83 _LocationCrossFrame.internal(); |
| 84 | 84 |
| 85 // Fields. | 85 // Fields. |
| 86 void set href(String) native "Location_href_Setter"; | 86 void set href(String) native "Location_href_Setter"; |
| 87 | 87 |
| 88 // Implementation support. | 88 // Implementation support. |
| 89 String get typeName => "Location"; | 89 String get typeName => "Location"; |
| 90 } | 90 } |
| 91 | 91 |
| 92 class _DOMStringMapImpl extends NativeFieldWrapperClass1 implements Map<String,
String> { | 92 class _DOMStringMap extends NativeFieldWrapperClass1 implements Map<String, Stri
ng> { |
| 93 _DOMStringMapImpl(); | 93 _DOMStringMap.internal(); |
| 94 | 94 |
| 95 bool containsValue(String value) => Maps.containsValue(this, value); | 95 bool containsValue(String value) => Maps.containsValue(this, value); |
| 96 bool containsKey(String key) native "DOMStringMap_containsKey_Callback"; | 96 bool containsKey(String key) native "DOMStringMap_containsKey_Callback"; |
| 97 String operator [](String key) native "DOMStringMap_item_Callback"; | 97 String operator [](String key) native "DOMStringMap_item_Callback"; |
| 98 void operator []=(String key, String value) native "DOMStringMap_setItem_Callb
ack"; | 98 void operator []=(String key, String value) native "DOMStringMap_setItem_Callb
ack"; |
| 99 String putIfAbsent(String key, String ifAbsent()) => Maps.putIfAbsent(this, ke
y, ifAbsent); | 99 String putIfAbsent(String key, String ifAbsent()) => Maps.putIfAbsent(this, ke
y, ifAbsent); |
| 100 String remove(String key) native "DOMStringMap_remove_Callback"; | 100 String remove(String key) native "DOMStringMap_remove_Callback"; |
| 101 void clear() => Maps.clear(this); | 101 void clear() => Maps.clear(this); |
| 102 void forEach(void f(String key, String value)) => Maps.forEach(this, f); | 102 void forEach(void f(String key, String value)) => Maps.forEach(this, f); |
| 103 Collection<String> get keys native "DOMStringMap_getKeys_Callback"; | 103 Collection<String> get keys native "DOMStringMap_getKeys_Callback"; |
| 104 Collection<String> get values => Maps.getValues(this); | 104 Collection<String> get values => Maps.getValues(this); |
| 105 int get length => Maps.length(this); | 105 int get length => Maps.length(this); |
| 106 bool get isEmpty => Maps.isEmpty(this); | 106 bool get isEmpty => Maps.isEmpty(this); |
| 107 } | 107 } |
| 108 | 108 |
| 109 get _printClosure => (s) { | 109 get _printClosure => (s) { |
| 110 try { | 110 try { |
| 111 window.console.log(s); | 111 window.console.log(s); |
| 112 } catch (_) { | 112 } catch (_) { |
| 113 _Utils.print(s); | 113 _Utils.print(s); |
| 114 } | 114 } |
| 115 }; | 115 }; |
| OLD | NEW |