| 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 typedef Object ComputeValue(); | 5 typedef Object ComputeValue(); |
| 6 | 6 |
| 7 class _MeasurementRequest<T> { | 7 class _MeasurementRequest<T> { |
| 8 final ComputeValue computeValue; | 8 final ComputeValue computeValue; |
| 9 final Completer<T> completer; | 9 final Completer<T> completer; |
| 10 Object value; | 10 Object value; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 */ | 92 */ |
| 93 class _MutationObserverScheduler extends _MeasurementScheduler { | 93 class _MutationObserverScheduler extends _MeasurementScheduler { |
| 94 MutationObserver _observer; | 94 MutationObserver _observer; |
| 95 Element _dummy; | 95 Element _dummy; |
| 96 | 96 |
| 97 _MutationObserverScheduler(_MeasurementCallback callback): super(callback) { | 97 _MutationObserverScheduler(_MeasurementCallback callback): super(callback) { |
| 98 // Mutation events get fired as soon as the current event stack is unwound | 98 // Mutation events get fired as soon as the current event stack is unwound |
| 99 // so we just make a dummy event and listen for that. | 99 // so we just make a dummy event and listen for that. |
| 100 _observer = new MutationObserver(this._handleMutation); | 100 _observer = new MutationObserver(this._handleMutation); |
| 101 _dummy = new DivElement(); | 101 _dummy = new DivElement(); |
| 102 // OPTIONALS _observer.observe(_dummy, attributes: true); | 102 _observer.observe(_dummy, attributes: true); |
| 103 _observer.observe(_dummy, {}, null, true); | |
| 104 } | 103 } |
| 105 | 104 |
| 106 void _schedule() { | 105 void _schedule() { |
| 107 // Toggle it to trigger the mutation event. | 106 // Toggle it to trigger the mutation event. |
| 108 _dummy.hidden = !_dummy.hidden; | 107 _dummy.hidden = !_dummy.hidden; |
| 109 } | 108 } |
| 110 | 109 |
| 111 _handleMutation(List<MutationRecord> mutations, MutationObserver observer) { | 110 _handleMutation(List<MutationRecord> mutations, MutationObserver observer) { |
| 112 this._onCallback(); | 111 this._onCallback(); |
| 113 } | 112 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 } | 190 } |
| 192 } | 191 } |
| 193 | 192 |
| 194 if (readyMeasurementFrameCallbacks !== null) { | 193 if (readyMeasurementFrameCallbacks !== null) { |
| 195 for (TimeoutHandler handler in readyMeasurementFrameCallbacks) { | 194 for (TimeoutHandler handler in readyMeasurementFrameCallbacks) { |
| 196 // TODO(jacobr): wrap each call to a handler in a try-catch block. | 195 // TODO(jacobr): wrap each call to a handler in a try-catch block. |
| 197 handler(); | 196 handler(); |
| 198 } | 197 } |
| 199 } | 198 } |
| 200 } | 199 } |
| OLD | NEW |