diff options
Diffstat (limited to 'Source/WebKit2/UIProcess/API/cpp')
6 files changed, 45 insertions, 212 deletions
diff --git a/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h b/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h index d5dbdf029..0b643da4c 100644 --- a/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h +++ b/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h @@ -26,8 +26,12 @@ #ifndef WKRetainPtr_h #define WKRetainPtr_h -#include <WebKit2/WKType.h> +#include <WebKit/WKType.h> #include <algorithm> +#include <wtf/GetPtr.h> +#include <wtf/HashFunctions.h> +#include <wtf/HashTraits.h> +#include <wtf/RefPtr.h> namespace WebKit { @@ -68,7 +72,6 @@ public: WKRetain(ptr); } -#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) template<typename U> WKRetainPtr(WKRetainPtr<U>&& o) : m_ptr(o.leakRef()) { @@ -78,7 +81,6 @@ public: : m_ptr(o.leakRef()) { } -#endif ~WKRetainPtr() { @@ -86,6 +88,15 @@ public: WKRelease(ptr); } + // Hash table deleted values, which are only constructed and never copied or destroyed. + WKRetainPtr(WTF::HashTableDeletedValueType) + : m_ptr(hashTableDeletedValue()) + { + } + + bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedValue(); } + constexpr static T hashTableDeletedValue() { return reinterpret_cast<T>(-1); } + PtrType get() const { return m_ptr; } void clear() @@ -115,10 +126,8 @@ public: WKRetainPtr& operator=(PtrType); template<typename U> WKRetainPtr& operator=(U*); -#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) WKRetainPtr& operator=(WKRetainPtr&&); template<typename U> WKRetainPtr& operator=(WKRetainPtr<U>&&); -#endif void adopt(PtrType); void swap(WKRetainPtr&); @@ -173,7 +182,6 @@ template<typename T> template<typename U> inline WKRetainPtr<T>& WKRetainPtr<T>: return *this; } -#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) template<typename T> inline WKRetainPtr<T>& WKRetainPtr<T>::operator=(WKRetainPtr<T>&& o) { adopt(o.leakRef()); @@ -185,7 +193,6 @@ template<typename T> template<typename U> inline WKRetainPtr<T>& WKRetainPtr<T>: adopt(o.leakRef()); return *this; } -#endif template<typename T> inline void WKRetainPtr<T>::adopt(PtrType optr) { @@ -236,8 +243,7 @@ template<typename T, typename U> inline bool operator!=(T* a, const WKRetainPtr< } template<typename T> inline WKRetainPtr<T> adoptWK(T) WARN_UNUSED_RETURN; - -template<typename T> inline WKRetainPtr<T> adoptWK(T o) +template<typename T> inline WKRetainPtr<T> adoptWK(T o) { return WKRetainPtr<T>(AdoptWK, o); } @@ -248,4 +254,24 @@ using WebKit::WKRetainPtr; using WebKit::AdoptWK; using WebKit::adoptWK; +namespace WTF { + +template <typename T> struct IsSmartPtr<WKRetainPtr<T>> { + static const bool value = true; +}; + +template<typename P> struct DefaultHash<WKRetainPtr<P>> { + typedef PtrHash<WKRetainPtr<P>> Hash; +}; + +template<typename P> struct HashTraits<WKRetainPtr<P>> : SimpleClassHashTraits<WKRetainPtr<P>> { + static P emptyValue() { return nullptr; } + + typedef P PeekType; + static PeekType peek(const WKRetainPtr<P>& value) { return value.get(); } + static PeekType peek(P value) { return value; } +}; + +} // namespace WTF + #endif // WKRetainPtr_h diff --git a/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.cpp b/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.cpp deleted file mode 100644 index ecb7b5f79..000000000 --- a/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "WKEinaSharedString.h" - -#include <WebKit2/WKAPICast.h> -#include <WebKit2/WKString.h> -#include <WebKit2/WKURL.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -template <typename WKRefType> -ALWAYS_INLINE const char* fromRefType(WKRefType strRef, bool adopt = false) -{ - const char* res = 0; - if (strRef) { - res = eina_stringshare_add(toImpl(strRef)->string().utf8().data()); - ASSERT(res); - if (adopt) - WKRelease(strRef); - } - - return res; -} - -WKEinaSharedString::WKEinaSharedString(const WKEinaSharedString& other) - : m_string(eina_stringshare_ref(other.m_string)) -{ -} - -WKEinaSharedString::WKEinaSharedString(const char* str) - : m_string(eina_stringshare_add(str)) -{ -} - -WKEinaSharedString::WKEinaSharedString(WKAdoptTag adoptTag, WKStringRef stringRef) - : m_string(fromRefType(stringRef, /*adopt*/ true)) -{ - ASSERT_UNUSED(adoptTag, adoptTag == AdoptWK); // Guard for future enum changes. -} - -WKEinaSharedString::WKEinaSharedString(WKStringRef stringRef) - : m_string(fromRefType(stringRef)) -{ -} - -WKEinaSharedString::WKEinaSharedString(WKAdoptTag adoptTag, WKURLRef urlRef) - : m_string(fromRefType(urlRef, /*adopt*/ true)) -{ - ASSERT_UNUSED(adoptTag, adoptTag == AdoptWK); // Guard for future enum changes. -} - -WKEinaSharedString::WKEinaSharedString(WKURLRef urlRef) - : m_string(fromRefType(urlRef)) -{ -} - -WKEinaSharedString::~WKEinaSharedString() -{ - if (m_string) - eina_stringshare_del(m_string); -} - -WKEinaSharedString& WKEinaSharedString::operator=(const WKEinaSharedString& other) -{ - if (this != &other) { - if (m_string) - eina_stringshare_del(m_string); - m_string = eina_stringshare_ref(other.m_string); - } - return *this; -} - -WKEinaSharedString& WKEinaSharedString::operator=(const char* str) -{ - eina_stringshare_replace(&m_string, str); - return *this; -} - -bool WKEinaSharedString::operator==(const char* str) const -{ - return (!str || !m_string) ? (str == m_string) : !strcmp(m_string, str); -} - -WKEinaSharedString WKEinaSharedString::adopt(Eina_Stringshare* string) -{ - WKEinaSharedString sharedString; - sharedString.m_string = static_cast<const char*>(string); - return sharedString; -} - -Eina_Stringshare* WKEinaSharedString::leakString() -{ - Eina_Stringshare* sharedString = m_string; - m_string = 0; - - return sharedString; -} diff --git a/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.h b/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.h deleted file mode 100644 index dbb5f4788..000000000 --- a/Source/WebKit2/UIProcess/API/cpp/efl/WKEinaSharedString.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WKEinaSharedString_h -#define WKEinaSharedString_h - -#include <Eina.h> -#include <WebKit2/WKBase.h> -#include <WebKit2/WKRetainPtr.h> - -namespace WebKit { - -class WK_EXPORT WKEinaSharedString { -public: - ALWAYS_INLINE WKEinaSharedString() : m_string(0) { } - WKEinaSharedString(const WKEinaSharedString& other); - WKEinaSharedString(const char* str); - - WKEinaSharedString(WKAdoptTag, WKStringRef); - WKEinaSharedString(WKStringRef); - - WKEinaSharedString(WKAdoptTag, WKURLRef); - WKEinaSharedString(WKURLRef); - - ~WKEinaSharedString(); - - Eina_Stringshare* leakString(); - - WKEinaSharedString& operator=(const WKEinaSharedString& other); - WKEinaSharedString& operator=(const char* str); - - ALWAYS_INLINE bool operator==(const WKEinaSharedString& other) const { return this->m_string == other.m_string; } - ALWAYS_INLINE bool operator!=(const WKEinaSharedString& other) const { return !(*this == other); } - - bool operator==(const char* str) const; - ALWAYS_INLINE bool operator!=(const char* str) const { return !(*this == str); } - - ALWAYS_INLINE operator const char* () const { return m_string; } - - ALWAYS_INLINE bool isNull() const { return !m_string; } - - ALWAYS_INLINE size_t length() const { return m_string ? static_cast<size_t>(eina_stringshare_strlen(m_string)) : 0; } - - static WKEinaSharedString adopt(Eina_Stringshare*); - -private: - const char* m_string; -}; - -} // namespace WebKit - -using WebKit::WKEinaSharedString; - -#endif // WKEinaSharedString_h diff --git a/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp index 4ae448e62..6fad021f6 100644 --- a/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp +++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp @@ -39,8 +39,13 @@ QString WKStringCopyQString(WKStringRef stringRef) { if (!stringRef) return QString(); - const WTF::String& string = toImpl(stringRef)->string(); - return QString(reinterpret_cast<const QChar*>(string.characters()), string.length()); + + auto stringView = toImpl(stringRef)->stringView(); + + if (stringView.is8Bit()) + return QString::fromLatin1(reinterpret_cast<const char*>(stringView.characters8()), stringView.length()); + + return QString(reinterpret_cast<const QChar*>(stringView.characters16()), stringView.length()); } namespace WebKit { diff --git a/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.h b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.h index ff2cfa837..3c2fda240 100644 --- a/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.h +++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.h @@ -22,7 +22,7 @@ #define WKStringQt_h #include <QString> -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> WK_EXPORT WKStringRef WKStringCreateWithQString(const QString& string); WK_EXPORT QString WKStringCopyQString(WKStringRef string); diff --git a/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h b/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h index b12f97459..6cef82f7c 100644 --- a/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h +++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h @@ -22,8 +22,8 @@ #define WKURLQt_h #include <QUrl> -#include <WebKit2/WKBase.h> -#include <WebKit2/WKURL.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKURL.h> WK_EXPORT WKURLRef WKURLCreateWithQString(const QString& url); WK_EXPORT QString WKURLCopyQString(WKURLRef url); |