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

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

Issue 24479002: Revert "Start of dartium custom element lifecycle event support." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/dom/scripts/systemnative.py ('k') | tools/dom/templates/html/impl/impl_HTMLDocument.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 c6bed40859224cf51f5d3aa3238956630f13637d..333d747169094cd902e7e68bf34ccc424bfdf0a9 100644
--- a/tools/dom/src/native_DOMImplementation.dart
+++ b/tools/dom/src/native_DOMImplementation.dart
@@ -6,7 +6,7 @@ part of html;
class _ConsoleVariables {
Map<String, Object> _data = new Map<String, Object>();
-
+
/**
* Forward member accesses to the backing JavaScript object.
*/
@@ -22,7 +22,7 @@ class _ConsoleVariables {
return Function.apply(_data[member], invocation.positionalArguments, invocation.namedArguments);
}
}
-
+
void clear() => _data.clear();
/**
@@ -93,17 +93,6 @@ class _Utils {
return new UnsupportedError('[info: $fileName:$lineNo]');
}
- static bool isTypeSubclassOf(Type type, Type other) {
- if (type == other) {
- return true;
- }
- var superclass = reflectClass(type).superclass;
- if (superclass != null) {
- return isTypeSubclassOf(superclass.reflectedType, other);
- }
- return false;
- }
-
static window() native "Utils_window";
static forwardingPrint(String message) native "Utils_forwardingPrint";
static void spawnDomFunction(Function f, int replyTo) native "Utils_spawnDomFunction";
@@ -172,13 +161,13 @@ class _Utils {
sb.write("final $arg");
args[arg] = value;
}
-
+
addArg("\$var", _consoleTempVariables);
-
+
for (int i = 0; i < locals.length; i+= 2) {
addArg(locals[i], locals[i+1]);
}
- sb..write(')=>\n$expression');
+ sb..write(')=>\n$expression');
return [sb.toString(), args.values.toList(growable: false)];
}
@@ -195,10 +184,10 @@ class _Utils {
* prepended to disambuguate. This scheme is simplistic but easy to encode and
* decode. The use case for this method is displaying all map keys in a human
* readable way in debugging tools.
- */
+ */
static List<String> getEncodedMapKeyList(dynamic obj) {
if (obj is! Map) return null;
-
+
var ret = new List<String>();
int i = 0;
return obj.keys.map((key) {
@@ -282,18 +271,40 @@ class _Utils {
return libName.startsWith('dart:');
}
- static void register(Document document, String tag, Type type,
- String extendsTagName) {
+ 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);
if (_isBuiltinType(cls)) {
throw new UnsupportedError("Invalid custom element from $libName.");
}
- _register(document, tag, type, extendsTagName);
+ 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(tag, type, nativeClass.reflectedType);
}
- static void _register(Document document, String tag, Type customType,
- String extendsTagName) native "Utils_register";
+ static void _register(String tag, Type customType, Type nativeType) native "Utils_register";
}
class _NPObject extends NativeFieldWrapperClass1 {
« no previous file with comments | « tools/dom/scripts/systemnative.py ('k') | tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698