| 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 20 matching lines...) Expand all  Loading... | 
| 31 #include "bindings/v8/IDBBindingUtilities.h" | 31 #include "bindings/v8/IDBBindingUtilities.h" | 
| 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 WebCore { | 35 namespace WebCore { | 
| 36 | 36 | 
| 37 PassRefPtr<IDBKeyRange> IDBKeyRange::fromScriptValue(ExecutionContext* context, 
     const ScriptValue& value, ExceptionState& exceptionState) | 37 PassRefPtr<IDBKeyRange> IDBKeyRange::fromScriptValue(ExecutionContext* context, 
     const ScriptValue& value, ExceptionState& exceptionState) | 
| 38 { | 38 { | 
| 39     DOMRequestState requestState(context); | 39     DOMRequestState requestState(context); | 
| 40     if (value.isUndefined() || value.isNull()) | 40     if (value.isUndefined() || value.isNull()) | 
| 41         return 0; | 41         return nullptr; | 
| 42 | 42 | 
| 43     RefPtr<IDBKeyRange> range = scriptValueToIDBKeyRange(&requestState, value); | 43     RefPtr<IDBKeyRange> range = scriptValueToIDBKeyRange(&requestState, value); | 
| 44     if (range) | 44     if (range) | 
| 45         return range.release(); | 45         return range.release(); | 
| 46 | 46 | 
| 47     RefPtr<IDBKey> key = scriptValueToIDBKey(&requestState, value); | 47     RefPtr<IDBKey> key = scriptValueToIDBKey(&requestState, value); | 
| 48     if (!key || !key->isValid()) { | 48     if (!key || !key->isValid()) { | 
| 49         exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
     rMessage); | 49         exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
     rMessage); | 
| 50         return 0; | 50         return nullptr; | 
| 51     } | 51     } | 
| 52 | 52 | 
| 53     return adoptRef(new IDBKeyRange(key, key, LowerBoundClosed, UpperBoundClosed
     )); | 53     return adoptRef(new IDBKeyRange(key, key, LowerBoundClosed, UpperBoundClosed
     )); | 
| 54 } | 54 } | 
| 55 | 55 | 
| 56 IDBKeyRange::IDBKeyRange(PassRefPtr<IDBKey> lower, PassRefPtr<IDBKey> upper, Low
     erBoundType lowerType, UpperBoundType upperType) | 56 IDBKeyRange::IDBKeyRange(PassRefPtr<IDBKey> lower, PassRefPtr<IDBKey> upper, Low
     erBoundType lowerType, UpperBoundType upperType) | 
| 57     : m_lower(lower) | 57     : m_lower(lower) | 
| 58     , m_upper(upper) | 58     , m_upper(upper) | 
| 59     , m_lowerType(lowerType) | 59     , m_lowerType(lowerType) | 
| 60     , m_upperType(upperType) | 60     , m_upperType(upperType) | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 72 { | 72 { | 
| 73     DOMRequestState requestState(context); | 73     DOMRequestState requestState(context); | 
| 74     return idbKeyToScriptValue(&requestState, m_upper); | 74     return idbKeyToScriptValue(&requestState, m_upper); | 
| 75 } | 75 } | 
| 76 | 76 | 
| 77 PassRefPtr<IDBKeyRange> IDBKeyRange::only(PassRefPtr<IDBKey> prpKey, ExceptionSt
     ate& exceptionState) | 77 PassRefPtr<IDBKeyRange> IDBKeyRange::only(PassRefPtr<IDBKey> prpKey, ExceptionSt
     ate& exceptionState) | 
| 78 { | 78 { | 
| 79     RefPtr<IDBKey> key = prpKey; | 79     RefPtr<IDBKey> key = prpKey; | 
| 80     if (!key || !key->isValid()) { | 80     if (!key || !key->isValid()) { | 
| 81         exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
     rMessage); | 81         exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
     rMessage); | 
| 82         return 0; | 82         return nullptr; | 
| 83     } | 83     } | 
| 84 | 84 | 
| 85     return IDBKeyRange::create(key, key, LowerBoundClosed, UpperBoundClosed); | 85     return IDBKeyRange::create(key, key, LowerBoundClosed, UpperBoundClosed); | 
| 86 } | 86 } | 
| 87 | 87 | 
| 88 PassRefPtr<IDBKeyRange> IDBKeyRange::only(ExecutionContext* context, const Scrip
     tValue& keyValue, ExceptionState& exceptionState) | 88 PassRefPtr<IDBKeyRange> IDBKeyRange::only(ExecutionContext* context, const Scrip
     tValue& keyValue, ExceptionState& exceptionState) | 
| 89 { | 89 { | 
| 90     DOMRequestState requestState(context); | 90     DOMRequestState requestState(context); | 
| 91     RefPtr<IDBKey> key = scriptValueToIDBKey(&requestState, keyValue); | 91     RefPtr<IDBKey> key = scriptValueToIDBKey(&requestState, keyValue); | 
| 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 nullptr; | 
| 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 PassRefPtr<IDBKeyRange> IDBKeyRange::lowerBound(ExecutionContext* context, const
      ScriptValue& boundValue, bool open, ExceptionState& exceptionState) | 100 PassRefPtr<IDBKeyRange> IDBKeyRange::lowerBound(ExecutionContext* context, const
      ScriptValue& boundValue, bool open, ExceptionState& exceptionState) | 
| 101 { | 101 { | 
| 102     DOMRequestState requestState(context); | 102     DOMRequestState requestState(context); | 
| 103     RefPtr<IDBKey> bound = scriptValueToIDBKey(&requestState, boundValue); | 103     RefPtr<IDBKey> bound = scriptValueToIDBKey(&requestState, boundValue); | 
| 104     if (!bound || !bound->isValid()) { | 104     if (!bound || !bound->isValid()) { | 
| 105         exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
     rMessage); | 105         exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
     rMessage); | 
| 106         return 0; | 106         return nullptr; | 
| 107     } | 107     } | 
| 108 | 108 | 
| 109     return IDBKeyRange::create(bound, 0, open ? LowerBoundOpen : LowerBoundClose
     d, UpperBoundOpen); | 109     return IDBKeyRange::create(bound, nullptr, open ? LowerBoundOpen : LowerBoun
     dClosed, UpperBoundOpen); | 
| 110 } | 110 } | 
| 111 | 111 | 
| 112 PassRefPtr<IDBKeyRange> IDBKeyRange::upperBound(ExecutionContext* context, const
      ScriptValue& boundValue, bool open, ExceptionState& exceptionState) | 112 PassRefPtr<IDBKeyRange> IDBKeyRange::upperBound(ExecutionContext* context, const
      ScriptValue& boundValue, bool open, ExceptionState& exceptionState) | 
| 113 { | 113 { | 
| 114     DOMRequestState requestState(context); | 114     DOMRequestState requestState(context); | 
| 115     RefPtr<IDBKey> bound = scriptValueToIDBKey(&requestState, boundValue); | 115     RefPtr<IDBKey> bound = scriptValueToIDBKey(&requestState, boundValue); | 
| 116     if (!bound || !bound->isValid()) { | 116     if (!bound || !bound->isValid()) { | 
| 117         exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
     rMessage); | 117         exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
     rMessage); | 
| 118         return 0; | 118         return nullptr; | 
| 119     } | 119     } | 
| 120 | 120 | 
| 121     return IDBKeyRange::create(0, bound, LowerBoundOpen, open ? UpperBoundOpen :
      UpperBoundClosed); | 121     return IDBKeyRange::create(nullptr, bound, LowerBoundOpen, open ? UpperBound
     Open : UpperBoundClosed); | 
| 122 } | 122 } | 
| 123 | 123 | 
| 124 PassRefPtr<IDBKeyRange> IDBKeyRange::bound(ExecutionContext* context, const Scri
     ptValue& lowerValue, const ScriptValue& upperValue, bool lowerOpen, bool upperOp
     en, ExceptionState& exceptionState) | 124 PassRefPtr<IDBKeyRange> IDBKeyRange::bound(ExecutionContext* context, const Scri
     ptValue& lowerValue, const ScriptValue& upperValue, bool lowerOpen, bool upperOp
     en, ExceptionState& exceptionState) | 
| 125 { | 125 { | 
| 126     DOMRequestState requestState(context); | 126     DOMRequestState requestState(context); | 
| 127     RefPtr<IDBKey> lower = scriptValueToIDBKey(&requestState, lowerValue); | 127     RefPtr<IDBKey> lower = scriptValueToIDBKey(&requestState, lowerValue); | 
| 128     RefPtr<IDBKey> upper = scriptValueToIDBKey(&requestState, upperValue); | 128     RefPtr<IDBKey> upper = scriptValueToIDBKey(&requestState, upperValue); | 
| 129 | 129 | 
| 130     if (!lower || !lower->isValid() || !upper || !upper->isValid()) { | 130     if (!lower || !lower->isValid() || !upper || !upper->isValid()) { | 
| 131         exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
     rMessage); | 131         exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
     rMessage); | 
| 132         return 0; | 132         return nullptr; | 
| 133     } | 133     } | 
| 134     if (upper->isLessThan(lower.get())) { | 134     if (upper->isLessThan(lower.get())) { | 
| 135         exceptionState.throwDOMException(DataError, "The lower key is greater th
     an the upper key."); | 135         exceptionState.throwDOMException(DataError, "The lower key is greater th
     an the upper key."); | 
| 136         return 0; | 136         return nullptr; | 
| 137     } | 137     } | 
| 138     if (upper->isEqual(lower.get()) && (lowerOpen || upperOpen)) { | 138     if (upper->isEqual(lower.get()) && (lowerOpen || upperOpen)) { | 
| 139         exceptionState.throwDOMException(DataError, "The lower key and upper key
      are equal and one of the bounds is open."); | 139         exceptionState.throwDOMException(DataError, "The lower key and upper key
      are equal and one of the bounds is open."); | 
| 140         return 0; | 140         return nullptr; | 
| 141     } | 141     } | 
| 142 | 142 | 
| 143     return IDBKeyRange::create(lower, upper, lowerOpen ? LowerBoundOpen : LowerB
     oundClosed, upperOpen ? UpperBoundOpen : UpperBoundClosed); | 143     return IDBKeyRange::create(lower, upper, lowerOpen ? LowerBoundOpen : LowerB
     oundClosed, upperOpen ? UpperBoundOpen : UpperBoundClosed); | 
| 144 } | 144 } | 
| 145 | 145 | 
| 146 } // namespace WebCore | 146 } // namespace WebCore | 
| OLD | NEW | 
|---|