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 23 matching lines...) Expand all Loading... |
34 #include "modules/indexeddb/IDBKey.h" | 34 #include "modules/indexeddb/IDBKey.h" |
35 | 35 |
36 namespace WebCore { | 36 namespace WebCore { |
37 | 37 |
38 PassRefPtr<IDBKeyRange> IDBKeyRange::create(PassRefPtr<IDBKey> prpKey) | 38 PassRefPtr<IDBKeyRange> IDBKeyRange::create(PassRefPtr<IDBKey> prpKey) |
39 { | 39 { |
40 RefPtr<IDBKey> key = prpKey; | 40 RefPtr<IDBKey> key = prpKey; |
41 return adoptRef(new IDBKeyRange(key, key, LowerBoundClosed, UpperBoundClosed
)); | 41 return adoptRef(new IDBKeyRange(key, key, LowerBoundClosed, UpperBoundClosed
)); |
42 } | 42 } |
43 | 43 |
| 44 PassRefPtr<IDBKeyRange> IDBKeyRange::fromScriptValue(ScriptExecutionContext* con
text, const ScriptValue& value, ExceptionState& es) |
| 45 { |
| 46 DOMRequestState requestState(context); |
| 47 if (value.isUndefined() || value.isNull()) |
| 48 return 0; |
| 49 |
| 50 RefPtr<IDBKeyRange> range = scriptValueToIDBKeyRange(&requestState, value); |
| 51 if (range) |
| 52 return range.release(); |
| 53 |
| 54 RefPtr<IDBKey> key = scriptValueToIDBKey(&requestState, value); |
| 55 if (!key || !key->isValid()) { |
| 56 es.throwDOMException(DataError, IDBDatabase::notValidKeyErrorMessage); |
| 57 return 0; |
| 58 } |
| 59 |
| 60 return adoptRef(new IDBKeyRange(key, key, LowerBoundClosed, UpperBoundClosed
)); |
| 61 } |
| 62 |
44 IDBKeyRange::IDBKeyRange(PassRefPtr<IDBKey> lower, PassRefPtr<IDBKey> upper, Low
erBoundType lowerType, UpperBoundType upperType) | 63 IDBKeyRange::IDBKeyRange(PassRefPtr<IDBKey> lower, PassRefPtr<IDBKey> upper, Low
erBoundType lowerType, UpperBoundType upperType) |
45 : m_lower(lower) | 64 : m_lower(lower) |
46 , m_upper(upper) | 65 , m_upper(upper) |
47 , m_lowerType(lowerType) | 66 , m_lowerType(lowerType) |
48 , m_upperType(upperType) | 67 , m_upperType(upperType) |
49 { | 68 { |
50 ScriptWrappable::init(this); | 69 ScriptWrappable::init(this); |
51 } | 70 } |
52 | 71 |
53 ScriptValue IDBKeyRange::lowerValue(ScriptExecutionContext* context) const | 72 ScriptValue IDBKeyRange::lowerValue(ScriptExecutionContext* context) const |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 { | 154 { |
136 if (m_lowerType != LowerBoundClosed || m_upperType != UpperBoundClosed) | 155 if (m_lowerType != LowerBoundClosed || m_upperType != UpperBoundClosed) |
137 return false; | 156 return false; |
138 | 157 |
139 ASSERT(m_lower); | 158 ASSERT(m_lower); |
140 ASSERT(m_upper); | 159 ASSERT(m_upper); |
141 return m_lower->isEqual(m_upper.get()); | 160 return m_lower->isEqual(m_upper.get()); |
142 } | 161 } |
143 | 162 |
144 } // namespace WebCore | 163 } // namespace WebCore |
OLD | NEW |