| OLD | NEW |
| 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 // Patch file for the dart:async library. | 5 // Patch file for the dart:async library. |
| 6 | 6 |
| 7 import 'dart:_js_helper' show | 7 import 'dart:_js_helper' show |
| 8 patch, | 8 patch, |
| 9 Primitives; | 9 Primitives; |
| 10 import 'dart:_isolate_helper' show | 10 import 'dart:_isolate_helper' show |
| 11 IsolateNatives, | 11 IsolateNatives, |
| 12 TimerImpl, | 12 TimerImpl, |
| 13 leaveJsAsync, | 13 leaveJsAsync, |
| 14 enterJsAsync, | 14 enterJsAsync, |
| 15 isWorker; | 15 isWorker; |
| 16 | 16 |
| 17 import 'dart:_foreign_helper' show JS; | 17 import 'dart:_foreign_helper' show JS; |
| 18 | 18 |
| 19 @patch | 19 @patch |
| 20 class _AsyncRun { | 20 class _AsyncRun { |
| 21 @patch | 21 @patch |
| 22 static void _scheduleImmediate(void callback()) { | 22 static void _scheduleImmediate(void callback()) { |
| 23 scheduleImmediateClosure(callback); | 23 _scheduleImmediateClosure(callback); |
| 24 } | 24 } |
| 25 | 25 |
| 26 // Lazily initialized. | 26 // Lazily initialized. |
| 27 static final Function scheduleImmediateClosure = | 27 static final Function _scheduleImmediateClosure = |
| 28 _initializeScheduleImmediate(); | 28 _initializeScheduleImmediate(); |
| 29 | 29 |
| 30 static Function _initializeScheduleImmediate() { | 30 static Function _initializeScheduleImmediate() { |
| 31 // TODO(rnystrom): Not needed by dev_compiler. |
| 32 // requiresPreamble(); |
| 31 if (JS('', 'self.scheduleImmediate') != null) { | 33 if (JS('', 'self.scheduleImmediate') != null) { |
| 32 return _scheduleImmediateJsOverride; | 34 return _scheduleImmediateJsOverride; |
| 33 } | 35 } |
| 34 if (JS('', 'self.MutationObserver') != null && | 36 if (JS('', 'self.MutationObserver') != null && |
| 35 JS('', 'self.document') != null) { | 37 JS('', 'self.document') != null) { |
| 36 // Use mutationObservers. | 38 // Use mutationObservers. |
| 37 var div = JS('', 'self.document.createElement("div")'); | 39 var div = JS('', 'self.document.createElement("div")'); |
| 38 var span = JS('', 'self.document.createElement("span")'); | 40 var span = JS('', 'self.document.createElement("span")'); |
| 39 var storedCallback; | 41 var storedCallback; |
| 40 | 42 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 111 |
| 110 @patch | 112 @patch |
| 111 static Timer _createPeriodicTimer(Duration duration, | 113 static Timer _createPeriodicTimer(Duration duration, |
| 112 void callback(Timer timer)) { | 114 void callback(Timer timer)) { |
| 113 int milliseconds = duration.inMilliseconds; | 115 int milliseconds = duration.inMilliseconds; |
| 114 if (milliseconds < 0) milliseconds = 0; | 116 if (milliseconds < 0) milliseconds = 0; |
| 115 return new TimerImpl.periodic(milliseconds, callback); | 117 return new TimerImpl.periodic(milliseconds, callback); |
| 116 } | 118 } |
| 117 } | 119 } |
| 118 | 120 |
| 119 bool get _hasDocument => JS('String', 'typeof document') == 'object'; | 121 @patch |
| 122 void _rethrow(Object error, StackTrace stackTrace) { |
| 123 // TODO(rnystrom): Not needed by dev_compiler. |
| 124 // error = wrapException(error); |
| 125 JS("void", "#.stack = #", error, stackTrace.toString()); |
| 126 JS("void", "throw #", error); |
| 127 } |
| OLD | NEW |