| Index: tools/dom/templates/html/dartium/html_dartium.darttemplate
|
| diff --git a/tools/dom/templates/html/dartium/html_dartium.darttemplate b/tools/dom/templates/html/dartium/html_dartium.darttemplate
|
| index 222865b43a178372775c7fc42d88be8f5e4847e7..4bd7279dea509a1dab4397a3a9d88d2121f87e69 100644
|
| --- a/tools/dom/templates/html/dartium/html_dartium.darttemplate
|
| +++ b/tools/dom/templates/html/dartium/html_dartium.darttemplate
|
| @@ -117,7 +117,7 @@ Window get window {
|
| }
|
| $if DARTIUM
|
| $if JSINTEROP
|
| - _window = wrap_jso(js.context['window']);
|
| + _window = wrap_jso(js.JsNative.getProperty(js.context, 'window'));
|
| $else
|
| _window = _Utils.window();
|
| $endif
|
| @@ -355,7 +355,11 @@ Function _getSvgFunction(String key) {
|
| var _knownCustomeElements = new Map<String, Type>();
|
|
|
| Rectangle make_dart_rectangle(r) =>
|
| - r == null ? null : new Rectangle(r['left'], r['top'], r['width'], r['height']);
|
| + r == null ? null : new Rectangle(
|
| + js.JsNative.getProperty(r, 'left'),
|
| + js.JsNative.getProperty(r, 'top'),
|
| + js.JsNative.getProperty(r, 'width'),
|
| + js.JsNative.getProperty(r, 'height'));
|
|
|
| // Need a default constructor for constructing classes with mixins that are
|
| // also extending NativeFieldWrapperClass2. Defining JsoNativeFieldWrapper
|
| @@ -409,11 +413,12 @@ wrap_jso(jsObject) {
|
| if (!identical(converted, jsObject)) {
|
| return converted;
|
| }
|
| - var constructor = jsObject['constructor'];
|
| +
|
| + var constructor = js.JsNative.getProperty(jsObject, 'constructor');
|
| if (__interop_checks) {
|
| debug_or_assert("constructor != null", constructor != null);
|
| }
|
| - var jsTypeName = constructor['name'];
|
| + var jsTypeName = js.JsNative.getProperty(constructor, 'name');
|
| if (__interop_checks) {
|
| debug_or_assert("constructor != null && jsTypeName.length > 0", constructor != null && jsTypeName.length > 0);
|
| }
|
| @@ -444,6 +449,7 @@ wrap_jso(jsObject) {
|
| }
|
| }
|
| }
|
| + // TODO(jacobr): cache that this is not a dart:html JS class.
|
| return dartClass_instance;
|
| } catch(e, stacktrace){
|
| if (__interop_checks) {
|
| @@ -458,6 +464,61 @@ wrap_jso(jsObject) {
|
| }
|
|
|
| /**
|
| + * Create Dart class that maps to the JS Type, add the JsObject as an expando
|
| + * on the Dart class and return the created Dart class.
|
| + */
|
| +wrap_jso_no_SerializedScriptvalue(jsObject) {
|
| + try {
|
| + if (jsObject is! js.JsObject || jsObject == null) {
|
| + // JS Interop converted the object to a Dart class e.g., Uint8ClampedList.
|
| + // or it's a simple type.
|
| + return jsObject;
|
| + }
|
| +
|
| + // TODO(alanknight): With upgraded custom elements this causes a failure because
|
| + // we need a new wrapper after the type changes. We could possibly invalidate this
|
| + // if the constructor name didn't match?
|
| + var wrapper = js.getDartHtmlWrapperFor(jsObject);
|
| + if (wrapper != null) {
|
| + return wrapper;
|
| + }
|
| +
|
| + if (jsObject is js.JsArray) {
|
| + var wrappingList = new _DartHtmlWrappingList(jsObject);
|
| + js.setDartHtmlWrapperFor(jsObject, wrappingList);
|
| + return wrappingList;
|
| + }
|
| +
|
| + var constructor = js.JsNative.getProperty(jsObject, 'constructor');
|
| + if (__interop_checks) {
|
| + debug_or_assert("constructor != null", constructor != null);
|
| + }
|
| + var jsTypeName = js.JsNative.getProperty(constructor, 'name');
|
| + if (__interop_checks) {
|
| + debug_or_assert("constructor != null && jsTypeName.length > 0", constructor != null && jsTypeName.length > 0);
|
| + }
|
| +
|
| + var func = getHtmlCreateFunction(jsTypeName);
|
| + if (func != null) {
|
| + var dartClass_instance = func();
|
| + dartClass_instance.blink_jsObject = jsObject;
|
| + js.setDartHtmlWrapperFor(jsObject, dartClass_instance);
|
| + return dartClass_instance;
|
| + }
|
| + return jsObject;
|
| + } catch(e, stacktrace){
|
| + if (__interop_checks) {
|
| + if (e is DebugAssertException)
|
| + window.console.log("${e.message}\n ${stacktrace}");
|
| + else
|
| + window.console.log("${stacktrace}");
|
| + }
|
| + }
|
| +
|
| + return null;
|
| +}
|
| +
|
| +/**
|
| * Create Dart class that maps to the JS Type that is the JS type being
|
| * extended using JS interop createCallback (we need the base type of the
|
| * custom element) not the Dart created constructor.
|
| @@ -549,9 +610,9 @@ js.JsFunction wrap_event_listener(theObject, Function listener) {
|
|
|
| Map<String, dynamic> convertNativeObjectToDartMap(js.JsObject jsObject) {
|
| var result = new Map();
|
| - var keys = js.context['Object'].callMethod('keys', [jsObject]);
|
| + var keys = js.JsNative.callMethod(js.JsNative.getProperty(js.context, 'Object'), 'keys', [jsObject]);
|
| for (var key in keys) {
|
| - result[key] = wrap_jso(jsObject[key]);
|
| + result[key] = wrap_jso(js.JsNative.getProperty(jsObject, key));
|
| }
|
| return result;
|
| }
|
| @@ -562,7 +623,7 @@ Map<String, dynamic> convertNativeObjectToDartMap(js.JsObject jsObject) {
|
| // code in html_common and be more general.
|
| convertDartToNative_Dictionary(Map dict) {
|
| if (dict == null) return null;
|
| - var jsObject = new js.JsObject(js.context['Object']);
|
| + var jsObject = new js.JsObject(js.JsNative.getProperty(js.context, 'Object'));
|
| dict.forEach((String key, value) {
|
| if (value is List) {
|
| var jsArray = new js.JsArray();
|
| @@ -586,17 +647,17 @@ List convertDartToNative_StringArray(List<String> input) => input;
|
| /**
|
| * Wraps a JsArray and will call wrap_jso on its entries.
|
| */
|
| -class _DartHtmlWrappingList extends ListBase {
|
| - _DartHtmlWrappingList(this._basicList);
|
| +class _DartHtmlWrappingList extends ListBase implements NativeFieldWrapperClass2 {
|
| + _DartHtmlWrappingList(this.blink_jsObject);
|
|
|
| - final js.JsArray _basicList;
|
| + final js.JsArray blink_jsObject;
|
|
|
| - operator [](int index) => wrap_jso(_basicList[index]);
|
| + operator [](int index) => wrap_jso(js.JsNative.getArrayIndex(blink_jsObject, index));
|
|
|
| - operator []=(int index, value) => _basicList[index] = unwrap_jso(value);
|
| + operator []=(int index, value) => blink_jsObject[index] = value;
|
|
|
| - int get length => _basicList.length;
|
| - int set length(int newLength) => _basicList.length = newLength;
|
| + int get length => blink_jsObject.length;
|
| + int set length(int newLength) => blink_jsObject.length = newLength;
|
| }
|
|
|
| /**
|
| @@ -612,7 +673,7 @@ createCustomUpgrader(Type customElementClass, $this) {
|
| // Need to remember the Dart class that was created for this custom so
|
| // return it and setup the blink_jsObject to the $this that we'll be working
|
| // with as we talk to blink.
|
| - $this['dart_class'] = dartClass;
|
| + js.setDartHtmlWrapperFor($this, dartClass);
|
| }
|
|
|
| return dartClass;
|
|
|