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

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Side-by-side diff isn't available for this file because of its large size.
Issue 27240004: Making all callbacks use zones (take 2) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tools/dom/scripts/htmlrenamer.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dartium/html_dartium.dart
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index 3fc527b5d632bfd5a80bb5688f00e71c16791b7b..072af06f68eb8f7bfbf1a10591ad7af2674d2e8e 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -12,7 +12,7 @@
*
* * If you've never written a web app before, try our
* tutorials—[A Game of Darts](http://dartlang.org/docs/tutorials).
- *
+ *
* * To see some web-based Dart apps in action and to play with the code,
* download
* [Dart Editor](http://www.dartlang.org/#get-started)
@@ -93,10 +93,6 @@ HtmlDocument get document {
return _document;
}
-
-Element query(String selector) => document.query(selector);
-ElementList queryAll(String selector) => document.queryAll(selector);
-
int _getNewIsolateId() => _Utils._getNewIsolateId();
bool _callPortInitialized = false;
@@ -12612,7 +12608,14 @@ class FontLoader extends EventTarget {
@DomName('FontLoader.notifyWhenFontsReady')
@DocsEditable()
- void notifyWhenFontsReady(VoidCallback callback) native "FontLoader_notifyWhenFontsReady_Callback";
+ void _notifyWhenFontsReady(VoidCallback callback) native "FontLoader_notifyWhenFontsReady_Callback";
+
+ Future notifyWhenFontsReady() {
+ var completer = new Completer();
+ _notifyWhenFontsReady(
+ () { completer.complete(); });
+ return completer.future;
+ }
@DomName('FontLoader.addEventListener')
@DocsEditable()
@@ -17722,7 +17725,14 @@ class MediaStreamTrack extends EventTarget {
@DomName('MediaStreamTrack.getSources')
@DocsEditable()
@Experimental() // untriaged
- static void getSources(MediaStreamTrackSourcesCallback callback) native "MediaStreamTrack_getSources_Callback";
+ static void _getSources(MediaStreamTrackSourcesCallback callback) native "MediaStreamTrack_getSources_Callback";
+
+ static Future<List<SourceInfo>> getSources() {
+ var completer = new Completer<List<SourceInfo>>();
+ _getSources(
+ (value) { completer.complete(value); });
+ return completer.future;
+ }
@DomName('MediaStreamTrack.addEventListener')
@DocsEditable()
@@ -18734,12 +18744,10 @@ class MutationEvent extends Event {
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental()
class MutationObserver extends NativeFieldWrapperClass1 {
- // To suppress missing implicit constructor warnings.
- factory MutationObserver._() { throw new UnsupportedError("Not supported"); }
@DomName('MutationObserver.MutationObserver')
@DocsEditable()
- factory MutationObserver(MutationCallback callback) => _create(callback);
+ factory MutationObserver._(MutationCallback callback) => _create(callback);
@DocsEditable()
static MutationObserver _create(callback) native "MutationObserver_constructorCallback";
@@ -18811,6 +18819,8 @@ class MutationObserver extends NativeFieldWrapperClass1 {
_observe(target, options);
}
+ factory MutationObserver(MutationCallback callback) =>
+ new MutationObserver._(_wrapZone(callback));
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -22258,6 +22268,13 @@ class RtcPeerConnection extends EventTarget {
(error) { completer.completeError(error); }, mediaConstraints);
return completer.future;
}
+
+ @DomName('RTCPeerConnection.getStats')
+ Future<RtcStatsResponse> getStats(MediaStreamTrack selector) {
+ var completer = new Completer<RtcStatsResponse>();
+ _getStats((value) { completer.complete(value); }, selector);
+ return completer.future;
+ }
// To suppress missing implicit constructor warnings.
factory RtcPeerConnection._() { throw new UnsupportedError("Not supported"); }
@@ -22356,7 +22373,7 @@ class RtcPeerConnection extends EventTarget {
@DomName('RTCPeerConnection.getStats')
@DocsEditable()
- void getStats(RtcStatsCallback successCallback, MediaStreamTrack selector) native "RTCPeerConnection_getStats_Callback";
+ void _getStats(RtcStatsCallback successCallback, MediaStreamTrack selector) native "RTCPeerConnection_getStats_Callback";
@DomName('RTCPeerConnection.getStreamById')
@DocsEditable()
@@ -24580,7 +24597,15 @@ class StorageQuota extends NativeFieldWrapperClass1 {
@DomName('StorageQuota.requestQuota')
@DocsEditable()
- void requestQuota(int newQuotaInBytes, [StorageQuotaCallback quotaCallback, StorageErrorCallback errorCallback]) native "StorageQuota_requestQuota_Callback";
+ void _requestQuota(int newQuotaInBytes, [StorageQuotaCallback quotaCallback, StorageErrorCallback errorCallback]) native "StorageQuota_requestQuota_Callback";
+
+ Future<int> requestQuota(int newQuotaInBytes) {
+ var completer = new Completer<int>();
+ _requestQuota(newQuotaInBytes,
+ (value) { completer.complete(value); },
+ (error) { completer.completeError(error); });
+ return completer.future;
+ }
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
@@ -26783,13 +26808,13 @@ class Url extends NativeFieldWrapperClass1 {
if ((blob_OR_source_OR_stream is Blob || blob_OR_source_OR_stream == null)) {
return _createObjectURL_1(blob_OR_source_OR_stream);
}
- if ((blob_OR_source_OR_stream is MediaSource || blob_OR_source_OR_stream == null)) {
+ if ((blob_OR_source_OR_stream is MediaStream || blob_OR_source_OR_stream == null)) {
return _createObjectURL_2(blob_OR_source_OR_stream);
}
- if ((blob_OR_source_OR_stream is _WebKitMediaSource || blob_OR_source_OR_stream == null)) {
+ if ((blob_OR_source_OR_stream is MediaSource || blob_OR_source_OR_stream == null)) {
return _createObjectURL_3(blob_OR_source_OR_stream);
}
- if ((blob_OR_source_OR_stream is MediaStream || blob_OR_source_OR_stream == null)) {
+ if ((blob_OR_source_OR_stream is _WebKitMediaSource || blob_OR_source_OR_stream == null)) {
return _createObjectURL_4(blob_OR_source_OR_stream);
}
throw new ArgumentError("Incorrect number or type of arguments");
@@ -27428,6 +27453,27 @@ class Window extends EventTarget implements WindowBase, WindowTimers, WindowBase
}
/**
+ * Called to draw an animation frame and then request the window to repaint
+ * after [callback] has finished (creating the animation).
+ *
+ * Use this method only if you need to later call [cancelAnimationFrame]. If
+ * not, the preferred Dart idiom is to set animation frames by calling
+ * [animationFrame], which returns a Future.
+ *
+ * Returns a non-zero valued integer to represent the request id for this
+ * request. This value only needs to be saved if you intend to call
+ * [cancelAnimationFrame] so you can specify the particular animation to
+ * cancel.
+ *
+ * Note: The supplied [callback] needs to call [requestAnimationFrame] again
+ * for the animation to continue.
+ */
+ @DomName('Window.requestAnimationFrame')
+ int requestAnimationFrame(RequestAnimationFrameCallback callback) {
+ return _requestAnimationFrame(_wrapZone(callback));
+ }
+
+ /**
* Access a sandboxed file system of the specified `size`. If `persistent` is
* true, the application will request permission from the user to create
* lasting storage. This storage cannot be freed without the user's
@@ -27934,7 +27980,7 @@ class Window extends EventTarget implements WindowBase, WindowTimers, WindowBase
@DomName('Window.requestAnimationFrame')
@DocsEditable()
- int requestAnimationFrame(RequestAnimationFrameCallback callback) native "Window_requestAnimationFrame_Callback";
+ int _requestAnimationFrame(RequestAnimationFrameCallback callback) native "Window_requestAnimationFrame_Callback";
@DomName('Window.resizeBy')
@DocsEditable()
@@ -31649,12 +31695,6 @@ class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> {
_tryResume();
}
- static _wrapZone(callback) {
- // For performance reasons avoid wrapping if we are in the root zone.
- if (Zone.current == Zone.ROOT) return callback;
- return Zone.current.bindUnaryCallback(callback, runGuarded: true);
- }
-
void cancel() {
if (_canceled) return;
@@ -35184,6 +35224,19 @@ class Platform {
// no-op, provided for dart2js polyfill.
}
}
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+_wrapZone(callback) {
+ // For performance reasons avoid wrapping if we are in the root zone.
+ if (Zone.current == Zone.ROOT) return callback;
+ return Zone.current.bindUnaryCallback(callback, runGuarded: true);
+}
+
+Element query(String selector) => document.query(selector);
+ElementList queryAll(String selector) => document.queryAll(selector);
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tools/dom/scripts/htmlrenamer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698