| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 part of html; | |
| 6 | |
| 7 class _Utils { | |
| 8 static List convertToList(List list) { | |
| 9 // FIXME: [possible optimization]: do not copy the array if Dart_IsArray is
fine w/ it. | |
| 10 final length = list.length; | |
| 11 List result = new List(length); | |
| 12 result.setRange(0, length, list); | |
| 13 return result; | |
| 14 } | |
| 15 | |
| 16 static List convertMapToList(Map map) { | |
| 17 List result = []; | |
| 18 map.forEach((k, v) => result.addAll([k, v])); | |
| 19 return result; | |
| 20 } | |
| 21 | |
| 22 static void populateMap(Map result, List list) { | |
| 23 for (int i = 0; i < list.length; i += 2) { | |
| 24 result[list[i]] = list[i + 1]; | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 static bool isMap(obj) => obj is Map; | |
| 29 | |
| 30 static Map createMap() => {}; | |
| 31 | |
| 32 static makeUnimplementedError(String fileName, int lineNo) { | |
| 33 return new UnsupportedError('[info: $fileName:$lineNo]'); | |
| 34 } | |
| 35 | |
| 36 static window() native "Utils_window"; | |
| 37 static print(String message) native "Utils_print"; | |
| 38 static SendPort spawnDomFunctionImpl(Function topLevelFunction) native "Utils_
spawnDomFunction"; | |
| 39 static int _getNewIsolateId() native "Utils_getNewIsolateId"; | |
| 40 static bool shadowRootSupported(Document document) native "Utils_shadowRootSup
ported"; | |
| 41 } | |
| 42 | |
| 43 class _NPObject extends NativeFieldWrapperClass1 { | |
| 44 _NPObject.internal(); | |
| 45 static _NPObject retrieve(String key) native "NPObject_retrieve"; | |
| 46 property(String propertyName) native "NPObject_property"; | |
| 47 invoke(String methodName, [List args = null]) native "NPObject_invoke"; | |
| 48 } | |
| 49 | |
| 50 class _DOMWindowCrossFrame extends NativeFieldWrapperClass1 implements | |
| 51 WindowBase { | |
| 52 _DOMWindowCrossFrame.internal(); | |
| 53 | |
| 54 // Fields. | |
| 55 HistoryBase get history native "DOMWindow_history_cross_frame_Getter"; | |
| 56 LocationBase get location native "DOMWindow_location_cross_frame_Getter"; | |
| 57 bool get closed native "DOMWindow_closed_Getter"; | |
| 58 int get length native "DOMWindow_length_Getter"; | |
| 59 WindowBase get opener native "DOMWindow_opener_Getter"; | |
| 60 WindowBase get parent native "DOMWindow_parent_Getter"; | |
| 61 WindowBase get top native "DOMWindow_top_Getter"; | |
| 62 | |
| 63 // Methods. | |
| 64 void close() native "DOMWindow_close_Callback"; | |
| 65 void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List
messagePorts]) native "DOMWindow_postMessage_Callback"; | |
| 66 | |
| 67 // Implementation support. | |
| 68 String get typeName => "DOMWindow"; | |
| 69 } | |
| 70 | |
| 71 class _HistoryCrossFrame extends NativeFieldWrapperClass1 implements HistoryBase
{ | |
| 72 _HistoryCrossFrame.internal(); | |
| 73 | |
| 74 // Methods. | |
| 75 void back() native "History_back_Callback"; | |
| 76 void forward() native "History_forward_Callback"; | |
| 77 void go(int distance) native "History_go_Callback"; | |
| 78 | |
| 79 // Implementation support. | |
| 80 String get typeName => "History"; | |
| 81 } | |
| 82 | |
| 83 class _LocationCrossFrame extends NativeFieldWrapperClass1 implements LocationBa
se { | |
| 84 _LocationCrossFrame.internal(); | |
| 85 | |
| 86 // Fields. | |
| 87 void set href(String) native "Location_href_Setter"; | |
| 88 | |
| 89 // Implementation support. | |
| 90 String get typeName => "Location"; | |
| 91 } | |
| 92 | |
| 93 class _DOMStringMap extends NativeFieldWrapperClass1 implements Map<String, Stri
ng> { | |
| 94 _DOMStringMap.internal(); | |
| 95 | |
| 96 bool containsValue(String value) => Maps.containsValue(this, value); | |
| 97 bool containsKey(String key) native "DOMStringMap_containsKey_Callback"; | |
| 98 String operator [](String key) native "DOMStringMap_item_Callback"; | |
| 99 void operator []=(String key, String value) native "DOMStringMap_setItem_Callb
ack"; | |
| 100 String putIfAbsent(String key, String ifAbsent()) => Maps.putIfAbsent(this, ke
y, ifAbsent); | |
| 101 String remove(String key) native "DOMStringMap_remove_Callback"; | |
| 102 void clear() => Maps.clear(this); | |
| 103 void forEach(void f(String key, String value)) => Maps.forEach(this, f); | |
| 104 Collection<String> get keys native "DOMStringMap_getKeys_Callback"; | |
| 105 Collection<String> get values => Maps.getValues(this); | |
| 106 int get length => Maps.length(this); | |
| 107 bool get isEmpty => Maps.isEmpty(this); | |
| 108 } | |
| 109 | |
| 110 get _printClosure => (s) { | |
| 111 try { | |
| 112 window.console.log(s); | |
| 113 } catch (_) { | |
| 114 _Utils.print(s); | |
| 115 } | |
| 116 }; | |
| OLD | NEW |