Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 html; | 5 part of html; |
| 6 | 6 |
| 7 class _Utils { | 7 class _Utils { |
| 8 static double dateTimeToDouble(DateTime dateTime) => | 8 static double dateTimeToDouble(DateTime dateTime) => |
| 9 dateTime.millisecondsSinceEpoch.toDouble(); | 9 dateTime.millisecondsSinceEpoch.toDouble(); |
| 10 static DateTime doubleToDateTime(double dateTime) { | 10 static DateTime doubleToDateTime(double dateTime) { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 static String stripTrailingDot(String str) => | 187 static String stripTrailingDot(String str) => |
| 188 (str != null && str[str.length - 1] == '.') ? str.substring(0, str.length - 1) : str; | 188 (str != null && str[str.length - 1] == '.') ? str.substring(0, str.length - 1) : str; |
| 189 | 189 |
| 190 static String addTrailingDot(String str) => '${str}.'; | 190 static String addTrailingDot(String str) => '${str}.'; |
| 191 | 191 |
| 192 static bool isNoSuchMethodError(obj) => obj is NoSuchMethodError; | 192 static bool isNoSuchMethodError(obj) => obj is NoSuchMethodError; |
| 193 | 193 |
| 194 // TODO(jacobr): we need a failsafe way to determine that a Node is really a | 194 // TODO(jacobr): we need a failsafe way to determine that a Node is really a |
| 195 // DOM node rather than just a class that extends Node. | 195 // DOM node rather than just a class that extends Node. |
| 196 static bool isNode(obj) => obj is Node; | 196 static bool isNode(obj) => obj is Node; |
| 197 | |
| 198 static void register(String tag, Type type) { | |
| 199 // TODO(vsm): Move these checks into native code. | |
| 200 if (type == null) { | |
| 201 throw new UnsupportedError("Invalid null type."); | |
| 202 } | |
| 203 ClassMirror cls = reflectClass(type); | |
| 204 LibraryMirror lib = cls.owner; | |
| 205 String libName = lib.uri.toString(); | |
| 206 if (libName.startsWith('dart:')) { | |
| 207 throw new UnsupportedError("Invalid custom element from $libName."); | |
| 208 } | |
| 209 ClassMirror superClass = cls.superclass; | |
| 210 | |
| 211 Symbol objectName = reflectClass(Object).qualifiedName; | |
| 212 bool isRoot(ClassMirror cls) => | |
| 213 cls == null || cls.qualifiedName == objectName; | |
| 214 Symbol elementName = reflectClass(Element).qualifiedName; | |
| 215 bool isElement(ClassMirror cls) => | |
| 216 cls != null && cls.qualifiedName == elementName; | |
| 217 | |
| 218 while(!isRoot(superClass) && !isElement(superClass)) { | |
| 219 print('testing ${superClass.simpleName.toString()}'); | |
|
blois
2013/08/13 17:15:44
Debug code
vsm
2013/08/13 19:23:30
Done.
| |
| 220 superClass = superClass.superclass; | |
| 221 } | |
| 222 | |
| 223 if (isRoot(superClass)) { | |
| 224 throw new UnsupportedError("Invalid custom element doesn't inherit from El ement."); | |
| 225 } | |
| 226 _register(tag, type); | |
| 227 } | |
| 228 | |
| 229 static void _register(String tag, Type type) native "Utils_register"; | |
| 197 } | 230 } |
| 198 | 231 |
| 199 class _NPObject extends NativeFieldWrapperClass1 { | 232 class _NPObject extends NativeFieldWrapperClass1 { |
| 200 _NPObject.internal(); | 233 _NPObject.internal(); |
| 201 static _NPObject retrieve(String key) native "NPObject_retrieve"; | 234 static _NPObject retrieve(String key) native "NPObject_retrieve"; |
| 202 property(String propertyName) native "NPObject_property"; | 235 property(String propertyName) native "NPObject_property"; |
| 203 invoke(String methodName, [List args = null]) native "NPObject_invoke"; | 236 invoke(String methodName, [List args = null]) native "NPObject_invoke"; |
| 204 } | 237 } |
| 205 | 238 |
| 206 class _DOMWindowCrossFrame extends NativeFieldWrapperClass1 implements | 239 class _DOMWindowCrossFrame extends NativeFieldWrapperClass1 implements |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 _send(msg) { | 421 _send(msg) { |
| 389 _sendToHelperIsolate(msg, _sendPort); | 422 _sendToHelperIsolate(msg, _sendPort); |
| 390 } | 423 } |
| 391 | 424 |
| 392 bool get isActive => _isActive; | 425 bool get isActive => _isActive; |
| 393 } | 426 } |
| 394 | 427 |
| 395 get _pureIsolateTimerFactoryClosure => | 428 get _pureIsolateTimerFactoryClosure => |
| 396 ((int milliSeconds, void callback(Timer time), bool repeating) => | 429 ((int milliSeconds, void callback(Timer time), bool repeating) => |
| 397 new _PureIsolateTimer(milliSeconds, callback, repeating)); | 430 new _PureIsolateTimer(milliSeconds, callback, repeating)); |
| OLD | NEW |