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

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

Issue 24491003: Revert "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_Document.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 333d747169094cd902e7e68bf34ccc424bfdf0a9..8991ee140adbac41c3e9300cdc05b3dc95839f99 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,6 +93,17 @@ 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";
@@ -161,13 +172,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)];
}
@@ -184,10 +195,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) {
@@ -271,40 +282,20 @@ class _Utils {
return libName.startsWith('dart:');
}
- static void register(String tag, Type type) {
+ static void register(Document document, String tag, Type type,
+ String extendsTagName) {
// 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.");
}
- 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);
+ _register(document, tag, type, extendsTagName);
}
- static void _register(String tag, Type customType, Type nativeType) native "Utils_register";
+ static void _register(Document document, String tag, Type customType,
+ String extendsTagName) native "Utils_register";
+
+ static Element createElement(Document document, String tagName) native "Utils_createElement";
}
class _NPObject extends NativeFieldWrapperClass1 {
« no previous file with comments | « tools/dom/scripts/systemnative.py ('k') | tools/dom/templates/html/impl/impl_Document.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698