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

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

Issue 184033007: Prototype of Dart proxies for JS objects. Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More tests. Created 6 years, 10 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
Index: tools/dom/src/native_DOMImplementation.dart
diff --git a/tools/dom/src/native_DOMImplementation.dart b/tools/dom/src/native_DOMImplementation.dart
index d84e39642d2b70ee6109a3f3526458306b73e5bc..c630c828db5467cf425e15552e67311813cf7033 100644
--- a/tools/dom/src/native_DOMImplementation.dart
+++ b/tools/dom/src/native_DOMImplementation.dart
@@ -394,48 +394,10 @@ class _Utils {
static bool isNoSuchMethodError(obj) => obj is NoSuchMethodError;
- static bool _isBuiltinType(ClassMirror cls) {
- // TODO(vsm): Find a less hackish way to do this.
- LibraryMirror lib = cls.owner;
- String libName = lib.uri.toString();
- return libName.startsWith('dart:');
- }
-
static void register(Document document, String tag, Type type,
String extendsTagName) {
- // TODO(vsm): Move these checks into native code.
- ClassMirror cls = reflectClass(type);
- if (_isBuiltinType(cls)) {
- throw new UnsupportedError("Invalid custom element from ${(cls.owner as LibraryMirror).uri}.");
- }
- var className = MirrorSystem.getName(cls.simpleName);
- var createdConstructor = cls.declarations[new Symbol('$className.created')];
- if (createdConstructor == null ||
- createdConstructor is! MethodMirror ||
- !createdConstructor.isConstructor) {
- throw new UnsupportedError(
- 'Class is missing constructor $className.created');
- }
+ var nativeClass = _validateCustomType(type);
- if (createdConstructor.parameters.length > 0) {
- throw new UnsupportedError(
- 'Constructor $className.created must take zero arguments');
- }
-
- 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 '
@@ -452,6 +414,8 @@ class _Utils {
static Element createElement(Document document, String tagName) native "Utils_createElement";
static void initializeCustomElement(HtmlElement element) native "Utils_initializeCustomElement";
+
+ static void changeElementWrapper(HtmlElement element, Type type) native "Utils_changeElementWrapper";
}
class _DOMWindowCrossFrame extends NativeFieldWrapperClass2 implements
« no previous file with comments | « tools/dom/src/dartium_CustomElementSupport.dart ('k') | tools/dom/templates/html/dartium/html_dartium.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698