| Index: lib/html/dartium/html_dartium.dart
|
| diff --git a/lib/html/dartium/html_dartium.dart b/lib/html/dartium/html_dartium.dart
|
| index d7043ce0d118f06152f0e31f47e7dd8d846662a1..59923f0ea5e483d34ad7478e130f86485d739f5f 100644
|
| --- a/lib/html/dartium/html_dartium.dart
|
| +++ b/lib/html/dartium/html_dartium.dart
|
| @@ -40787,6 +40787,26 @@ class JsProxy {
|
| }
|
| }
|
|
|
| +int _localNextElementId = 0;
|
| +
|
| +const _DART_ID = 'data-dart_id';
|
| +
|
| +var _elementId(Element e) {
|
| + if (e.attributes.containsKey(_DART_ID)) return e.attributes[_DART_ID];
|
| + var id = '$_isolateId-${_localNextElementId++}';
|
| + e.attributes[_DART_ID] = id;
|
| + return id;
|
| +}
|
| +
|
| +Element _getElement(var id) {
|
| + var list = queryAll('[$_DART_ID="$id"]');
|
| + if (list.length > 1) throw 'Non unique ID: $id';
|
| + if (list.length == 0) {
|
| + throw 'Only elements attached to document can be serialized: $id';
|
| + }
|
| + return list[0];
|
| +}
|
| +
|
| class _JsSerializer extends _Serializer {
|
|
|
| visitSendPortSync(SendPortSync x) {
|
| @@ -40813,6 +40833,7 @@ class _JsSerializer extends _Serializer {
|
| visitObject(Object x) {
|
| if (x is Function) return visitFunction(x);
|
| if (x is JsProxy) return visitJsProxy(x);
|
| + if (x is Element) return visitElement(x);
|
|
|
| // TODO: Handle DOM elements and proxy other objects.
|
| var proxyId = _dartProxyRegistry._add(x);
|
| @@ -40829,6 +40850,14 @@ class _JsSerializer extends _Serializer {
|
| visitJsProxy(JsProxy proxy) {
|
| return [ 'objref', proxy._id, visitSendPortSync(proxy._port) ];
|
| }
|
| +
|
| + visitElement(Element element) {
|
| + var id = _elementId(element);
|
| + // Verify that the element is connected to the document.
|
| + // Otherwise, we will not be able to find it on the other side.
|
| + _getElement(id);
|
| + return [ 'element', id ];
|
| + }
|
| }
|
|
|
| // Leaking implementation. Later will be backend specific and hopefully
|
| @@ -40933,6 +40962,7 @@ class _JsDeserializer extends _Deserializer {
|
| switch (tag) {
|
| case 'funcref': return deserializeFunction(x);
|
| case 'objref': return deserializeProxy(x);
|
| + case 'element': return deserializeElement(x);
|
| default: throw 'Illegal object type: $x';
|
| }
|
| }
|
| @@ -40960,6 +40990,11 @@ class _JsDeserializer extends _Deserializer {
|
| if (port is _RemoteSendPortSync) throw 'Remote Dart proxies unsupported';
|
| throw 'Illegal proxy: $port';
|
| }
|
| +
|
| + deserializeElement(x) {
|
| + var id = x[1];
|
| + return _getElement(id);
|
| + }
|
| }
|
|
|
| // The receiver is JS.
|
| @@ -41097,6 +41132,8 @@ class ReceivePortSync {
|
| }
|
| }
|
|
|
| +get _isolateId => ReceivePortSync._isolateId;
|
| +
|
| void _dispatchEvent(String receiver, var message) {
|
| var event = document.$dom_createEvent('TextEvent');
|
| event.initTextEvent(receiver, false, false, window, JSON.stringify(message));
|
|
|