| 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 // Conversions for IDBKey. | 5 // Conversions for IDBKey. |
| 6 // | 6 // |
| 7 // Per http://www.w3.org/TR/IndexedDB/#key-construct | 7 // Per http://www.w3.org/TR/IndexedDB/#key-construct |
| 8 // | 8 // |
| 9 // "A value is said to be a valid key if it is one of the following types: Array | 9 // "A value is said to be a valid key if it is one of the following types: Array |
| 10 // JavaScript objects [ECMA-262], DOMString [WEBIDL], Date [ECMA-262] or float | 10 // JavaScript objects [ECMA-262], DOMString [WEBIDL], Date [ECMA-262] or float |
| 11 // [WEBIDL]. However Arrays are only valid keys if every item in the array is | 11 // [WEBIDL]. However Arrays are only valid keys if every item in the array is |
| 12 // defined and is a valid key (i.e. sparse arrays can not be valid keys) and if | 12 // defined and is a valid key (i.e. sparse arrays can not be valid keys) and if |
| 13 // the Array doesn't directly or indirectly contain itself. Any non-numeric | 13 // the Array doesn't directly or indirectly contain itself. Any non-numeric |
| 14 // properties are ignored, and thus does not affect whether the Array is a valid | 14 // properties are ignored, and thus does not affect whether the Array is a valid |
| 15 // key. Additionally, if the value is of type float, it is only a valid key if | 15 // key. Additionally, if the value is of type float, it is only a valid key if |
| 16 // it is not NaN, and if the value is of type Date it is only a valid key if its | 16 // it is not NaN, and if the value is of type Date it is only a valid key if its |
| 17 // [[PrimitiveValue]] internal property, as defined by [ECMA-262], is not NaN." | 17 // [[PrimitiveValue]] internal property, as defined by [ECMA-262], is not NaN." |
| 18 | 18 |
| 19 // What is required is to ensure that an Lists in the key are actually | 19 // What is required is to ensure that an Lists in the key are actually |
| 20 // JavaScript arrays, and any Dates are JavaScript Dates. | 20 // JavaScript arrays, and any Dates are JavaScript Dates. |
| 21 | 21 |
| 22 // Conversions for Window. These check if the window is the local | 22 // Conversions for Window. These check if the window is the local |
| 23 // window, and if it's not, wraps or unwraps it with a secure wrapper. | 23 // window, and if it's not, wraps or unwraps it with a secure wrapper. |
| 24 // We need to test for EventTarget here as well as it's a base type. | 24 // We need to test for EventTarget here as well as it's a base type. |
| 25 // We omit an unwrapper for Window as no methods take a non-local | 25 // We omit an unwrapper for Window as no methods take a non-local |
| 26 // window as a parameter. | 26 // window as a parameter. |
| 27 | 27 |
| 28 part of "html_common.dart"; | 28 part of html_common; |
| 29 | 29 |
| 30 /// Converts a Dart value into a JavaScript SerializedScriptValue. | 30 /// Converts a Dart value into a JavaScript SerializedScriptValue. |
| 31 convertDartToNative_SerializedScriptValue(value) { | 31 convertDartToNative_SerializedScriptValue(value) { |
| 32 return convertDartToNative_PrepareForStructuredClone(value); | 32 return convertDartToNative_PrepareForStructuredClone(value); |
| 33 } | 33 } |
| 34 | 34 |
| 35 /// Since the source object may be viewed via a JavaScript event listener the | 35 /// Since the source object may be viewed via a JavaScript event listener the |
| 36 /// original may not be modified. | 36 /// original may not be modified. |
| 37 convertNativeToDart_SerializedScriptValue(object) { | 37 convertNativeToDart_SerializedScriptValue(object) { |
| 38 return convertNativeToDart_AcceptStructuredClone(object, mustCopy: true); | 38 return convertNativeToDart_AcceptStructuredClone(object, mustCopy: true); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 | 349 |
| 350 // We can get rid of this conversion if _TypedImageData implements the fields | 350 // We can get rid of this conversion if _TypedImageData implements the fields |
| 351 // with native names. | 351 // with native names. |
| 352 convertDartToNative_ImageData(ImageData imageData) { | 352 convertDartToNative_ImageData(ImageData imageData) { |
| 353 if (imageData is _TypedImageData) { | 353 if (imageData is _TypedImageData) { |
| 354 return JS('', '{data: #, height: #, width: #}', imageData.data, | 354 return JS('', '{data: #, height: #, width: #}', imageData.data, |
| 355 imageData.height, imageData.width); | 355 imageData.height, imageData.width); |
| 356 } | 356 } |
| 357 return imageData; | 357 return imageData; |
| 358 } | 358 } |
| OLD | NEW |