| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 21 matching lines...) Expand all Loading... |
| 32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
| 33 #include "modules/indexeddb/IDBDatabase.h" | 33 #include "modules/indexeddb/IDBDatabase.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 IDBKeyRange* IDBKeyRange::fromScriptValue(ExecutionContext* context, const Scrip
tValue& value, ExceptionState& exceptionState) | 37 IDBKeyRange* IDBKeyRange::fromScriptValue(ExecutionContext* context, const Scrip
tValue& value, ExceptionState& exceptionState) |
| 38 { | 38 { |
| 39 if (value.isUndefined() || value.isNull()) | 39 if (value.isUndefined() || value.isNull()) |
| 40 return 0; | 40 return 0; |
| 41 | 41 |
| 42 IDBKeyRange* range = value.to<IDBKeyRange*>(exceptionState); | 42 IDBKeyRange* range = ScriptValue::to<IDBKeyRange*>(toIsolate(context), value
, exceptionState); |
| 43 if (range) | 43 if (range) |
| 44 return range; | 44 return range; |
| 45 | 45 |
| 46 IDBKey* key = value.to<IDBKey*>(exceptionState); | 46 IDBKey* key = ScriptValue::to<IDBKey*>(toIsolate(context), value, exceptionS
tate); |
| 47 if (!key || !key->isValid()) { | 47 if (!key || !key->isValid()) { |
| 48 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 48 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
| 49 return 0; | 49 return 0; |
| 50 } | 50 } |
| 51 | 51 |
| 52 return new IDBKeyRange(key, key, LowerBoundClosed, UpperBoundClosed); | 52 return new IDBKeyRange(key, key, LowerBoundClosed, UpperBoundClosed); |
| 53 } | 53 } |
| 54 | 54 |
| 55 IDBKeyRange::IDBKeyRange(IDBKey* lower, IDBKey* upper, LowerBoundType lowerType,
UpperBoundType upperType) | 55 IDBKeyRange::IDBKeyRange(IDBKey* lower, IDBKey* upper, LowerBoundType lowerType,
UpperBoundType upperType) |
| 56 : m_lower(lower) | 56 : m_lower(lower) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 81 if (!key || !key->isValid()) { | 81 if (!key || !key->isValid()) { |
| 82 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 82 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
| 83 return 0; | 83 return 0; |
| 84 } | 84 } |
| 85 | 85 |
| 86 return IDBKeyRange::create(key, key, LowerBoundClosed, UpperBoundClosed); | 86 return IDBKeyRange::create(key, key, LowerBoundClosed, UpperBoundClosed); |
| 87 } | 87 } |
| 88 | 88 |
| 89 IDBKeyRange* IDBKeyRange::only(ExecutionContext* context, const ScriptValue& key
Value, ExceptionState& exceptionState) | 89 IDBKeyRange* IDBKeyRange::only(ExecutionContext* context, const ScriptValue& key
Value, ExceptionState& exceptionState) |
| 90 { | 90 { |
| 91 IDBKey* key = keyValue.to<IDBKey*>(exceptionState); | 91 IDBKey* key = ScriptValue::to<IDBKey*>(toIsolate(context), keyValue, excepti
onState); |
| 92 if (!key || !key->isValid()) { | 92 if (!key || !key->isValid()) { |
| 93 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 93 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
| 94 return 0; | 94 return 0; |
| 95 } | 95 } |
| 96 | 96 |
| 97 return IDBKeyRange::create(key, key, LowerBoundClosed, UpperBoundClosed); | 97 return IDBKeyRange::create(key, key, LowerBoundClosed, UpperBoundClosed); |
| 98 } | 98 } |
| 99 | 99 |
| 100 IDBKeyRange* IDBKeyRange::lowerBound(ExecutionContext* context, const ScriptValu
e& boundValue, bool open, ExceptionState& exceptionState) | 100 IDBKeyRange* IDBKeyRange::lowerBound(ExecutionContext* context, const ScriptValu
e& boundValue, bool open, ExceptionState& exceptionState) |
| 101 { | 101 { |
| 102 IDBKey* bound = boundValue.to<IDBKey*>(exceptionState); | 102 IDBKey* bound = ScriptValue::to<IDBKey*>(toIsolate(context), boundValue, exc
eptionState); |
| 103 if (!bound || !bound->isValid()) { | 103 if (!bound || !bound->isValid()) { |
| 104 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 104 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
| 105 return 0; | 105 return 0; |
| 106 } | 106 } |
| 107 | 107 |
| 108 return IDBKeyRange::create(bound, 0, open ? LowerBoundOpen : LowerBoundClose
d, UpperBoundOpen); | 108 return IDBKeyRange::create(bound, 0, open ? LowerBoundOpen : LowerBoundClose
d, UpperBoundOpen); |
| 109 } | 109 } |
| 110 | 110 |
| 111 IDBKeyRange* IDBKeyRange::upperBound(ExecutionContext* context, const ScriptValu
e& boundValue, bool open, ExceptionState& exceptionState) | 111 IDBKeyRange* IDBKeyRange::upperBound(ExecutionContext* context, const ScriptValu
e& boundValue, bool open, ExceptionState& exceptionState) |
| 112 { | 112 { |
| 113 IDBKey* bound = boundValue.to<IDBKey*>(exceptionState); | 113 IDBKey* bound = ScriptValue::to<IDBKey*>(toIsolate(context), boundValue, exc
eptionState); |
| 114 if (!bound || !bound->isValid()) { | 114 if (!bound || !bound->isValid()) { |
| 115 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 115 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
| 116 return 0; | 116 return 0; |
| 117 } | 117 } |
| 118 | 118 |
| 119 return IDBKeyRange::create(0, bound, LowerBoundOpen, open ? UpperBoundOpen :
UpperBoundClosed); | 119 return IDBKeyRange::create(0, bound, LowerBoundOpen, open ? UpperBoundOpen :
UpperBoundClosed); |
| 120 } | 120 } |
| 121 | 121 |
| 122 IDBKeyRange* IDBKeyRange::bound(ExecutionContext* context, const ScriptValue& lo
werValue, const ScriptValue& upperValue, bool lowerOpen, bool upperOpen, Excepti
onState& exceptionState) | 122 IDBKeyRange* IDBKeyRange::bound(ExecutionContext* context, const ScriptValue& lo
werValue, const ScriptValue& upperValue, bool lowerOpen, bool upperOpen, Excepti
onState& exceptionState) |
| 123 { | 123 { |
| 124 IDBKey* lower = lowerValue.to<IDBKey*>(exceptionState); | 124 IDBKey* lower = ScriptValue::to<IDBKey*>(toIsolate(context), lowerValue, exc
eptionState); |
| 125 IDBKey* upper = upperValue.to<IDBKey*>(exceptionState); | 125 IDBKey* upper = ScriptValue::to<IDBKey*>(toIsolate(context), upperValue, exc
eptionState); |
| 126 | 126 |
| 127 if (!lower || !lower->isValid() || !upper || !upper->isValid()) { | 127 if (!lower || !lower->isValid() || !upper || !upper->isValid()) { |
| 128 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 128 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
| 129 return 0; | 129 return 0; |
| 130 } | 130 } |
| 131 if (upper->isLessThan(lower)) { | 131 if (upper->isLessThan(lower)) { |
| 132 exceptionState.throwDOMException(DataError, "The lower key is greater th
an the upper key."); | 132 exceptionState.throwDOMException(DataError, "The lower key is greater th
an the upper key."); |
| 133 return 0; | 133 return 0; |
| 134 } | 134 } |
| 135 if (upper->isEqual(lower) && (lowerOpen || upperOpen)) { | 135 if (upper->isEqual(lower) && (lowerOpen || upperOpen)) { |
| 136 exceptionState.throwDOMException(DataError, "The lower key and upper key
are equal and one of the bounds is open."); | 136 exceptionState.throwDOMException(DataError, "The lower key and upper key
are equal and one of the bounds is open."); |
| 137 return 0; | 137 return 0; |
| 138 } | 138 } |
| 139 | 139 |
| 140 return IDBKeyRange::create(lower, upper, lowerOpen ? LowerBoundOpen : LowerB
oundClosed, upperOpen ? UpperBoundOpen : UpperBoundClosed); | 140 return IDBKeyRange::create(lower, upper, lowerOpen ? LowerBoundOpen : LowerB
oundClosed, upperOpen ? UpperBoundOpen : UpperBoundClosed); |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace blink | 143 } // namespace blink |
| OLD | NEW |