| 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 part of html; | 5 part of html; |
| 6 | 6 |
| 7 typedef void _MicrotaskCallback(); | 7 typedef void _MicrotaskCallback(); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * This class attempts to invoke a callback as soon as the current event stack | 10 * This class attempts to invoke a callback as soon as the current event stack |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Toggle it to trigger the mutation event. | 99 // Toggle it to trigger the mutation event. |
| 100 _dummy.hidden = !_dummy.hidden; | 100 _dummy.hidden = !_dummy.hidden; |
| 101 } | 101 } |
| 102 | 102 |
| 103 _handleMutation(List<MutationRecord> mutations, MutationObserver observer) { | 103 _handleMutation(List<MutationRecord> mutations, MutationObserver observer) { |
| 104 this._onCallback(); | 104 this._onCallback(); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 /** | 108 /** |
| 109 * Scheduler which uses window.setImmediate to schedule events. | 109 * Scheduler which uses window.immediate to schedule events. |
| 110 */ | 110 */ |
| 111 class _SetImmediateScheduler extends _MicrotaskScheduler { | 111 class _SetImmediateScheduler extends _MicrotaskScheduler { |
| 112 _SetImmediateScheduler(_MicrotaskCallback callback): super(callback); | 112 _SetImmediateScheduler(_MicrotaskCallback callback): super(callback); |
| 113 | 113 |
| 114 void _schedule() { | 114 void _schedule() { |
| 115 window._setImmediate(_handleImmediate); | 115 window._setImmediate(_handleImmediate); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void _handleImmediate() { | 118 void _handleImmediate() { |
| 119 this._onCallback(); | 119 this._onCallback(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 147 /** | 147 /** |
| 148 * Complete all pending microtasks. | 148 * Complete all pending microtasks. |
| 149 */ | 149 */ |
| 150 void _completeMicrotasks() { | 150 void _completeMicrotasks() { |
| 151 var callbacks = _pendingMicrotasks; | 151 var callbacks = _pendingMicrotasks; |
| 152 _pendingMicrotasks = null; | 152 _pendingMicrotasks = null; |
| 153 for (var callback in callbacks) { | 153 for (var callback in callbacks) { |
| 154 callback(); | 154 callback(); |
| 155 } | 155 } |
| 156 } | 156 } |
| OLD | NEW |