| 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.copyFrom(list, 0, 0, length); | 10 result.copyFrom(list, 0, 0, length); |
| 11 return result; | 11 return result; |
| 12 } | 12 } |
| 13 | 13 |
| 14 static List convertMapToList(Map map) { | 14 static List convertMapToList(Map map) { |
| 15 List result = []; | 15 List result = []; |
| 16 map.forEach((k, v) => result.addAll([k, v])); | 16 map.forEach((k, v) => result.addAll([k, v])); |
| 17 return result; | 17 return result; |
| 18 } | 18 } |
| 19 | 19 |
| 20 static void populateMap(Map result, List list) { | 20 static void populateMap(Map result, List list) { |
| 21 for (int i = 0; i < list.length; i += 2) { | 21 for (int i = 0; i < list.length; i += 2) { |
| 22 result[list[i]] = list[i + 1]; | 22 result[list[i]] = list[i + 1]; |
| 23 } | 23 } |
| 24 } | 24 } |
| 25 | 25 |
| 26 static bool isMap(obj) => obj is Map; | 26 static bool isMap(obj) => obj is Map; |
| 27 | 27 |
| 28 static Map createMap() => {}; | 28 static Map createMap() => {}; |
| 29 | 29 |
| 30 static makeNotImplementedException(String fileName, int lineNo) { | 30 static makeNotImplementedException(String fileName, int lineNo) { |
| 31 return new UnsupportedOperationException('[info: $fileName:$lineNo]'); | 31 return new UnsupportedOperationException('[info: $fileName:$lineNo]'); |
| 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 SendPort spawnDomIsolateImpl(_DOMWindow window, String entryPoint) nati
ve "Utils_spawnDomIsolate"; |
| 36 static SendPort spawnDomIsolate(Window window, String entryPoint) native "Util
s_spawnDomIsolate"; | |
| 37 } | 36 } |
| 38 | 37 |
| 39 /* | 38 Utils_print(String message) native "Utils_print"; |
| 40 * [NPObjectBase] is native wrapper class injected from embedder's code. | 39 |
| 41 */ | 40 class _NPObject extends _DOMWrapperBase { |
| 42 class NPObject extends DOMWrapperBase { | 41 static _NPObject retrieve(String key) native "NPObject_retrieve"; |
| 43 static NPObject retrieve(String key) native "NPObject_retrieve"; | |
| 44 property(String propertyName) native "NPObject_property"; | 42 property(String propertyName) native "NPObject_property"; |
| 45 invoke(String methodName, [ObjectArray args = null]) native "NPObject_invoke"; | 43 invoke(String methodName, [ObjectArray args = null]) native "NPObject_invoke"; |
| 46 | 44 |
| 47 static _createNPObject() => new NPObject._createNPObject(); | 45 static _create_NPObject() => new _NPObject._create_NPObject(); |
| 48 NPObject._createNPObject(); | 46 _NPObject._create_NPObject(); |
| 49 } | 47 } |
| 50 | 48 |
| 51 class DOMWindowCrossFrameImplementation extends DOMWrapperBase implements DOMWin
dow { | 49 class _DOMWindowCrossFrameDOMImpl extends _DOMWrapperBase implements _DOMWindow
{ |
| 52 // Fields. | 50 // Fields. |
| 53 History get history() native "DOMWindow_history_cross_frame_Getter"; | 51 History get history() native "DOMWindow_history_cross_frame_Getter"; |
| 54 Location get location() native "DOMWindow_location_cross_frame_Getter"; | 52 Location get location() native "DOMWindow_location_cross_frame_Getter"; |
| 55 bool get closed() native "DOMWindow_closed_Getter"; | 53 bool get closed() native "DOMWindow_closed_Getter"; |
| 56 int get length() native "DOMWindow_length_Getter"; | 54 int get length() native "DOMWindow_length_Getter"; |
| 57 DOMWindow get opener() native "DOMWindow_opener_Getter"; | 55 DOMWindow get opener() native "DOMWindow_opener_Getter"; |
| 58 DOMWindow get parent() native "DOMWindow_parent_Getter"; | 56 DOMWindow get parent() native "DOMWindow_parent_Getter"; |
| 59 DOMWindow get top() native "DOMWindow_top_Getter"; | 57 DOMWindow get top() native "DOMWindow_top_Getter"; |
| 60 | 58 |
| 61 // Methods. | 59 // Methods. |
| 62 void focus() native "DOMWindow_focus_Callback"; | 60 void focus() native "DOMWindow_focus_Callback"; |
| 63 void blur() native "DOMWindow_blur_Callback"; | 61 void blur() native "DOMWindow_blur_Callback"; |
| 64 void close() native "DOMWindow_close_Callback"; | 62 void close() native "DOMWindow_close_Callback"; |
| 65 void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List
messagePorts]) native "DOMWindow_postMessage_Callback"; | 63 void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List
messagePorts]) native "DOMWindow_postMessage_Callback"; |
| 66 | 64 |
| 67 // Implementation support. | 65 // Implementation support. |
| 68 static DOMWindowCrossFrameImplementation _createDOMWindowCrossFrameImplementat
ion() => new DOMWindowCrossFrameImplementation._createDOMWindowCrossFrameImpleme
ntation(); | 66 static _DOMWindowCrossFrameDOMImpl _create_DOMWindowCrossFrameDOMImpl() => new
_DOMWindowCrossFrameDOMImpl._create_DOMWindowCrossFrameDOMImpl(); |
| 69 DOMWindowCrossFrameImplementation._createDOMWindowCrossFrameImplementation(); | 67 _DOMWindowCrossFrameDOMImpl._create_DOMWindowCrossFrameDOMImpl(); |
| 70 | |
| 71 String get typeName() => "DOMWindow"; | 68 String get typeName() => "DOMWindow"; |
| 72 } | 69 } |
| 73 | 70 |
| 74 class HistoryCrossFrameImplementation extends DOMWrapperBase implements History
{ | 71 class _HistoryCrossFrameDOMImpl extends _DOMWrapperBase implements _History { |
| 75 // Methods. | 72 // Methods. |
| 76 void back() native "History_back_Callback"; | 73 void back() native "History_back_Callback"; |
| 77 void forward() native "History_forward_Callback"; | 74 void forward() native "History_forward_Callback"; |
| 78 void go(int distance) native "History_go_Callback"; | 75 void go(int distance) native "History_go_Callback"; |
| 79 | 76 |
| 80 // Implementation support. | 77 // Implementation support. |
| 81 static HistoryCrossFrameImplementation _createHistoryCrossFrameImplementation(
) => new HistoryCrossFrameImplementation._createHistoryCrossFrameImplementation(
); | 78 static _HistoryCrossFrameDOMImpl _create_HistoryCrossFrameDOMImpl() => new _Hi
storyCrossFrameDOMImpl._create_HistoryCrossFrameDOMImpl(); |
| 82 HistoryCrossFrameImplementation._createHistoryCrossFrameImplementation(); | 79 _HistoryCrossFrameDOMImpl._create_HistoryCrossFrameDOMImpl(); |
| 83 | |
| 84 String get typeName() => "History"; | 80 String get typeName() => "History"; |
| 85 } | 81 } |
| 86 | 82 |
| 87 class LocationCrossFrameImplementation extends DOMWrapperBase implements Locatio
n { | 83 class _LocationCrossFrameDOMImpl extends _DOMWrapperBase implements _Location { |
| 88 // Fields. | 84 // Fields. |
| 89 void set href(String) native "Location_href_Setter"; | 85 void set href(String) native "Location_href_Setter"; |
| 90 | 86 |
| 91 // Implementation support. | 87 // Implementation support. |
| 92 static LocationCrossFrameImplementation _createLocationCrossFrameImplementatio
n() => new LocationCrossFrameImplementation._createLocationCrossFrameImplementat
ion(); | 88 static _LocationCrossFrameDOMImpl _create_LocationCrossFrameDOMImpl() => new _
LocationCrossFrameDOMImpl._create_LocationCrossFrameDOMImpl(); |
| 93 LocationCrossFrameImplementation._createLocationCrossFrameImplementation(); | 89 _LocationCrossFrameDOMImpl._create_LocationCrossFrameDOMImpl(); |
| 94 | |
| 95 String get typeName() => "Location"; | 90 String get typeName() => "Location"; |
| 96 } | 91 } |
| 97 | |
| 98 class DOMStringMapImplementation extends DOMWrapperBase implements DOMStringMap
{ | |
| 99 static DOMStringMapImplementation _createDOMStringMapImplementation() => new D
OMStringMapImplementation._createDOMStringMapImplementation(); | |
| 100 DOMStringMapImplementation._createDOMStringMapImplementation(); | |
| 101 | |
| 102 bool containsValue(String value) => Maps.containsValue(this, value); | |
| 103 bool containsKey(String key) native "DOMStringMap_containsKey_Callback"; | |
| 104 String operator [](String key) native "DOMStringMap_item_Callback"; | |
| 105 void operator []=(String key, String value) native "DOMStringMap_setItem_Callb
ack"; | |
| 106 String putIfAbsent(String key, String ifAbsent()) => Maps.putIfAbsent(this, ke
y, ifAbsent); | |
| 107 String remove(String key) native "DOMStringMap_remove_Callback"; | |
| 108 void clear() => Maps.clear(this); | |
| 109 void forEach(void f(String key, String value)) => Maps.forEach(this, f); | |
| 110 Collection<String> getKeys() native "DOMStringMap_getKeys_Callback"; | |
| 111 Collection<String> getValues() => Maps.getValues(this); | |
| 112 int get length() => Maps.length(this); | |
| 113 bool isEmpty() => Maps.isEmpty(this); | |
| 114 } | |
| OLD | NEW |