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

Side by Side Diff: third_party/pkg/js/lib/js.dart

Issue 180843004: Revert revision 33053 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /** 5 /**
6 * The js.dart library provides simple JavaScript invocation from Dart that 6 * The js.dart library provides simple JavaScript invocation from Dart that
7 * works on both Dartium and on other modern browsers via Dart2JS. 7 * works on both Dartium and on other modern browsers via Dart2JS.
8 * 8 *
9 * It provides a model based on scoped [Proxy] objects. Proxies give Dart 9 * It provides a model based on scoped [Proxy] objects. Proxies give Dart
10 * code access to JavaScript objects, fields, and functions as well as the 10 * code access to JavaScript objects, fields, and functions as well as the
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 * See [samples](http://dart-lang.github.com/js-interop/example) for more 63 * See [samples](http://dart-lang.github.com/js-interop/example) for more
64 * examples of usage. 64 * examples of usage.
65 * 65 *
66 * See this [article](http://www.dartlang.org/articles/js-dart-interop) for 66 * See this [article](http://www.dartlang.org/articles/js-dart-interop) for
67 * more detailed discussion. 67 * more detailed discussion.
68 */ 68 */
69 69
70 library js; 70 library js;
71 71
72 import 'dart:js' as js; 72 import 'dart:js' as js;
73 @MirrorsUsed(symbols: '*')
73 import 'dart:mirrors'; 74 import 'dart:mirrors';
74 75
75 /** 76 /**
76 * A proxy on the global JavaScript context for this page. 77 * A proxy on the global JavaScript context for this page.
77 */ 78 */
78 final Proxy context = new Proxy._(js.context); 79 final Proxy context = new Proxy._(js.context);
79 80
80 /** 81 /**
81 * Check if [proxy] is instance of [type]. 82 * Check if [proxy] is instance of [type].
82 */ 83 */
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 args.map((e) => _deserialize(e)).toList())); 252 args.map((e) => _deserialize(e)).toList()));
252 } 253 }
253 } 254 }
254 255
255 /// A [Proxy] subtype to JavaScript functions. 256 /// A [Proxy] subtype to JavaScript functions.
256 class FunctionProxy extends Proxy<FunctionProxy> implements Function { 257 class FunctionProxy extends Proxy<FunctionProxy> implements Function {
257 final js.JsFunction _jsFunction; 258 final js.JsFunction _jsFunction;
258 final _thisArg; 259 final _thisArg;
259 260
260 FunctionProxy._(js.JsFunction jsFunction, {thisArg}) : 261 FunctionProxy._(js.JsFunction jsFunction, {thisArg}) :
261 _jsFunction = jsFunction, 262 this._jsFunction = jsFunction,
262 _thisArg = thisArg, 263 this._thisArg = thisArg,
263 super._(jsFunction); 264 super._(jsFunction);
264 265
265 factory FunctionProxy(Function f) => new FunctionProxy._( 266 factory FunctionProxy(Function f) => new FunctionProxy._(
266 new js.JsFunction.withThis(new _CallbackFunction(f))); 267 new js.JsFunction.withThis(new _CallbackFunction(f)));
267 268
268 factory FunctionProxy.withThis(Function f) => new FunctionProxy._( 269 factory FunctionProxy.withThis(Function f) => new FunctionProxy._(
269 new js.JsFunction.withThis(new _CallbackFunction(f, withThis: true))); 270 new js.JsFunction.withThis(new _CallbackFunction(f, withThis: true)));
270 271
271 // We need to implement call() to satisfy the Function "interface" 272 // We need to implement call() to satisfy the Function "interface"
272 // This handles the no-arg case, noSuchMethod handles the rest. 273 // This handles the no-arg case, noSuchMethod handles the rest.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 if (o == null) { 319 if (o == null) {
319 return null; 320 return null;
320 } else if (o is js.JsFunction) { 321 } else if (o is js.JsFunction) {
321 return new FunctionProxy._(o, thisArg: thisArg); 322 return new FunctionProxy._(o, thisArg: thisArg);
322 } else if (o is js.JsObject) { 323 } else if (o is js.JsObject) {
323 return new Proxy._(o); 324 return new Proxy._(o);
324 } else { 325 } else {
325 return o; 326 return o;
326 } 327 }
327 } 328 }
OLDNEW
« no previous file with comments | « third_party/pkg/js/gh-pages-template/example/index.html ('k') | third_party/pkg/js/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698