| 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 | 5 |
| 6 // Conversions for Window. These check if the window is the local | 6 // Conversions for Window. These check if the window is the local |
| 7 // window, and if it's not, wraps or unwraps it with a secure wrapper. | 7 // window, and if it's not, wraps or unwraps it with a secure wrapper. |
| 8 // We need to test for EventTarget here as well as it's a base type. | 8 // We need to test for EventTarget here as well as it's a base type. |
| 9 // We omit an unwrapper for Window as no methods take a non-local | 9 // We omit an unwrapper for Window as no methods take a non-local |
| 10 // window as a parameter. | 10 // window as a parameter. |
| 11 | 11 |
| 12 part of html; | 12 part of html; |
| 13 | 13 |
| 14 DateTime _convertNativeToDart_DateTime(date) { | 14 DateTime _convertNativeToDart_DateTime(date) { |
| 15 var millisSinceEpoch = JS('int', '#.getTime()', date); | 15 var millisSinceEpoch = JS('int', '#.getTime()', date); |
| 16 return new DateTime.fromMillisecondsSinceEpoch(millisSinceEpoch, isUtc: true); | 16 return new DateTime.fromMillisecondsSinceEpoch(millisSinceEpoch, isUtc: true); |
| 17 } | 17 } |
| 18 | 18 |
| 19 _convertDartToNative_DateTime(DateTime date) { | 19 _convertDartToNative_DateTime(DateTime date) { |
| 20 return JS('', 'new Date(#)', date.millisecondsSinceEpoch); | 20 return JS('', 'new Date(#)', date.millisecondsSinceEpoch); |
| 21 } | 21 } |
| 22 | 22 |
| 23 WindowBase _convertNativeToDart_Window(win) { | 23 WindowBase _convertNativeToDart_Window(win) { |
| 24 return _DOMWindowCrossFrame._createSafe(win); | 24 return _DOMWindowCrossFrame._createSafe(win); |
| 25 } | 25 } |
| 26 | 26 |
| 27 EventTarget _convertNativeToDart_EventTarget(e) { | 27 EventTarget _convertNativeToDart_EventTarget(e) { |
| 28 if (e == null) { |
| 29 return null; |
| 30 } |
| 28 // Assume it's a Window if it contains the setInterval property. It may be | 31 // Assume it's a Window if it contains the setInterval property. It may be |
| 29 // from a different frame - without a patched prototype - so we cannot | 32 // from a different frame - without a patched prototype - so we cannot |
| 30 // rely on Dart type checking. | 33 // rely on Dart type checking. |
| 31 if (JS('bool', r'"setInterval" in #', e)) | 34 if (JS('bool', r'"setInterval" in #', e)) |
| 32 return _DOMWindowCrossFrame._createSafe(e); | 35 return _DOMWindowCrossFrame._createSafe(e); |
| 33 else | 36 else |
| 34 return e; | 37 return e; |
| 35 } | 38 } |
| 36 | 39 |
| 37 EventTarget _convertDartToNative_EventTarget(e) { | 40 EventTarget _convertDartToNative_EventTarget(e) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 80 |
| 78 // We can get rid of this conversion if _TypedImageData implements the fields | 81 // We can get rid of this conversion if _TypedImageData implements the fields |
| 79 // with native names. | 82 // with native names. |
| 80 _convertDartToNative_ImageData(ImageData imageData) { | 83 _convertDartToNative_ImageData(ImageData imageData) { |
| 81 if (imageData is _TypedImageData) { | 84 if (imageData is _TypedImageData) { |
| 82 return JS('', '{data: #, height: #, width: #}', | 85 return JS('', '{data: #, height: #, width: #}', |
| 83 imageData.data, imageData.height, imageData.width); | 86 imageData.data, imageData.height, imageData.width); |
| 84 } | 87 } |
| 85 return imageData; | 88 return imageData; |
| 86 } | 89 } |
| OLD | NEW |