Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1238)

Side by Side Diff: lib/dom/templates/html/dartium/html_dartium.darttemplate

Issue 10702110: Added Dartium support for JS to Dart PortSync calls (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed tabbing Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/dart.js ('k') | lib/dom/templates/html/dartium/impl_Window.darttemplate » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // DO NOT EDIT 5 // DO NOT EDIT
6 // Auto-generated dart:html library. 6 // Auto-generated dart:html library.
7 7
8 #library("html"); 8 #library("html");
9 9
10 #import("dart:isolate"); 10 #import("dart:isolate");
11 #import("dart:json"); 11 #import("dart:json");
12 #import("dart:nativewrappers"); 12 #import("dart:nativewrappers");
13 13
14 $!GENERATED_DART_FILES 14 $!GENERATED_DART_FILES
15 15
16 #source('$AUXILIARY_DIR/EventListener.dart'); 16 #source('$AUXILIARY_DIR/EventListener.dart');
17 #source('$AUXILIARY_DIR/KeyLocation.dart'); 17 #source('$AUXILIARY_DIR/KeyLocation.dart');
18 #source('$AUXILIARY_DIR/KeyName.dart'); 18 #source('$AUXILIARY_DIR/KeyName.dart');
19 #source('$AUXILIARY_DIR/ReadyState.dart'); 19 #source('$AUXILIARY_DIR/ReadyState.dart');
20 #source('$AUXILIARY_DIR/_Collections.dart'); 20 #source('$AUXILIARY_DIR/_Collections.dart');
21 #source('$AUXILIARY_DIR/_XMLHttpRequestUtils.dart'); 21 #source('$AUXILIARY_DIR/_XMLHttpRequestUtils.dart');
22 #source('$AUXILIARY_DIR/../../html/src/shared_FactoryProviders.dart'); 22 #source('$AUXILIARY_DIR/../../html/src/shared_FactoryProviders.dart');
23 #source('$AUXILIARY_DIR/../../html/src/dartium_FactoryProviders.dart'); 23 #source('$AUXILIARY_DIR/../../html/src/dartium_FactoryProviders.dart');
24 #source('$AUXILIARY_DIR/../../html/src/IDBOpenDBRequest.dart'); 24 #source('$AUXILIARY_DIR/../../html/src/IDBOpenDBRequest.dart');
25 #source('$AUXILIARY_DIR/../../html/src/Isolates.dart');
25 #source('$AUXILIARY_DIR/../../html/src/Measurement.dart'); 26 #source('$AUXILIARY_DIR/../../html/src/Measurement.dart');
26 #source('$AUXILIARY_DIR/../../html/src/Device.dart'); 27 #source('$AUXILIARY_DIR/../../html/src/Device.dart');
27 #source('$AUXILIARY_DIR/../../html/src/_Testing.dart'); 28 #source('$AUXILIARY_DIR/../../html/src/_Testing.dart');
28 #source('$AUXILIARY_DIR/_ListIterators.dart'); 29 #source('$AUXILIARY_DIR/_ListIterators.dart');
29 #source('$AUXILIARY_DIR/_Lists.dart'); 30 #source('$AUXILIARY_DIR/_Lists.dart');
30 #source('$AUXILIARY_DIR/../../isolate/serialization.dart'); 31 #source('$AUXILIARY_DIR/../../isolate/serialization.dart');
31 32
32 #source('$AUXILIARY_DIR/native_DOMPublic.dart'); 33 #source('$AUXILIARY_DIR/native_DOMPublic.dart');
33 #source('$AUXILIARY_DIR/native_DOMImplementation.dart'); 34 #source('$AUXILIARY_DIR/native_DOMImplementation.dart');
34 35
(...skipping 23 matching lines...) Expand all
58 59
59 Element query(String selector) => _document.query(selector); 60 Element query(String selector) => _document.query(selector);
60 ElementList queryAll(String selector) => _document.queryAll(selector); 61 ElementList queryAll(String selector) => _document.queryAll(selector);
61 62
62 class _Null { 63 class _Null {
63 const _Null(); 64 const _Null();
64 } 65 }
65 66
66 final _null = const _Null(); 67 final _null = const _Null();
67 68
68 // TODO(vsm): Move this to a separate Isolates.dart file. 69 int _getNewIsolateId() {
69 _serialize(var message) { 70 // TODO(vsm): We need a Dartium native for this.
70 // TODO(kasperl): Specialize the serializer. 71 return 1;
71 return new _Serializer().traverse(message);
72 } 72 }
73 73
74 _deserialize(var message) { 74 bool _callPortInitialized = false;
75 return new _JsDeserializer().deserialize(message); 75 var _callPortLastResult = null;
76
77 _callPortSync(num id, var message) {
78 if (!_callPortInitialized) {
79 window.on['js-result'].add((event) {
80 _callPortLastResult = JSON.parse(event.data);
81 }, false);
82 _callPortInitialized = true;
83 }
84 var data = JSON.stringify({ 'id': id, 'message': message });
85 var event = document.$dom_createEvent('TextEvent');
86 event.initTextEvent('js-sync-message', false, false, window, data);
87 assert(_callPortLastResult == null);
88 window.$dom_dispatchEvent(event);
89 var result = _callPortLastResult;
90 _callPortLastResult = null;
91 return result;
76 } 92 }
77
78 class _JsDeserializer extends _Deserializer {
79
80 deserializeSendPort(List x) {
81 num id = x[1];
82 return new _JsSendPortSync(id);
83 }
84
85 }
86
87 class _JsSendPortSync implements SendPortSync {
88
89 static bool initialized = false;
90 static var lastResult = null;
91
92 num _id;
93 _JsSendPortSync(this._id) {
94 if (initialized) return;
95 window.on['js-result'].add((event) {
96 lastResult = JSON.parse(event.data);
97 }, false);
98 initialized = true;
99 }
100
101 callSync(var message) {
102 var serialized = _serialize(message);
103 var result = _callUsingEvent(_id, serialized);
104 return _deserialize(result);
105 }
106
107 static _callUsingEvent(num id, var message) {
108 var data = JSON.stringify({ 'id': id, 'message': message });
109 var event = document.$dom_createEvent('TextEvent');
110 event.initTextEvent('js-sync-message', false, false, window, data);
111 assert(lastResult == null);
112 window.$dom_dispatchEvent(event);
113 var result = lastResult;
114 lastResult = null;
115 return result;
116 }
117
118 }
OLDNEW
« no previous file with comments | « client/dart.js ('k') | lib/dom/templates/html/dartium/impl_Window.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698