OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 return value; | 158 return value; |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 ASSERT_NOT_REACHED(); | 162 ASSERT_NOT_REACHED(); |
163 return v8::Undefined(isolate); | 163 return v8::Undefined(isolate); |
164 } | 164 } |
165 | 165 |
166 static const size_t maximumDepth = 2000; | 166 static const size_t maximumDepth = 2000; |
167 | 167 |
168 static IDBKey* createIDBKeyFromValue(v8::Isolate* isolate, v8::Local<v8::Value>
value, Vector<v8::Local<v8::Array> >& stack, bool allowExperimentalTypes = false
) | 168 static IDBKey* createIDBKeyFromValue(v8::Isolate* isolate, v8::Local<v8::Value>
value, Vector<v8::Local<v8::Array>>& stack, bool allowExperimentalTypes = false) |
169 { | 169 { |
170 if (value->IsNumber() && !std::isnan(value->NumberValue())) | 170 if (value->IsNumber() && !std::isnan(value->NumberValue())) |
171 return IDBKey::createNumber(value->NumberValue()); | 171 return IDBKey::createNumber(value->NumberValue()); |
172 if (value->IsString()) | 172 if (value->IsString()) |
173 return IDBKey::createString(toCoreString(value.As<v8::String>())); | 173 return IDBKey::createString(toCoreString(value.As<v8::String>())); |
174 if (value->IsDate() && !std::isnan(value->NumberValue())) | 174 if (value->IsDate() && !std::isnan(value->NumberValue())) |
175 return IDBKey::createDate(value->NumberValue()); | 175 return IDBKey::createDate(value->NumberValue()); |
176 if (value->IsUint8Array() && (allowExperimentalTypes || RuntimeEnabledFeatur
es::indexedDBExperimentalEnabled())) { | 176 if (value->IsUint8Array() && (allowExperimentalTypes || RuntimeEnabledFeatur
es::indexedDBExperimentalEnabled())) { |
177 // Per discussion in https://www.w3.org/Bugs/Public/show_bug.cgi?id=2333
2 the | 177 // Per discussion in https://www.w3.org/Bugs/Public/show_bug.cgi?id=2333
2 the |
178 // input type is constrained to Uint8Array to match the output type. | 178 // input type is constrained to Uint8Array to match the output type. |
(...skipping 23 matching lines...) Expand all Loading... |
202 } | 202 } |
203 | 203 |
204 stack.removeLast(); | 204 stack.removeLast(); |
205 return IDBKey::createArray(subkeys); | 205 return IDBKey::createArray(subkeys); |
206 } | 206 } |
207 return 0; | 207 return 0; |
208 } | 208 } |
209 | 209 |
210 static IDBKey* createIDBKeyFromValue(v8::Isolate* isolate, v8::Local<v8::Value>
value, bool allowExperimentalTypes = false) | 210 static IDBKey* createIDBKeyFromValue(v8::Isolate* isolate, v8::Local<v8::Value>
value, bool allowExperimentalTypes = false) |
211 { | 211 { |
212 Vector<v8::Local<v8::Array> > stack; | 212 Vector<v8::Local<v8::Array>> stack; |
213 if (IDBKey* key = createIDBKeyFromValue(isolate, value, stack, allowExperime
ntalTypes)) | 213 if (IDBKey* key = createIDBKeyFromValue(isolate, value, stack, allowExperime
ntalTypes)) |
214 return key; | 214 return key; |
215 return IDBKey::createInvalid(); | 215 return IDBKey::createInvalid(); |
216 } | 216 } |
217 | 217 |
218 template<typename T> | 218 template<typename T> |
219 static bool getValueFrom(T indexOrName, v8::Local<v8::Value>& v8Value, v8::Isola
te* isolate) | 219 static bool getValueFrom(T indexOrName, v8::Local<v8::Value>& v8Value, v8::Isola
te* isolate) |
220 { | 220 { |
221 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); | 221 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); |
222 if (!object->Has(indexOrName)) | 222 if (!object->Has(indexOrName)) |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 const bool allowExperimentalTypes = true; | 458 const bool allowExperimentalTypes = true; |
459 IDBKey* expectedKey = createIDBKeyFromScriptValueAndKeyPathInternal(isolate,
scriptValue, keyPath, allowExperimentalTypes); | 459 IDBKey* expectedKey = createIDBKeyFromScriptValueAndKeyPathInternal(isolate,
scriptValue, keyPath, allowExperimentalTypes); |
460 ASSERT(!expectedKey || expectedKey->isEqual(key)); | 460 ASSERT(!expectedKey || expectedKey->isEqual(key)); |
461 | 461 |
462 bool injected = injectV8KeyIntoV8Value(isolate, keyValue.v8Value(), scriptVa
lue.v8Value(), keyPath); | 462 bool injected = injectV8KeyIntoV8Value(isolate, keyValue.v8Value(), scriptVa
lue.v8Value(), keyPath); |
463 ASSERT_UNUSED(injected, injected); | 463 ASSERT_UNUSED(injected, injected); |
464 } | 464 } |
465 #endif | 465 #endif |
466 | 466 |
467 } // namespace blink | 467 } // namespace blink |
OLD | NEW |