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

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

Issue 32703006: Validating that types which require extendsTag actually provide it (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:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/html/custom/document_register_type_extensions_test.dart ('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 e650c6fd0c5c0aef41f0256b35e434d6420ea27e..a5d923b4377dda9a1cc6417ea3369c398e87c9ca 100644
--- a/tools/dom/src/native_DOMImplementation.dart
+++ b/tools/dom/src/native_DOMImplementation.dart
@@ -411,8 +411,31 @@ class _Utils {
}
var className = MirrorSystem.getName(cls.simpleName);
if (!cls.constructors.containsKey(new Symbol('$className.created'))) {
- throw new UnsupportedError('Class is missing constructor $className.created');
+ throw new UnsupportedError(
+ 'Class is missing constructor $className.created');
}
+
+ Symbol objectName = reflectClass(Object).qualifiedName;
+ bool isRoot(ClassMirror cls) =>
+ cls == null || cls.qualifiedName == objectName;
+ Symbol elementName = reflectClass(HtmlElement).qualifiedName;
+ bool isElement(ClassMirror cls) =>
+ cls != null && cls.qualifiedName == elementName;
+ ClassMirror superClass = cls.superclass;
+ ClassMirror nativeClass = _isBuiltinType(superClass) ? superClass : null;
+ while(!isRoot(superClass) && !isElement(superClass)) {
+ superClass = superClass.superclass;
+ if (nativeClass == null && _isBuiltinType(superClass)) {
+ nativeClass = superClass;
+ }
+ }
+ if (extendsTagName == null) {
+ if (nativeClass.reflectedType != HtmlElement) {
+ throw new UnsupportedError('Class must provide extendsTag if base '
+ 'native class is not HTMLElement');
+ }
+ }
+
_register(document, tag, type, extendsTagName);
}
« no previous file with comments | « tests/html/custom/document_register_type_extensions_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698