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

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

Issue 24509004: Run DOM callbacks in the zone they are coming from. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Wrap into expectAsync0. Created 7 years, 3 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
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 25a0c3242ad73671264ca3ca6459ec665edee2f3..a597d0c5b474c9289d47738eb7a8f0fb0a33e4f6 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -30710,11 +30710,17 @@ class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> {
var _onData;
final bool _useCapture;
- _EventStreamSubscription(this._target, this._eventType, this._onData,
- this._useCapture) {
+ _EventStreamSubscription(this._target, this._eventType, onData,
+ this._useCapture) : _onData = _wrapZone(onData) {
_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);
+ }
+
void cancel() {
if (_canceled) return;
@@ -30733,7 +30739,7 @@ class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> {
// Remove current event listener.
_unlisten();
- _onData = handleData;
+ _onData = _wrapZone(handleData);
_tryResume();
}
@@ -34729,39 +34735,15 @@ class _Utils {
static void register(Document document, String tag, Type type,
String extendsTagName) {
// TODO(vsm): Move these checks into native code.
- if (type == null) {
- throw new UnsupportedError("Invalid null type.");
- }
ClassMirror cls = reflectClass(type);
if (_isBuiltinType(cls)) {
throw new UnsupportedError("Invalid custom element from $libName.");
}
- ClassMirror superClass = cls.superclass;
-
- Symbol objectName = reflectClass(Object).qualifiedName;
- bool isRoot(ClassMirror cls) =>
- cls == null || cls.qualifiedName == objectName;
- // TODO(vsm): Support extending SvgElement as well.
- Symbol elementName = reflectClass(HtmlElement).qualifiedName;
- bool isElement(ClassMirror cls) =>
- cls != null && cls.qualifiedName == elementName;
-
- ClassMirror nativeClass = _isBuiltinType(superClass) ? superClass : null;
- while(!isRoot(superClass) && !isElement(superClass)) {
- superClass = superClass.superclass;
- if (nativeClass == null && _isBuiltinType(superClass)) {
- nativeClass = superClass;
- }
- }
-
- if (isRoot(superClass)) {
- throw new UnsupportedError("Invalid custom element doesn't inherit from HtmlElement.");
- }
- _register(document, tag, type, extendsTagName, nativeClass.reflectedType);
+ _register(document, tag, type, extendsTagName);
}
static void _register(Document document, String tag, Type customType,
- String extendsTagName, Type nativeType) native "Utils_register";
+ String extendsTagName) native "Utils_register";
}
class _NPObject extends NativeFieldWrapperClass1 {

Powered by Google App Engine
This is Rietveld 408576698