| Index: lib/dom/src/native_DOMImplementation.dart
|
| diff --git a/lib/dom/src/native_DOMImplementation.dart b/lib/dom/src/native_DOMImplementation.dart
|
| index 677975125cbf7be8e14e088b7c911e9bb7d14f87..3338ce88ec7a14fa37a7b7824de2b897977e4ca1 100644
|
| --- a/lib/dom/src/native_DOMImplementation.dart
|
| +++ b/lib/dom/src/native_DOMImplementation.dart
|
| @@ -2,53 +2,86 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -class Utils {
|
| - static List convertToList(List list) {
|
| - // FIXME: [possible optimization]: do not copy the array if Dart_IsArray is fine w/ it.
|
| - final length = list.length;
|
| - List result = new List(length);
|
| - result.copyFrom(list, 0, 0, length);
|
| - return result;
|
| - }
|
| +_dom_window() native "Utils_window";
|
|
|
| - static List convertMapToList(Map map) {
|
| - List result = [];
|
| - map.forEach((k, v) => result.addAll([k, v]));
|
| - return result;
|
| +// This API is exploratory.
|
| +spawnDomIsolate(Window targetWindowWrapped, String entryPoint) {
|
| + final targetWindow = _unwrap(targetWindowWrapped);
|
| + if (targetWindow is! _DOMWindowDOMImpl && targetWindow is! _DOMWindowCrossFrameDOMImpl) {
|
| + throw 'Bad window argument: $targetWindow';
|
| }
|
| + final result = new Completer<SendPort>();
|
| + final port = _spawnDomIsolateImpl(targetWindow, entryPoint);
|
| + window.setTimeout(() { result.complete(port); }, 0);
|
| + return result.future;
|
| +}
|
|
|
| - static void populateMap(Map result, List list) {
|
| - for (int i = 0; i < list.length; i += 2) {
|
| - result[list[i]] = list[i + 1];
|
| - }
|
| - }
|
| +SendPort _spawnDomIsolateImpl(_DOMWindow window, String entryPoint) native "Utils_spawnDomIsolate";
|
|
|
| - static bool isMap(obj) => obj is Map;
|
| +// layoutTestController implementation.
|
| +// FIXME: provide a separate lib for layoutTestController.
|
|
|
| - static Map createMap() => {};
|
| +var _layoutTestController;
|
|
|
| - static makeNotImplementedException(String fileName, int lineNo) {
|
| - return new UnsupportedOperationException('[info: $fileName:$lineNo]');
|
| - }
|
| +LayoutTestController get layoutTestController() {
|
| + if (_layoutTestController === null)
|
| + _layoutTestController = new LayoutTestController._(_NPObject.retrieve("layoutTestController"));
|
| + return _layoutTestController;
|
| +}
|
| +
|
| +class LayoutTestController {
|
| + final _NPObject _npObject;
|
| +
|
| + LayoutTestController._(this._npObject);
|
|
|
| - static window() native "Utils_window";
|
| - static print(String message) native "Utils_print";
|
| - static SendPort spawnDomIsolate(Window window, String entryPoint) native "Utils_spawnDomIsolate";
|
| + display() => _npObject.invoke('display');
|
| + dumpAsText() => _npObject.invoke('dumpAsText');
|
| + notifyDone() => _npObject.invoke('notifyDone');
|
| + setCanOpenWindows() => _npObject.invoke('setCanOpenWindows');
|
| + waitUntilDone() => _npObject.invoke('waitUntilDone');
|
| }
|
|
|
| -/*
|
| - * [NPObjectBase] is native wrapper class injected from embedder's code.
|
| - */
|
| -class NPObject extends DOMWrapperBase {
|
| - static NPObject retrieve(String key) native "NPObject_retrieve";
|
| +class _NPObject extends _DOMWrapperBase {
|
| + static _NPObject retrieve(String key) native "NPObject_retrieve";
|
| property(String propertyName) native "NPObject_property";
|
| invoke(String methodName, [ObjectArray args = null]) native "NPObject_invoke";
|
|
|
| - static _createNPObject() => new NPObject._createNPObject();
|
| - NPObject._createNPObject();
|
| + _NPObject._createNPObject();
|
| +}
|
| +
|
| +_create_NPObject() => new _NPObject._createNPObject();
|
| +
|
| +List _Utils_convertToList(List list) {
|
| + // FIXME: [possible optimization]: do not copy the array if Dart_IsArray is fine w/ it.
|
| + final length = list.length;
|
| + List result = new List(length);
|
| + result.copyFrom(list, 0, 0, length);
|
| + return result;
|
| +}
|
| +
|
| +List _Utils_convertMapToList(Map map) {
|
| + List result = [];
|
| + map.forEach((k, v) => result.addAll([k, v]));
|
| + return result;
|
| +}
|
| +
|
| +_Utils_populateMap(Map result, List list) {
|
| + for (int i = 0; i < list.length; i += 2) {
|
| + result[list[i]] = list[i + 1];
|
| + }
|
| }
|
|
|
| -class DOMWindowCrossFrameImplementation extends DOMWrapperBase implements DOMWindow {
|
| +bool _Utils_isMap(obj) => obj is Map;
|
| +
|
| +Map _Utils_createMap() => {};
|
| +
|
| +_Utils_makeNotImplementedException(String fileName, int lineNo) {
|
| + return new UnsupportedOperationException('[info: $fileName:$lineNo]');
|
| +}
|
| +
|
| +Utils_print(String message) native "Utils_print";
|
| +
|
| +class _DOMWindowCrossFrameDOMImpl extends _DOMWrapperBase implements _DOMWindow {
|
| // Fields.
|
| History get history() native "DOMWindow_history_cross_frame_Getter";
|
| Location get location() native "DOMWindow_location_cross_frame_Getter";
|
| @@ -65,50 +98,32 @@ class DOMWindowCrossFrameImplementation extends DOMWrapperBase implements DOMWin
|
| void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List messagePorts]) native "DOMWindow_postMessage_Callback";
|
|
|
| // Implementation support.
|
| - static DOMWindowCrossFrameImplementation _createDOMWindowCrossFrameImplementation() => new DOMWindowCrossFrameImplementation._createDOMWindowCrossFrameImplementation();
|
| - DOMWindowCrossFrameImplementation._createDOMWindowCrossFrameImplementation();
|
| -
|
| + _DOMWindowCrossFrameDOMImpl._create_DOMWindowCrossFrameDOMImpl();
|
| String get typeName() => "DOMWindow";
|
| }
|
|
|
| -class HistoryCrossFrameImplementation extends DOMWrapperBase implements History {
|
| +_create_DOMWindowCrossFrameDOMImpl() => new _DOMWindowCrossFrameDOMImpl._create_DOMWindowCrossFrameDOMImpl();
|
| +
|
| +class _HistoryCrossFrameDOMImpl extends _DOMWrapperBase implements _History {
|
| // Methods.
|
| void back() native "History_back_Callback";
|
| void forward() native "History_forward_Callback";
|
| void go(int distance) native "History_go_Callback";
|
|
|
| // Implementation support.
|
| - static HistoryCrossFrameImplementation _createHistoryCrossFrameImplementation() => new HistoryCrossFrameImplementation._createHistoryCrossFrameImplementation();
|
| - HistoryCrossFrameImplementation._createHistoryCrossFrameImplementation();
|
| -
|
| + _HistoryCrossFrameDOMImpl._create_HistoryCrossFrameDOMImpl();
|
| String get typeName() => "History";
|
| }
|
|
|
| -class LocationCrossFrameImplementation extends DOMWrapperBase implements Location {
|
| +_create_HistoryCrossFrameDOMImpl() => new _HistoryCrossFrameDOMImpl._create_HistoryCrossFrameDOMImpl();
|
| +
|
| +class _LocationCrossFrameDOMImpl extends _DOMWrapperBase implements _Location {
|
| // Fields.
|
| void set href(String) native "Location_href_Setter";
|
|
|
| // Implementation support.
|
| - static LocationCrossFrameImplementation _createLocationCrossFrameImplementation() => new LocationCrossFrameImplementation._createLocationCrossFrameImplementation();
|
| - LocationCrossFrameImplementation._createLocationCrossFrameImplementation();
|
| -
|
| + _LocationCrossFrameDOMImpl._create_LocationCrossFrameDOMImpl();
|
| String get typeName() => "Location";
|
| }
|
|
|
| -class DOMStringMapImplementation extends DOMWrapperBase implements DOMStringMap {
|
| - static DOMStringMapImplementation _createDOMStringMapImplementation() => new DOMStringMapImplementation._createDOMStringMapImplementation();
|
| - DOMStringMapImplementation._createDOMStringMapImplementation();
|
| -
|
| - bool containsValue(String value) => Maps.containsValue(this, value);
|
| - bool containsKey(String key) native "DOMStringMap_containsKey_Callback";
|
| - String operator [](String key) native "DOMStringMap_item_Callback";
|
| - void operator []=(String key, String value) native "DOMStringMap_setItem_Callback";
|
| - String putIfAbsent(String key, String ifAbsent()) => Maps.putIfAbsent(this, key, ifAbsent);
|
| - String remove(String key) native "DOMStringMap_remove_Callback";
|
| - void clear() => Maps.clear(this);
|
| - void forEach(void f(String key, String value)) => Maps.forEach(this, f);
|
| - Collection<String> getKeys() native "DOMStringMap_getKeys_Callback";
|
| - Collection<String> getValues() => Maps.getValues(this);
|
| - int get length() => Maps.length(this);
|
| - bool isEmpty() => Maps.isEmpty(this);
|
| -}
|
| +_create_LocationCrossFrameDOMImpl() => new _LocationCrossFrameDOMImpl._create_LocationCrossFrameDOMImpl();
|
|
|