diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-25 15:09:11 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-25 15:09:11 +0200 |
commit | a89b2ebb8e192c5e8cea21079bda2ee2c0c7dddd (patch) | |
tree | b7abd9f49ae1d4d2e426a5883bfccd42b8e2ee12 /Source/WebKit/chromium/src/WebIDBKeyPath.cpp | |
parent | 8d473cf9743f1d30a16a27114e93bd5af5648d23 (diff) | |
download | qtwebkit-a89b2ebb8e192c5e8cea21079bda2ee2c0c7dddd.tar.gz |
Imported WebKit commit eb5c1b8fe4d4b1b90b5137433fc58a91da0e6878 (http://svn.webkit.org/repository/webkit/trunk@118516)
Diffstat (limited to 'Source/WebKit/chromium/src/WebIDBKeyPath.cpp')
-rw-r--r-- | Source/WebKit/chromium/src/WebIDBKeyPath.cpp | 92 |
1 files changed, 35 insertions, 57 deletions
diff --git a/Source/WebKit/chromium/src/WebIDBKeyPath.cpp b/Source/WebKit/chromium/src/WebIDBKeyPath.cpp index bcf5dbd0d..17c158f34 100644 --- a/Source/WebKit/chromium/src/WebIDBKeyPath.cpp +++ b/Source/WebKit/chromium/src/WebIDBKeyPath.cpp @@ -37,101 +37,79 @@ using namespace WebCore; namespace WebKit { -WebIDBKeyPath WebIDBKeyPath::create(const WebVector<WebString>&) +WebIDBKeyPath::~WebIDBKeyPath() { - // FIXME: Array-type key paths not yet supported. http://webkit.org/b/84207 - WEBKIT_ASSERT_NOT_REACHED(); - return createNull(); + m_private.reset(0); } WebIDBKeyPath WebIDBKeyPath::create(const WebString& keyPath) { - if (keyPath.isNull()) - return createNull(); - - WTF::Vector<WTF::String> idbElements; - IDBKeyPathParseError idbError; - IDBParseKeyPath(keyPath, idbElements, idbError); - return WebIDBKeyPath(idbElements, static_cast<int>(idbError)); -} - -WebIDBKeyPath WebIDBKeyPath::createNull() -{ - return WebIDBKeyPath(WebString()); + return WebIDBKeyPath(IDBKeyPath(keyPath)); } -WebIDBKeyPath::WebIDBKeyPath(const WebIDBKeyPath& keyPath) +WebIDBKeyPath WebIDBKeyPath::create(const WebVector<WebString>& keyPath) { - assign(keyPath); + Vector<String> strings; + for (size_t i = 0; i < keyPath.size(); ++i) + strings.append(keyPath[i]); + return WebIDBKeyPath(IDBKeyPath(strings)); } -WebIDBKeyPath::WebIDBKeyPath(const WTF::Vector<WTF::String>& elements, int parseError) - : m_private(new WTF::Vector<WTF::String>(elements)) - , m_parseError(parseError) +WebIDBKeyPath WebIDBKeyPath::createNull() { + return WebIDBKeyPath(IDBKeyPath()); } bool WebIDBKeyPath::isValid() const { - return m_parseError == IDBKeyPathParseErrorNone; + ASSERT(m_private.get()); + return m_private->isValid(); } WebIDBKeyPath::Type WebIDBKeyPath::type() const { - return m_private.get() ? StringType : NullType; + ASSERT(m_private.get()); + return Type(m_private->type()); } -WebString WebIDBKeyPath::string() const + +WebVector<WebString> WebIDBKeyPath::array() const { - if (!m_private.get()) - return WebString(); - - // FIXME: Store the complete string instead of rebuilding it. - // http://webkit.org/b/84207 - WTF::String string(""); - WTF::Vector<WTF::String>& array = *m_private.get(); - for (size_t i = 0; i < array.size(); ++i) { - if (i) - string.append("."); - string.append(array[i]); - } - return WebString(string); + ASSERT(m_private.get()); + ASSERT(m_private->type() == IDBKeyPath::ArrayType); + return m_private->array(); } -WebIDBKeyPath::WebIDBKeyPath(const WebString& keyPath) - : m_parseError(IDBKeyPathParseErrorNone) +WebString WebIDBKeyPath::string() const { - if (!keyPath.isNull()) { - m_private.reset(new WTF::Vector<WTF::String>()); - IDBKeyPathParseError idbParseError; - IDBParseKeyPath(keyPath, *m_private.get(), idbParseError); - m_parseError = idbParseError; - } + ASSERT(m_private.get()); + ASSERT(m_private->type() == IDBKeyPath::StringType); + return m_private->string(); } -int WebIDBKeyPath::parseError() const +WebIDBKeyPath::WebIDBKeyPath(const WebIDBKeyPath& keyPath) + : m_private(new IDBKeyPath(keyPath)) { - return m_parseError; + ASSERT(m_private.get()); } -void WebIDBKeyPath::assign(const WebIDBKeyPath& keyPath) +WebIDBKeyPath::WebIDBKeyPath(const WebCore::IDBKeyPath& value) + : m_private(new IDBKeyPath(value)) { - m_parseError = keyPath.m_parseError; - if (keyPath.m_private.get()) - m_private.reset(new WTF::Vector<WTF::String>(keyPath)); - else - m_private.reset(0); + ASSERT(m_private.get()); } -void WebIDBKeyPath::reset() +WebIDBKeyPath& WebIDBKeyPath::operator=(const WebCore::IDBKeyPath& value) { - m_private.reset(0); + ASSERT(m_private.get()); + m_private.reset(new IDBKeyPath(value)); + return *this; } -WebIDBKeyPath::operator const WTF::Vector<WTF::String, 0>&() const +WebIDBKeyPath::operator const WebCore::IDBKeyPath&() const { ASSERT(m_private.get()); - return *m_private.get(); + return *(m_private.get()); } } // namespace WebKit |