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

Unified Diff: tools/dom/src/native_DOMImplementation.dart

Issue 22859033: Support for type extensions in Dartium (part 1) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/html/html.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/src/native_DOMImplementation.dart
diff --git a/tools/dom/src/native_DOMImplementation.dart b/tools/dom/src/native_DOMImplementation.dart
index a7c0e97c2ffdbf48d617f9cbf18b78c9ead3b6f1..80676b0d88498117b995158352e96bb5a852adb2 100644
--- a/tools/dom/src/native_DOMImplementation.dart
+++ b/tools/dom/src/native_DOMImplementation.dart
@@ -195,15 +195,20 @@ class _Utils {
// DOM node rather than just a class that extends Node.
static bool isNode(obj) => obj is Node;
+ static bool _isBuiltinType(ClassMirror cls) {
+ // TODO(vsm): Find a less hackish way to do this.
+ LibraryMirror lib = cls.owner;
+ String libName = lib.uri.toString();
+ return libName.startsWith('dart:');
+ }
+
static void register(String tag, Type type) {
// TODO(vsm): Move these checks into native code.
if (type == null) {
throw new UnsupportedError("Invalid null type.");
}
ClassMirror cls = reflectClass(type);
- LibraryMirror lib = cls.owner;
- String libName = lib.uri.toString();
- if (libName.startsWith('dart:')) {
+ if (_isBuiltinType(cls)) {
throw new UnsupportedError("Invalid custom element from $libName.");
}
ClassMirror superClass = cls.superclass;
@@ -216,17 +221,21 @@ class _Utils {
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(tag, type);
+ _register(tag, type, nativeClass.reflectedType);
}
- static void _register(String tag, Type type) native "Utils_register";
+ static void _register(String tag, Type customType, Type nativeType) native "Utils_register";
}
class _NPObject extends NativeFieldWrapperClass1 {
« no previous file with comments | « tests/html/html.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698