Chromium Code Reviews| Index: tools/dom/src/native_DOMImplementation.dart |
| diff --git a/tools/dom/src/native_DOMImplementation.dart b/tools/dom/src/native_DOMImplementation.dart |
| index ad04f3fe91adde83434f595fc7cefafee7045e8b..519e39bee8dca99e24299494071e19338d73c8ba 100644 |
| --- a/tools/dom/src/native_DOMImplementation.dart |
| +++ b/tools/dom/src/native_DOMImplementation.dart |
| @@ -194,6 +194,39 @@ class _Utils { |
| // TODO(jacobr): we need a failsafe way to determine that a Node is really a |
| // DOM node rather than just a class that extends Node. |
| static bool isNode(obj) => obj is Node; |
| + |
| + 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:')) { |
| + 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; |
| + Symbol elementName = reflectClass(Element).qualifiedName; |
| + bool isElement(ClassMirror cls) => |
| + cls != null && cls.qualifiedName == elementName; |
| + |
| + while(!isRoot(superClass) && !isElement(superClass)) { |
| + print('testing ${superClass.simpleName.toString()}'); |
|
blois
2013/08/13 17:15:44
Debug code
vsm
2013/08/13 19:23:30
Done.
|
| + superClass = superClass.superclass; |
| + } |
| + |
| + if (isRoot(superClass)) { |
| + throw new UnsupportedError("Invalid custom element doesn't inherit from Element."); |
| + } |
| + _register(tag, type); |
| + } |
| + |
| + static void _register(String tag, Type type) native "Utils_register"; |
| } |
| class _NPObject extends NativeFieldWrapperClass1 { |