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

Side by Side Diff: sdk/lib/html/src/Measurement.dart

Issue 11647044: Adding annotation for partial browser support and example implementation for MutationObservers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added experimental annotation to MutationObserver. Created 8 years 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) 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 Object ComputeValue(); 7 typedef Object ComputeValue();
8 8
9 class _MeasurementRequest<T> { 9 class _MeasurementRequest<T> {
10 final ComputeValue computeValue; 10 final ComputeValue computeValue;
11 final Completer<T> completer; 11 final Completer<T> completer;
12 Object value; 12 Object value;
13 bool exception = false; 13 bool exception = false;
14 _MeasurementRequest(this.computeValue, this.completer); 14 _MeasurementRequest(this.computeValue, this.completer);
15 } 15 }
16 16
17 typedef void _MeasurementCallback(); 17 typedef void _MeasurementCallback();
18 18
19
20 /** 19 /**
21 * This class attempts to invoke a callback as soon as the current event stack 20 * This class attempts to invoke a callback as soon as the current event stack
22 * unwinds, but before the browser repaints. 21 * unwinds, but before the browser repaints.
23 */ 22 */
24 abstract class _MeasurementScheduler { 23 abstract class _MeasurementScheduler {
25 bool _nextMeasurementFrameScheduled = false; 24 bool _nextMeasurementFrameScheduled = false;
26 _MeasurementCallback _callback; 25 _MeasurementCallback _callback;
27 26
28 _MeasurementScheduler(this._callback); 27 _MeasurementScheduler(this._callback);
29 28
30 /** 29 /**
31 * Creates the best possible measurement scheduler for the current platform. 30 * Creates the best possible measurement scheduler for the current platform.
32 */ 31 */
33 factory _MeasurementScheduler.best(_MeasurementCallback callback) { 32 factory _MeasurementScheduler.best(_MeasurementCallback callback) {
34 if (_isMutationObserverSupported()) { 33 if (MutationObserver.supported) {
35 return new _MutationObserverScheduler(callback); 34 return new _MutationObserverScheduler(callback);
36 } 35 }
37 return new _PostMessageScheduler(callback); 36 return new _PostMessageScheduler(callback);
38 } 37 }
39 38
40 /** 39 /**
41 * Schedules a measurement callback if one has not been scheduled already. 40 * Schedules a measurement callback if one has not been scheduled already.
42 */ 41 */
43 void maybeSchedule() { 42 void maybeSchedule() {
44 if (this._nextMeasurementFrameScheduled) { 43 if (this._nextMeasurementFrameScheduled) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 191 }
193 } 192 }
194 193
195 if (readyMeasurementFrameCallbacks != null) { 194 if (readyMeasurementFrameCallbacks != null) {
196 for (TimeoutHandler handler in readyMeasurementFrameCallbacks) { 195 for (TimeoutHandler handler in readyMeasurementFrameCallbacks) {
197 // TODO(jacobr): wrap each call to a handler in a try-catch block. 196 // TODO(jacobr): wrap each call to a handler in a try-catch block.
198 handler(); 197 handler();
199 } 198 }
200 } 199 }
201 } 200 }
OLDNEW
« no previous file with comments | « sdk/lib/html/html_common/metadata.dart ('k') | sdk/lib/html/src/dart2js_MutationObserverSupported.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698