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

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

Issue 22912004: Initial Dartium custom element support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Mark tests fail until parser fix 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 | « tools/dom/scripts/htmlrenamer.py ('k') | tools/dom/templates/html/dartium/html_dartium.darttemplate » ('j') | 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 ad04f3fe91adde83434f595fc7cefafee7045e8b..8cdf24d8e3edc1a85b4d60aad7253bdcede07677 100644
--- a/tools/dom/src/native_DOMImplementation.dart
+++ b/tools/dom/src/native_DOMImplementation.dart
@@ -194,6 +194,38 @@ 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)) {
+ 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 {
« no previous file with comments | « tools/dom/scripts/htmlrenamer.py ('k') | tools/dom/templates/html/dartium/html_dartium.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698