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

Side by Side Diff: tools/dom/src/dartium_CustomElementSupport.dart

Issue 943043005: Do not allow abstract classes to be registered as custom elements (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.dom.html; 5 part of dart.dom.html;
6 6
7 /// Dartium ElementUpgrader implementation. 7 /// Dartium ElementUpgrader implementation.
8 class _VMElementUpgrader implements ElementUpgrader { 8 class _VMElementUpgrader implements ElementUpgrader {
9 final Type _type; 9 final Type _type;
10 final Type _nativeType; 10 final Type _nativeType;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 /// 42 ///
43 /// Then returns the native base class. 43 /// Then returns the native base class.
44 ClassMirror _validateCustomType(Type type) { 44 ClassMirror _validateCustomType(Type type) {
45 ClassMirror cls = reflectClass(type); 45 ClassMirror cls = reflectClass(type);
46 if (_isBuiltinType(cls)) { 46 if (_isBuiltinType(cls)) {
47 throw new UnsupportedError('Invalid custom element from ' 47 throw new UnsupportedError('Invalid custom element from '
48 '${(cls.owner as LibraryMirror).uri}.'); 48 '${(cls.owner as LibraryMirror).uri}.');
49 } 49 }
50 50
51 var className = MirrorSystem.getName(cls.simpleName); 51 var className = MirrorSystem.getName(cls.simpleName);
52 if (cls.isAbstract) {
53 throw new UnsupportedError('Invalid custom element '
54 'class $className is abstract.');
55 }
56
52 var createdConstructor = cls.declarations[new Symbol('$className.created')]; 57 var createdConstructor = cls.declarations[new Symbol('$className.created')];
53 if (createdConstructor == null || 58 if (createdConstructor == null ||
54 createdConstructor is! MethodMirror || 59 createdConstructor is! MethodMirror ||
55 !createdConstructor.isConstructor) { 60 !createdConstructor.isConstructor) {
56 throw new UnsupportedError( 61 throw new UnsupportedError(
57 'Class is missing constructor $className.created'); 62 'Class is missing constructor $className.created');
58 } 63 }
59 64
60 if (createdConstructor.parameters.length > 0) { 65 if (createdConstructor.parameters.length > 0) {
61 throw new UnsupportedError( 66 throw new UnsupportedError(
(...skipping 17 matching lines...) Expand all
79 return nativeClass; 84 return nativeClass;
80 } 85 }
81 86
82 87
83 bool _isBuiltinType(ClassMirror cls) { 88 bool _isBuiltinType(ClassMirror cls) {
84 // TODO(vsm): Find a less hackish way to do this. 89 // TODO(vsm): Find a less hackish way to do this.
85 LibraryMirror lib = cls.owner; 90 LibraryMirror lib = cls.owner;
86 String libName = lib.uri.toString(); 91 String libName = lib.uri.toString();
87 return libName.startsWith('dart:'); 92 return libName.startsWith('dart:');
88 } 93 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698