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

Side by Side Diff: client/html/src/Measurement.dart

Issue 8835006: New version of dart:html (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typos Created 9 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
« no previous file with comments | « client/html/src/GlobalProperties.dart ('k') | client/html/src/SVGDocument.dart » ('j') | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 void _completeMeasurementFutures() { 79 void _completeMeasurementFutures() {
80 if (_nextMeasurementFrameScheduled == false) { 80 if (_nextMeasurementFrameScheduled == false) {
81 // Ignore spurious call to this function. 81 // Ignore spurious call to this function.
82 return; 82 return;
83 } 83 }
84 84
85 _nextMeasurementFrameScheduled = false; 85 _nextMeasurementFrameScheduled = false;
86 // We must compute all new values before fulfilling the futures as 86 // We must compute all new values before fulfilling the futures as
87 // the onComplete callbacks for the futures could modify the DOM making 87 // the onComplete callbacks for the futures could modify the DOM making
88 // subsequent measurement calculations expensive to compute. 88 // subsequent measurement calculations expensive to compute.
89 for (_MeasurementRequest request in _pendingRequests) { 89 if (_pendingRequests !== null) {
90 try { 90 for (_MeasurementRequest request in _pendingRequests) {
91 request.value = request.computeValue(); 91 try {
92 } catch(var e) { 92 request.value = request.computeValue();
93 request.value = e; 93 } catch(var e) {
94 request.exception = true; 94 request.value = e;
95 request.exception = true;
96 }
95 } 97 }
96 } 98 }
97 99
98 final completedRequests = _pendingRequests; 100 final completedRequests = _pendingRequests;
99 final readyMeasurementFrameCallbacks = _pendingMeasurementFrameCallbacks; 101 final readyMeasurementFrameCallbacks = _pendingMeasurementFrameCallbacks;
100 _pendingRequests = null; 102 _pendingRequests = null;
101 _pendingMeasurementFrameCallbacks = null; 103 _pendingMeasurementFrameCallbacks = null;
102 for (_MeasurementRequest request in completedRequests) { 104 if (completedRequests !== null) {
103 if (request.exception) { 105 for (_MeasurementRequest request in completedRequests) {
104 request.completer.completeException(request.value); 106 if (request.exception) {
105 } else { 107 request.completer.completeException(request.value);
106 request.completer.complete(request.value); 108 } else {
109 request.completer.complete(request.value);
110 }
107 } 111 }
108 } 112 }
109 113
110 if (readyMeasurementFrameCallbacks !== null) { 114 if (readyMeasurementFrameCallbacks !== null) {
111 for (TimeoutHandler handler in readyMeasurementFrameCallbacks) { 115 for (TimeoutHandler handler in readyMeasurementFrameCallbacks) {
112 // TODO(jacobr): wrap each call to a handler in a try-catch block. 116 // TODO(jacobr): wrap each call to a handler in a try-catch block.
113 handler(); 117 handler();
114 } 118 }
115 } 119 }
116 } 120 }
OLDNEW
« no previous file with comments | « client/html/src/GlobalProperties.dart ('k') | client/html/src/SVGDocument.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698