summaryrefslogtreecommitdiff
path: root/Source/WebKit2/Shared/API
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebKit2/Shared/API
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebKit2/Shared/API')
-rw-r--r--Source/WebKit2/Shared/API/APIArray.cpp85
-rw-r--r--Source/WebKit2/Shared/API/APIArray.h112
-rw-r--r--Source/WebKit2/Shared/API/APIClient.h85
-rw-r--r--Source/WebKit2/Shared/API/APIData.cpp49
-rw-r--r--Source/WebKit2/Shared/API/APIData.h110
-rw-r--r--Source/WebKit2/Shared/API/APIDictionary.cpp84
-rw-r--r--Source/WebKit2/Shared/API/APIDictionary.h90
-rw-r--r--Source/WebKit2/Shared/API/APIError.cpp56
-rw-r--r--Source/WebKit2/Shared/API/APIError.h78
-rw-r--r--Source/WebKit2/Shared/API/APIFrameHandle.cpp74
-rw-r--r--Source/WebKit2/Shared/API/APIFrameHandle.h60
-rw-r--r--Source/WebKit2/Shared/API/APIGeometry.cpp96
-rw-r--r--Source/WebKit2/Shared/API/APIGeometry.h104
-rw-r--r--Source/WebKit2/Shared/API/APINumber.h75
-rw-r--r--Source/WebKit2/Shared/API/APIObject.cpp43
-rw-r--r--Source/WebKit2/Shared/API/APIObject.h276
-rw-r--r--Source/WebKit2/Shared/API/APIPageGroupHandle.cpp63
-rw-r--r--Source/WebKit2/Shared/API/APIPageGroupHandle.h59
-rw-r--r--Source/WebKit2/Shared/API/APIPageHandle.cpp74
-rw-r--r--Source/WebKit2/Shared/API/APIPageHandle.h60
-rw-r--r--Source/WebKit2/Shared/API/APISecurityOrigin.h67
-rw-r--r--Source/WebKit2/Shared/API/APISerializedScriptValue.h81
-rw-r--r--Source/WebKit2/Shared/API/APIString.h79
-rw-r--r--Source/WebKit2/Shared/API/APIURL.h134
-rw-r--r--Source/WebKit2/Shared/API/APIURLRequest.cpp71
-rw-r--r--Source/WebKit2/Shared/API/APIURLRequest.h63
-rw-r--r--Source/WebKit2/Shared/API/APIURLResponse.cpp55
-rw-r--r--Source/WebKit2/Shared/API/APIURLResponse.h60
-rw-r--r--Source/WebKit2/Shared/API/APIUserContentURLPattern.h64
-rw-r--r--Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h59
-rw-r--r--Source/WebKit2/Shared/API/c/WKActionMenuTypes.h55
-rw-r--r--Source/WebKit2/Shared/API/c/WKArray.cpp10
-rw-r--r--Source/WebKit2/Shared/API/c/WKArray.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKBase.h52
-rw-r--r--Source/WebKit2/Shared/API/c/WKCertificateInfo.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKConnectionRef.h12
-rw-r--r--Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp48
-rw-r--r--Source/WebKit2/Shared/API/c/WKContextMenuItem.h4
-rw-r--r--Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKData.cpp2
-rw-r--r--Source/WebKit2/Shared/API/c/WKData.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h10
-rw-r--r--Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp67
-rw-r--r--Source/WebKit2/Shared/API/c/WKDiagnosticLoggingResultType.h (renamed from Source/WebKit2/Shared/API/c/soup/WKBaseSoup.h)25
-rw-r--r--Source/WebKit2/Shared/API/c/WKDictionary.cpp13
-rw-r--r--Source/WebKit2/Shared/API/c/WKDictionary.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKErrorRef.cpp (renamed from Source/WebKit2/Shared/API/c/WKError.cpp)2
-rw-r--r--Source/WebKit2/Shared/API/c/WKErrorRef.h (renamed from Source/WebKit2/Shared/API/c/WKError.h)13
-rw-r--r--Source/WebKit2/Shared/API/c/WKEvent.h5
-rw-r--r--Source/WebKit2/Shared/API/c/WKGeometry.cpp6
-rw-r--r--Source/WebKit2/Shared/API/c/WKGeometry.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKImage.cpp4
-rw-r--r--Source/WebKit2/Shared/API/c/WKImage.h9
-rw-r--r--Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h52
-rw-r--r--Source/WebKit2/Shared/API/c/WKMutableArray.cpp2
-rw-r--r--Source/WebKit2/Shared/API/c/WKMutableArray.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp5
-rw-r--r--Source/WebKit2/Shared/API/c/WKMutableDictionary.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKNumber.cpp12
-rw-r--r--Source/WebKit2/Shared/API/c/WKNumber.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKPluginInformation.cpp56
-rw-r--r--Source/WebKit2/Shared/API/c/WKPluginInformation.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKRenderLayer.cpp14
-rw-r--r--Source/WebKit2/Shared/API/c/WKRenderLayer.h9
-rw-r--r--Source/WebKit2/Shared/API/c/WKRenderObject.cpp18
-rw-r--r--Source/WebKit2/Shared/API/c/WKRenderObject.h7
-rw-r--r--Source/WebKit2/Shared/API/c/WKSecurityOriginRef.cpp (renamed from Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp)30
-rw-r--r--Source/WebKit2/Shared/API/c/WKSecurityOriginRef.h (renamed from Source/WebKit2/Shared/API/c/WKSecurityOrigin.h)8
-rw-r--r--Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp12
-rw-r--r--Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKSharedAPICast.h228
-rw-r--r--Source/WebKit2/Shared/API/c/WKString.cpp74
-rw-r--r--Source/WebKit2/Shared/API/c/WKString.h3
-rw-r--r--Source/WebKit2/Shared/API/c/WKStringPrivate.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKType.cpp7
-rw-r--r--Source/WebKit2/Shared/API/c/WKType.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKURL.cpp6
-rw-r--r--Source/WebKit2/Shared/API/c/WKURL.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKURLRequest.cpp10
-rw-r--r--Source/WebKit2/Shared/API/c/WKURLRequest.h4
-rw-r--r--Source/WebKit2/Shared/API/c/WKURLResponse.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp7
-rw-r--r--Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h2
-rw-r--r--Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h4
-rw-r--r--Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp8
-rw-r--r--Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h4
87 files changed, 3066 insertions, 351 deletions
diff --git a/Source/WebKit2/Shared/API/APIArray.cpp b/Source/WebKit2/Shared/API/APIArray.cpp
new file mode 100644
index 000000000..9548ab724
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIArray.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 "APIArray.h"
+
+#include "APIString.h"
+
+namespace API {
+
+Ref<Array> Array::create()
+{
+ return create(Vector<RefPtr<Object>>());
+}
+
+Ref<Array> Array::create(Vector<RefPtr<Object>>&& elements)
+{
+ return adoptRef(*new Array(WTFMove(elements)));
+}
+
+Ref<Array> Array::createStringArray(const Vector<WTF::String>& strings)
+{
+ Vector<RefPtr<Object>> elements;
+ elements.reserveInitialCapacity(strings.size());
+
+ for (const auto& string : strings)
+ elements.uncheckedAppend(API::String::create(string));
+
+ return create(WTFMove(elements));
+}
+
+Vector<WTF::String> Array::toStringVector()
+{
+ Vector<WTF::String> patternsVector;
+
+ size_t size = this->size();
+ if (!size)
+ return patternsVector;
+
+ patternsVector.reserveInitialCapacity(size);
+ for (const auto& entry : elementsOfType<API::String>())
+ patternsVector.uncheckedAppend(entry->string());
+ return patternsVector;
+}
+
+Ref<API::Array> Array::copy()
+{
+ size_t size = this->size();
+ if (!size)
+ return Array::create();
+
+ Vector<RefPtr<Object>> elements;
+ elements.reserveInitialCapacity(size);
+ for (const auto& entry : this->elements())
+ elements.uncheckedAppend(entry);
+ return Array::create(WTFMove(elements));
+}
+
+Array::~Array()
+{
+}
+
+} // namespace API
diff --git a/Source/WebKit2/Shared/API/APIArray.h b/Source/WebKit2/Shared/API/APIArray.h
new file mode 100644
index 000000000..1fef06932
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIArray.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2010, 2013 Apple Inc. 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 APIArray_h
+#define APIArray_h
+
+#include "APIObject.h"
+#include <wtf/Forward.h>
+#include <wtf/IteratorAdaptors.h>
+#include <wtf/IteratorRange.h>
+#include <wtf/Vector.h>
+
+namespace API {
+
+class Array final : public ObjectImpl<Object::Type::Array> {
+private:
+ template <class T>
+ struct IsTypePredicate {
+ bool operator()(const RefPtr<Object>& object) const { return object->type() == T::APIType; }
+ };
+
+ template <class T>
+ struct GetObjectTransform {
+ const T* operator()(const RefPtr<Object>& object) const { return static_cast<const T*>(object.get()); }
+ };
+
+ template <typename T>
+ using ElementsOfTypeRange = WTF::IteratorRange<WTF::TransformIterator<GetObjectTransform<T>, WTF::FilterIterator<IsTypePredicate<T>, Vector<RefPtr<Object>>::const_iterator>>>;
+
+public:
+ static Ref<Array> create();
+ static Ref<Array> create(Vector<RefPtr<Object>>&&);
+ static Ref<Array> createStringArray(const Vector<WTF::String>&);
+ Vector<WTF::String> toStringVector();
+ Ref<Array> copy();
+
+ virtual ~Array();
+
+ template<typename T>
+ T* at(size_t i) const
+ {
+ if (!m_elements[i] || m_elements[i]->type() != T::APIType)
+ return nullptr;
+
+ return static_cast<T*>(m_elements[i].get());
+ }
+
+ Object* at(size_t i) const { return m_elements[i].get(); }
+ size_t size() const { return m_elements.size(); }
+
+ const Vector<RefPtr<Object>>& elements() const { return m_elements; }
+ Vector<RefPtr<Object>>& elements() { return m_elements; }
+
+ template<typename T>
+ ElementsOfTypeRange<T> elementsOfType() const
+ {
+ return WTF::makeIteratorRange(
+ WTF::makeTransformIterator(GetObjectTransform<T>(), WTF::makeFilterIterator(IsTypePredicate<T>(), m_elements.begin(), m_elements.end())),
+ WTF::makeTransformIterator(GetObjectTransform<T>(), WTF::makeFilterIterator(IsTypePredicate<T>(), m_elements.end(), m_elements.end()))
+ );
+ }
+
+ template<typename MatchFunction>
+ unsigned removeAllMatching(const MatchFunction& matchFunction)
+ {
+ return m_elements.removeAllMatching(matchFunction);
+ }
+
+ template<typename T, typename MatchFunction>
+ unsigned removeAllOfTypeMatching(const MatchFunction& matchFunction)
+ {
+ return m_elements.removeAllMatching([&] (const RefPtr<Object>& object) -> bool {
+ if (object->type() != T::APIType)
+ return false;
+ return matchFunction(static_pointer_cast<T>(object));
+ });
+ }
+
+private:
+ explicit Array(Vector<RefPtr<Object>>&& elements)
+ : m_elements(WTFMove(elements))
+ {
+ }
+
+ Vector<RefPtr<Object>> m_elements;
+};
+
+} // namespace API
+
+#endif // APIArray_h
diff --git a/Source/WebKit2/Shared/API/APIClient.h b/Source/WebKit2/Shared/API/APIClient.h
new file mode 100644
index 000000000..2d2d89a5c
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIClient.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 APIClient_h
+#define APIClient_h
+
+#include <algorithm>
+#include <array>
+
+namespace API {
+
+template<typename ClientInterface> struct ClientTraits;
+
+template<typename ClientInterface> class Client {
+ typedef typename ClientTraits<ClientInterface>::Versions ClientVersions;
+ static const int latestClientVersion = std::tuple_size<ClientVersions>::value - 1;
+ typedef typename std::tuple_element<latestClientVersion, ClientVersions>::type LatestClientInterface;
+
+ // Helper class that can return an std::array of element sizes in a tuple.
+ template<typename> struct InterfaceSizes;
+ template<typename... Interfaces> struct InterfaceSizes<std::tuple<Interfaces...>> {
+ static std::array<size_t, sizeof...(Interfaces)> sizes()
+ {
+ return { { sizeof(Interfaces)... } };
+ }
+ };
+
+public:
+ Client()
+ {
+#if !ASSERT_DISABLED
+ auto interfaceSizes = InterfaceSizes<ClientVersions>::sizes();
+ ASSERT(std::is_sorted(interfaceSizes.begin(), interfaceSizes.end()));
+#endif
+
+ initialize(nullptr);
+ }
+
+ void initialize(const ClientInterface* client)
+ {
+ if (client && client->version == latestClientVersion) {
+ m_client = *reinterpret_cast<const LatestClientInterface*>(client);
+ return;
+ }
+
+ memset(&m_client, 0, sizeof(m_client));
+
+ if (client && client->version < latestClientVersion) {
+ auto interfaceSizes = InterfaceSizes<ClientVersions>::sizes();
+
+ memcpy(&m_client, client, interfaceSizes[client->version]);
+ }
+ }
+
+ const LatestClientInterface& client() const { return m_client; }
+
+protected:
+ LatestClientInterface m_client;
+};
+
+} // namespace API
+
+#endif // APIClient_h
diff --git a/Source/WebKit2/Shared/API/APIData.cpp b/Source/WebKit2/Shared/API/APIData.cpp
new file mode 100644
index 000000000..61343bd94
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIData.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2013 Apple Inc. 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 "APIData.h"
+
+#include "Decoder.h"
+#include "Encoder.h"
+
+namespace API {
+
+void Data::encode(IPC::Encoder& encoder) const
+{
+ encoder << dataReference();
+}
+
+bool Data::decode(IPC::Decoder& decoder, RefPtr<API::Object>& result)
+{
+ IPC::DataReference dataReference;
+ if (!decoder.decode(dataReference))
+ return false;
+
+ result = create(dataReference.data(), dataReference.size());
+ return true;
+}
+
+} // namespace API
diff --git a/Source/WebKit2/Shared/API/APIData.h b/Source/WebKit2/Shared/API/APIData.h
new file mode 100644
index 000000000..066fa441f
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIData.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 APIData_h
+#define APIData_h
+
+#include "APIObject.h"
+#include "DataReference.h"
+#include <wtf/Forward.h>
+#include <wtf/Vector.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+OBJC_CLASS NSData;
+
+namespace API {
+
+class Data : public ObjectImpl<API::Object::Type::Data> {
+public:
+ typedef void (*FreeDataFunction)(unsigned char*, const void* context);
+
+ static Ref<Data> createWithoutCopying(const unsigned char* bytes, size_t size, FreeDataFunction freeDataFunction, const void* context)
+ {
+ return adoptRef(*new Data(bytes, size, freeDataFunction, context));
+ }
+
+ static Ref<Data> create(const unsigned char* bytes, size_t size)
+ {
+ unsigned char *copiedBytes = 0;
+
+ if (size) {
+ copiedBytes = static_cast<unsigned char*>(fastMalloc(size));
+ memcpy(copiedBytes, bytes, size);
+ }
+
+ return createWithoutCopying(copiedBytes, size, fastFreeBytes, 0);
+ }
+
+ static Ref<Data> create(const Vector<unsigned char>& buffer)
+ {
+ return create(buffer.data(), buffer.size());
+ }
+
+#if PLATFORM(COCOA)
+ static Ref<Data> createWithoutCopying(RetainPtr<NSData>);
+#endif
+
+ ~Data()
+ {
+ m_freeDataFunction(const_cast<unsigned char*>(m_bytes), m_context);
+ }
+
+ const unsigned char* bytes() const { return m_bytes; }
+ size_t size() const { return m_size; }
+
+ IPC::DataReference dataReference() const { return IPC::DataReference(m_bytes, m_size); }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<API::Object>&);
+
+private:
+ Data(const unsigned char* bytes, size_t size, FreeDataFunction freeDataFunction, const void* context)
+ : m_bytes(bytes)
+ , m_size(size)
+ , m_freeDataFunction(freeDataFunction)
+ , m_context(context)
+ {
+ }
+
+ static void fastFreeBytes(unsigned char* bytes, const void*)
+ {
+ if (bytes)
+ fastFree(static_cast<void*>(bytes));
+ }
+
+ const unsigned char* m_bytes;
+ size_t m_size;
+
+ FreeDataFunction m_freeDataFunction;
+ const void* m_context;
+};
+
+} // namespace API
+
+#endif // APIData_h
diff --git a/Source/WebKit2/Shared/API/APIDictionary.cpp b/Source/WebKit2/Shared/API/APIDictionary.cpp
new file mode 100644
index 000000000..894e98dd1
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIDictionary.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 "APIDictionary.h"
+
+#include "APIArray.h"
+#include "APIString.h"
+
+namespace API {
+
+Ref<Dictionary> Dictionary::create()
+{
+ return create({ });
+}
+
+Ref<Dictionary> Dictionary::create(MapType map)
+{
+ return adoptRef(*new Dictionary(WTFMove(map)));
+}
+
+Dictionary::Dictionary(MapType map)
+ : m_map(WTFMove(map))
+{
+}
+
+Dictionary::~Dictionary()
+{
+}
+
+Ref<Array> Dictionary::keys() const
+{
+ if (m_map.isEmpty())
+ return API::Array::create();
+
+ Vector<RefPtr<API::Object>> keys;
+ keys.reserveInitialCapacity(m_map.size());
+
+ for (const auto& key : m_map.keys())
+ keys.uncheckedAppend(API::String::create(key));
+
+ return API::Array::create(WTFMove(keys));
+}
+
+bool Dictionary::add(const WTF::String& key, PassRefPtr<API::Object> item)
+{
+ MapType::AddResult result = m_map.add(key, item);
+ return result.isNewEntry;
+}
+
+bool Dictionary::set(const WTF::String& key, PassRefPtr<API::Object> item)
+{
+ MapType::AddResult result = m_map.set(key, item);
+ return result.isNewEntry;
+}
+
+void Dictionary::remove(const WTF::String& key)
+{
+ m_map.remove(key);
+}
+
+} // namespace API
diff --git a/Source/WebKit2/Shared/API/APIDictionary.h b/Source/WebKit2/Shared/API/APIDictionary.h
new file mode 100644
index 000000000..50599129a
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIDictionary.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 APIDictionary_h
+#define APIDictionary_h
+
+#include "APIObject.h"
+#include <wtf/HashMap.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
+
+namespace API {
+
+class Array;
+
+class Dictionary final : public ObjectImpl<Object::Type::Dictionary> {
+public:
+ typedef HashMap<WTF::String, RefPtr<Object>> MapType;
+
+ static Ref<Dictionary> create();
+ static Ref<Dictionary> create(MapType);
+
+ virtual ~Dictionary();
+
+ template<typename T>
+ T* get(const WTF::String& key) const
+ {
+ RefPtr<Object> item = m_map.get(key);
+ if (!item)
+ return 0;
+
+ if (item->type() != T::APIType)
+ return 0;
+
+ return static_cast<T*>(item.get());
+ }
+
+ Object* get(const WTF::String& key) const
+ {
+ return m_map.get(key);
+ }
+
+ Object* get(const WTF::String& key, bool& exists) const
+ {
+ auto it = m_map.find(key);
+ exists = it != m_map.end();
+ return it->value.get();
+ }
+
+ Ref<Array> keys() const;
+
+ bool add(const WTF::String& key, PassRefPtr<Object>);
+ bool set(const WTF::String& key, PassRefPtr<Object>);
+ void remove(const WTF::String& key);
+
+ size_t size() const { return m_map.size(); }
+
+ const MapType& map() const { return m_map; }
+
+protected:
+ explicit Dictionary(MapType);
+
+ MapType m_map;
+};
+
+} // namespace API
+
+#endif // APIDictionary_h
diff --git a/Source/WebKit2/Shared/API/APIError.cpp b/Source/WebKit2/Shared/API/APIError.cpp
new file mode 100644
index 000000000..839fb0f14
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIError.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 "APIError.h"
+
+#include "WebCoreArgumentCoders.h"
+#include <wtf/NeverDestroyed.h>
+#include <wtf/text/WTFString.h>
+
+namespace API {
+
+const WTF::String& Error::webKitErrorDomain()
+{
+ static NeverDestroyed<WTF::String> webKitErrorDomainString(ASCIILiteral("WebKitErrorDomain"));
+ return webKitErrorDomainString;
+}
+
+void Error::encode(IPC::Encoder& encoder) const
+{
+ encoder << platformError();
+}
+
+bool Error::decode(IPC::Decoder& decoder, RefPtr<Object>& result)
+{
+ WebCore::ResourceError error;
+ if (!decoder.decode(error))
+ return false;
+
+ result = create(error);
+ return true;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/API/APIError.h b/Source/WebKit2/Shared/API/APIError.h
new file mode 100644
index 000000000..8c36027df
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIError.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 APIError_h
+#define APIError_h
+
+#include "APIObject.h"
+#include <WebCore/ResourceError.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace API {
+
+class Error : public ObjectImpl<Object::Type::Error> {
+public:
+ static Ref<Error> create()
+ {
+ return adoptRef(*new Error);
+ }
+
+ static Ref<Error> create(const WebCore::ResourceError& error)
+ {
+ return adoptRef(*new Error(error));
+ }
+
+ static const WTF::String& webKitErrorDomain();
+
+ const WTF::String& domain() const { return m_platformError.domain(); }
+ int errorCode() const { return m_platformError.errorCode(); }
+ const WTF::String& failingURL() const { return m_platformError.failingURL(); }
+ const WTF::String& localizedDescription() const { return m_platformError.localizedDescription(); }
+
+ const WebCore::ResourceError& platformError() const { return m_platformError; }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<Object>&);
+
+private:
+ Error()
+ {
+ }
+
+ Error(const WebCore::ResourceError& error)
+ : m_platformError(error)
+ {
+ }
+
+ WebCore::ResourceError m_platformError;
+};
+
+} // namespace API
+
+#endif // APIError_h
diff --git a/Source/WebKit2/Shared/API/APIFrameHandle.cpp b/Source/WebKit2/Shared/API/APIFrameHandle.cpp
new file mode 100644
index 000000000..79646ac6e
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIFrameHandle.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013 Apple Inc. 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 "APIFrameHandle.h"
+
+#include "Decoder.h"
+#include "Encoder.h"
+
+namespace API {
+
+Ref<FrameHandle> FrameHandle::create(uint64_t frameID)
+{
+ return adoptRef(*new FrameHandle(frameID, false));
+}
+
+Ref<FrameHandle> FrameHandle::createAutoconverting(uint64_t frameID)
+{
+ return adoptRef(*new FrameHandle(frameID, true));
+}
+
+FrameHandle::FrameHandle(uint64_t frameID, bool isAutoconverting)
+ : m_frameID(frameID)
+ , m_isAutoconverting(isAutoconverting)
+{
+}
+
+FrameHandle::~FrameHandle()
+{
+}
+
+void FrameHandle::encode(IPC::Encoder& encoder) const
+{
+ encoder << m_frameID;
+ encoder << m_isAutoconverting;
+}
+
+bool FrameHandle::decode(IPC::Decoder& decoder, RefPtr<Object>& result)
+{
+ uint64_t frameID;
+ if (!decoder.decode(frameID))
+ return false;
+
+ bool isAutoconverting;
+ if (!decoder.decode(isAutoconverting))
+ return false;
+
+ result = isAutoconverting ? createAutoconverting(frameID) : create(frameID);
+ return true;
+}
+
+} // namespace API
diff --git a/Source/WebKit2/Shared/API/APIFrameHandle.h b/Source/WebKit2/Shared/API/APIFrameHandle.h
new file mode 100644
index 000000000..b10e808a4
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIFrameHandle.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2013 Apple Inc. 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 APIFrameHandle_h
+#define APIFrameHandle_h
+
+#include "APIObject.h"
+#include <wtf/Ref.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace API {
+
+class FrameHandle : public ObjectImpl<Object::Type::FrameHandle> {
+public:
+ static Ref<FrameHandle> create(uint64_t frameID);
+ static Ref<FrameHandle> createAutoconverting(uint64_t frameID);
+
+ explicit FrameHandle(uint64_t frameID, bool isAutoconverting);
+ virtual ~FrameHandle();
+
+ uint64_t frameID() const { return m_frameID; }
+ bool isAutoconverting() const { return m_isAutoconverting; }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<Object>&);
+
+private:
+ const uint64_t m_frameID;
+ const bool m_isAutoconverting;
+};
+
+} // namespace API
+
+#endif // APIFrameHandle_h
diff --git a/Source/WebKit2/Shared/API/APIGeometry.cpp b/Source/WebKit2/Shared/API/APIGeometry.cpp
new file mode 100644
index 000000000..3d8cb61a3
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIGeometry.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2013 Apple Inc. 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 "APIGeometry.h"
+
+#include "Decoder.h"
+#include "Encoder.h"
+
+namespace API {
+
+void Point::encode(IPC::Encoder& encoder) const
+{
+ encoder << m_point.x;
+ encoder << m_point.y;
+}
+
+bool Point::decode(IPC::Decoder& decoder, RefPtr<API::Object>& result)
+{
+ WKPoint point;
+ if (!decoder.decode(point.x))
+ return false;
+ if (!decoder.decode(point.y))
+ return false;
+
+ result = Point::create(point);
+ return true;
+}
+
+
+void Size::encode(IPC::Encoder& encoder) const
+{
+ encoder << m_size.width;
+ encoder << m_size.height;
+}
+
+bool Size::decode(IPC::Decoder& decoder, RefPtr<API::Object>& result)
+{
+ WKSize size;
+ if (!decoder.decode(size.width))
+ return false;
+ if (!decoder.decode(size.height))
+ return false;
+
+ result = Size::create(size);
+ return true;
+}
+
+
+void Rect::encode(IPC::Encoder& encoder) const
+{
+ encoder << m_rect.origin.x;
+ encoder << m_rect.origin.y;
+ encoder << m_rect.size.width;
+ encoder << m_rect.size.height;
+}
+
+bool Rect::decode(IPC::Decoder& decoder, RefPtr<API::Object>& result)
+{
+ WKRect rect;
+ if (!decoder.decode(rect.origin.x))
+ return false;
+ if (!decoder.decode(rect.origin.y))
+ return false;
+ if (!decoder.decode(rect.size.width))
+ return false;
+ if (!decoder.decode(rect.size.height))
+ return false;
+
+ result = Rect::create(rect);
+ return true;
+}
+
+} // namespace API
diff --git a/Source/WebKit2/Shared/API/APIGeometry.h b/Source/WebKit2/Shared/API/APIGeometry.h
new file mode 100644
index 000000000..0ff94cca9
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIGeometry.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2011 Apple Inc. 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 APIGeometry_h
+#define APIGeometry_h
+
+#include "APIObject.h"
+#include "WKGeometry.h"
+#include <WebCore/FloatRect.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace API {
+
+class Size : public API::ObjectImpl<API::Object::Type::Size> {
+public:
+ static Ref<Size> create(const WKSize& size)
+ {
+ return adoptRef(*new Size(size));
+ }
+
+ const WKSize& size() const { return m_size; }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<API::Object>&);
+
+private:
+ explicit Size(const WKSize& size)
+ : m_size(size)
+ {
+ }
+
+ WKSize m_size;
+};
+
+class Point : public API::ObjectImpl<API::Object::Type::Point> {
+public:
+ static Ref<Point> create(const WKPoint& point)
+ {
+ return adoptRef(*new Point(point));
+ }
+
+ const WKPoint& point() const { return m_point; }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<API::Object>&);
+
+private:
+ explicit Point(const WKPoint& point)
+ : m_point(point)
+ { }
+
+ WKPoint m_point;
+};
+
+class Rect : public API::ObjectImpl<API::Object::Type::Rect> {
+public:
+ static Ref<Rect> create(const WKRect& rect)
+ {
+ return adoptRef(*new Rect(rect));
+ }
+
+ const WKRect& rect() const { return m_rect; }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<API::Object>&);
+
+private:
+ explicit Rect(const WKRect& rect)
+ : m_rect(rect)
+ {
+ }
+
+ WKRect m_rect;
+};
+
+} // namespace API
+
+#endif // APIGeometry_h
diff --git a/Source/WebKit2/Shared/API/APINumber.h b/Source/WebKit2/Shared/API/APINumber.h
new file mode 100644
index 000000000..fe5734981
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APINumber.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 APINumber_h
+#define APINumber_h
+
+#include "APIObject.h"
+#include "Decoder.h"
+#include "Encoder.h"
+
+namespace API {
+
+template<typename NumberType, API::Object::Type APIObjectType>
+class Number : public ObjectImpl<APIObjectType> {
+public:
+ static Ref<Number> create(NumberType value)
+ {
+ return adoptRef(*new Number(value));
+ }
+
+ NumberType value() const { return m_value; }
+
+ void encode(IPC::Encoder& encoder) const
+ {
+ encoder << m_value;
+ }
+
+ static bool decode(IPC::Decoder& decoder, RefPtr<Object>& result)
+ {
+ NumberType value;
+ if (!decoder.decode(value))
+ return false;
+
+ result = Number::create(value);
+ return true;
+ }
+
+private:
+ explicit Number(NumberType value)
+ : m_value(value)
+ {
+ }
+
+ const NumberType m_value;
+};
+
+typedef Number<bool, API::Object::Type::Boolean> Boolean;
+typedef Number<double, API::Object::Type::Double> Double;
+typedef Number<uint64_t, API::Object::Type::UInt64> UInt64;
+
+} // namespace API
+
+#endif // APINumber_h
diff --git a/Source/WebKit2/Shared/API/APIObject.cpp b/Source/WebKit2/Shared/API/APIObject.cpp
new file mode 100644
index 000000000..26e38f008
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIObject.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 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.
+ *
+ * Neither the name of Motorola Mobility, Inc. nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER OR
+ * 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 "APIObject.h"
+
+#include "WebKit2Initialize.h"
+
+namespace API {
+
+Object::Object()
+{
+ WebKit::InitializeWebKit2();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/API/APIObject.h b/Source/WebKit2/Shared/API/APIObject.h
new file mode 100644
index 000000000..f2cb0540a
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIObject.h
@@ -0,0 +1,276 @@
+/*
+ * Copyright (C) 2010-2017 Apple Inc. 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 APIObject_h
+#define APIObject_h
+
+#include <functional>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/ThreadSafeRefCounted.h>
+
+#if PLATFORM(COCOA)
+#include "WKFoundation.h"
+#ifdef __OBJC__
+#include "WKObject.h"
+#endif
+#endif
+
+#define DELEGATE_REF_COUNTING_TO_COCOA (PLATFORM(COCOA) && WK_API_ENABLED)
+
+#if DELEGATE_REF_COUNTING_TO_COCOA
+OBJC_CLASS NSObject;
+#endif
+
+namespace API {
+
+class Object
+#if !DELEGATE_REF_COUNTING_TO_COCOA
+ : public ThreadSafeRefCounted<Object>
+#endif
+{
+public:
+ enum class Type {
+ // Base types
+ Null = 0,
+ Array,
+ AuthenticationChallenge,
+ AuthenticationDecisionListener,
+ CertificateInfo,
+ Connection,
+ ContextMenuItem,
+ Credential,
+ Data,
+ Dictionary,
+ Error,
+ FrameHandle,
+ Image,
+ PageGroupData,
+ PageHandle,
+ PageGroupHandle,
+ ProtectionSpace,
+ RenderLayer,
+ RenderObject,
+ SecurityOrigin,
+ SessionState,
+ SerializedScriptValue,
+ String,
+ URL,
+ URLRequest,
+ URLResponse,
+ UserContentURLPattern,
+ UserScript,
+ UserStyleSheet,
+ WebArchive,
+ WebArchiveResource,
+
+ // Base numeric types
+ Boolean,
+ Double,
+ UInt64,
+
+ // Geometry types
+ Point,
+ Size,
+ Rect,
+
+ // UIProcess types
+ ApplicationCacheManager,
+ AutomationSession,
+ BackForwardList,
+ BackForwardListItem,
+ CacheManager,
+ ColorPickerResultListener,
+ ContextMenuListener,
+ CookieManager,
+ Download,
+ ExperimentalFeature,
+ FormSubmissionListener,
+ Frame,
+ FrameInfo,
+ FramePolicyListener,
+ FullScreenManager,
+ GeolocationManager,
+ GeolocationPermissionRequest,
+ HitTestResult,
+ GeolocationPosition,
+ GrammarDetail,
+ IconDatabase,
+ Inspector,
+ KeyValueStorageManager,
+ MediaCacheManager,
+ Navigation,
+ NavigationAction,
+ NavigationData,
+ NavigationResponse,
+ Notification,
+ NotificationManager,
+ NotificationPermissionRequest,
+ OpenPanelParameters,
+ OpenPanelResultListener,
+ OriginDataManager,
+ Page,
+ PageConfiguration,
+ PageGroup,
+ ProcessPool,
+ ProcessPoolConfiguration,
+ PluginSiteDataManager,
+ Preferences,
+ ResourceLoadStatisticsStore,
+ RunBeforeUnloadConfirmPanelResultListener,
+ RunJavaScriptAlertResultListener,
+ RunJavaScriptConfirmResultListener,
+ RunJavaScriptPromptResultListener,
+ TextChecker,
+ UserContentController,
+ UserContentExtension,
+ UserContentExtensionStore,
+ UserContentWorld,
+ UserInitiatedAction,
+ UserMediaPermissionCheck,
+ UserMediaPermissionRequest,
+ Vibration,
+ ViewportAttributes,
+ VisitedLinkStore,
+ WebResourceLoadStatisticsManager,
+ WebsiteDataRecord,
+ WebsiteDataStore,
+ WebsitePolicies,
+ WindowFeatures,
+
+#if ENABLE(MEDIA_SESSION)
+ MediaSessionFocusManager,
+ MediaSessionMetadata,
+#endif
+
+ // Bundle types
+ Bundle,
+ BundleBackForwardList,
+ BundleBackForwardListItem,
+ BundleCSSStyleDeclarationHandle,
+ BundleDOMWindowExtension,
+ BundleFileHandle,
+ BundleFrame,
+ BundleHitTestResult,
+ BundleInspector,
+ BundleNavigationAction,
+ BundleNodeHandle,
+ BundlePage,
+ BundlePageBanner,
+ BundlePageGroup,
+ BundlePageOverlay,
+ BundleRangeHandle,
+ BundleScriptWorld,
+
+ // Platform specific
+ EditCommandProxy,
+ ObjCObjectGraph,
+ View,
+#if USE(SOUP)
+ SoupRequestManager,
+ SoupCustomProtocolRequestManager,
+#endif
+ };
+
+ virtual ~Object()
+ {
+ }
+
+ virtual Type type() const = 0;
+
+#if DELEGATE_REF_COUNTING_TO_COCOA
+#ifdef __OBJC__
+ template<typename T, typename... Args>
+ static void constructInWrapper(NSObject <WKObject> *wrapper, Args&&... args)
+ {
+ Object* object = new (&wrapper._apiObject) T(std::forward<Args>(args)...);
+ object->m_wrapper = wrapper;
+ }
+#endif
+
+ NSObject *wrapper() { return m_wrapper; }
+
+ void ref();
+ void deref();
+#endif // DELEGATE_REF_COUNTING_TO_COCOA
+
+ static void* wrap(API::Object*);
+ static API::Object* unwrap(void*);
+
+protected:
+ Object();
+
+#if DELEGATE_REF_COUNTING_TO_COCOA
+ static void* newObject(size_t, Type);
+
+private:
+ // Derived classes must override operator new and call newObject().
+ void* operator new(size_t) = delete;
+
+ NSObject *m_wrapper;
+#endif // DELEGATE_REF_COUNTING_TO_COCOA
+};
+
+template <Object::Type ArgumentType>
+class ObjectImpl : public Object {
+public:
+ static const Type APIType = ArgumentType;
+
+ virtual ~ObjectImpl()
+ {
+ }
+
+protected:
+ friend class Object;
+
+ ObjectImpl()
+ {
+ }
+
+ Type type() const override { return APIType; }
+
+#if DELEGATE_REF_COUNTING_TO_COCOA
+ void* operator new(size_t size) { return newObject(size, APIType); }
+ void* operator new(size_t, void* value) { return value; }
+#endif
+};
+
+#if !DELEGATE_REF_COUNTING_TO_COCOA
+inline void* Object::wrap(API::Object* object)
+{
+ return static_cast<void*>(object);
+}
+
+inline API::Object* Object::unwrap(void* object)
+{
+ return static_cast<API::Object*>(object);
+}
+#endif
+
+} // namespace Object
+
+#undef DELEGATE_REF_COUNTING_TO_COCOA
+
+#endif // APIObject_h
diff --git a/Source/WebKit2/Shared/API/APIPageGroupHandle.cpp b/Source/WebKit2/Shared/API/APIPageGroupHandle.cpp
new file mode 100644
index 000000000..c8fd224ee
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIPageGroupHandle.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014 Apple Inc. 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 "APIPageGroupHandle.h"
+
+#include "Decoder.h"
+#include "Encoder.h"
+
+namespace API {
+
+Ref<PageGroupHandle> PageGroupHandle::create(WebKit::WebPageGroupData&& webPageGroupData)
+{
+ return adoptRef(*new PageGroupHandle(WTFMove(webPageGroupData)));
+}
+
+PageGroupHandle::PageGroupHandle(WebKit::WebPageGroupData&& webPageGroupData)
+ : m_webPageGroupData(WTFMove(webPageGroupData))
+{
+}
+
+PageGroupHandle::~PageGroupHandle()
+{
+}
+
+void PageGroupHandle::encode(IPC::Encoder& encoder) const
+{
+ encoder << m_webPageGroupData;
+}
+
+bool PageGroupHandle::decode(IPC::Decoder& decoder, RefPtr<Object>& result)
+{
+ WebKit::WebPageGroupData webPageGroupData;
+ if (!decoder.decode(webPageGroupData))
+ return false;
+
+ result = create(WTFMove(webPageGroupData));
+ return true;
+}
+
+}
diff --git a/Source/WebKit2/Shared/API/APIPageGroupHandle.h b/Source/WebKit2/Shared/API/APIPageGroupHandle.h
new file mode 100644
index 000000000..eaca5dfbd
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIPageGroupHandle.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2014 Apple Inc. 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 APIPageGroupHandle_h
+#define APIPageGroupHandle_h
+
+#include "APIObject.h"
+#include "WebPageGroupData.h"
+#include <wtf/RefPtr.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace API {
+
+class PageGroupHandle : public ObjectImpl<Object::Type::PageGroupHandle> {
+public:
+ static Ref<PageGroupHandle> create(WebKit::WebPageGroupData&&);
+ virtual ~PageGroupHandle();
+
+ const WebKit::WebPageGroupData& webPageGroupData() const { return m_webPageGroupData; }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<Object>&);
+
+private:
+ explicit PageGroupHandle(WebKit::WebPageGroupData&&);
+
+ const WebKit::WebPageGroupData m_webPageGroupData;
+};
+
+} // namespace API
+
+
+#endif // APIPageGroupHandle_h
diff --git a/Source/WebKit2/Shared/API/APIPageHandle.cpp b/Source/WebKit2/Shared/API/APIPageHandle.cpp
new file mode 100644
index 000000000..a6a009955
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIPageHandle.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013 Apple Inc. 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 "APIPageHandle.h"
+
+#include "Decoder.h"
+#include "Encoder.h"
+
+namespace API {
+
+Ref<PageHandle> PageHandle::create(uint64_t pageID)
+{
+ return adoptRef(*new PageHandle(pageID, false));
+}
+
+Ref<PageHandle> PageHandle::createAutoconverting(uint64_t pageID)
+{
+ return adoptRef(*new PageHandle(pageID, true));
+}
+
+PageHandle::PageHandle(uint64_t pageID, bool isAutoconverting)
+ : m_pageID(pageID)
+ , m_isAutoconverting(isAutoconverting)
+{
+}
+
+PageHandle::~PageHandle()
+{
+}
+
+void PageHandle::encode(IPC::Encoder& encoder) const
+{
+ encoder << m_pageID;
+ encoder << m_isAutoconverting;
+}
+
+bool PageHandle::decode(IPC::Decoder& decoder, RefPtr<Object>& result)
+{
+ uint64_t pageID;
+ if (!decoder.decode(pageID))
+ return false;
+
+ bool isAutoconverting;
+ if (!decoder.decode(isAutoconverting))
+ return false;
+
+ result = isAutoconverting ? createAutoconverting(pageID) : create(pageID);
+ return true;
+}
+
+} // namespace API
diff --git a/Source/WebKit2/Shared/API/APIPageHandle.h b/Source/WebKit2/Shared/API/APIPageHandle.h
new file mode 100644
index 000000000..f30fafbdc
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIPageHandle.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2013 Apple Inc. 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 APIPageHandle_h
+#define APIPageHandle_h
+
+#include "APIObject.h"
+#include <wtf/Ref.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace API {
+
+class PageHandle : public ObjectImpl<Object::Type::PageHandle> {
+public:
+ static Ref<PageHandle> create(uint64_t pageID);
+ static Ref<PageHandle> createAutoconverting(uint64_t pageID);
+ virtual ~PageHandle();
+
+ uint64_t pageID() const { return m_pageID; }
+ bool isAutoconverting() const { return m_isAutoconverting; }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<Object>&);
+
+private:
+ explicit PageHandle(uint64_t pageID, bool isAutoconverting);
+
+ const uint64_t m_pageID;
+ const bool m_isAutoconverting;
+};
+
+} // namespace API
+
+#endif // APIPageHandle_h
diff --git a/Source/WebKit2/Shared/API/APISecurityOrigin.h b/Source/WebKit2/Shared/API/APISecurityOrigin.h
new file mode 100644
index 000000000..8917c6704
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APISecurityOrigin.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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.
+ */
+
+#pragma once
+
+#include "APIObject.h"
+#include <WebCore/SecurityOrigin.h>
+#include <wtf/PassRefPtr.h>
+
+namespace API {
+
+class SecurityOrigin : public API::ObjectImpl<API::Object::Type::SecurityOrigin> {
+public:
+ static RefPtr<SecurityOrigin> createFromString(const WTF::String& string)
+ {
+ return create(WebCore::SecurityOrigin::createFromString(string));
+ }
+
+ static RefPtr<SecurityOrigin> create(const WTF::String& protocol, const WTF::String& host, std::optional<uint16_t> port)
+ {
+ return create(WebCore::SecurityOrigin::create(protocol, host, port));
+ }
+
+ static RefPtr<SecurityOrigin> create(const WebCore::SecurityOrigin& securityOrigin)
+ {
+ return adoptRef(new SecurityOrigin(securityOrigin));
+ }
+
+ WebCore::SecurityOrigin& securityOrigin() const { return *m_securityOrigin; }
+
+private:
+ SecurityOrigin(PassRefPtr<WebCore::SecurityOrigin> securityOrigin)
+ : m_securityOrigin(securityOrigin)
+ {
+ }
+
+ SecurityOrigin(const WebCore::SecurityOrigin& securityOrigin)
+ : m_securityOrigin(securityOrigin.isolatedCopy())
+ {
+ }
+
+ RefPtr<WebCore::SecurityOrigin> m_securityOrigin;
+};
+
+}
diff --git a/Source/WebKit2/Shared/API/APISerializedScriptValue.h b/Source/WebKit2/Shared/API/APISerializedScriptValue.h
new file mode 100644
index 000000000..6569d4d4c
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APISerializedScriptValue.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 APISerializedScriptValue_h
+#define APISerializedScriptValue_h
+
+#include "APIObject.h"
+
+#include "DataReference.h"
+#include <WebCore/SerializedScriptValue.h>
+#include <wtf/RefPtr.h>
+
+namespace API {
+
+class SerializedScriptValue : public API::ObjectImpl<API::Object::Type::SerializedScriptValue> {
+public:
+ static Ref<SerializedScriptValue> create(PassRefPtr<WebCore::SerializedScriptValue> serializedValue)
+ {
+ return adoptRef(*new SerializedScriptValue(serializedValue));
+ }
+
+ static RefPtr<SerializedScriptValue> create(JSContextRef context, JSValueRef value, JSValueRef* exception)
+ {
+ RefPtr<WebCore::SerializedScriptValue> serializedValue = WebCore::SerializedScriptValue::create(context, value, exception);
+ if (!serializedValue)
+ return nullptr;
+ return adoptRef(*new SerializedScriptValue(serializedValue.get()));
+ }
+
+ static Ref<SerializedScriptValue> adopt(Vector<uint8_t>&& buffer)
+ {
+ return adoptRef(*new SerializedScriptValue(WebCore::SerializedScriptValue::adopt(WTFMove(buffer))));
+ }
+
+ JSValueRef deserialize(JSContextRef context, JSValueRef* exception)
+ {
+ return m_serializedScriptValue->deserialize(context, exception);
+ }
+
+#if PLATFORM(COCOA) && defined(__OBJC__)
+ static id deserialize(WebCore::SerializedScriptValue&, JSValueRef* exception);
+#endif
+
+ IPC::DataReference dataReference() const { return m_serializedScriptValue->data(); }
+
+ WebCore::SerializedScriptValue* internalRepresentation() { return m_serializedScriptValue.get(); }
+
+private:
+ explicit SerializedScriptValue(PassRefPtr<WebCore::SerializedScriptValue> serializedScriptValue)
+ : m_serializedScriptValue(serializedScriptValue)
+ {
+ }
+
+ RefPtr<WebCore::SerializedScriptValue> m_serializedScriptValue;
+};
+
+}
+
+#endif
diff --git a/Source/WebKit2/Shared/API/APIString.h b/Source/WebKit2/Shared/API/APIString.h
new file mode 100644
index 000000000..2722b1b8b
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIString.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 APIString_h
+#define APIString_h
+
+#include "APIObject.h"
+#include <wtf/Ref.h>
+#include <wtf/text/StringView.h>
+#include <wtf/text/WTFString.h>
+#include <wtf/unicode/UTF8.h>
+
+namespace API {
+
+class String final : public ObjectImpl<Object::Type::String> {
+public:
+ static Ref<String> createNull()
+ {
+ return adoptRef(*new String);
+ }
+
+ static Ref<String> create(WTF::String&& string)
+ {
+ return adoptRef(*new String(string.isNull() ? WTF::String(StringImpl::empty()) : string.isolatedCopy()));
+ }
+
+ static Ref<String> create(const WTF::String& string)
+ {
+ return create(string.isolatedCopy());
+ }
+
+ virtual ~String()
+ {
+ }
+
+ WTF::StringView stringView() const { return m_string; }
+ WTF::String string() const { return m_string.isolatedCopy(); }
+
+private:
+ String()
+ : m_string()
+ {
+ }
+
+ String(WTF::String&& string)
+ : m_string(WTFMove(string))
+ {
+ ASSERT(!m_string.isNull());
+ ASSERT(m_string.isSafeToSendToAnotherThread());
+ }
+
+ const WTF::String m_string;
+};
+
+} // namespace WebKit
+
+#endif // APIString_h
diff --git a/Source/WebKit2/Shared/API/APIURL.h b/Source/WebKit2/Shared/API/APIURL.h
new file mode 100644
index 000000000..7e0fae174
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIURL.h
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 WebURL_h
+#define WebURL_h
+
+#include "APIObject.h"
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/URL.h>
+#include <wtf/Forward.h>
+#include <wtf/text/WTFString.h>
+
+namespace API {
+
+class URL : public ObjectImpl<Object::Type::URL> {
+public:
+ static Ref<URL> create(const WTF::String& string)
+ {
+ return adoptRef(*new URL(string));
+ }
+
+ static Ref<URL> create(const URL* baseURL, const WTF::String& relativeURL)
+ {
+ ASSERT(baseURL);
+ baseURL->parseURLIfNecessary();
+ auto absoluteURL = std::make_unique<WebCore::URL>(*baseURL->m_parsedURL.get(), relativeURL);
+ const WTF::String& absoluteURLString = absoluteURL->string();
+
+ return adoptRef(*new URL(WTFMove(absoluteURL), absoluteURLString));
+ }
+
+ bool isNull() const { return m_string.isNull(); }
+ bool isEmpty() const { return m_string.isEmpty(); }
+
+ const WTF::String& string() const { return m_string; }
+
+ static bool equals(const URL& a, const URL& b)
+ {
+ return a.url() == b.url();
+ }
+
+ WTF::String host() const
+ {
+ parseURLIfNecessary();
+ return m_parsedURL->isValid() ? m_parsedURL->host() : WTF::String();
+ }
+
+ WTF::String protocol() const
+ {
+ parseURLIfNecessary();
+ return m_parsedURL->isValid() ? m_parsedURL->protocol().toString() : WTF::String();
+ }
+
+ WTF::String path() const
+ {
+ parseURLIfNecessary();
+ return m_parsedURL->isValid() ? m_parsedURL->path() : WTF::String();
+ }
+
+ WTF::String lastPathComponent() const
+ {
+ parseURLIfNecessary();
+ return m_parsedURL->isValid() ? m_parsedURL->lastPathComponent() : WTF::String();
+ }
+
+ void encode(IPC::Encoder& encoder) const
+ {
+ encoder << m_string;
+ }
+
+ static bool decode(IPC::Decoder& decoder, RefPtr<Object>& result)
+ {
+ WTF::String string;
+ if (!decoder.decode(string))
+ return false;
+
+ result = create(string);
+ return true;
+ }
+
+private:
+ URL(const WTF::String& string)
+ : m_string(string)
+ {
+ }
+
+ URL(std::unique_ptr<WebCore::URL> parsedURL, const WTF::String& string)
+ : m_string(string)
+ , m_parsedURL(WTFMove(parsedURL))
+ {
+ }
+
+ const WebCore::URL& url() const
+ {
+ parseURLIfNecessary();
+ return *m_parsedURL;
+ }
+
+ void parseURLIfNecessary() const
+ {
+ if (m_parsedURL)
+ return;
+ m_parsedURL = std::make_unique<WebCore::URL>(WebCore::URL(), m_string);
+ }
+
+ WTF::String m_string;
+ mutable std::unique_ptr<WebCore::URL> m_parsedURL;
+};
+
+} // namespace WebKit
+
+#endif // URL_h
diff --git a/Source/WebKit2/Shared/API/APIURLRequest.cpp b/Source/WebKit2/Shared/API/APIURLRequest.cpp
new file mode 100644
index 000000000..ac904d409
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIURLRequest.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 "APIURLRequest.h"
+
+#include "WebCoreArgumentCoders.h"
+#include "WebProcessPool.h"
+
+using namespace WebCore;
+using namespace WebKit;
+
+namespace API {
+
+URLRequest::URLRequest(const ResourceRequest& request)
+ : m_request(request)
+{
+}
+
+double URLRequest::defaultTimeoutInterval()
+{
+ return ResourceRequest::defaultTimeoutInterval();
+}
+
+// FIXME: This function should really be on WebProcessPool or WebPageProxy.
+void URLRequest::setDefaultTimeoutInterval(double timeoutInterval)
+{
+ ResourceRequest::setDefaultTimeoutInterval(timeoutInterval);
+
+ for (auto* processPool : WebProcessPool::allProcessPools())
+ processPool->setDefaultRequestTimeoutInterval(timeoutInterval);
+}
+
+void URLRequest::encode(IPC::Encoder& encoder) const
+{
+ encoder << resourceRequest();
+}
+
+bool URLRequest::decode(IPC::Decoder& decoder, RefPtr<Object>& result)
+{
+ ResourceRequest request;
+ if (!decoder.decode(request))
+ return false;
+
+ result = create(request);
+ return true;
+}
+
+} // namespace API
diff --git a/Source/WebKit2/Shared/API/APIURLRequest.h b/Source/WebKit2/Shared/API/APIURLRequest.h
new file mode 100644
index 000000000..2a01602de
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIURLRequest.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 APIURLRequest_h
+#define APIURLRequest_h
+
+#include "APIObject.h"
+#include <WebCore/ResourceRequest.h>
+#include <wtf/Forward.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace API {
+
+class URLRequest : public ObjectImpl<Object::Type::URLRequest> {
+public:
+ static Ref<URLRequest> create(const WebCore::ResourceRequest& request)
+ {
+ return adoptRef(*new URLRequest(request));
+ }
+
+ const WebCore::ResourceRequest& resourceRequest() const { return m_request; }
+
+ static double defaultTimeoutInterval(); // May return 0 when using platform default.
+ static void setDefaultTimeoutInterval(double);
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<Object>&);
+
+private:
+ explicit URLRequest(const WebCore::ResourceRequest&);
+
+ WebCore::ResourceRequest m_request;
+};
+
+} // namespace API
+
+#endif // APIURLRequest_h
diff --git a/Source/WebKit2/Shared/API/APIURLResponse.cpp b/Source/WebKit2/Shared/API/APIURLResponse.cpp
new file mode 100644
index 000000000..1d93b62d3
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIURLResponse.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 "APIURLResponse.h"
+
+#include "WebCoreArgumentCoders.h"
+
+using namespace WebCore;
+
+namespace API {
+
+URLResponse::URLResponse(const WebCore::ResourceResponse& response)
+ : m_response(response)
+{
+}
+
+void URLResponse::encode(IPC::Encoder& encoder) const
+{
+ encoder << resourceResponse();
+}
+
+bool URLResponse::decode(IPC::Decoder& decoder, RefPtr<Object>& result)
+{
+ ResourceResponse response;
+ if (!decoder.decode(response))
+ return false;
+
+ result = create(response);
+ return true;
+}
+
+} // namespace API
diff --git a/Source/WebKit2/Shared/API/APIURLResponse.h b/Source/WebKit2/Shared/API/APIURLResponse.h
new file mode 100644
index 000000000..125e03711
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIURLResponse.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 APIURLResponse_h
+#define APIURLResponse_h
+
+#include "APIObject.h"
+#include <WebCore/ResourceResponse.h>
+#include <wtf/Forward.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace API {
+
+class URLResponse : public ObjectImpl<Object::Type::URLResponse> {
+public:
+ static Ref<URLResponse> create(const WebCore::ResourceResponse& response)
+ {
+ return adoptRef(*new URLResponse(response));
+ }
+
+ const WebCore::ResourceResponse& resourceResponse() const { return m_response; }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, RefPtr<Object>&);
+
+private:
+ explicit URLResponse(const WebCore::ResourceResponse&);
+
+ WebCore::ResourceResponse m_response;
+};
+
+} // namespace API
+
+#endif // APIURLResponse_h
diff --git a/Source/WebKit2/Shared/API/APIUserContentURLPattern.h b/Source/WebKit2/Shared/API/APIUserContentURLPattern.h
new file mode 100644
index 000000000..aff461310
--- /dev/null
+++ b/Source/WebKit2/Shared/API/APIUserContentURLPattern.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Apple Inc. 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 APIUserContentURLPattern_h
+#define APIUserContentURLPattern_h
+
+#include "APIObject.h"
+
+#include <WebCore/URL.h>
+#include <WebCore/UserContentURLPattern.h>
+
+namespace API {
+
+class UserContentURLPattern : public API::ObjectImpl<API::Object::Type::UserContentURLPattern> {
+public:
+ static Ref<UserContentURLPattern> create(const WTF::String& pattern)
+ {
+ return adoptRef(*new UserContentURLPattern(pattern));
+ }
+
+ const WTF::String& host() const { return m_pattern.host(); }
+ const WTF::String& scheme() const { return m_pattern.scheme(); }
+ bool isValid() const { return m_pattern.isValid(); };
+ bool matchesURL(const WTF::String& url) const { return m_pattern.matches(WebCore::URL(WebCore::ParsedURLString, url)); }
+ bool matchesSubdomains() const { return m_pattern.matchSubdomains(); }
+
+ const WTF::String& patternString() const { return m_patternString; }
+
+private:
+ explicit UserContentURLPattern(const WTF::String& pattern)
+ : m_pattern(WebCore::UserContentURLPattern(pattern))
+ , m_patternString(pattern)
+ {
+ }
+
+ WebCore::UserContentURLPattern m_pattern;
+ WTF::String m_patternString;
+};
+
+}
+
+#endif
diff --git a/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h b/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h
new file mode 100644
index 000000000..7ab00f53a
--- /dev/null
+++ b/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2014 Apple Inc. 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 WKActionMenuItemTypes_h
+#define WKActionMenuItemTypes_h
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Deprecated; remove when there are no more clients.
+enum {
+ kWKContextActionItemTagNoAction = 0,
+ kWKContextActionItemTagOpenLinkInDefaultBrowser,
+ kWKContextActionItemTagPreviewLink,
+ kWKContextActionItemTagAddLinkToSafariReadingList,
+ kWKContextActionItemTagCopyImage,
+ kWKContextActionItemTagAddImageToPhotos,
+ kWKContextActionItemTagSaveImageToDownloads,
+ kWKContextActionItemTagShareImage,
+ kWKContextActionItemTagCopyText,
+ kWKContextActionItemTagLookupText,
+ kWKContextActionItemTagPaste,
+ kWKContextActionItemTagTextSuggestions,
+ kWKContextActionItemTagCopyVideoURL,
+ kWKContextActionItemTagSaveVideoToDownloads,
+ kWKContextActionItemTagShareVideo,
+ kWKContextActionItemTagShareLink
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKActionMenuItemTypes_h */
diff --git a/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h b/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h
new file mode 100644
index 000000000..4769c390d
--- /dev/null
+++ b/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2014 Apple Inc. 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 WKActionMenuTypes_h
+#define WKActionMenuTypes_h
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Deprecated; remove when there are no more clients.
+enum {
+ kWKActionMenuNone = 0,
+ kWKActionMenuLink,
+ kWKActionMenuImage,
+ kWKActionMenuDataDetectedItem,
+ kWKActionMenuReadOnlyText,
+ kWKActionMenuEditableText,
+ kWKActionMenuEditableTextWithSuggestions,
+ kWKActionMenuWhitespaceInEditableArea,
+ kWKActionMenuVideo,
+ kWKActionMenuMailtoLink,
+ kWKActionMenuTelLink
+};
+typedef uint32_t _WKActionMenuType;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKActionMenuTypes_h */
diff --git a/Source/WebKit2/Shared/API/c/WKArray.cpp b/Source/WebKit2/Shared/API/c/WKArray.cpp
index 30f9781f3..844161124 100644
--- a/Source/WebKit2/Shared/API/c/WKArray.cpp
+++ b/Source/WebKit2/Shared/API/c/WKArray.cpp
@@ -42,9 +42,9 @@ WKArrayRef WKArrayCreate(WKTypeRef* values, size_t numberOfValues)
elements.reserveInitialCapacity(numberOfValues);
for (size_t i = 0; i < numberOfValues; ++i)
- elements.uncheckedAppend(const_cast<API::Object*>(static_cast<const API::Object*>(values[i])));
+ elements.uncheckedAppend(toImpl(values[i]));
- return toAPI(API::Array::create(std::move(elements)).leakRef());
+ return toAPI(&API::Array::create(WTFMove(elements)).leakRef());
}
WKArrayRef WKArrayCreateAdoptingValues(WKTypeRef* values, size_t numberOfValues)
@@ -53,14 +53,14 @@ WKArrayRef WKArrayCreateAdoptingValues(WKTypeRef* values, size_t numberOfValues)
elements.reserveInitialCapacity(numberOfValues);
for (size_t i = 0; i < numberOfValues; ++i)
- elements.uncheckedAppend(adoptRef(const_cast<API::Object*>(static_cast<const API::Object*>(values[i]))));
+ elements.uncheckedAppend(adoptRef(toImpl(values[i])));
- return toAPI(API::Array::create(std::move(elements)).leakRef());
+ return toAPI(&API::Array::create(WTFMove(elements)).leakRef());
}
WKTypeRef WKArrayGetItemAtIndex(WKArrayRef arrayRef, size_t index)
{
- return toImpl(arrayRef)->at(index);
+ return toAPI(toImpl(arrayRef)->at(index));
}
size_t WKArrayGetSize(WKArrayRef arrayRef)
diff --git a/Source/WebKit2/Shared/API/c/WKArray.h b/Source/WebKit2/Shared/API/c/WKArray.h
index 25900f313..ff8d39bfe 100644
--- a/Source/WebKit2/Shared/API/c/WKArray.h
+++ b/Source/WebKit2/Shared/API/c/WKArray.h
@@ -26,7 +26,7 @@
#ifndef WKArray_h
#define WKArray_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#include <stddef.h>
diff --git a/Source/WebKit2/Shared/API/c/WKBase.h b/Source/WebKit2/Shared/API/c/WKBase.h
index d41894c13..2e8fbfbbe 100644
--- a/Source/WebKit2/Shared/API/c/WKBase.h
+++ b/Source/WebKit2/Shared/API/c/WKBase.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
* Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,23 +27,15 @@
#ifndef WKBase_h
#define WKBase_h
-#include <WebKit2/WKDeclarationSpecifiers.h>
+#include <WebKit/WKDeclarationSpecifiers.h>
#include <stdint.h>
#if defined(BUILDING_GTK__)
-#include <WebKit2/WKBaseGtk.h>
+#include <WebKit/WKBaseGtk.h>
#endif
-#if defined(WTF_USE_SOUP)
-#include <WebKit2/WKBaseSoup.h>
-#endif
-
-#if defined(BUILDING_EFL__)
-#include <WebKit2/WKBaseEfl.h>
-#endif
-
-#if defined(__APPLE__)
-#include <WebKit2/WKBaseMac.h>
+#if defined(__APPLE__) && !defined(BUILDING_GTK__)
+#include <WebKit/WKBaseMac.h>
#endif
/* WebKit2 shared types */
@@ -89,16 +81,17 @@ typedef const struct OpaqueWKAuthenticationChallenge* WKAuthenticationChallengeR
typedef const struct OpaqueWKAuthenticationDecisionListener* WKAuthenticationDecisionListenerRef;
typedef const struct OpaqueWKBackForwardList* WKBackForwardListRef;
typedef const struct OpaqueWKBackForwardListItem* WKBackForwardListItemRef;
-typedef const struct OpaqueWKBatteryManager* WKBatteryManagerRef;
-typedef const struct OpaqueWKBatteryStatus* WKBatteryStatusRef;
typedef const struct OpaqueWKResourceCacheManager* WKResourceCacheManagerRef;
typedef const struct OpaqueWKColorPickerResultListener* WKColorPickerResultListenerRef;
typedef const struct OpaqueWKContext* WKContextRef;
+typedef const struct OpaqueWKContextConfiguration* WKContextConfigurationRef;
+typedef const struct OpaqueWKContextMenuListener* WKContextMenuListenerRef;
typedef const struct OpaqueWKCookieManager* WKCookieManagerRef;
typedef const struct OpaqueWKCredential* WKCredentialRef;
-typedef const struct OpaqueWKDatabaseManager* WKDatabaseManagerRef;
typedef const struct OpaqueWKDownload* WKDownloadRef;
typedef const struct OpaqueWKFormSubmissionListener* WKFormSubmissionListenerRef;
+typedef const struct OpaqueWKFrameHandle* WKFrameHandleRef;
+typedef const struct OpaqueWKFrameInfo* WKFrameInfoRef;
typedef const struct OpaqueWKFrame* WKFrameRef;
typedef const struct OpaqueWKFramePolicyListener* WKFramePolicyListenerRef;
typedef const struct OpaqueWKGeolocationManager* WKGeolocationManagerRef;
@@ -109,26 +102,42 @@ typedef const struct OpaqueWKHitTestResult* WKHitTestResultRef;
typedef const struct OpaqueWKIconDatabase* WKIconDatabaseRef;
typedef const struct OpaqueWKInspector* WKInspectorRef;
typedef const struct OpaqueWKKeyValueStorageManager* WKKeyValueStorageManagerRef;
-typedef const struct OpaqueWKMediaCacheManager* WKMediaCacheManagerRef;
+typedef const struct OpaqueWKMediaSessionFocusManager* WKMediaSessionFocusManagerRef;
+typedef const struct OpaqueWKMediaSessionMetadata* WKMediaSessionMetadataRef;
+typedef const struct OpaqueWKNavigationAction* WKNavigationActionRef;
typedef const struct OpaqueWKNavigationData* WKNavigationDataRef;
-typedef const struct OpaqueWKNetworkInfoManager* WKNetworkInfoManagerRef;
-typedef const struct OpaqueWKNetworkInfo* WKNetworkInfoRef;
+typedef const struct OpaqueWKNavigation* WKNavigationRef;
+typedef const struct OpaqueWKNavigationResponse* WKNavigationResponseRef;
typedef const struct OpaqueWKNotification* WKNotificationRef;
typedef const struct OpaqueWKNotificationManager* WKNotificationManagerRef;
typedef const struct OpaqueWKNotificationPermissionRequest* WKNotificationPermissionRequestRef;
typedef const struct OpaqueWKNotificationProvider* WKNotificationProviderRef;
typedef const struct OpaqueWKOpenPanelParameters* WKOpenPanelParametersRef;
typedef const struct OpaqueWKOpenPanelResultListener* WKOpenPanelResultListenerRef;
-typedef const struct OpaqueWKOriginDataManager* WKOriginDataManagerRef;
typedef const struct OpaqueWKPage* WKPageRef;
+typedef const struct OpaqueWKPageConfiguration* WKPageConfigurationRef;
typedef const struct OpaqueWKPageGroup* WKPageGroupRef;
-typedef const struct OpaqueWKPluginSiteDataManager* WKPluginSiteDataManagerRef;
typedef const struct OpaqueWKPreferences* WKPreferencesRef;
typedef const struct OpaqueWKProtectionSpace* WKProtectionSpaceRef;
+typedef const struct OpaqueWKPageRunBeforeUnloadConfirmPanelResultListener* WKPageRunBeforeUnloadConfirmPanelResultListenerRef;
+typedef const struct OpaqueWKPageRunJavaScriptAlertResultListener* WKPageRunJavaScriptAlertResultListenerRef;
+typedef const struct OpaqueWKPageRunJavaScriptConfirmResultListener* WKPageRunJavaScriptConfirmResultListenerRef;
+typedef const struct OpaqueWKPageRunJavaScriptPromptResultListener* WKPageRunJavaScriptPromptResultListenerRef;
+typedef const struct OpaqueWKResourceLoadStatisticsManager* WKResourceLoadStatisticsManagerRef;
typedef const struct OpaqueWKTextChecker* WKTextCheckerRef;
typedef const struct OpaqueWKSession* WKSessionRef;
+typedef const struct OpaqueWKSessionState* WKSessionStateRef;
+typedef const struct OpaqueWKUserContentController* WKUserContentControllerRef;
+typedef const struct OpaqueWKUserContentExtensionStore* WKUserContentExtensionStoreRef;
+typedef const struct OpaqueWKUserContentFilter* WKUserContentFilterRef;
+typedef const struct OpaqueWKUserMediaPermissionCheck* WKUserMediaPermissionCheckRef;
+typedef const struct OpaqueWKUserMediaPermissionRequest* WKUserMediaPermissionRequestRef;
+typedef const struct OpaqueWKUserScript* WKUserScriptRef;
typedef const struct OpaqueWKVibration* WKVibrationRef;
typedef const struct OpaqueWKViewportAttributes* WKViewportAttributesRef;
+typedef const struct OpaqueWKWebsiteDataStore* WKWebsiteDataStoreRef;
+typedef const struct OpaqueWKWebsitePolicies* WKWebsitePoliciesRef;
+typedef const struct OpaqueWKWindowFeatures* WKWindowFeaturesRef;
/* WebKit2 Bundle types */
@@ -137,6 +146,7 @@ typedef const struct OpaqueWKBundleBackForwardList* WKBundleBackForwardListRef;
typedef const struct OpaqueWKBundleBackForwardListItem* WKBundleBackForwardListItemRef;
typedef const struct OpaqueWKBundleDOMCSSStyleDeclaration* WKBundleCSSStyleDeclarationRef;
typedef const struct OpaqueWKBundleDOMWindowExtension* WKBundleDOMWindowExtensionRef;
+typedef const struct OpaqueWKBundleFileHandle* WKBundleFileHandleRef;
typedef const struct OpaqueWKBundleFrame* WKBundleFrameRef;
typedef const struct OpaqueWKBundleHitTestResult* WKBundleHitTestResultRef;
typedef const struct OpaqueWKBundleInspector* WKBundleInspectorRef;
diff --git a/Source/WebKit2/Shared/API/c/WKCertificateInfo.h b/Source/WebKit2/Shared/API/c/WKCertificateInfo.h
index d4a2ed91d..f88f93c1a 100644
--- a/Source/WebKit2/Shared/API/c/WKCertificateInfo.h
+++ b/Source/WebKit2/Shared/API/c/WKCertificateInfo.h
@@ -26,7 +26,7 @@
#ifndef WKCertificateInfo_h
#define WKCertificateInfo_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKConnectionRef.h b/Source/WebKit2/Shared/API/c/WKConnectionRef.h
index 614024575..fd94cb614 100644
--- a/Source/WebKit2/Shared/API/c/WKConnectionRef.h
+++ b/Source/WebKit2/Shared/API/c/WKConnectionRef.h
@@ -26,7 +26,7 @@
#ifndef WKConnectionRef_h
#define WKConnectionRef_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
@@ -48,16 +48,6 @@ typedef struct WKConnectionClientV0 {
WKConnectionDidCloseCallback didClose;
} WKConnectionClientV0;
-enum { WKConnectionClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 };
-typedef struct WKConnectionClient {
- int version;
- const void * clientInfo;
-
- // Version 0.
- WKConnectionDidReceiveMessageCallback didReceiveMessage;
- WKConnectionDidCloseCallback didClose;
-} WKConnectionClient WK_DEPRECATED("Use an explicit versioned struct instead");
-
WK_EXPORT WKTypeID WKConnectionGetTypeID();
WK_EXPORT void WKConnectionSetConnectionClient(WKConnectionRef connection, const WKConnectionClientBase* client);
diff --git a/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp b/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp
index 53064ff50..0514f1825 100644
--- a/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp
+++ b/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp
@@ -32,10 +32,6 @@
#include "WKAPICast.h"
#include "WKContextMenuItemTypes.h"
-#if PLATFORM(MAC)
-#import <mach-o/dyld.h>
-#endif
-
using namespace WebCore;
using namespace WebKit;
@@ -51,7 +47,7 @@ WKTypeID WKContextMenuItemGetTypeID()
WKContextMenuItemRef WKContextMenuItemCreateAsAction(WKContextMenuItemTag tag, WKStringRef title, bool enabled)
{
#if ENABLE(CONTEXT_MENUS)
- return toAPI(WebContextMenuItem::create(WebContextMenuItemData(ActionType, toImpl(tag), toImpl(title)->string(), enabled, false)).leakRef());
+ return toAPI(&WebContextMenuItem::create(WebContextMenuItemData(ActionType, toImpl(tag), toImpl(title)->string(), enabled, false)).leakRef());
#else
UNUSED_PARAM(tag);
UNUSED_PARAM(title);
@@ -63,7 +59,7 @@ WKContextMenuItemRef WKContextMenuItemCreateAsAction(WKContextMenuItemTag tag, W
WKContextMenuItemRef WKContextMenuItemCreateAsCheckableAction(WKContextMenuItemTag tag, WKStringRef title, bool enabled, bool checked)
{
#if ENABLE(CONTEXT_MENUS)
- return toAPI(WebContextMenuItem::create(WebContextMenuItemData(CheckableActionType, toImpl(tag), toImpl(title)->string(), enabled, checked)).leakRef());
+ return toAPI(&WebContextMenuItem::create(WebContextMenuItemData(CheckableActionType, toImpl(tag), toImpl(title)->string(), enabled, checked)).leakRef());
#else
UNUSED_PARAM(tag);
UNUSED_PARAM(title);
@@ -94,38 +90,10 @@ WKContextMenuItemRef WKContextMenuItemSeparatorItem()
#endif
}
-#if ENABLE(CONTEXT_MENUS)
-#if PLATFORM(MAC)
-static WKContextMenuItemTag compatibleContextMenuItemTag(WKContextMenuItemTag tag)
-{
- static bool needsWorkaround = ^bool {
- const int32_t safariFrameworkVersionWithIncompatibleContextMenuItemTags = 0x02181900; // 536.25.0 (Safari 6.0)
- return NSVersionOfRunTimeLibrary("Safari") == safariFrameworkVersionWithIncompatibleContextMenuItemTags;
- }();
-
- if (!needsWorkaround)
- return tag;
-
- // kWKContextMenuItemTagDictationAlternative was inserted before kWKContextMenuItemTagInspectElement.
- // DictationAlternative is now at the end like it should have been. To be compatible we need to return
- // InspectElement for DictationAlternative and shift InspectElement and after by one.
- if (tag == kWKContextMenuItemTagDictationAlternative)
- return kWKContextMenuItemTagInspectElement;
- if (tag >= kWKContextMenuItemTagInspectElement && tag < kWKContextMenuItemBaseApplicationTag)
- return tag + 1;
- return tag;
-}
-#endif
-#endif // ENABLE(CONTEXT_MENUS)
-
WKContextMenuItemTag WKContextMenuItemGetTag(WKContextMenuItemRef itemRef)
{
#if ENABLE(CONTEXT_MENUS)
-#if PLATFORM(MAC)
- return compatibleContextMenuItemTag(toAPI(toImpl(itemRef)->data()->action()));
-#else
- return toAPI(toImpl(itemRef)->data()->action());
-#endif
+ return toAPI(toImpl(itemRef)->data().action());
#else
UNUSED_PARAM(itemRef);
return toAPI(ContextMenuItemTagNoAction);
@@ -135,7 +103,7 @@ WKContextMenuItemTag WKContextMenuItemGetTag(WKContextMenuItemRef itemRef)
WKContextMenuItemType WKContextMenuItemGetType(WKContextMenuItemRef itemRef)
{
#if ENABLE(CONTEXT_MENUS)
- return toAPI(toImpl(itemRef)->data()->type());
+ return toAPI(toImpl(itemRef)->data().type());
#else
UNUSED_PARAM(itemRef);
return toAPI(ActionType);
@@ -145,7 +113,7 @@ WKContextMenuItemType WKContextMenuItemGetType(WKContextMenuItemRef itemRef)
WKStringRef WKContextMenuItemCopyTitle(WKContextMenuItemRef itemRef)
{
#if ENABLE(CONTEXT_MENUS)
- return toCopiedAPI(toImpl(itemRef)->data()->title().impl());
+ return toCopiedAPI(toImpl(itemRef)->data().title().impl());
#else
UNUSED_PARAM(itemRef);
return 0;
@@ -155,7 +123,7 @@ WKStringRef WKContextMenuItemCopyTitle(WKContextMenuItemRef itemRef)
bool WKContextMenuItemGetEnabled(WKContextMenuItemRef itemRef)
{
#if ENABLE(CONTEXT_MENUS)
- return toImpl(itemRef)->data()->enabled();
+ return toImpl(itemRef)->data().enabled();
#else
UNUSED_PARAM(itemRef);
return false;
@@ -165,7 +133,7 @@ bool WKContextMenuItemGetEnabled(WKContextMenuItemRef itemRef)
bool WKContextMenuItemGetChecked(WKContextMenuItemRef itemRef)
{
#if ENABLE(CONTEXT_MENUS)
- return toImpl(itemRef)->data()->checked();
+ return toImpl(itemRef)->data().checked();
#else
UNUSED_PARAM(itemRef);
return false;
@@ -175,7 +143,7 @@ bool WKContextMenuItemGetChecked(WKContextMenuItemRef itemRef)
WKArrayRef WKContextMenuCopySubmenuItems(WKContextMenuItemRef itemRef)
{
#if ENABLE(CONTEXT_MENUS)
- return toAPI(toImpl(itemRef)->submenuItemsAsAPIArray().leakRef());
+ return toAPI(&toImpl(itemRef)->submenuItemsAsAPIArray().leakRef());
#else
UNUSED_PARAM(itemRef);
return 0;
diff --git a/Source/WebKit2/Shared/API/c/WKContextMenuItem.h b/Source/WebKit2/Shared/API/c/WKContextMenuItem.h
index 9b978400c..caf1b7632 100644
--- a/Source/WebKit2/Shared/API/c/WKContextMenuItem.h
+++ b/Source/WebKit2/Shared/API/c/WKContextMenuItem.h
@@ -26,8 +26,8 @@
#ifndef WKContextMenuItem_h
#define WKContextMenuItem_h
-#include <WebKit2/WKBase.h>
-#include <WebKit2/WKContextMenuItemTypes.h>
+#include <WebKit/WKBase.h>
+#include <WebKit/WKContextMenuItemTypes.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h b/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h
index f61703e32..2a67631c4 100644
--- a/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h
+++ b/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h
@@ -121,6 +121,8 @@ enum {
kWKContextMenuItemTagSelectAll,
kWKContextMenuItemTagOpenLinkInThisWindow,
kWKContextMenuItemTagToggleVideoFullscreen,
+ kWKContextMenuItemTagShareMenu,
+ kWKContextMenuItemTagToggleVideoEnhancedFullscreen,
kWKContextMenuItemBaseApplicationTag = 10000
};
typedef uint32_t WKContextMenuItemTag;
diff --git a/Source/WebKit2/Shared/API/c/WKData.cpp b/Source/WebKit2/Shared/API/c/WKData.cpp
index ebc40b142..fdbca73dc 100644
--- a/Source/WebKit2/Shared/API/c/WKData.cpp
+++ b/Source/WebKit2/Shared/API/c/WKData.cpp
@@ -38,7 +38,7 @@ WKTypeID WKDataGetTypeID()
WKDataRef WKDataCreate(const unsigned char* bytes, size_t size)
{
- return toAPI(API::Data::create(bytes, size).leakRef());
+ return toAPI(&API::Data::create(bytes, size).leakRef());
}
const unsigned char* WKDataGetBytes(WKDataRef dataRef)
diff --git a/Source/WebKit2/Shared/API/c/WKData.h b/Source/WebKit2/Shared/API/c/WKData.h
index a647ee4e4..19e1fff7c 100644
--- a/Source/WebKit2/Shared/API/c/WKData.h
+++ b/Source/WebKit2/Shared/API/c/WKData.h
@@ -26,7 +26,7 @@
#ifndef WKData_h
#define WKData_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#include <stddef.h>
diff --git a/Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h b/Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h
index b5d8f13cb..ce8adcfbb 100644
--- a/Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h
+++ b/Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h
@@ -51,15 +51,9 @@
#endif
#if defined(__has_extension) && __has_extension(enumerator_attributes) && __has_extension(attribute_unavailable_with_message)
-#define WK_DEPRECATED(message) __attribute__((deprecated(message)))
+#define WK_C_DEPRECATED(message) __attribute__((deprecated(message)))
#else
-#define WK_DEPRECATED(message)
-#endif
-
-#if defined(__has_extension) && __has_extension(enumerator_attributes) && __has_extension(attribute_unavailable_with_message)
-#define WK_ENUM_DEPRECATED(message) __attribute__((deprecated(message)))
-#else
-#define WK_ENUM_DEPRECATED(message)
+#define WK_C_DEPRECATED(message)
#endif
#endif /* WKDeclarationSpecifiers_h */
diff --git a/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp b/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp
index 1319b76f3..915f44a7f 100644
--- a/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp
+++ b/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp
@@ -25,10 +25,15 @@
#include "config.h"
-#include "MutableDictionary.h"
+#include "APIDictionary.h"
+#include "APIUserContentExtension.h"
+#include "WKAPICast.h"
#include "WKArray.h"
+#include "WKContextPrivate.h"
#include "WKMutableDictionary.h"
-#include "WKSharedAPICast.h"
+#include "WKPreferencesRefPrivate.h"
+#include "WebPageGroup.h"
+#include "WebUserContentControllerProxy.h"
#if PLATFORM(MAC)
#include "WKContextPrivateMac.h"
@@ -36,53 +41,53 @@
// Deprecated functions that should be removed from the framework once nobody uses them.
-using namespace WebKit;
-
extern "C" {
-WK_EXPORT bool WKArrayIsMutable(WKArrayRef array);
-
-WK_EXPORT bool WKDictionaryAddItem(WKMutableDictionaryRef dictionary, WKStringRef key, WKTypeRef item);
-WK_EXPORT bool WKDictionaryIsMutable(WKDictionaryRef dictionary);
-WK_EXPORT void WKDictionaryRemoveItem(WKMutableDictionaryRef dictionary, WKStringRef key);
-
-#if PLATFORM(MAC)
-WK_EXPORT CGContextRef WKGraphicsContextGetCGContext(WKGraphicsContextRef graphicsContext);
-#endif
+WK_EXPORT WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroup);
+WK_EXPORT void WKPageGroupAddUserContentFilter(WKPageGroupRef pageGroup, WKUserContentFilterRef userContentFilter);
+WK_EXPORT void WKPageGroupRemoveUserContentFilter(WKPageGroupRef pageGroup, WKStringRef userContentFilterName);
+WK_EXPORT void WKPageGroupRemoveAllUserContentFilters(WKPageGroupRef pageGroup);
}
-bool WKArrayIsMutable(WKArrayRef)
-{
- return false;
-}
+using namespace WebKit;
-bool WKDictionaryIsMutable(WKDictionaryRef dictionaryRef)
+void WKContextSetUsesNetworkProcess(WKContextRef, bool)
{
- return toImpl(dictionaryRef)->isMutable();
}
-bool WKDictionaryAddItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef, WKTypeRef itemRef)
+void WKContextSetProcessModel(WKContextRef, WKProcessModel)
{
- return toImpl(dictionaryRef)->add(toImpl(keyRef)->string(), toImpl(itemRef));
}
-void WKDictionaryRemoveItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef)
+WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef)
{
- toImpl(dictionaryRef)->remove(toImpl(keyRef)->string());
+ return nullptr;
}
-
-#if PLATFORM(MAC)
-CGContextRef WKGraphicsContextGetCGContext(WKGraphicsContextRef graphicsContext)
+void WKPageGroupAddUserContentFilter(WKPageGroupRef pageGroupRef, WKUserContentFilterRef userContentFilterRef)
{
- return nullptr;
+#if ENABLE(CONTENT_EXTENSIONS)
+ toImpl(pageGroupRef)->userContentController().addUserContentExtension(*toImpl(userContentFilterRef));
+#else
+ UNUSED_PARAM(pageGroupRef);
+ UNUSED_PARAM(userContentFilterRef);
+#endif
}
-bool WKContextGetProcessSuppressionEnabled(WKContextRef)
+void WKPageGroupRemoveUserContentFilter(WKPageGroupRef pageGroupRef, WKStringRef userContentFilterNameRef)
{
- return true;
+#if ENABLE(CONTENT_EXTENSIONS)
+ toImpl(pageGroupRef)->userContentController().removeUserContentExtension(toWTFString(userContentFilterNameRef));
+#else
+ UNUSED_PARAM(pageGroupRef);
+ UNUSED_PARAM(userContentFilterNameRef);
+#endif
}
-void WKContextSetProcessSuppressionEnabled(WKContextRef, bool)
+void WKPageGroupRemoveAllUserContentFilters(WKPageGroupRef pageGroupRef)
{
-}
+#if ENABLE(CONTENT_EXTENSIONS)
+ toImpl(pageGroupRef)->userContentController().removeAllUserContentExtensions();
+#else
+ UNUSED_PARAM(pageGroupRef);
#endif
+}
diff --git a/Source/WebKit2/Shared/API/c/soup/WKBaseSoup.h b/Source/WebKit2/Shared/API/c/WKDiagnosticLoggingResultType.h
index 600f0857f..581c74f96 100644
--- a/Source/WebKit2/Shared/API/c/soup/WKBaseSoup.h
+++ b/Source/WebKit2/Shared/API/c/WKDiagnosticLoggingResultType.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Igalia S.L.
+ * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,14 +23,23 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WKBaseSoup_h
-#define WKBaseSoup_h
+#ifndef WKDiagnosticLoggingResultType_h
+#define WKDiagnosticLoggingResultType_h
-#ifndef WKBase_h
-#error "Please #include \"WKBase.h\" instead of this file directly."
+#ifdef __cplusplus
+extern "C" {
#endif
-typedef const struct OpaqueWKSoupRequestManager* WKSoupRequestManagerRef;
-typedef const struct OpaqueWKSoupCustomProtocolRequestManager* WKSoupCustomProtocolRequestManagerRef;
+enum {
+ kWKDiagnosticLoggingResultPass = 0,
+ kWKDiagnosticLoggingResultFail = 1,
+ kWKDiagnosticLoggingResultNoop = 2,
+};
+typedef uint32_t WKDiagnosticLoggingResultType;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKDiagnosticLoggingResultType_h */
-#endif /* WKBaseSoup_h */
diff --git a/Source/WebKit2/Shared/API/c/WKDictionary.cpp b/Source/WebKit2/Shared/API/c/WKDictionary.cpp
index 44c61e162..654e1e61e 100644
--- a/Source/WebKit2/Shared/API/c/WKDictionary.cpp
+++ b/Source/WebKit2/Shared/API/c/WKDictionary.cpp
@@ -27,28 +27,28 @@
#include "WKDictionary.h"
#include "APIArray.h"
-#include "ImmutableDictionary.h"
+#include "APIDictionary.h"
#include "WKAPICast.h"
using namespace WebKit;
WKTypeID WKDictionaryGetTypeID()
{
- return toAPI(ImmutableDictionary::APIType);
+ return toAPI(API::Dictionary::APIType);
}
WK_EXPORT WKDictionaryRef WKDictionaryCreate(const WKStringRef* keys, const WKTypeRef* values, size_t numberOfValues)
{
- ImmutableDictionary::MapType map;
+ API::Dictionary::MapType map;
for (size_t i = 0; i < numberOfValues; ++i)
map.add(toImpl(keys[i])->string(), toImpl(values[i]));
- return toAPI(ImmutableDictionary::create(std::move(map)).release().leakRef());
+ return toAPI(&API::Dictionary::create(WTFMove(map)).leakRef());
}
WKTypeRef WKDictionaryGetItemForKey(WKDictionaryRef dictionaryRef, WKStringRef key)
{
- return toImpl(dictionaryRef)->get(toImpl(key)->string());
+ return toAPI(toImpl(dictionaryRef)->get(toImpl(key)->string()));
}
size_t WKDictionaryGetSize(WKDictionaryRef dictionaryRef)
@@ -58,6 +58,5 @@ size_t WKDictionaryGetSize(WKDictionaryRef dictionaryRef)
WKArrayRef WKDictionaryCopyKeys(WKDictionaryRef dictionaryRef)
{
- RefPtr<API::Array> keys = toImpl(dictionaryRef)->keys();
- return toAPI(keys.release().leakRef());
+ return toAPI(&toImpl(dictionaryRef)->keys().leakRef());
}
diff --git a/Source/WebKit2/Shared/API/c/WKDictionary.h b/Source/WebKit2/Shared/API/c/WKDictionary.h
index c416e3c29..e486cc2a8 100644
--- a/Source/WebKit2/Shared/API/c/WKDictionary.h
+++ b/Source/WebKit2/Shared/API/c/WKDictionary.h
@@ -26,7 +26,7 @@
#ifndef WKDictionary_h
#define WKDictionary_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#include <stddef.h>
diff --git a/Source/WebKit2/Shared/API/c/WKError.cpp b/Source/WebKit2/Shared/API/c/WKErrorRef.cpp
index 315f43e9f..c1e75eb00 100644
--- a/Source/WebKit2/Shared/API/c/WKError.cpp
+++ b/Source/WebKit2/Shared/API/c/WKErrorRef.cpp
@@ -24,7 +24,7 @@
*/
#include "config.h"
-#include "WKError.h"
+#include "WKErrorRef.h"
#include "APIError.h"
#include "WKAPICast.h"
diff --git a/Source/WebKit2/Shared/API/c/WKError.h b/Source/WebKit2/Shared/API/c/WKErrorRef.h
index b099b732c..0d76384d3 100644
--- a/Source/WebKit2/Shared/API/c/WKError.h
+++ b/Source/WebKit2/Shared/API/c/WKErrorRef.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,10 +23,10 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WKError_h
-#define WKError_h
+#ifndef WKErrorRef_h
+#define WKErrorRef_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
@@ -37,6 +37,8 @@ enum {
kWKErrorCodeCannotShowURL = 101,
kWKErrorCodeFrameLoadInterruptedByPolicyChange = 102,
kWKErrorCodeCannotUseRestrictedPort = 103,
+ kWKErrorCodeFrameLoadBlockedByContentBlocker = 104,
+ kWKErrorCodeFrameLoadBlockedByContentFilter = 105,
kWKErrorCodeCannotFindPlugIn = 200,
kWKErrorCodeCannotLoadPlugIn = 201,
kWKErrorCodeJavaUnavailable = 202,
@@ -45,7 +47,6 @@ enum {
kWKErrorCodeInsecurePlugInVersion = 205,
kWKErrorInternal = 300,
};
-typedef uint32_t WKErrorCode;
WK_EXPORT WKTypeID WKErrorGetTypeID();
@@ -60,4 +61,4 @@ WK_EXPORT WKStringRef WKErrorCopyLocalizedDescription(WKErrorRef error);
}
#endif
-#endif // WKError_h
+#endif // WKErrorRef_h
diff --git a/Source/WebKit2/Shared/API/c/WKEvent.h b/Source/WebKit2/Shared/API/c/WKEvent.h
index b15c47ad2..477d554c9 100644
--- a/Source/WebKit2/Shared/API/c/WKEvent.h
+++ b/Source/WebKit2/Shared/API/c/WKEvent.h
@@ -26,7 +26,7 @@
#ifndef WKEvent_h
#define WKEvent_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
@@ -36,7 +36,8 @@ enum {
kWKEventModifiersShiftKey = 1 << 0,
kWKEventModifiersControlKey = 1 << 1,
kWKEventModifiersAltKey = 1 << 2,
- kWKEventModifiersMetaKey = 1 << 3
+ kWKEventModifiersMetaKey = 1 << 3,
+ kWKEventModifiersCapsLockKey = 1 << 4
};
typedef uint32_t WKEventModifiers;
diff --git a/Source/WebKit2/Shared/API/c/WKGeometry.cpp b/Source/WebKit2/Shared/API/c/WKGeometry.cpp
index 96c3f19f7..e1ea82435 100644
--- a/Source/WebKit2/Shared/API/c/WKGeometry.cpp
+++ b/Source/WebKit2/Shared/API/c/WKGeometry.cpp
@@ -48,17 +48,17 @@ WKTypeID WKRectGetTypeID()
WKPointRef WKPointCreate(WKPoint point)
{
- return toAPI(API::Point::create(point).leakRef());
+ return toAPI(&API::Point::create(point).leakRef());
}
WKSizeRef WKSizeCreate(WKSize size)
{
- return toAPI(API::Size::create(size).leakRef());
+ return toAPI(&API::Size::create(size).leakRef());
}
WKRectRef WKRectCreate(WKRect rect)
{
- return toAPI(API::Rect::create(rect).leakRef());
+ return toAPI(&API::Rect::create(rect).leakRef());
}
WKSize WKSizeGetValue(WKSizeRef size)
diff --git a/Source/WebKit2/Shared/API/c/WKGeometry.h b/Source/WebKit2/Shared/API/c/WKGeometry.h
index 97bf242e9..124fe2498 100644
--- a/Source/WebKit2/Shared/API/c/WKGeometry.h
+++ b/Source/WebKit2/Shared/API/c/WKGeometry.h
@@ -26,7 +26,7 @@
#ifndef WKGeometry_h
#define WKGeometry_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKImage.cpp b/Source/WebKit2/Shared/API/c/WKImage.cpp
index 23278b3a7..2741199e2 100644
--- a/Source/WebKit2/Shared/API/c/WKImage.cpp
+++ b/Source/WebKit2/Shared/API/c/WKImage.cpp
@@ -38,8 +38,8 @@ WKTypeID WKImageGetTypeID()
WKImageRef WKImageCreate(WKSize size, WKImageOptions options)
{
- RefPtr<WebImage> webImage = WebImage::create(toIntSize(size), toImageOptions(options));
- return toAPI(webImage.release().leakRef());
+ auto webImage = WebImage::create(toIntSize(size), toImageOptions(options));
+ return toAPI(webImage.leakRef());
}
WKSize WKImageGetSize(WKImageRef imageRef)
diff --git a/Source/WebKit2/Shared/API/c/WKImage.h b/Source/WebKit2/Shared/API/c/WKImage.h
index 07437bd76..27a34544e 100644
--- a/Source/WebKit2/Shared/API/c/WKImage.h
+++ b/Source/WebKit2/Shared/API/c/WKImage.h
@@ -26,8 +26,8 @@
#ifndef WKImage_h
#define WKImage_h
-#include <WebKit2/WKBase.h>
-#include <WebKit2/WKGeometry.h>
+#include <WebKit/WKBase.h>
+#include <WebKit/WKGeometry.h>
#ifdef __cplusplus
extern "C" {
@@ -42,7 +42,10 @@ enum {
kWKSnapshotOptionsShareable = 1 << 0,
kWKSnapshotOptionsExcludeSelectionHighlighting = 1 << 1,
kWKSnapshotOptionsInViewCoordinates = 1 << 2,
- kWKSnapshotOptionsPaintSelectionRectangle = 1 << 3
+ kWKSnapshotOptionsPaintSelectionRectangle = 1 << 3,
+ kWKSnapshotOptionsForceBlackText = 1 << 4,
+ kWKSnapshotOptionsForceWhiteText = 1 << 5,
+ kWKSnapshotOptionsPrinting = 1 << 6,
};
typedef uint32_t WKSnapshotOptions;
diff --git a/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h b/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h
new file mode 100644
index 000000000..5fdc29a9e
--- /dev/null
+++ b/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2014 Apple Inc. 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 WKImmediateActionTypes_h
+#define WKImmediateActionTypes_h
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ kWKImmediateActionNone = 0,
+ kWKImmediateActionLinkPreview,
+ kWKImmediateActionDataDetectedItem,
+ kWKImmediateActionLookupText,
+ kWKImmediateActionMailtoLink,
+ kWKImmediateActionTelLink
+};
+
+#ifndef _WKImmediateActionType
+#define _WKImmediateActionType uint32_t
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKImmediateActionTypes_h */
diff --git a/Source/WebKit2/Shared/API/c/WKMutableArray.cpp b/Source/WebKit2/Shared/API/c/WKMutableArray.cpp
index f06782dae..5dc85260f 100644
--- a/Source/WebKit2/Shared/API/c/WKMutableArray.cpp
+++ b/Source/WebKit2/Shared/API/c/WKMutableArray.cpp
@@ -33,7 +33,7 @@ using namespace WebKit;
WKMutableArrayRef WKMutableArrayCreate()
{
- return const_cast<WKMutableArrayRef>(toAPI(API::Array::create().leakRef()));
+ return const_cast<WKMutableArrayRef>(toAPI(&API::Array::create().leakRef()));
}
void WKArrayAppendItem(WKMutableArrayRef arrayRef, WKTypeRef itemRef)
diff --git a/Source/WebKit2/Shared/API/c/WKMutableArray.h b/Source/WebKit2/Shared/API/c/WKMutableArray.h
index 7f05c2830..80bd8c029 100644
--- a/Source/WebKit2/Shared/API/c/WKMutableArray.h
+++ b/Source/WebKit2/Shared/API/c/WKMutableArray.h
@@ -26,7 +26,7 @@
#ifndef WKMutableArray_h
#define WKMutableArray_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#include <stddef.h>
#ifndef __cplusplus
diff --git a/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp b/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp
index 7ea5a3630..96b89bd45 100644
--- a/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp
+++ b/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp
@@ -26,15 +26,14 @@
#include "config.h"
#include "WKMutableDictionary.h"
-#include "MutableDictionary.h"
+#include "APIDictionary.h"
#include "WKAPICast.h"
using namespace WebKit;
WKMutableDictionaryRef WKMutableDictionaryCreate()
{
- RefPtr<MutableDictionary> dictionary = MutableDictionary::create();
- return toAPI(dictionary.release().leakRef());
+ return const_cast<WKMutableDictionaryRef>(toAPI(&API::Dictionary::create().leakRef()));
}
bool WKDictionarySetItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef, WKTypeRef itemRef)
diff --git a/Source/WebKit2/Shared/API/c/WKMutableDictionary.h b/Source/WebKit2/Shared/API/c/WKMutableDictionary.h
index e8297daa8..0c3b33a12 100644
--- a/Source/WebKit2/Shared/API/c/WKMutableDictionary.h
+++ b/Source/WebKit2/Shared/API/c/WKMutableDictionary.h
@@ -26,7 +26,7 @@
#ifndef WKMutableDictionary_h
#define WKMutableDictionary_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifndef __cplusplus
#include <stdbool.h>
diff --git a/Source/WebKit2/Shared/API/c/WKNumber.cpp b/Source/WebKit2/Shared/API/c/WKNumber.cpp
index 11300632c..418e029ea 100644
--- a/Source/WebKit2/Shared/API/c/WKNumber.cpp
+++ b/Source/WebKit2/Shared/API/c/WKNumber.cpp
@@ -38,8 +38,8 @@ WKTypeID WKBooleanGetTypeID()
WKBooleanRef WKBooleanCreate(bool value)
{
- RefPtr<API::Boolean> booleanObject = API::Boolean::create(value);
- return toAPI(booleanObject.release().leakRef());
+ auto booleanObject = API::Boolean::create(value);
+ return toAPI(&booleanObject.leakRef());
}
bool WKBooleanGetValue(WKBooleanRef booleanRef)
@@ -54,8 +54,8 @@ WKTypeID WKDoubleGetTypeID()
WKDoubleRef WKDoubleCreate(double value)
{
- RefPtr<API::Double> doubleObject = API::Double::create(value);
- return toAPI(doubleObject.release().leakRef());
+ auto doubleObject = API::Double::create(value);
+ return toAPI(&doubleObject.leakRef());
}
double WKDoubleGetValue(WKDoubleRef doubleRef)
@@ -70,8 +70,8 @@ WKTypeID WKUInt64GetTypeID()
WKUInt64Ref WKUInt64Create(uint64_t value)
{
- RefPtr<API::UInt64> uint64Object = API::UInt64::create(value);
- return toAPI(uint64Object.release().leakRef());
+ auto uint64Object = API::UInt64::create(value);
+ return toAPI(&uint64Object.leakRef());
}
uint64_t WKUInt64GetValue(WKUInt64Ref uint64Ref)
diff --git a/Source/WebKit2/Shared/API/c/WKNumber.h b/Source/WebKit2/Shared/API/c/WKNumber.h
index c8c912965..2ebe73a8c 100644
--- a/Source/WebKit2/Shared/API/c/WKNumber.h
+++ b/Source/WebKit2/Shared/API/c/WKNumber.h
@@ -26,7 +26,7 @@
#ifndef WKNumber_h
#define WKNumber_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp b/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp
index a4a1ce743..e3ae4f5f0 100644
--- a/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp
+++ b/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp
@@ -35,8 +35,8 @@ using namespace WebKit;
WKStringRef WKPluginInformationBundleIdentifierKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationBundleIdentifierKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationBundleIdentifierKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -45,8 +45,8 @@ WKStringRef WKPluginInformationBundleIdentifierKey()
WKStringRef WKPluginInformationBundleVersionKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationBundleVersionKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationBundleVersionKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -55,8 +55,8 @@ WKStringRef WKPluginInformationBundleVersionKey()
WKStringRef WKPluginInformationBundleShortVersionKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationBundleShortVersionKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationBundleShortVersionKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -65,8 +65,8 @@ WKStringRef WKPluginInformationBundleShortVersionKey()
WKStringRef WKPluginInformationPathKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationPathKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationPathKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -75,8 +75,8 @@ WKStringRef WKPluginInformationPathKey()
WKStringRef WKPluginInformationDisplayNameKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationDisplayNameKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationDisplayNameKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -85,8 +85,8 @@ WKStringRef WKPluginInformationDisplayNameKey()
WKStringRef WKPluginInformationDefaultLoadPolicyKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationDefaultLoadPolicyKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationDefaultLoadPolicyKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -95,8 +95,8 @@ WKStringRef WKPluginInformationDefaultLoadPolicyKey()
WKStringRef WKPluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -105,8 +105,8 @@ WKStringRef WKPluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()
WKStringRef WKPluginInformationHasSandboxProfileKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationHasSandboxProfileKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationHasSandboxProfileKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -115,8 +115,8 @@ WKStringRef WKPluginInformationHasSandboxProfileKey()
WKStringRef WKPluginInformationFrameURLKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationFrameURLKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationFrameURLKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -125,8 +125,8 @@ WKStringRef WKPluginInformationFrameURLKey()
WKStringRef WKPluginInformationMIMETypeKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationMIMETypeKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationMIMETypeKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -135,8 +135,8 @@ WKStringRef WKPluginInformationMIMETypeKey()
WKStringRef WKPluginInformationPageURLKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationPageURLKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationPageURLKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -145,8 +145,8 @@ WKStringRef WKPluginInformationPageURLKey()
WKStringRef WKPluginInformationPluginspageAttributeURLKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationPluginspageAttributeURLKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationPluginspageAttributeURLKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -155,8 +155,8 @@ WKStringRef WKPluginInformationPluginspageAttributeURLKey()
WKStringRef WKPluginInformationPluginURLKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationPluginURLKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationPluginURLKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -165,8 +165,8 @@ WKStringRef WKPluginInformationPluginURLKey()
WKStringRef WKPlugInInformationReplacementObscuredKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(plugInInformationReplacementObscuredKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(plugInInformationReplacementObscuredKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
diff --git a/Source/WebKit2/Shared/API/c/WKPluginInformation.h b/Source/WebKit2/Shared/API/c/WKPluginInformation.h
index 0bcaef192..08970844b 100644
--- a/Source/WebKit2/Shared/API/c/WKPluginInformation.h
+++ b/Source/WebKit2/Shared/API/c/WKPluginInformation.h
@@ -26,7 +26,7 @@
#ifndef WKPluginInformation_h
#define WKPluginInformation_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKRenderLayer.cpp b/Source/WebKit2/Shared/API/c/WKRenderLayer.cpp
index 82cf959be..da21e69aa 100644
--- a/Source/WebKit2/Shared/API/c/WKRenderLayer.cpp
+++ b/Source/WebKit2/Shared/API/c/WKRenderLayer.cpp
@@ -53,7 +53,7 @@ WKStringRef WKRenderLayerCopyElementTagName(WKRenderLayerRef renderLayerRef)
if (!renderLayer->renderer()->elementTagName().isNull())
return toCopiedAPI(renderLayer->renderer()->elementTagName());
- return 0;
+ return nullptr;
}
WKStringRef WKRenderLayerCopyElementID(WKRenderLayerRef renderLayerRef)
@@ -62,7 +62,7 @@ WKStringRef WKRenderLayerCopyElementID(WKRenderLayerRef renderLayerRef)
if (!renderLayer->renderer()->elementID().isNull())
return toCopiedAPI(renderLayer->renderer()->elementID());
- return 0;
+ return nullptr;
}
WKArrayRef WKRenderLayerGetElementClassNames(WKRenderLayerRef renderLayerRef)
@@ -110,6 +110,11 @@ WKCompositingLayerType WKRenderLayerGetCompositingLayerType(WKRenderLayerRef ren
return kWKCompositingLayerTypeNone;
}
+WK_EXPORT double WKRenderLayerGetBackingStoreMemoryEstimate(WKRenderLayerRef renderLayerRef)
+{
+ return toImpl(renderLayerRef)->backingStoreMemoryEstimate();
+}
+
WKArrayRef WKRenderLayerGetNegativeZOrderList(WKRenderLayerRef renderLayerRef)
{
return toAPI(toImpl(renderLayerRef)->negativeZOrderList());
@@ -124,3 +129,8 @@ WKArrayRef WKRenderLayerGetPositiveZOrderList(WKRenderLayerRef renderLayerRef)
{
return toAPI(toImpl(renderLayerRef)->positiveZOrderList());
}
+
+WKRenderLayerRef WKRenderLayerGetFrameContentsLayer(WKRenderLayerRef renderLayerRef)
+{
+ return toAPI(toImpl(renderLayerRef)->frameContentsLayer());
+}
diff --git a/Source/WebKit2/Shared/API/c/WKRenderLayer.h b/Source/WebKit2/Shared/API/c/WKRenderLayer.h
index 72f28e0b9..7aeae7855 100644
--- a/Source/WebKit2/Shared/API/c/WKRenderLayer.h
+++ b/Source/WebKit2/Shared/API/c/WKRenderLayer.h
@@ -27,8 +27,8 @@
#define WKRenderLayer_h
-#include <WebKit2/WKBase.h>
-#include <WebKit2/WKGeometry.h>
+#include <WebKit/WKBase.h>
+#include <WebKit/WKGeometry.h>
#ifdef __cplusplus
extern "C" {
@@ -38,7 +38,7 @@ WK_EXPORT WKTypeID WKRenderLayerGetTypeID();
WK_EXPORT WKRenderObjectRef WKRenderLayerGetRenderer(WKRenderLayerRef renderLayer);
-// FIXME: Remove this function once Safari does not require it.
+// FIXME: Remove this function once Safari does not require it. Clients can access this data via the renderer.
WK_EXPORT WKStringRef WKRenderLayerCopyRendererName(WKRenderLayerRef renderLayer);
// FIXME: Remove these three functions once Safari does not require them.
@@ -62,11 +62,14 @@ enum WKCompositingLayerType {
typedef enum WKCompositingLayerType WKCompositingLayerType;
WK_EXPORT WKCompositingLayerType WKRenderLayerGetCompositingLayerType(WKRenderLayerRef renderLayer);
+WK_EXPORT double WKRenderLayerGetBackingStoreMemoryEstimate(WKRenderLayerRef renderLayer);
WK_EXPORT WKArrayRef WKRenderLayerGetNegativeZOrderList(WKRenderLayerRef renderLayer);
WK_EXPORT WKArrayRef WKRenderLayerGetNormalFlowList(WKRenderLayerRef renderLayer);
WK_EXPORT WKArrayRef WKRenderLayerGetPositiveZOrderList(WKRenderLayerRef renderLayer);
+WK_EXPORT WKRenderLayerRef WKRenderLayerGetFrameContentsLayer(WKRenderLayerRef renderLayer);
+
#ifdef __cplusplus
}
#endif
diff --git a/Source/WebKit2/Shared/API/c/WKRenderObject.cpp b/Source/WebKit2/Shared/API/c/WKRenderObject.cpp
index 864b6e7ad..df2e743dd 100644
--- a/Source/WebKit2/Shared/API/c/WKRenderObject.cpp
+++ b/Source/WebKit2/Shared/API/c/WKRenderObject.cpp
@@ -42,13 +42,27 @@ WKStringRef WKRenderObjectCopyName(WKRenderObjectRef renderObjectRef)
return toCopiedAPI(toImpl(renderObjectRef)->name());
}
+WKStringRef WKRenderObjectCopyTextSnippet(WKRenderObjectRef renderObjectRef)
+{
+ WebRenderObject* renderObject = toImpl(renderObjectRef);
+ if (!renderObject->textSnippet().isNull())
+ return toCopiedAPI(renderObject->textSnippet());
+
+ return nullptr;
+}
+
+unsigned WKRenderObjectGetTextLength(WKRenderObjectRef renderObjectRef)
+{
+ return toImpl(renderObjectRef)->textLength();
+}
+
WKStringRef WKRenderObjectCopyElementTagName(WKRenderObjectRef renderObjectRef)
{
WebRenderObject* renderObject = toImpl(renderObjectRef);
if (!renderObject->elementTagName().isNull())
return toCopiedAPI(renderObject->elementTagName());
- return 0;
+ return nullptr;
}
WKStringRef WKRenderObjectCopyElementID(WKRenderObjectRef renderObjectRef)
@@ -57,7 +71,7 @@ WKStringRef WKRenderObjectCopyElementID(WKRenderObjectRef renderObjectRef)
if (!renderObject->elementID().isNull())
return toCopiedAPI(renderObject->elementID());
- return 0;
+ return nullptr;
}
WKArrayRef WKRenderObjectGetElementClassNames(WKRenderObjectRef renderObjectRef)
diff --git a/Source/WebKit2/Shared/API/c/WKRenderObject.h b/Source/WebKit2/Shared/API/c/WKRenderObject.h
index 965cf2a96..0973ae8cf 100644
--- a/Source/WebKit2/Shared/API/c/WKRenderObject.h
+++ b/Source/WebKit2/Shared/API/c/WKRenderObject.h
@@ -26,8 +26,8 @@
#ifndef WKRenderObject_h
#define WKRenderObject_h
-#include <WebKit2/WKBase.h>
-#include <WebKit2/WKGeometry.h>
+#include <WebKit/WKBase.h>
+#include <WebKit/WKGeometry.h>
#ifdef __cplusplus
extern "C" {
@@ -36,7 +36,8 @@ extern "C" {
WK_EXPORT WKTypeID WKRenderObjectGetTypeID();
WK_EXPORT WKStringRef WKRenderObjectCopyName(WKRenderObjectRef renderObject);
-
+WK_EXPORT WKStringRef WKRenderObjectCopyTextSnippet(WKRenderObjectRef renderObject);
+WK_EXPORT unsigned WKRenderObjectGetTextLength(WKRenderObjectRef renderObject);
WK_EXPORT WKStringRef WKRenderObjectCopyElementTagName(WKRenderObjectRef renderObject);
WK_EXPORT WKStringRef WKRenderObjectCopyElementID(WKRenderObjectRef renderObject);
WK_EXPORT WKArrayRef WKRenderObjectGetElementClassNames(WKRenderObjectRef renderObject);
diff --git a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.cpp
index f7291065f..d1160740c 100644
--- a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp
+++ b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.cpp
@@ -24,59 +24,61 @@
*/
#include "config.h"
-#include "WKSecurityOrigin.h"
+#include "WKSecurityOriginRef.h"
+#include "APISecurityOrigin.h"
#include "WKAPICast.h"
-#include "WebSecurityOrigin.h"
+#include <WebCore/SecurityOriginData.h>
using namespace WebKit;
WKTypeID WKSecurityOriginGetTypeID()
{
- return toAPI(WebSecurityOrigin::APIType);
+ return toAPI(API::SecurityOrigin::APIType);
}
WKSecurityOriginRef WKSecurityOriginCreateFromString(WKStringRef string)
{
- RefPtr<WebSecurityOrigin> securityOrigin = WebSecurityOrigin::createFromString(toImpl(string)->string());
- return toAPI(securityOrigin.release().leakRef());
+ return toAPI(API::SecurityOrigin::create(WebCore::SecurityOrigin::createFromString(toImpl(string)->string())).leakRef());
}
WKSecurityOriginRef WKSecurityOriginCreateFromDatabaseIdentifier(WKStringRef identifier)
{
- RefPtr<WebSecurityOrigin> securityOrigin = WebSecurityOrigin::createFromDatabaseIdentifier(toImpl(identifier)->string());
- return toAPI(securityOrigin.release().leakRef());
+ auto origin = WebCore::SecurityOriginData::fromDatabaseIdentifier(toImpl(identifier)->string());
+ if (!origin)
+ return nullptr;
+ return toAPI(API::SecurityOrigin::create(origin.value().securityOrigin()).leakRef());
}
WKSecurityOriginRef WKSecurityOriginCreate(WKStringRef protocol, WKStringRef host, int port)
{
- RefPtr<WebSecurityOrigin> securityOrigin = WebSecurityOrigin::create(toImpl(protocol)->string(), toImpl(host)->string(), port);
- return toAPI(securityOrigin.release().leakRef());
+ auto securityOrigin = API::SecurityOrigin::create(toImpl(protocol)->string(), toImpl(host)->string(), port);
+ return toAPI(securityOrigin.leakRef());
}
WKStringRef WKSecurityOriginCopyDatabaseIdentifier(WKSecurityOriginRef securityOrigin)
{
- return toCopiedAPI(toImpl(securityOrigin)->databaseIdentifier());
+ return toCopiedAPI(WebCore::SecurityOriginData::fromSecurityOrigin(toImpl(securityOrigin)->securityOrigin()).databaseIdentifier());
}
WKStringRef WKSecurityOriginCopyToString(WKSecurityOriginRef securityOrigin)
{
- return toCopiedAPI(toImpl(securityOrigin)->toString());
+ return toCopiedAPI(toImpl(securityOrigin)->securityOrigin().toString());
}
WKStringRef WKSecurityOriginCopyProtocol(WKSecurityOriginRef securityOrigin)
{
- return toCopiedAPI(toImpl(securityOrigin)->protocol());
+ return toCopiedAPI(toImpl(securityOrigin)->securityOrigin().protocol());
}
WKStringRef WKSecurityOriginCopyHost(WKSecurityOriginRef securityOrigin)
{
- return toCopiedAPI(toImpl(securityOrigin)->host());
+ return toCopiedAPI(toImpl(securityOrigin)->securityOrigin().host());
}
unsigned short WKSecurityOriginGetPort(WKSecurityOriginRef securityOrigin)
{
- return toImpl(securityOrigin)->port();
+ return toImpl(securityOrigin)->securityOrigin().port().value_or(0);
}
// For backwards ABI compatibility.
diff --git a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.h b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.h
index d932e93a4..3c3356b38 100644
--- a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.h
+++ b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.h
@@ -23,10 +23,10 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WKSecurityOrigin_h
-#define WKSecurityOrigin_h
+#ifndef WKSecurityOriginRef_h
+#define WKSecurityOriginRef_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
@@ -48,4 +48,4 @@ WK_EXPORT unsigned short WKSecurityOriginGetPort(WKSecurityOriginRef securityOri
}
#endif
-#endif /* WKSecurityOrigin_h */
+#endif /* WKSecurityOriginRef_h */
diff --git a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp
index f45c388e9..862fd7f60 100644
--- a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp
+++ b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp
@@ -27,26 +27,26 @@
#include "WKSerializedScriptValue.h"
#include "WKSerializedScriptValuePrivate.h"
+#include "APISerializedScriptValue.h"
#include "WKAPICast.h"
-#include "WebSerializedScriptValue.h"
using namespace WebKit;
WKTypeID WKSerializedScriptValueGetTypeID()
{
- return toAPI(WebSerializedScriptValue::APIType);
+ return toAPI(API::SerializedScriptValue::APIType);
}
WKSerializedScriptValueRef WKSerializedScriptValueCreate(JSContextRef context, JSValueRef value, JSValueRef* exception)
{
- RefPtr<WebSerializedScriptValue> serializedValue = WebSerializedScriptValue::create(context, value, exception);
- return toAPI(serializedValue.release().leakRef());
+ auto serializedValue = API::SerializedScriptValue::create(context, value, exception);
+ return toAPI(serializedValue.leakRef());
}
WKSerializedScriptValueRef WKSerializedScriptValueCreateWithInternalRepresentation(void* internalRepresentation)
{
- RefPtr<WebSerializedScriptValue> serializedValue = WebSerializedScriptValue::create(static_cast<WebCore::SerializedScriptValue*>(internalRepresentation));
- return toAPI(serializedValue.release().leakRef());
+ auto serializedValue = API::SerializedScriptValue::create(static_cast<WebCore::SerializedScriptValue*>(internalRepresentation));
+ return toAPI(&serializedValue.leakRef());
}
JSValueRef WKSerializedScriptValueDeserialize(WKSerializedScriptValueRef scriptValueRef, JSContextRef contextRef, JSValueRef* exception)
diff --git a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h
index 3f73d7a06..625afe05b 100644
--- a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h
+++ b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h
@@ -27,7 +27,7 @@
#define WKSerializedScriptValue_h
#include <JavaScriptCore/JavaScript.h>
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h b/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h
index 27e184906..837067fb7 100644
--- a/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h
+++ b/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h
@@ -26,7 +26,7 @@
#ifndef WKSerializedScriptValuePrivate_h
#define WKSerializedScriptValuePrivate_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKSharedAPICast.h b/Source/WebKit2/Shared/API/c/WKSharedAPICast.h
index 8439dbca4..864baff16 100644
--- a/Source/WebKit2/Shared/API/c/WKSharedAPICast.h
+++ b/Source/WebKit2/Shared/API/c/WKSharedAPICast.h
@@ -28,7 +28,7 @@
#include "APIError.h"
#include "APINumber.h"
-#include "APISession.h"
+#include "APISecurityOrigin.h"
#include "APIString.h"
#include "APIURL.h"
#include "APIURLRequest.h"
@@ -37,6 +37,7 @@
#include "SameDocumentNavigationType.h"
#include "WKBase.h"
#include "WKContextMenuItemTypes.h"
+#include "WKDiagnosticLoggingResultType.h"
#include "WKEvent.h"
#include "WKFindOptions.h"
#include "WKGeometry.h"
@@ -48,8 +49,8 @@
#include "WKUserScriptInjectionTime.h"
#include "WebEvent.h"
#include "WebFindOptions.h"
-#include "WebSecurityOrigin.h"
#include <WebCore/ContextMenuItem.h>
+#include <WebCore/DiagnosticLoggingResultType.h>
#include <WebCore/FloatRect.h>
#include <WebCore/FrameLoaderTypes.h>
#include <WebCore/IntRect.h>
@@ -61,34 +62,32 @@
namespace API {
class Array;
+class Dictionary;
class Data;
class Point;
class Rect;
+class SecurityOrigin;
+class SerializedScriptValue;
class Size;
+class UserContentURLPattern;
+class WebArchive;
+class WebArchiveResource;
}
namespace WebKit {
-class ImmutableDictionary;
-class MutableDictionary;
class ObjCObjectGraph;
-class WebArchive;
-class WebArchiveResource;
class WebCertificateInfo;
class WebConnection;
class WebContextMenuItem;
-class WebGraphicsContext;
class WebImage;
-class WebSecurityOrigin;
-class WebSerializedScriptValue;
-class WebUserContentURLPattern;
-template<typename APIType> struct APITypeInfo { };
-template<typename ImplType> struct ImplTypeInfo { };
+template<typename APIType> struct APITypeInfo;
+template<typename ImplType> struct ImplTypeInfo;
#define WK_ADD_API_MAPPING(TheAPIType, TheImplType) \
- template<> struct APITypeInfo<TheAPIType> { typedef TheImplType* ImplType; }; \
- template<> struct ImplTypeInfo<TheImplType*> { typedef TheAPIType APIType; };
+ template<> struct APITypeInfo<TheAPIType> { typedef TheImplType ImplType; }; \
+ template<> struct ImplTypeInfo<TheImplType> { typedef TheAPIType APIType; };
WK_ADD_API_MAPPING(WKArrayRef, API::Array)
WK_ADD_API_MAPPING(WKBooleanRef, API::Boolean)
@@ -96,16 +95,14 @@ WK_ADD_API_MAPPING(WKCertificateInfoRef, WebCertificateInfo)
WK_ADD_API_MAPPING(WKConnectionRef, WebConnection)
WK_ADD_API_MAPPING(WKContextMenuItemRef, WebContextMenuItem)
WK_ADD_API_MAPPING(WKDataRef, API::Data)
-WK_ADD_API_MAPPING(WKDictionaryRef, ImmutableDictionary)
+WK_ADD_API_MAPPING(WKDictionaryRef, API::Dictionary)
WK_ADD_API_MAPPING(WKDoubleRef, API::Double)
WK_ADD_API_MAPPING(WKErrorRef, API::Error)
-WK_ADD_API_MAPPING(WKGraphicsContextRef, WebGraphicsContext)
WK_ADD_API_MAPPING(WKImageRef, WebImage)
-WK_ADD_API_MAPPING(WKMutableDictionaryRef, MutableDictionary)
WK_ADD_API_MAPPING(WKPointRef, API::Point)
WK_ADD_API_MAPPING(WKRectRef, API::Rect)
-WK_ADD_API_MAPPING(WKSecurityOriginRef, WebSecurityOrigin)
-WK_ADD_API_MAPPING(WKSerializedScriptValueRef, WebSerializedScriptValue)
+WK_ADD_API_MAPPING(WKSecurityOriginRef, API::SecurityOrigin)
+WK_ADD_API_MAPPING(WKSerializedScriptValueRef, API::SerializedScriptValue)
WK_ADD_API_MAPPING(WKSizeRef, API::Size)
WK_ADD_API_MAPPING(WKStringRef, API::String)
WK_ADD_API_MAPPING(WKTypeRef, API::Object)
@@ -113,24 +110,30 @@ WK_ADD_API_MAPPING(WKUInt64Ref, API::UInt64)
WK_ADD_API_MAPPING(WKURLRef, API::URL)
WK_ADD_API_MAPPING(WKURLRequestRef, API::URLRequest)
WK_ADD_API_MAPPING(WKURLResponseRef, API::URLResponse)
-WK_ADD_API_MAPPING(WKUserContentURLPatternRef, WebUserContentURLPattern)
-WK_ADD_API_MAPPING(WKSessionRef, API::Session)
+WK_ADD_API_MAPPING(WKUserContentURLPatternRef, API::UserContentURLPattern)
-template<> struct APITypeInfo<WKMutableArrayRef> { typedef API::Array* ImplType; };
+template<> struct APITypeInfo<WKMutableArrayRef> { typedef API::Array ImplType; };
+template<> struct APITypeInfo<WKMutableDictionaryRef> { typedef API::Dictionary ImplType; };
-#if PLATFORM(MAC)
-WK_ADD_API_MAPPING(WKWebArchiveRef, WebArchive)
-WK_ADD_API_MAPPING(WKWebArchiveResourceRef, WebArchiveResource)
+#if PLATFORM(COCOA)
+WK_ADD_API_MAPPING(WKWebArchiveRef, API::WebArchive)
+WK_ADD_API_MAPPING(WKWebArchiveResourceRef, API::WebArchiveResource)
WK_ADD_API_MAPPING(WKObjCTypeWrapperRef, ObjCObjectGraph)
#endif
-template<typename T>
-inline typename ImplTypeInfo<T>::APIType toAPI(T t)
+template<typename T, typename APIType = typename ImplTypeInfo<T>::APIType>
+auto toAPI(T* t) -> APIType
+{
+ return reinterpret_cast<APIType>(API::Object::wrap(t));
+}
+
+template<typename T, typename ImplType = typename APITypeInfo<T>::ImplType>
+auto toImpl(T t) -> ImplType*
{
- return reinterpret_cast<typename ImplTypeInfo<T>::APIType>(t);
+ return static_cast<ImplType*>(API::Object::unwrap(static_cast<void*>(const_cast<typename std::remove_const<typename std::remove_pointer<T>::type>::type*>(t))));
}
-template<typename ImplType, typename APIType = typename ImplTypeInfo<ImplType*>::APIType>
+template<typename ImplType, typename APIType = typename ImplTypeInfo<ImplType>::APIType>
class ProxyingRefPtr {
public:
ProxyingRefPtr(PassRefPtr<ImplType> impl)
@@ -138,26 +141,17 @@ public:
{
}
+ ProxyingRefPtr(Ref<ImplType>&& impl)
+ : m_impl(WTFMove(impl))
+ {
+ }
+
operator APIType() { return toAPI(m_impl.get()); }
private:
RefPtr<ImplType> m_impl;
};
-/* Opaque typing convenience methods */
-
-template<typename T>
-inline typename APITypeInfo<T>::ImplType toImpl(T t)
-{
- // An example of the conversions that take place:
- // const struct OpaqueWKArray* -> const struct OpaqueWKArray -> struct OpaqueWKArray -> struct OpaqueWKArray* -> API::Array*
-
- typedef typename std::remove_pointer<T>::type PotentiallyConstValueType;
- typedef typename std::remove_const<PotentiallyConstValueType>::type NonConstValueType;
-
- return reinterpret_cast<typename APITypeInfo<T>::ImplType>(const_cast<NonConstValueType*>(t));
-}
-
/* Special cases. */
inline ProxyingRefPtr<API::String> toAPI(StringImpl* string)
@@ -167,23 +161,21 @@ inline ProxyingRefPtr<API::String> toAPI(StringImpl* string)
inline WKStringRef toCopiedAPI(const String& string)
{
- RefPtr<API::String> apiString = API::String::create(string);
- return toAPI(apiString.release().leakRef());
+ return toAPI(&API::String::create(string).leakRef());
}
inline ProxyingRefPtr<API::URL> toURLRef(StringImpl* string)
{
if (!string)
- return ProxyingRefPtr<API::URL>(0);
+ return ProxyingRefPtr<API::URL>(nullptr);
return ProxyingRefPtr<API::URL>(API::URL::create(String(string)));
}
inline WKURLRef toCopiedURLAPI(const String& string)
{
if (!string)
- return 0;
- RefPtr<API::URL> url = API::URL::create(string);
- return toAPI(url.release().leakRef());
+ return nullptr;
+ return toAPI(&API::URL::create(string).leakRef());
}
inline String toWTFString(WKStringRef stringRef)
@@ -219,7 +211,7 @@ inline WKSecurityOriginRef toCopiedAPI(WebCore::SecurityOrigin* origin)
{
if (!origin)
return 0;
- return toAPI(WebSecurityOrigin::create(origin).leakRef());
+ return toAPI(API::SecurityOrigin::create(*origin).leakRef());
}
/* Geometry conversions */
@@ -300,6 +292,8 @@ inline WKEventModifiers toAPI(WebEvent::Modifiers modifiers)
wkModifiers |= kWKEventModifiersAltKey;
if (modifiers & WebEvent::MetaKey)
wkModifiers |= kWKEventModifiersMetaKey;
+ if (modifiers & WebEvent::CapsLockKey)
+ wkModifiers |= kWKEventModifiersCapsLockKey;
return wkModifiers;
}
@@ -342,7 +336,7 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action)
return kWKContextMenuItemTagDownloadImageToDisk;
case WebCore::ContextMenuItemTagCopyImageToClipboard:
return kWKContextMenuItemTagCopyImageToClipboard;
-#if PLATFORM(EFL) || PLATFORM(GTK)
+#if PLATFORM(GTK)
case WebCore::ContextMenuItemTagCopyImageUrlToClipboard:
return kWKContextMenuItemTagCopyImageUrlToClipboard;
#endif
@@ -362,7 +356,7 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action)
return kWKContextMenuItemTagCut;
case WebCore::ContextMenuItemTagPaste:
return kWKContextMenuItemTagPaste;
-#if PLATFORM(EFL) || PLATFORM(GTK)
+#if PLATFORM(GTK)
case WebCore::ContextMenuItemTagSelectAll:
return kWKContextMenuItemTagSelectAll;
#endif
@@ -452,10 +446,8 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action)
return kWKContextMenuItemTagPDFFacingPagesScrolling;
case WebCore::ContextMenuItemTagDictationAlternative:
return kWKContextMenuItemTagDictationAlternative;
-#if ENABLE(INSPECTOR)
case WebCore::ContextMenuItemTagInspectElement:
return kWKContextMenuItemTagInspectElement;
-#endif
case WebCore::ContextMenuItemTagTextDirectionMenu:
return kWKContextMenuItemTagTextDirectionMenu;
case WebCore::ContextMenuItemTagTextDirectionDefault:
@@ -478,11 +470,13 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action)
return kWKContextMenuItemTagToggleVideoFullscreen;
case WebCore::ContextMenuItemTagEnterVideoFullscreen:
return kWKContextMenuItemTagEnterVideoFullscreen;
+ case WebCore::ContextMenuItemTagToggleVideoEnhancedFullscreen:
+ return kWKContextMenuItemTagToggleVideoEnhancedFullscreen;
case WebCore::ContextMenuItemTagMediaPlayPause:
return kWKContextMenuItemTagMediaPlayPause;
case WebCore::ContextMenuItemTagMediaMute:
return kWKContextMenuItemTagMediaMute;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
case WebCore::ContextMenuItemTagCorrectSpellingAutomatically:
return kWKContextMenuItemTagCorrectSpellingAutomatically;
case WebCore::ContextMenuItemTagSubstitutionsMenu:
@@ -510,11 +504,11 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action)
case WebCore::ContextMenuItemTagChangeBack:
return kWKContextMenuItemTagChangeBack;
#endif
- case WebCore::ContextMenuItemTagOpenLinkInThisWindow:
- return kWKContextMenuItemTagOpenLinkInThisWindow;
+ case WebCore::ContextMenuItemTagShareMenu:
+ return kWKContextMenuItemTagShareMenu;
default:
- if (action < WebCore::ContextMenuItemBaseApplicationTag)
- LOG_ERROR("ContextMenuAction %i is an unknown tag but is below the allowable custom tag value of %i", action, WebCore:: ContextMenuItemBaseApplicationTag);
+ if (action < WebCore::ContextMenuItemBaseApplicationTag && !(action >= WebCore::ContextMenuItemBaseCustomTag && action <= WebCore::ContextMenuItemLastCustomTag))
+ LOG_ERROR("ContextMenuAction %i is an unknown tag but is below the allowable custom tag value of %i", action, WebCore::ContextMenuItemBaseApplicationTag);
return static_cast<WKContextMenuItemTag>(action);
}
}
@@ -537,7 +531,7 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag)
case kWKContextMenuItemTagCopyImageToClipboard:
return WebCore::ContextMenuItemTagCopyImageToClipboard;
case kWKContextMenuItemTagOpenFrameInNewWindow:
-#if PLATFORM(EFL) || PLATFORM(GTK)
+#if PLATFORM(GTK)
case kWKContextMenuItemTagCopyImageUrlToClipboard:
return WebCore::ContextMenuItemTagCopyImageUrlToClipboard;
#endif
@@ -556,7 +550,7 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag)
return WebCore::ContextMenuItemTagCut;
case kWKContextMenuItemTagPaste:
return WebCore::ContextMenuItemTagPaste;
-#if PLATFORM(EFL) || PLATFORM(GTK)
+#if PLATFORM(GTK)
case kWKContextMenuItemTagSelectAll:
return WebCore::ContextMenuItemTagSelectAll;
#endif
@@ -646,10 +640,8 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag)
return WebCore::ContextMenuItemTagPDFFacingPagesScrolling;
case kWKContextMenuItemTagDictationAlternative:
return WebCore::ContextMenuItemTagDictationAlternative;
-#if ENABLE(INSPECTOR)
case kWKContextMenuItemTagInspectElement:
return WebCore::ContextMenuItemTagInspectElement;
-#endif
case kWKContextMenuItemTagTextDirectionMenu:
return WebCore::ContextMenuItemTagTextDirectionMenu;
case kWKContextMenuItemTagTextDirectionDefault:
@@ -672,11 +664,13 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag)
return WebCore::ContextMenuItemTagToggleVideoFullscreen;
case kWKContextMenuItemTagEnterVideoFullscreen:
return WebCore::ContextMenuItemTagEnterVideoFullscreen;
+ case kWKContextMenuItemTagToggleVideoEnhancedFullscreen:
+ return WebCore::ContextMenuItemTagToggleVideoEnhancedFullscreen;
case kWKContextMenuItemTagMediaPlayPause:
return WebCore::ContextMenuItemTagMediaPlayPause;
case kWKContextMenuItemTagMediaMute:
return WebCore::ContextMenuItemTagMediaMute;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
case kWKContextMenuItemTagCorrectSpellingAutomatically:
return WebCore::ContextMenuItemTagCorrectSpellingAutomatically;
case kWKContextMenuItemTagSubstitutionsMenu:
@@ -703,11 +697,12 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag)
return WebCore::ContextMenuItemTagCapitalize;
case kWKContextMenuItemTagChangeBack:
return WebCore::ContextMenuItemTagChangeBack;
+ case kWKContextMenuItemTagShareMenu:
+ return WebCore::ContextMenuItemTagShareMenu;
#endif
case kWKContextMenuItemTagOpenLinkInThisWindow:
- return WebCore::ContextMenuItemTagOpenLinkInThisWindow;
default:
- if (tag < kWKContextMenuItemBaseApplicationTag)
+ if (tag < kWKContextMenuItemBaseApplicationTag && !(tag >= WebCore::ContextMenuItemBaseCustomTag && tag <= WebCore::ContextMenuItemLastCustomTag))
LOG_ERROR("WKContextMenuItemTag %i is an unknown tag but is below the allowable custom tag value of %i", tag, kWKContextMenuItemBaseApplicationTag);
return static_cast<WebCore::ContextMenuAction>(tag);
}
@@ -759,22 +754,22 @@ inline WKFrameNavigationType toAPI(WebCore::NavigationType type)
WKFrameNavigationType wkType = kWKFrameNavigationTypeOther;
switch (type) {
- case WebCore::NavigationTypeLinkClicked:
+ case WebCore::NavigationType::LinkClicked:
wkType = kWKFrameNavigationTypeLinkClicked;
break;
- case WebCore::NavigationTypeFormSubmitted:
+ case WebCore::NavigationType::FormSubmitted:
wkType = kWKFrameNavigationTypeFormSubmitted;
break;
- case WebCore::NavigationTypeBackForward:
+ case WebCore::NavigationType::BackForward:
wkType = kWKFrameNavigationTypeBackForward;
break;
- case WebCore::NavigationTypeReload:
+ case WebCore::NavigationType::Reload:
wkType = kWKFrameNavigationTypeReload;
break;
- case WebCore::NavigationTypeFormResubmitted:
+ case WebCore::NavigationType::FormResubmitted:
wkType = kWKFrameNavigationTypeFormResubmitted;
break;
- case WebCore::NavigationTypeOther:
+ case WebCore::NavigationType::Other:
wkType = kWKFrameNavigationTypeOther;
break;
}
@@ -804,6 +799,66 @@ inline WKSameDocumentNavigationType toAPI(SameDocumentNavigationType type)
return wkType;
}
+inline SameDocumentNavigationType toSameDocumentNavigationType(WKSameDocumentNavigationType wkType)
+{
+ SameDocumentNavigationType type = SameDocumentNavigationAnchorNavigation;
+
+ switch (wkType) {
+ case kWKSameDocumentNavigationAnchorNavigation:
+ type = SameDocumentNavigationAnchorNavigation;
+ break;
+ case kWKSameDocumentNavigationSessionStatePush:
+ type = SameDocumentNavigationSessionStatePush;
+ break;
+ case kWKSameDocumentNavigationSessionStateReplace:
+ type = SameDocumentNavigationSessionStateReplace;
+ break;
+ case kWKSameDocumentNavigationSessionStatePop:
+ type = SameDocumentNavigationSessionStatePop;
+ break;
+ }
+
+ return type;
+}
+
+inline WKDiagnosticLoggingResultType toAPI(WebCore::DiagnosticLoggingResultType type)
+{
+ WKDiagnosticLoggingResultType wkType;
+
+ switch (type) {
+ case WebCore::DiagnosticLoggingResultPass:
+ wkType = kWKDiagnosticLoggingResultPass;
+ break;
+ case WebCore::DiagnosticLoggingResultFail:
+ wkType = kWKDiagnosticLoggingResultFail;
+ break;
+ case WebCore::DiagnosticLoggingResultNoop:
+ wkType = kWKDiagnosticLoggingResultNoop;
+ break;
+ }
+
+ return wkType;
+}
+
+inline WebCore::DiagnosticLoggingResultType toDiagnosticLoggingResultType(WKDiagnosticLoggingResultType wkType)
+{
+ WebCore::DiagnosticLoggingResultType type;
+
+ switch (wkType) {
+ case kWKDiagnosticLoggingResultPass:
+ type = WebCore::DiagnosticLoggingResultPass;
+ break;
+ case kWKDiagnosticLoggingResultFail:
+ type = WebCore::DiagnosticLoggingResultFail;
+ break;
+ case kWKDiagnosticLoggingResultNoop:
+ type = WebCore::DiagnosticLoggingResultNoop;
+ break;
+ }
+
+ return type;
+}
+
inline WKLayoutMilestones toWKLayoutMilestones(WebCore::LayoutMilestones milestones)
{
unsigned wkMilestones = 0;
@@ -848,15 +903,15 @@ inline WebCore::PageVisibilityState toPageVisibilityState(WKPageVisibilityState
{
switch (wkPageVisibilityState) {
case kWKPageVisibilityStateVisible:
- return WebCore::PageVisibilityStateVisible;
+ return WebCore::PageVisibilityState::Visible;
case kWKPageVisibilityStateHidden:
- return WebCore::PageVisibilityStateHidden;
+ return WebCore::PageVisibilityState::Hidden;
case kWKPageVisibilityStatePrerender:
- return WebCore::PageVisibilityStatePrerender;
+ return WebCore::PageVisibilityState::Prerender;
}
ASSERT_NOT_REACHED();
- return WebCore::PageVisibilityStateVisible;
+ return WebCore::PageVisibilityState::Visible;
}
inline ImageOptions toImageOptions(WKImageOptions wkImageOptions)
@@ -891,11 +946,17 @@ inline SnapshotOptions toSnapshotOptions(WKSnapshotOptions wkSnapshotOptions)
snapshotOptions |= SnapshotOptionsInViewCoordinates;
if (wkSnapshotOptions & kWKSnapshotOptionsPaintSelectionRectangle)
snapshotOptions |= SnapshotOptionsPaintSelectionRectangle;
+ if (wkSnapshotOptions & kWKSnapshotOptionsForceBlackText)
+ snapshotOptions |= SnapshotOptionsForceBlackText;
+ if (wkSnapshotOptions & kWKSnapshotOptionsForceWhiteText)
+ snapshotOptions |= SnapshotOptionsForceWhiteText;
+ if (wkSnapshotOptions & kWKSnapshotOptionsPrinting)
+ snapshotOptions |= SnapshotOptionsPrinting;
return snapshotOptions;
}
-inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(WKUserScriptInjectionTime wkInjectedTime)
+inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(_WKUserScriptInjectionTime wkInjectedTime)
{
switch (wkInjectedTime) {
case kWKInjectAtDocumentStart:
@@ -908,6 +969,19 @@ inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(WKUserScriptIn
return WebCore::InjectAtDocumentStart;
}
+inline _WKUserScriptInjectionTime toWKUserScriptInjectionTime(WebCore::UserScriptInjectionTime injectedTime)
+{
+ switch (injectedTime) {
+ case WebCore::InjectAtDocumentStart:
+ return kWKInjectAtDocumentStart;
+ case WebCore::InjectAtDocumentEnd:
+ return kWKInjectAtDocumentEnd;
+ }
+
+ ASSERT_NOT_REACHED();
+ return kWKInjectAtDocumentStart;
+}
+
inline WebCore::UserContentInjectedFrames toUserContentInjectedFrames(WKUserContentInjectedFrames wkInjectedFrames)
{
switch (wkInjectedFrames) {
diff --git a/Source/WebKit2/Shared/API/c/WKString.cpp b/Source/WebKit2/Shared/API/c/WKString.cpp
index 5f13b9ca7..650367045 100644
--- a/Source/WebKit2/Shared/API/c/WKString.cpp
+++ b/Source/WebKit2/Shared/API/c/WKString.cpp
@@ -28,6 +28,9 @@
#include "WKStringPrivate.h"
#include "WKAPICast.h"
+#include <JavaScriptCore/InitializeThreading.h>
+#include <JavaScriptCore/JSStringRef.h>
+#include <JavaScriptCore/OpaqueJSString.h>
using namespace WebKit;
@@ -38,58 +41,101 @@ WKTypeID WKStringGetTypeID()
WKStringRef WKStringCreateWithUTF8CString(const char* string)
{
- RefPtr<API::String> apiString = API::String::createFromUTF8String(string);
- return toAPI(apiString.release().leakRef());
+ return toAPI(&API::String::create(WTF::String::fromUTF8(string)).leakRef());
}
bool WKStringIsEmpty(WKStringRef stringRef)
{
- return toImpl(stringRef)->isEmpty();
+ return toImpl(stringRef)->stringView().isEmpty();
}
size_t WKStringGetLength(WKStringRef stringRef)
{
- return toImpl(stringRef)->length();
+ return toImpl(stringRef)->stringView().length();
}
size_t WKStringGetCharacters(WKStringRef stringRef, WKChar* buffer, size_t bufferLength)
{
- COMPILE_ASSERT(sizeof(WKChar) == sizeof(UChar), WKStringGetCharacters_sizeof_WKChar_matches_UChar);
- return (toImpl(stringRef)->getCharacters(static_cast<UChar*>(buffer), bufferLength));
+ static_assert(sizeof(WKChar) == sizeof(UChar), "Size of WKChar must match size of UChar");
+
+ unsigned unsignedBufferLength = std::min<size_t>(bufferLength, std::numeric_limits<unsigned>::max());
+ auto substring = toImpl(stringRef)->stringView().substring(0, unsignedBufferLength);
+
+ substring.getCharactersWithUpconvert(reinterpret_cast<UChar*>(buffer));
+ return substring.length();
}
size_t WKStringGetMaximumUTF8CStringSize(WKStringRef stringRef)
{
- return toImpl(stringRef)->maximumUTF8CStringSize();
+ return toImpl(stringRef)->stringView().length() * 3 + 1;
+}
+
+enum StrictType { NonStrict = false, Strict = true };
+
+template <StrictType strict>
+size_t WKStringGetUTF8CStringImpl(WKStringRef stringRef, char* buffer, size_t bufferSize)
+{
+ if (!bufferSize)
+ return 0;
+
+ auto stringView = toImpl(stringRef)->stringView();
+
+ char* p = buffer;
+ WTF::Unicode::ConversionResult result;
+
+ if (stringView.is8Bit()) {
+ const LChar* characters = stringView.characters8();
+ result = WTF::Unicode::convertLatin1ToUTF8(&characters, characters + stringView.length(), &p, p + bufferSize - 1);
+ } else {
+ const UChar* characters = stringView.characters16();
+ result = WTF::Unicode::convertUTF16ToUTF8(&characters, characters + stringView.length(), &p, p + bufferSize - 1, strict);
+ }
+
+ if (result != WTF::Unicode::conversionOK && result != WTF::Unicode::targetExhausted)
+ return 0;
+
+ *p++ = '\0';
+ return p - buffer;
}
size_t WKStringGetUTF8CString(WKStringRef stringRef, char* buffer, size_t bufferSize)
{
- return toImpl(stringRef)->getUTF8CString(buffer, bufferSize);
+ return WKStringGetUTF8CStringImpl<StrictType::Strict>(stringRef, buffer, bufferSize);
+}
+
+size_t WKStringGetUTF8CStringNonStrict(WKStringRef stringRef, char* buffer, size_t bufferSize)
+{
+ return WKStringGetUTF8CStringImpl<StrictType::NonStrict>(stringRef, buffer, bufferSize);
}
bool WKStringIsEqual(WKStringRef aRef, WKStringRef bRef)
{
- return toImpl(aRef)->equal(toImpl(bRef));
+ return toImpl(aRef)->stringView() == toImpl(bRef)->stringView();
}
bool WKStringIsEqualToUTF8CString(WKStringRef aRef, const char* b)
{
- return toImpl(aRef)->equalToUTF8String(b);
+ // FIXME: Should we add a fast path that avoids memory allocation when the string is all ASCII?
+ // FIXME: We can do even the general case more efficiently if we write a function in StringView that understands UTF-8 C strings.
+ return toImpl(aRef)->stringView() == WTF::String::fromUTF8(b);
}
bool WKStringIsEqualToUTF8CStringIgnoringCase(WKStringRef aRef, const char* b)
{
- return toImpl(aRef)->equalToUTF8StringIgnoringCase(b);
+ // FIXME: Should we add a fast path that avoids memory allocation when the string is all ASCII?
+ // FIXME: We can do even the general case more efficiently if we write a function in StringView that understands UTF-8 C strings.
+ return equalIgnoringASCIICase(toImpl(aRef)->stringView(), WTF::String::fromUTF8(b));
}
WKStringRef WKStringCreateWithJSString(JSStringRef jsStringRef)
{
- RefPtr<API::String> apiString = API::String::create(jsStringRef);
- return toAPI(apiString.release().leakRef());
+ auto apiString = jsStringRef ? API::String::create(jsStringRef->string()) : API::String::createNull();
+
+ return toAPI(&apiString.leakRef());
}
JSStringRef WKStringCopyJSString(WKStringRef stringRef)
{
- return toImpl(stringRef)->createJSString();
+ JSC::initializeThreading();
+ return OpaqueJSString::create(toImpl(stringRef)->string()).leakRef();
}
diff --git a/Source/WebKit2/Shared/API/c/WKString.h b/Source/WebKit2/Shared/API/c/WKString.h
index dd5b877a7..4c6a20422 100644
--- a/Source/WebKit2/Shared/API/c/WKString.h
+++ b/Source/WebKit2/Shared/API/c/WKString.h
@@ -26,7 +26,7 @@
#ifndef WKString_h
#define WKString_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#include <stddef.h>
#ifndef __cplusplus
@@ -55,6 +55,7 @@ WK_EXPORT size_t WKStringGetCharacters(WKStringRef string, WKChar* buffer, size_
WK_EXPORT size_t WKStringGetMaximumUTF8CStringSize(WKStringRef string);
WK_EXPORT size_t WKStringGetUTF8CString(WKStringRef string, char* buffer, size_t bufferSize);
+WK_EXPORT size_t WKStringGetUTF8CStringNonStrict(WKStringRef string, char* buffer, size_t bufferSize);
WK_EXPORT bool WKStringIsEqual(WKStringRef a, WKStringRef b);
WK_EXPORT bool WKStringIsEqualToUTF8CString(WKStringRef a, const char* b);
diff --git a/Source/WebKit2/Shared/API/c/WKStringPrivate.h b/Source/WebKit2/Shared/API/c/WKStringPrivate.h
index f174f0166..74bc8a1f0 100644
--- a/Source/WebKit2/Shared/API/c/WKStringPrivate.h
+++ b/Source/WebKit2/Shared/API/c/WKStringPrivate.h
@@ -27,7 +27,7 @@
#define WKStringPrivate_h
#include <JavaScriptCore/JavaScript.h>
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKType.cpp b/Source/WebKit2/Shared/API/c/WKType.cpp
index bb165e4dd..fd20e6fff 100644
--- a/Source/WebKit2/Shared/API/c/WKType.cpp
+++ b/Source/WebKit2/Shared/API/c/WKType.cpp
@@ -33,16 +33,17 @@ using namespace WebKit;
WKTypeID WKGetTypeID(WKTypeRef typeRef)
{
- return toAPI(static_cast<API::Object*>(const_cast<void*>(typeRef))->type());
+ return toAPI(toImpl(typeRef)->type());
}
WKTypeRef WKRetain(WKTypeRef typeRef)
{
- static_cast<API::Object*>(const_cast<void*>(typeRef))->ref();
+ toImpl(typeRef)->ref();
+
return typeRef;
}
void WKRelease(WKTypeRef typeRef)
{
- static_cast<API::Object*>(const_cast<void*>(typeRef))->deref();
+ toImpl(typeRef)->deref();
}
diff --git a/Source/WebKit2/Shared/API/c/WKType.h b/Source/WebKit2/Shared/API/c/WKType.h
index 02f036c6f..e57ea379c 100644
--- a/Source/WebKit2/Shared/API/c/WKType.h
+++ b/Source/WebKit2/Shared/API/c/WKType.h
@@ -26,7 +26,7 @@
#ifndef WKType_h
#define WKType_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKURL.cpp b/Source/WebKit2/Shared/API/c/WKURL.cpp
index 80bbb10df..f1a1ea546 100644
--- a/Source/WebKit2/Shared/API/c/WKURL.cpp
+++ b/Source/WebKit2/Shared/API/c/WKURL.cpp
@@ -37,12 +37,12 @@ WKTypeID WKURLGetTypeID()
WKURLRef WKURLCreateWithUTF8CString(const char* string)
{
- return toAPI(API::URL::create(String::fromUTF8(string)).leakRef());
+ return toAPI(&API::URL::create(String::fromUTF8(string)).leakRef());
}
WKURLRef WKURLCreateWithBaseURL(WKURLRef baseURL, const char* relative)
{
- return toAPI(API::URL::create(toImpl(baseURL), String::fromUTF8(relative)).leakRef());
+ return toAPI(&API::URL::create(toImpl(baseURL), String::fromUTF8(relative)).leakRef());
}
WKStringRef WKURLCopyString(WKURLRef url)
@@ -52,7 +52,7 @@ WKStringRef WKURLCopyString(WKURLRef url)
bool WKURLIsEqual(WKURLRef a, WKURLRef b)
{
- return toImpl(a)->string() == toImpl(b)->string();
+ return API::URL::equals(*toImpl(a), *toImpl(b));
}
WKStringRef WKURLCopyHostName(WKURLRef url)
diff --git a/Source/WebKit2/Shared/API/c/WKURL.h b/Source/WebKit2/Shared/API/c/WKURL.h
index 2c0a02cc4..6bbc2b392 100644
--- a/Source/WebKit2/Shared/API/c/WKURL.h
+++ b/Source/WebKit2/Shared/API/c/WKURL.h
@@ -26,7 +26,7 @@
#ifndef WKURL_h
#define WKURL_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKURLRequest.cpp b/Source/WebKit2/Shared/API/c/WKURLRequest.cpp
index edbf219dc..736e1f3e6 100644
--- a/Source/WebKit2/Shared/API/c/WKURLRequest.cpp
+++ b/Source/WebKit2/Shared/API/c/WKURLRequest.cpp
@@ -28,6 +28,7 @@
#include "APIURLRequest.h"
#include "WKAPICast.h"
+#include "WKData.h"
#include <WebCore/URL.h>
using namespace WebCore;
@@ -40,7 +41,7 @@ WKTypeID WKURLRequestGetTypeID()
WKURLRequestRef WKURLRequestCreateWithWKURL(WKURLRef url)
{
- return toAPI(API::URLRequest::create(URL(URL(), toImpl(url)->string())).leakRef());
+ return toAPI(&API::URLRequest::create(URL(URL(), toImpl(url)->string())).leakRef());
}
WKURLRef WKURLRequestCopyURL(WKURLRequestRef requestRef)
@@ -58,6 +59,13 @@ WKStringRef WKURLRequestCopyHTTPMethod(WKURLRequestRef requestRef)
return toCopiedAPI(toImpl(requestRef)->resourceRequest().httpMethod());
}
+WKURLRequestRef WKURLRequestCopySettingHTTPBody(WKURLRequestRef requestRef, WKDataRef body)
+{
+ WebCore::ResourceRequest requestCopy(toImpl(requestRef)->resourceRequest());
+ requestCopy.setHTTPBody(FormData::create(WKDataGetBytes(body), WKDataGetSize(body)));
+ return toAPI(&API::URLRequest::create(requestCopy).leakRef());
+}
+
void WKURLRequestSetDefaultTimeoutInterval(double timeoutInterval)
{
API::URLRequest::setDefaultTimeoutInterval(timeoutInterval);
diff --git a/Source/WebKit2/Shared/API/c/WKURLRequest.h b/Source/WebKit2/Shared/API/c/WKURLRequest.h
index 85df3d389..174180423 100644
--- a/Source/WebKit2/Shared/API/c/WKURLRequest.h
+++ b/Source/WebKit2/Shared/API/c/WKURLRequest.h
@@ -26,7 +26,7 @@
#ifndef WKURLRequest_h
#define WKURLRequest_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
@@ -42,6 +42,8 @@ WK_EXPORT WKURLRef WKURLRequestCopyFirstPartyForCookies(WKURLRequestRef);
WK_EXPORT WKStringRef WKURLRequestCopyHTTPMethod(WKURLRequestRef);
+WK_EXPORT WKURLRequestRef WKURLRequestCopySettingHTTPBody(WKURLRequestRef, WKDataRef);
+
WK_EXPORT void WKURLRequestSetDefaultTimeoutInterval(double);
#ifdef __cplusplus
diff --git a/Source/WebKit2/Shared/API/c/WKURLResponse.h b/Source/WebKit2/Shared/API/c/WKURLResponse.h
index d56027ae9..9093b7791 100644
--- a/Source/WebKit2/Shared/API/c/WKURLResponse.h
+++ b/Source/WebKit2/Shared/API/c/WKURLResponse.h
@@ -26,7 +26,7 @@
#ifndef WKURLResponse_h
#define WKURLResponse_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp
index f6a204ab6..ceedc7696 100644
--- a/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp
+++ b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp
@@ -26,21 +26,20 @@
#include "config.h"
#include "WKUserContentURLPattern.h"
+#include "APIUserContentURLPattern.h"
#include "WKAPICast.h"
#include "WKString.h"
-#include "WebUserContentURLPattern.h"
using namespace WebKit;
WKTypeID WKUserContentURLPatternGetTypeID()
{
- return toAPI(WebUserContentURLPattern::APIType);
+ return toAPI(API::UserContentURLPattern::APIType);
}
WKUserContentURLPatternRef WKUserContentURLPatternCreate(WKStringRef patternRef)
{
- RefPtr<WebUserContentURLPattern> userContentURLPattern = WebUserContentURLPattern::create(toImpl(patternRef)->string());
- return toAPI(userContentURLPattern.release().leakRef());
+ return toAPI(&API::UserContentURLPattern::create(toImpl(patternRef)->string()).leakRef());
}
WKStringRef WKUserContentURLPatternCopyHost(WKUserContentURLPatternRef urlPatternRef)
diff --git a/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h
index 6e4c6c132..407729663 100644
--- a/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h
+++ b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h
@@ -27,7 +27,7 @@
#define WKUserContentURLPattern_h
#include <JavaScriptCore/JavaScript.h>
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
#ifdef __cplusplus
extern "C" {
diff --git a/Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h b/Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h
index f4d38b2c1..45d241072 100644
--- a/Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h
+++ b/Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h
@@ -26,10 +26,10 @@
#ifndef WKUserScriptInjectionTime_h
#define WKUserScriptInjectionTime_h
-enum WKUserScriptInjectionTime {
+enum _WKUserScriptInjectionTime {
kWKInjectAtDocumentStart,
kWKInjectAtDocumentEnd
};
-typedef enum WKUserScriptInjectionTime WKUserScriptInjectionTime;
+typedef enum _WKUserScriptInjectionTime _WKUserScriptInjectionTime;
#endif /* WKUserScriptInjectionTime_h */
diff --git a/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp b/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp
index afb49932b..bb2485f6a 100644
--- a/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp
+++ b/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp
@@ -39,14 +39,14 @@ using namespace WebCore;
cairo_surface_t* WKImageCreateCairoSurface(WKImageRef imageRef)
{
// We cannot pass a RefPtr through the API here, so we just leak the reference.
- return toImpl(imageRef)->bitmap()->createCairoSurface().leakRef();
+ return toImpl(imageRef)->bitmap().createCairoSurface().leakRef();
}
WKImageRef WKImageCreateFromCairoSurface(cairo_surface_t* surface, WKImageOptions options)
{
IntSize imageSize(cairo_image_surface_get_width(surface), cairo_image_surface_get_height(surface));
- RefPtr<WebImage> webImage = WebImage::create(imageSize, toImageOptions(options));
- auto graphicsContext = webImage->bitmap()->createGraphicsContext();
+ auto webImage = WebImage::create(imageSize, toImageOptions(options));
+ auto graphicsContext = webImage->bitmap().createGraphicsContext();
cairo_t* cr = graphicsContext->platformContext()->cr();
cairo_set_source_surface(cr, surface, 0, 0);
@@ -54,5 +54,5 @@ WKImageRef WKImageCreateFromCairoSurface(cairo_surface_t* surface, WKImageOption
cairo_rectangle(cr, 0, 0, imageSize.width(), imageSize.height());
cairo_fill(cr);
- return toAPI(webImage.release().leakRef());
+ return toAPI(webImage.leakRef());
}
diff --git a/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h b/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h
index 5c1e5413f..06749f6a2 100644
--- a/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h
+++ b/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h
@@ -27,8 +27,8 @@
#ifndef WKImageCairo_h
#define WKImageCairo_h
-#include <WebKit2/WKBase.h>
-#include <WebKit2/WKImage.h>
+#include <WebKit/WKBase.h>
+#include <WebKit/WKImage.h>
typedef struct _cairo_surface cairo_surface_t;