| Index: tools/dom/templates/html/dartium/indexed_db_dartium.darttemplate
|
| diff --git a/tools/dom/templates/html/dartium/indexed_db_dartium.darttemplate b/tools/dom/templates/html/dartium/indexed_db_dartium.darttemplate
|
| index ef3928c9988eb73de4db3deed21b378b6cc98adf..dee0cace7878aa865dfd442d4052f9f20cd9495a 100644
|
| --- a/tools/dom/templates/html/dartium/indexed_db_dartium.darttemplate
|
| +++ b/tools/dom/templates/html/dartium/indexed_db_dartium.darttemplate
|
| @@ -112,10 +112,66 @@ final indexed_dbBlinkMap = {
|
| $!TYPE_MAP
|
| };
|
|
|
| -$if JSINTEROP
|
| -// FIXME: Can we make this private?
|
| -@Deprecated("Internal Use Only")
|
| -final indexed_dbBlinkFunctionMap = {
|
| -$!TYPE_FUNCTION_MAP
|
| -};
|
| -$endif
|
| +
|
| +//
|
| +// Per http://www.w3.org/TR/IndexedDB/#key-construct
|
| +//
|
| +// "A value is said to be a valid key if it is one of the following types: Array
|
| +// JavaScript objects [ECMA-262], DOMString [WEBIDL], Date [ECMA-262] or float
|
| +// [WEBIDL]. However Arrays are only valid keys if every item in the array is
|
| +// defined and is a valid key (i.e. sparse arrays can not be valid keys) and if
|
| +// the Array doesn't directly or indirectly contain itself. Any non-numeric
|
| +// properties are ignored, and thus does not affect whether the Array is a valid
|
| +// key. Additionally, if the value is of type float, it is only a valid key if
|
| +// it is not NaN, and if the value is of type Date it is only a valid key if its
|
| +// [[PrimitiveValue]] internal property, as defined by [ECMA-262], is not NaN."
|
| +
|
| +// What is required is to ensure that an Lists in the key are actually
|
| +// JavaScript arrays, and any Dates are JavaScript Dates.
|
| +
|
| +
|
| +/**
|
| + * Converts a native IDBKey into a Dart object.
|
| + *
|
| + * May return the original input. May mutate the original input (but will be
|
| + * idempotent if mutation occurs). It is assumed that this conversion happens
|
| + * on native IDBKeys on all paths that return IDBKeys from native DOM calls.
|
| + *
|
| + * If necessary, JavaScript Dates are converted into Dart Dates.
|
| + */
|
| +_convertNativeToDart_IDBKey(nativeKey) {
|
| + containsDate(object) {
|
| + if (object is DateTime) return true;
|
| + if (object is List) {
|
| + for (int i = 0; i < object.length; i++) {
|
| + if (containsDate(object[i])) return true;
|
| + }
|
| + }
|
| + return false; // number, string.
|
| + }
|
| + if (nativeKey is DateTime) {
|
| + throw new UnimplementedError('Key containing DateTime');
|
| + }
|
| + // TODO: Cache conversion somewhere?
|
| + return nativeKey;
|
| +}
|
| +
|
| +/**
|
| + * Converts a Dart object into a valid IDBKey.
|
| + *
|
| + * May return the original input. Does not mutate input.
|
| + *
|
| + * If necessary, [dartKey] may be copied to ensure all lists are converted into
|
| + * JavaScript Arrays and Dart Dates into JavaScript Dates.
|
| + */
|
| +_convertDartToNative_IDBKey(dartKey) {
|
| + // TODO: Implement.
|
| + return dartKey;
|
| +}
|
| +
|
| +
|
| +
|
| +/// May modify original. If so, action is idempotent.
|
| +_convertNativeToDart_IDBAny(object) {
|
| + return convertNativeToDart_AcceptStructuredClone(object, mustCopy: false);
|
| +}
|
|
|