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

Side by Side Diff: pkg/dev_compiler/tool/input_sdk/lib/js/dart2js/js_dart2js.dart

Issue 2610813003: Fix DDC cross-window JS interop on FireFox. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « pkg/dev_compiler/test/browser/language_tests.js ('k') | no next file » | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 * Support for interoperating with JavaScript. 6 * Support for interoperating with JavaScript.
7 * 7 *
8 * This library provides access to JavaScript objects from Dart, allowing 8 * This library provides access to JavaScript objects from Dart, allowing
9 * Dart code to get and set properties, and call methods of JavaScript objects 9 * Dart code to get and set properties, and call methods of JavaScript objects
10 * and invoke JavaScript functions. The library takes care of converting 10 * and invoke JavaScript functions. The library takes care of converting
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 var args = <Object>[start, length]..addAll(iterable.skip(skipCount).take(len gth)); 424 var args = <Object>[start, length]..addAll(iterable.skip(skipCount).take(len gth));
425 callMethod('splice', args); 425 callMethod('splice', args);
426 } 426 }
427 427
428 void sort([int compare(E a, E b)]) { 428 void sort([int compare(E a, E b)]) {
429 // Note: arr.sort(null) is a type error in FF 429 // Note: arr.sort(null) is a type error in FF
430 callMethod('sort', compare == null ? [] : [compare]); 430 callMethod('sort', compare == null ? [] : [compare]);
431 } 431 }
432 } 432 }
433 433
434 // Cross frame objects should not be considered browser types.
435 // We include the the instanceof Object test to filter out cross frame objects
436 // on FireFox. Surprisingly on FireFox the instanceof Window test succeeds for
437 // cross frame windows while the instanceof Object test fails.
434 bool _isBrowserType(o) => JS('bool', 438 bool _isBrowserType(o) => JS('bool',
439 '# instanceof Object && ('
435 '# instanceof Blob || ' 440 '# instanceof Blob || '
436 '# instanceof Event || ' 441 '# instanceof Event || '
437 '(window.KeyRange && # instanceof KeyRange) || ' 442 '(window.KeyRange && # instanceof KeyRange) || '
438 '(window.IDBKeyRange && # instanceof IDBKeyRange) || ' 443 '(window.IDBKeyRange && # instanceof IDBKeyRange) || '
439 '# instanceof ImageData || ' 444 '# instanceof ImageData || '
440 '# instanceof Node || ' 445 '# instanceof Node || '
441 // Int8Array.__proto__ is TypedArray. 446 // Int8Array.__proto__ is TypedArray.
442 '(window.Int8Array && # instanceof Int8Array.__proto__) || ' 447 '(window.Int8Array && # instanceof Int8Array.__proto__) || '
443 '# instanceof Window', o, o, o, o, o, o, o, o); 448 '# instanceof Window)', o, o, o, o, o, o, o, o, o);
444 449
445 class _DartObject { 450 class _DartObject {
446 final _dartObj; 451 final _dartObj;
447 _DartObject(this._dartObj); 452 _DartObject(this._dartObj);
448 } 453 }
449 454
450 dynamic _convertToJS(dynamic o) { 455 dynamic _convertToJS(dynamic o) {
451 if (o == null || 456 if (o == null ||
452 o is String || 457 o is String ||
453 o is num || 458 o is num ||
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 ' for (let arg of arguments) {' 560 ' for (let arg of arguments) {'
556 ' args.push(arg);' 561 ' args.push(arg);'
557 ' }' 562 ' }'
558 ' return #(...args);' 563 ' return #(...args);'
559 '}', 564 '}',
560 f); 565 f);
561 _interopCaptureThisExpando[f] = ret; 566 _interopCaptureThisExpando[f] = ret;
562 } 567 }
563 return ret; 568 return ret;
564 } 569 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/test/browser/language_tests.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698