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

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 27082002: Making all callbacks use zones (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 | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 35b7ab92fcfc2b1feaacad82c0b6a4480ef9a0ff..d144dad2eaba8a0ea8c47e4efa9f7ea79ea3cb63 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -56,7 +56,7 @@ import 'dart:_js_helper' show
makeLeafDispatchRecord;
import 'dart:_interceptors' show
Interceptor, JSExtendableArray, findInterceptorConstructorForType,
- findConstructorForWebComponentType, getNativeInterceptor,
+ findConstructorForWebComponentType, getNativeInterceptor,
setDispatchProperty, findInterceptorForType;
export 'dart:math' show Rectangle, Point;
@@ -85,9 +85,6 @@ Window get window => JS('Window', 'window');
*/
HtmlDocument get document => JS('HtmlDocument', 'document');
-Element query(String selector) => document.query(selector);
-ElementList queryAll(String selector) => document.queryAll(selector);
-
// Workaround for tags like <cite> that lack their own Element subclass --
// Dart issue 1990.
class HtmlElement extends Element native "HTMLElement" {
@@ -12075,9 +12072,20 @@ class FontLoader extends EventTarget native "FontLoader" {
@DocsEditable()
void _loadFont_1(params) native;
+ @JSName('notifyWhenFontsReady')
@DomName('FontLoader.notifyWhenFontsReady')
@DocsEditable()
- void notifyWhenFontsReady(VoidCallback callback) native;
+ void _notifyWhenFontsReady(VoidCallback callback) native;
+
+ @JSName('notifyWhenFontsReady')
+ @DomName('FontLoader.notifyWhenFontsReady')
+ @DocsEditable()
+ Future notifyWhenFontsReady() {
+ var completer = new Completer();
+ _notifyWhenFontsReady(
+ () { completer.complete(); });
+ return completer.future;
+ }
@DomName('FontLoader.onerror')
@DocsEditable()
@@ -16390,10 +16398,22 @@ class MediaStreamTrack extends EventTarget native "MediaStreamTrack" {
@DocsEditable()
final String readyState;
+ @JSName('getSources')
@DomName('MediaStreamTrack.getSources')
@DocsEditable()
@Experimental() // untriaged
- static void getSources(MediaStreamTrackSourcesCallback callback) native;
+ static void _getSources(MediaStreamTrackSourcesCallback callback) native;
+
+ @JSName('getSources')
+ @DomName('MediaStreamTrack.getSources')
+ @DocsEditable()
+ @Experimental() // untriaged
+ static Future<List<SourceInfo>> getSources() {
+ var completer = new Completer<List<SourceInfo>>();
+ _getSources(
+ (value) { completer.complete(value); });
+ return completer.future;
+ }
@DomName('MediaStreamTrack.onended')
@DocsEditable()
@@ -17383,7 +17403,7 @@ class MutationObserver extends Interceptor native "MutationObserver,WebKitMutati
return JS('MutationObserver',
'new(window.MutationObserver||window.WebKitMutationObserver||'
'window.MozMutationObserver)(#)',
- convertDartClosureToJS(callback, 2));
+ convertDartClosureToJS(_wrapZone(callback), 2));
}
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
@@ -20642,9 +20662,20 @@ class RtcPeerConnection extends EventTarget native "RTCPeerConnection,mozRTCPeer
@DocsEditable()
List<MediaStream> getRemoteStreams() native;
+ @JSName('getStats')
@DomName('RTCPeerConnection.getStats')
@DocsEditable()
- void getStats(RtcStatsCallback successCallback, MediaStreamTrack selector) native;
+ void _getStats(RtcStatsCallback successCallback, MediaStreamTrack selector) native;
+
+ @JSName('getStats')
+ @DomName('RTCPeerConnection.getStats')
+ @DocsEditable()
+ Future<RtcStatsResponse> getStats(MediaStreamTrack selector) {
+ var completer = new Completer<RtcStatsResponse>();
+ _getStats(selector,
+ (value) { completer.complete(value); });
+ return completer.future;
+ }
@DomName('RTCPeerConnection.getStreamById')
@DocsEditable()
@@ -22515,13 +22546,37 @@ class StorageInfoUsage {
@Experimental()
class StorageQuota extends Interceptor native "StorageQuota" {
+ @JSName('queryUsageAndQuota')
+ @DomName('StorageQuota.queryUsageAndQuota')
+ @DocsEditable()
+ void _queryUsageAndQuota(StorageUsageCallback usageCallback, [StorageErrorCallback errorCallback]) native;
+
+ @JSName('queryUsageAndQuota')
@DomName('StorageQuota.queryUsageAndQuota')
@DocsEditable()
- void queryUsageAndQuota(StorageUsageCallback usageCallback, [StorageErrorCallback errorCallback]) native;
+ Future<int> queryUsageAndQuota() {
+ var completer = new Completer<int>();
+ _queryUsageAndQuota(
+ (value) { completer.complete(value); },
+ (error) { completer.completeError(error); });
+ return completer.future;
+ }
+
+ @JSName('requestQuota')
+ @DomName('StorageQuota.requestQuota')
+ @DocsEditable()
+ void _requestQuota(int newQuotaInBytes, [StorageQuotaCallback quotaCallback, StorageErrorCallback errorCallback]) native;
+ @JSName('requestQuota')
@DomName('StorageQuota.requestQuota')
@DocsEditable()
- void requestQuota(int newQuotaInBytes, [StorageQuotaCallback quotaCallback, StorageErrorCallback errorCallback]) native;
+ 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
// for details. All rights reserved. Use of this source code is governed by a
@@ -25300,7 +25355,7 @@ class Window extends EventTarget implements WindowBase, WindowTimers, WindowBase
@DomName('Window.requestAnimationFrame')
int requestAnimationFrame(RequestAnimationFrameCallback callback) {
_ensureRequestAnimationFrame();
- return _requestAnimationFrame(callback);
+ return _requestAnimationFrame(_wrapZone(callback));
}
void cancelAnimationFrame(int id) {
@@ -29280,12 +29335,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;
@@ -33079,6 +33128,19 @@ class Platform {
// 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) 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.
+
+
/**
* Interface used to validate that only accepted elements and attributes are
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698