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

Side by Side Diff: sdk/lib/html/html_common/conversions_dartium.dart

Issue 1349293006: Start using the dart2js type conversions in Dartium as well. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged Created 5 years, 3 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
OLDNEW
(Empty)
1 part of html_common;
2
3 convertDartToNative_PrepareForStructuredClone(value) =>
4 new _StructuredCloneDartium().convertDartToNative_PrepareForStructuredClone( value);
5
6 convertNativeToDart_AcceptStructuredClone(object, {mustCopy: false}) =>
7 new _AcceptStructuredCloneDartium().convertNativeToDart_AcceptStructuredClon e(object, mustCopy: mustCopy);
8
9 class _StructuredCloneDartium extends _StructuredClone {
10 newJsMap() => new js.JsObject(js.context["Object"]);
11 putIntoMap(map, key, value) => map[key] = value;
12 newJSList(length) => new js.JsArray();
13 cloneNotRequired(e) => e is js.JsObject;
14 }
15
16 class _AcceptStructuredCloneDartium extends _AcceptStructuredClone {
17 newDartList(length) => new List(length);
18
19 // JsObjects won't be identical, but will be equal only if the underlying
20 // Js entities are identical.
21 bool identicalInJs(a, b) =>
22 (a is js.JsObject) ? a == b : identical(a, b);
23
24 void forEachJsField(jsObject, action) {
25 var keys = js.context["Object"].callMethod("keys", [jsObject]);
26 for (var key in keys) {
27 action(key, jsObject[key]);
28 }
29 }
30 }
31
32 final _dateConstructor = js.context["Date"];
33 final _regexConstructor = js.context["RegExp"];
34
35 bool isJavaScriptDate(value) => value is js.JsObject && value.instanceof(_dateCo nstructor);
36 bool isJavaScriptRegExp(value) => value is js.JsObject && value.instanceof(_rege xConstructor);
37 bool isJavaScriptArray(value) => value is js.JsArray;
38
39 final _object = js.context["Object"];
40 final _getPrototypeOf = _object["getPrototypeOf"];
41 _getProto(object) {
42 return _getPrototypeOf.apply([object]);
43 }
44 final _objectProto = js.context["Object"]["prototype"];
45
46 bool isJavaScriptSimpleObject(value) {
47 if (!value is js.JsObject) return false;
48 var proto = _getProto(value);
49 return proto == _objectProto || proto == null;
50 }
51 bool isImmutableJavaScriptArray(value) =>
52 isJavaScriptArray(value) && value["immutable$list"] != null;
53
54 final _promiseConstructor = js.context['Promise'];
55 bool isJavaScriptPromise(value) => value is js.JsObject && value['constructor'] == _promiseConstructor;
56
57 Future convertNativePromiseToDartFuture(js.JsObject promise) {
58 var completer = new Completer();
59 var newPromise = promise
60 .callMethod("then", [(result) => completer.complete(result)])
61 .callMethod("catch", [(result) => completer.completeError(result)]);
62 return completer.future;
63 }
OLDNEW
« no previous file with comments | « sdk/lib/html/html_common/conversions_dart2js.dart ('k') | sdk/lib/html/html_common/html_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698