| 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 superClass = superClass.superclass; |
| 220 } |
| 221 |
| 222 if (isRoot(superClass)) { |
| 223 throw new UnsupportedError("Invalid custom element doesn't inherit from El
ement."); |
| 224 } |
| 225 _register(tag, type); |
| 226 } |
| 227 |
| 228 static void _register(String tag, Type type) native "Utils_register"; |
| 197 } | 229 } |
| 198 | 230 |
| 199 class _NPObject extends NativeFieldWrapperClass1 { | 231 class _NPObject extends NativeFieldWrapperClass1 { |
| 200 _NPObject.internal(); | 232 _NPObject.internal(); |
| 201 static _NPObject retrieve(String key) native "NPObject_retrieve"; | 233 static _NPObject retrieve(String key) native "NPObject_retrieve"; |
| 202 property(String propertyName) native "NPObject_property"; | 234 property(String propertyName) native "NPObject_property"; |
| 203 invoke(String methodName, [List args = null]) native "NPObject_invoke"; | 235 invoke(String methodName, [List args = null]) native "NPObject_invoke"; |
| 204 } | 236 } |
| 205 | 237 |
| 206 class _DOMWindowCrossFrame extends NativeFieldWrapperClass1 implements | 238 class _DOMWindowCrossFrame extends NativeFieldWrapperClass1 implements |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 _send(msg) { | 420 _send(msg) { |
| 389 _sendToHelperIsolate(msg, _sendPort); | 421 _sendToHelperIsolate(msg, _sendPort); |
| 390 } | 422 } |
| 391 | 423 |
| 392 bool get isActive => _isActive; | 424 bool get isActive => _isActive; |
| 393 } | 425 } |
| 394 | 426 |
| 395 get _pureIsolateTimerFactoryClosure => | 427 get _pureIsolateTimerFactoryClosure => |
| 396 ((int milliSeconds, void callback(Timer time), bool repeating) => | 428 ((int milliSeconds, void callback(Timer time), bool repeating) => |
| 397 new _PureIsolateTimer(milliSeconds, callback, repeating)); | 429 new _PureIsolateTimer(milliSeconds, callback, repeating)); |
| OLD | NEW |