| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 IDBKeyRange* IDBKeyRange::only(IDBKey* key, ExceptionState& exceptionState) { | 82 IDBKeyRange* IDBKeyRange::only(IDBKey* key, ExceptionState& exceptionState) { |
| 83 if (!key || !key->isValid()) { | 83 if (!key || !key->isValid()) { |
| 84 exceptionState.throwDOMException(DataError, | 84 exceptionState.throwDOMException(DataError, |
| 85 IDBDatabase::notValidKeyErrorMessage); | 85 IDBDatabase::notValidKeyErrorMessage); |
| 86 return nullptr; | 86 return nullptr; |
| 87 } | 87 } |
| 88 | 88 |
| 89 return IDBKeyRange::create(key, key, LowerBoundClosed, UpperBoundClosed); | 89 return IDBKeyRange::create(key, key, LowerBoundClosed, UpperBoundClosed); |
| 90 } | 90 } |
| 91 | 91 |
| 92 IDBKeyRange* IDBKeyRange::only(ExecutionContext* context, | 92 IDBKeyRange* IDBKeyRange::only(ScriptState* scriptState, |
| 93 const ScriptValue& keyValue, | 93 const ScriptValue& keyValue, |
| 94 ExceptionState& exceptionState) { | 94 ExceptionState& exceptionState) { |
| 95 IDBKey* key = | 95 IDBKey* key = ScriptValue::to<IDBKey*>( |
| 96 ScriptValue::to<IDBKey*>(toIsolate(context), keyValue, exceptionState); | 96 toIsolate(scriptState->getExecutionContext()), keyValue, exceptionState); |
| 97 if (exceptionState.hadException()) | 97 if (exceptionState.hadException()) |
| 98 return nullptr; | 98 return nullptr; |
| 99 if (!key || !key->isValid()) { | 99 if (!key || !key->isValid()) { |
| 100 exceptionState.throwDOMException(DataError, | 100 exceptionState.throwDOMException(DataError, |
| 101 IDBDatabase::notValidKeyErrorMessage); | 101 IDBDatabase::notValidKeyErrorMessage); |
| 102 return nullptr; | 102 return nullptr; |
| 103 } | 103 } |
| 104 | 104 |
| 105 return IDBKeyRange::create(key, key, LowerBoundClosed, UpperBoundClosed); | 105 return IDBKeyRange::create(key, key, LowerBoundClosed, UpperBoundClosed); |
| 106 } | 106 } |
| 107 | 107 |
| 108 IDBKeyRange* IDBKeyRange::lowerBound(ExecutionContext* context, | 108 IDBKeyRange* IDBKeyRange::lowerBound(ScriptState* scriptState, |
| 109 const ScriptValue& boundValue, | 109 const ScriptValue& boundValue, |
| 110 bool open, | 110 bool open, |
| 111 ExceptionState& exceptionState) { | 111 ExceptionState& exceptionState) { |
| 112 IDBKey* bound = | 112 IDBKey* bound = |
| 113 ScriptValue::to<IDBKey*>(toIsolate(context), boundValue, exceptionState); | 113 ScriptValue::to<IDBKey*>(toIsolate(scriptState->getExecutionContext()), |
| 114 boundValue, exceptionState); |
| 114 if (exceptionState.hadException()) | 115 if (exceptionState.hadException()) |
| 115 return nullptr; | 116 return nullptr; |
| 116 if (!bound || !bound->isValid()) { | 117 if (!bound || !bound->isValid()) { |
| 117 exceptionState.throwDOMException(DataError, | 118 exceptionState.throwDOMException(DataError, |
| 118 IDBDatabase::notValidKeyErrorMessage); | 119 IDBDatabase::notValidKeyErrorMessage); |
| 119 return nullptr; | 120 return nullptr; |
| 120 } | 121 } |
| 121 | 122 |
| 122 return IDBKeyRange::create( | 123 return IDBKeyRange::create( |
| 123 bound, nullptr, open ? LowerBoundOpen : LowerBoundClosed, UpperBoundOpen); | 124 bound, nullptr, open ? LowerBoundOpen : LowerBoundClosed, UpperBoundOpen); |
| 124 } | 125 } |
| 125 | 126 |
| 126 IDBKeyRange* IDBKeyRange::upperBound(ExecutionContext* context, | 127 IDBKeyRange* IDBKeyRange::upperBound(ScriptState* scriptState, |
| 127 const ScriptValue& boundValue, | 128 const ScriptValue& boundValue, |
| 128 bool open, | 129 bool open, |
| 129 ExceptionState& exceptionState) { | 130 ExceptionState& exceptionState) { |
| 130 IDBKey* bound = | 131 IDBKey* bound = |
| 131 ScriptValue::to<IDBKey*>(toIsolate(context), boundValue, exceptionState); | 132 ScriptValue::to<IDBKey*>(toIsolate(scriptState->getExecutionContext()), |
| 133 boundValue, exceptionState); |
| 132 if (exceptionState.hadException()) | 134 if (exceptionState.hadException()) |
| 133 return nullptr; | 135 return nullptr; |
| 134 if (!bound || !bound->isValid()) { | 136 if (!bound || !bound->isValid()) { |
| 135 exceptionState.throwDOMException(DataError, | 137 exceptionState.throwDOMException(DataError, |
| 136 IDBDatabase::notValidKeyErrorMessage); | 138 IDBDatabase::notValidKeyErrorMessage); |
| 137 return nullptr; | 139 return nullptr; |
| 138 } | 140 } |
| 139 | 141 |
| 140 return IDBKeyRange::create(nullptr, bound, LowerBoundOpen, | 142 return IDBKeyRange::create(nullptr, bound, LowerBoundOpen, |
| 141 open ? UpperBoundOpen : UpperBoundClosed); | 143 open ? UpperBoundOpen : UpperBoundClosed); |
| 142 } | 144 } |
| 143 | 145 |
| 144 IDBKeyRange* IDBKeyRange::bound(ExecutionContext* context, | 146 IDBKeyRange* IDBKeyRange::bound(ScriptState* scriptState, |
| 145 const ScriptValue& lowerValue, | 147 const ScriptValue& lowerValue, |
| 146 const ScriptValue& upperValue, | 148 const ScriptValue& upperValue, |
| 147 bool lowerOpen, | 149 bool lowerOpen, |
| 148 bool upperOpen, | 150 bool upperOpen, |
| 149 ExceptionState& exceptionState) { | 151 ExceptionState& exceptionState) { |
| 150 IDBKey* lower = | 152 IDBKey* lower = |
| 151 ScriptValue::to<IDBKey*>(toIsolate(context), lowerValue, exceptionState); | 153 ScriptValue::to<IDBKey*>(toIsolate(scriptState->getExecutionContext()), |
| 154 lowerValue, exceptionState); |
| 152 if (exceptionState.hadException()) | 155 if (exceptionState.hadException()) |
| 153 return nullptr; | 156 return nullptr; |
| 154 if (!lower || !lower->isValid()) { | 157 if (!lower || !lower->isValid()) { |
| 155 exceptionState.throwDOMException(DataError, | 158 exceptionState.throwDOMException(DataError, |
| 156 IDBDatabase::notValidKeyErrorMessage); | 159 IDBDatabase::notValidKeyErrorMessage); |
| 157 return nullptr; | 160 return nullptr; |
| 158 } | 161 } |
| 159 | 162 |
| 160 IDBKey* upper = | 163 IDBKey* upper = |
| 161 ScriptValue::to<IDBKey*>(toIsolate(context), upperValue, exceptionState); | 164 ScriptValue::to<IDBKey*>(toIsolate(scriptState->getExecutionContext()), |
| 165 upperValue, exceptionState); |
| 162 if (exceptionState.hadException()) | 166 if (exceptionState.hadException()) |
| 163 return nullptr; | 167 return nullptr; |
| 164 if (!upper || !upper->isValid()) { | 168 if (!upper || !upper->isValid()) { |
| 165 exceptionState.throwDOMException(DataError, | 169 exceptionState.throwDOMException(DataError, |
| 166 IDBDatabase::notValidKeyErrorMessage); | 170 IDBDatabase::notValidKeyErrorMessage); |
| 167 return nullptr; | 171 return nullptr; |
| 168 } | 172 } |
| 169 | 173 |
| 170 if (upper->isLessThan(lower)) { | 174 if (upper->isLessThan(lower)) { |
| 171 exceptionState.throwDOMException( | 175 exceptionState.throwDOMException( |
| 172 DataError, "The lower key is greater than the upper key."); | 176 DataError, "The lower key is greater than the upper key."); |
| 173 return nullptr; | 177 return nullptr; |
| 174 } | 178 } |
| 175 if (upper->isEqual(lower) && (lowerOpen || upperOpen)) { | 179 if (upper->isEqual(lower) && (lowerOpen || upperOpen)) { |
| 176 exceptionState.throwDOMException( | 180 exceptionState.throwDOMException( |
| 177 DataError, | 181 DataError, |
| 178 "The lower key and upper key are equal and one of the bounds is open."); | 182 "The lower key and upper key are equal and one of the bounds is open."); |
| 179 return nullptr; | 183 return nullptr; |
| 180 } | 184 } |
| 181 | 185 |
| 182 return IDBKeyRange::create(lower, upper, | 186 return IDBKeyRange::create(lower, upper, |
| 183 lowerOpen ? LowerBoundOpen : LowerBoundClosed, | 187 lowerOpen ? LowerBoundOpen : LowerBoundClosed, |
| 184 upperOpen ? UpperBoundOpen : UpperBoundClosed); | 188 upperOpen ? UpperBoundOpen : UpperBoundClosed); |
| 185 } | 189 } |
| 186 | 190 |
| 187 bool IDBKeyRange::includes(ExecutionContext* context, | 191 bool IDBKeyRange::includes(ScriptState* scriptState, |
| 188 const ScriptValue& keyValue, | 192 const ScriptValue& keyValue, |
| 189 ExceptionState& exceptionState) { | 193 ExceptionState& exceptionState) { |
| 190 IDBKey* key = | 194 IDBKey* key = ScriptValue::to<IDBKey*>( |
| 191 ScriptValue::to<IDBKey*>(toIsolate(context), keyValue, exceptionState); | 195 toIsolate(scriptState->getExecutionContext()), keyValue, exceptionState); |
| 192 if (exceptionState.hadException()) | 196 if (exceptionState.hadException()) |
| 193 return false; | 197 return false; |
| 194 if (!key || !key->isValid()) { | 198 if (!key || !key->isValid()) { |
| 195 exceptionState.throwDOMException(DataError, | 199 exceptionState.throwDOMException(DataError, |
| 196 IDBDatabase::notValidKeyErrorMessage); | 200 IDBDatabase::notValidKeyErrorMessage); |
| 197 return false; | 201 return false; |
| 198 } | 202 } |
| 199 | 203 |
| 200 if (m_lower) { | 204 if (m_lower) { |
| 201 short c = key->compare(m_lower); | 205 short c = key->compare(m_lower); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 215 return false; | 219 return false; |
| 216 } else { | 220 } else { |
| 217 if (c > 0) | 221 if (c > 0) |
| 218 return false; | 222 return false; |
| 219 } | 223 } |
| 220 } | 224 } |
| 221 return true; | 225 return true; |
| 222 } | 226 } |
| 223 | 227 |
| 224 } // namespace blink | 228 } // namespace blink |
| OLD | NEW |