diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2016-08-25 19:20:41 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2017-02-02 12:30:55 +0000 |
commit | 6882a04fb36642862b11efe514251d32070c3d65 (patch) | |
tree | b7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebKit2/Shared/API | |
parent | ab6df191029eeeb0b0f16f127d553265659f739e (diff) | |
download | qtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz |
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebKit2/Shared/API')
112 files changed, 2945 insertions, 1607 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..3b6d34302 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIArray.h @@ -0,0 +1,97 @@ +/* + * 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())) + ); + } + + +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/c/mac/WKObjCTypeWrapperRef.h b/Source/WebKit2/Shared/API/APIData.cpp index 7cf79624c..57bf8c741 100644 --- a/Source/WebKit2/Shared/API/c/mac/WKObjCTypeWrapperRef.h +++ b/Source/WebKit2/Shared/API/APIData.cpp @@ -23,23 +23,27 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKObjCTypeWrapperRef_h -#define WKObjCTypeWrapperRef_h +#include "config.h" +#include "APIData.h" -#include <Foundation/Foundation.h> -#include <WebKit2/WKBase.h> +#include "ArgumentDecoder.h" +#include "ArgumentEncoder.h" -#ifdef __cplusplus -extern "C" { -#endif +namespace API { -WK_EXPORT WKTypeID WKObjCTypeWrapperGetTypeID(); - -WK_EXPORT WKObjCTypeWrapperRef WKObjCTypeWrapperCreate(id object); -WK_EXPORT id WKObjCTypeWrapperGetObject(WKObjCTypeWrapperRef wrapper); +void Data::encode(IPC::ArgumentEncoder& encoder) const +{ + encoder << dataReference(); +} -#ifdef __cplusplus +bool Data::decode(IPC::ArgumentDecoder& decoder, RefPtr<API::Object>& result) +{ + IPC::DataReference dataReference; + if (!decoder.decode(dataReference)) + return false; + + result = create(dataReference.data(), dataReference.size()); + return true; } -#endif -#endif /* WKObjCTypeWrapperRef_h */ +} // namespace API diff --git a/Source/WebKit2/Shared/API/APIData.h b/Source/WebKit2/Shared/API/APIData.h new file mode 100644 index 000000000..f5035244d --- /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 ArgumentDecoder; +class ArgumentEncoder; +} + +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::ArgumentEncoder&) const; + static bool decode(IPC::ArgumentDecoder&, 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/c/cg/WKImageCG.cpp b/Source/WebKit2/Shared/API/APIDictionary.cpp index 1071ef592..894e98dd1 100644 --- a/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp +++ b/Source/WebKit2/Shared/API/APIDictionary.cpp @@ -24,39 +24,61 @@ */ #include "config.h" -#include "WKImageCG.h" +#include "APIDictionary.h" -#include "ShareableBitmap.h" -#include "WKSharedAPICast.h" -#include "WebImage.h" -#include <WebCore/ColorSpace.h> -#include <WebCore/GraphicsContext.h> +#include "APIArray.h" +#include "APIString.h" -using namespace WebKit; -using namespace WebCore; +namespace API { -CGImageRef WKImageCreateCGImage(WKImageRef imageRef) +Ref<Dictionary> Dictionary::create() { - WebImage* webImage = toImpl(imageRef); - if (!webImage->bitmap()) - return 0; + return create({ }); +} + +Ref<Dictionary> Dictionary::create(MapType map) +{ + return adoptRef(*new Dictionary(WTFMove(map))); +} + +Dictionary::Dictionary(MapType map) + : m_map(WTFMove(map)) +{ +} + +Dictionary::~Dictionary() +{ +} - return webImage->bitmap()->makeCGImageCopy().leakRef(); +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; } -WKImageRef WKImageCreateFromCGImage(CGImageRef imageRef, WKImageOptions options) +bool Dictionary::set(const WTF::String& key, PassRefPtr<API::Object> item) { - if (!imageRef) - return 0; - - IntSize imageSize(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)); - RefPtr<WebImage> webImage = WebImage::create(imageSize, toImageOptions(options)); - if (!webImage->bitmap()) - return 0; + MapType::AddResult result = m_map.set(key, item); + return result.isNewEntry; +} - OwnPtr<GraphicsContext> graphicsContext = webImage->bitmap()->createGraphicsContext(); - FloatRect rect(FloatPoint(0, 0), imageSize); - graphicsContext->clearRect(rect); - graphicsContext->drawNativeImage(imageRef, imageSize, WebCore::ColorSpaceDeviceRGB, rect, rect); - return toAPI(webImage.release().leakRef()); +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/c/cf/WKURLRequestCF.cpp b/Source/WebKit2/Shared/API/APIError.cpp index 22a9b763c..86a1db0b0 100644 --- a/Source/WebKit2/Shared/API/c/cf/WKURLRequestCF.cpp +++ b/Source/WebKit2/Shared/API/APIError.cpp @@ -24,21 +24,33 @@ */ #include "config.h" -#include "WKURLRequestCF.h" +#include "APIError.h" -#include "WKAPICast.h" -#include "WebURLRequest.h" +#include "WebCoreArgumentCoders.h" +#include <wtf/NeverDestroyed.h> +#include <wtf/text/WTFString.h> -using namespace WebKit; +namespace API { -WKURLRequestRef WKURLRequestCreateWithCFURLRequest(CFURLRequestRef urlRequest) +const WTF::String& Error::webKitErrorDomain() { - CFURLRequestRef copiedURLRequest = CFURLRequestCreateCopy(kCFAllocatorDefault, urlRequest); - RefPtr<WebURLRequest> request = WebURLRequest::create(copiedURLRequest); - return toAPI(request.release().leakRef()); + static NeverDestroyed<WTF::String> webKitErrorDomainString(ASCIILiteral("WebKitErrorDomain")); + return webKitErrorDomainString; } -CFURLRequestRef WKURLRequestCopyCFURLRequest(CFAllocatorRef alloc, WKURLRequestRef urlRequest) +void Error::encode(IPC::ArgumentEncoder& encoder) const { - return CFURLRequestCreateCopy(alloc, toImpl(urlRequest)->platformRequest()); + encoder << platformError(); } + +bool Error::decode(IPC::ArgumentDecoder& 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/c/cairo/WKImageCairo.cpp b/Source/WebKit2/Shared/API/APIError.h index 703d86901..c29e95ff3 100644 --- a/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp +++ b/Source/WebKit2/Shared/API/APIError.h @@ -1,6 +1,5 @@ /* * Copyright (C) 2010 Apple Inc. All rights reserved. - * Copyright (C) 2011 Igalia S.L. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -24,35 +23,56 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include "config.h" -#include "WKImageCairo.h" +#ifndef APIError_h +#define APIError_h -#include "ShareableBitmap.h" -#include "WKSharedAPICast.h" -#include "WebImage.h" -#include <WebCore/GraphicsContext.h> -#include <WebCore/PlatformContextCairo.h> +#include "APIObject.h" +#include <WebCore/ResourceError.h> -using namespace WebKit; -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(); +namespace IPC { +class ArgumentDecoder; +class ArgumentEncoder; } -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)); - OwnPtr<GraphicsContext> graphicsContext = webImage->bitmap()->createGraphicsContext(); +namespace API { - cairo_t* cr = graphicsContext->platformContext()->cr(); - cairo_set_source_surface(cr, surface, 0, 0); - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - cairo_rectangle(cr, 0, 0, imageSize.width(), imageSize.height()); - cairo_fill(cr); +class Error : public ObjectImpl<Object::Type::Error> { +public: + static Ref<Error> create() + { + return adoptRef(*new Error); + } - return toAPI(webImage.release().leakRef()); -} + 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::ArgumentEncoder&) const; + static bool decode(IPC::ArgumentDecoder&, 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..4f3860baf --- /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 "ArgumentDecoder.h" +#include "ArgumentEncoder.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::ArgumentEncoder& encoder) const +{ + encoder << m_frameID; + encoder << m_isAutoconverting; +} + +bool FrameHandle::decode(IPC::ArgumentDecoder& 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/c/mac/WKObjCTypeWrapperRef.mm b/Source/WebKit2/Shared/API/APIFrameHandle.h index ee0125ba1..f40d33727 100644 --- a/Source/WebKit2/Shared/API/c/mac/WKObjCTypeWrapperRef.mm +++ b/Source/WebKit2/Shared/API/APIFrameHandle.h @@ -23,26 +23,38 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#import "config.h" -#import "WKObjCTypeWrapperRef.h" +#ifndef APIFrameHandle_h +#define APIFrameHandle_h -#import "ObjCObjectGraph.h" -#import "WKSharedAPICast.h" +#include "APIObject.h" +#include <wtf/Ref.h> -using namespace WebKit; - -WKTypeID WKObjCTypeWrapperGetTypeID() -{ - return toAPI(ObjCObjectGraph::APIType); +namespace IPC { +class ArgumentDecoder; +class ArgumentEncoder; } -WKObjCTypeWrapperRef WKObjCTypeWrapperCreate(id object) -{ - RefPtr<ObjCObjectGraph> objectWrapper = ObjCObjectGraph::create(object); - return toAPI(objectWrapper.release().leakRef()); -} +namespace API { -id WKObjCTypeWrapperGetObject(WKObjCTypeWrapperRef wrapperRef) -{ - return toImpl(wrapperRef)->rootObject(); -} +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::ArgumentEncoder&) const; + static bool decode(IPC::ArgumentDecoder&, 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..c59827b18 --- /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 "ArgumentDecoder.h" +#include "ArgumentEncoder.h" + +namespace API { + +void Point::encode(IPC::ArgumentEncoder& encoder) const +{ + encoder << m_point.x; + encoder << m_point.y; +} + +bool Point::decode(IPC::ArgumentDecoder& 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::ArgumentEncoder& encoder) const +{ + encoder << m_size.width; + encoder << m_size.height; +} + +bool Size::decode(IPC::ArgumentDecoder& 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::ArgumentEncoder& 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::ArgumentDecoder& 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..12221983b --- /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 ArgumentDecoder; +class ArgumentEncoder; +} + +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::ArgumentEncoder&) const; + static bool decode(IPC::ArgumentDecoder&, 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::ArgumentEncoder&) const; + static bool decode(IPC::ArgumentDecoder&, 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::ArgumentEncoder&) const; + static bool decode(IPC::ArgumentDecoder&, 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..d3c7fd0b7 --- /dev/null +++ b/Source/WebKit2/Shared/API/APINumber.h @@ -0,0 +1,76 @@ +/* + * 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 "ArgumentDecoder.h" +#include "ArgumentEncoder.h" +#include <wtf/PassRefPtr.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::ArgumentEncoder& encoder) const + { + encoder << m_value; + } + + static bool decode(IPC::ArgumentDecoder& 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..676c583f4 --- /dev/null +++ b/Source/WebKit2/Shared/API/APIObject.h @@ -0,0 +1,279 @@ +/* + * 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 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, + BatteryManager, + BatteryStatus, + CacheManager, + ColorPickerResultListener, + CookieManager, + Download, + 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, + RunBeforeUnloadConfirmPanelResultListener, + RunJavaScriptAlertResultListener, + RunJavaScriptConfirmResultListener, + RunJavaScriptPromptResultListener, + Session, + TextChecker, + UserContentController, + UserContentExtension, + UserContentExtensionStore, + UserMediaPermissionCheck, + UserMediaPermissionRequest, + Vibration, + ViewportAttributes, + VisitedLinkStore, + WebsiteDataRecord, + WebsiteDataStore, + 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 +#if PLATFORM(EFL) + PopupMenuItem, +#if ENABLE(TOUCH_EVENTS) + TouchPoint, + TouchEvent, +#endif +#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() + { + } + + virtual 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/c/cf/WKURLResponseCF.cpp b/Source/WebKit2/Shared/API/APIPageGroupHandle.cpp index ea33e9c3d..5e9f21802 100644 --- a/Source/WebKit2/Shared/API/c/cf/WKURLResponseCF.cpp +++ b/Source/WebKit2/Shared/API/APIPageGroupHandle.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * 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 @@ -24,31 +24,40 @@ */ #include "config.h" -#include "WKURLResponseCF.h" +#include "APIPageGroupHandle.h" -#include "WKAPICast.h" -#include "WebURLResponse.h" +#include "ArgumentDecoder.h" +#include "ArgumentEncoder.h" -using namespace WebKit; +namespace API { -WKURLResponseRef WKURLResponseCreateWithCFURLResponse(CFURLResponseRef urlResponse) +Ref<PageGroupHandle> PageGroupHandle::create(WebKit::WebPageGroupData&& webPageGroupData) { - if (!urlResponse) - return 0; + return adoptRef(*new PageGroupHandle(WTFMove(webPageGroupData))); +} - CFURLResponseRef copiedURLResponse = CFURLResponseCreateCopy(kCFAllocatorDefault, urlResponse); - RefPtr<WebURLResponse> response = WebURLResponse::create(copiedURLResponse); - return toAPI(response.release().leakRef()); +PageGroupHandle::PageGroupHandle(WebKit::WebPageGroupData&& webPageGroupData) + : m_webPageGroupData(WTFMove(webPageGroupData)) +{ } -CFURLResponseRef WKURLResponseCopyCFURLResponse(CFAllocatorRef alloc, WKURLResponseRef urlResponse) +PageGroupHandle::~PageGroupHandle() { - if (!urlResponse) - return 0; +} - PlatformResponse platformURLResponse = toImpl(urlResponse)->platformResponse(); - if (!platformURLResponse) - return 0; +void PageGroupHandle::encode(IPC::ArgumentEncoder& encoder) const +{ + encoder << m_webPageGroupData; +} + +bool PageGroupHandle::decode(IPC::ArgumentDecoder& decoder, RefPtr<Object>& result) +{ + WebKit::WebPageGroupData webPageGroupData; + if (!decoder.decode(webPageGroupData)) + return false; + + result = create(WTFMove(webPageGroupData)); + return true; +} - return CFURLResponseCreateCopy(alloc, toImpl(urlResponse)->platformResponse()); } diff --git a/Source/WebKit2/Shared/API/APIPageGroupHandle.h b/Source/WebKit2/Shared/API/APIPageGroupHandle.h new file mode 100644 index 000000000..cedc17eac --- /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 ArgumentDecoder; +class ArgumentEncoder; +} + +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::ArgumentEncoder&) const; + static bool decode(IPC::ArgumentDecoder&, RefPtr<Object>&); + +private: + explicit PageGroupHandle(WebKit::WebPageGroupData&&); + + const WebKit::WebPageGroupData m_webPageGroupData; +}; + +} // namespace API + + +#endif // APIPageGroupHandle_h diff --git a/Source/WebKit2/Shared/API/c/mac/WKWebArchive.h b/Source/WebKit2/Shared/API/APIPageHandle.cpp index 757fba573..ffb01f449 100644 --- a/Source/WebKit2/Shared/API/c/mac/WKWebArchive.h +++ b/Source/WebKit2/Shared/API/APIPageHandle.cpp @@ -23,30 +23,52 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKWebArchive_h -#define WKWebArchive_h +#include "config.h" +#include "APIPageHandle.h" -#include <WebKit2/WKBase.h> +#include "ArgumentDecoder.h" +#include "ArgumentEncoder.h" -#include <stddef.h> +namespace API { -#ifdef __cplusplus -extern "C" { -#endif +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() +{ +} -WK_EXPORT WKTypeID WKWebArchiveGetTypeID(); +void PageHandle::encode(IPC::ArgumentEncoder& encoder) const +{ + encoder << m_pageID; + encoder << m_isAutoconverting; +} -WK_EXPORT WKWebArchiveRef WKWebArchiveCreate(WKWebArchiveResourceRef mainResource, WKArrayRef subresources, WKArrayRef subframeArchives); -WK_EXPORT WKWebArchiveRef WKWebArchiveCreateWithData(WKDataRef data); -WK_EXPORT WKWebArchiveRef WKWebArchiveCreateFromRange(WKBundleRangeHandleRef range); +bool PageHandle::decode(IPC::ArgumentDecoder& decoder, RefPtr<Object>& result) +{ + uint64_t pageID; + if (!decoder.decode(pageID)) + return false; -WK_EXPORT WKWebArchiveResourceRef WKWebArchiveCopyMainResource(WKWebArchiveRef webArchive); -WK_EXPORT WKArrayRef WKWebArchiveCopySubresources(WKWebArchiveRef webArchive); -WK_EXPORT WKArrayRef WKWebArchiveCopySubframeArchives(WKWebArchiveRef webArchive); -WK_EXPORT WKDataRef WKWebArchiveCopyData(WKWebArchiveRef webArchive); + bool isAutoconverting; + if (!decoder.decode(isAutoconverting)) + return false; -#ifdef __cplusplus + result = isAutoconverting ? createAutoconverting(pageID) : create(pageID); + return true; } -#endif -#endif // WKWebArchive_h +} // namespace API diff --git a/Source/WebKit2/Shared/API/c/mac/WKWebArchiveResource.h b/Source/WebKit2/Shared/API/APIPageHandle.h index 3e14c4ef5..a1d2c873d 100644 --- a/Source/WebKit2/Shared/API/c/mac/WKWebArchiveResource.h +++ b/Source/WebKit2/Shared/API/APIPageHandle.h @@ -23,28 +23,38 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKWebArchiveResource_h -#define WKWebArchiveResource_h +#ifndef APIPageHandle_h +#define APIPageHandle_h -#include <WebKit2/WKBase.h> +#include "APIObject.h" +#include <wtf/Ref.h> -#include <stddef.h> +namespace IPC { +class ArgumentDecoder; +class ArgumentEncoder; +} -#ifdef __cplusplus -extern "C" { -#endif +namespace API { -WK_EXPORT WKTypeID WKWebArchiveResourceGetTypeID(); +class PageHandle : public ObjectImpl<Object::Type::PageHandle> { +public: + static Ref<PageHandle> create(uint64_t pageID); + static Ref<PageHandle> createAutoconverting(uint64_t pageID); + virtual ~PageHandle(); -WK_EXPORT WKWebArchiveResourceRef WKWebArchiveResourceCreate(WKDataRef data, WKURLRef URL, WKStringRef MIMEType, WKStringRef textEncoding); + uint64_t pageID() const { return m_pageID; } + bool isAutoconverting() const { return m_isAutoconverting; } -WK_EXPORT WKDataRef WKWebArchiveResourceCopyData(WKWebArchiveResourceRef webArchiveResource); -WK_EXPORT WKURLRef WKWebArchiveResourceCopyURL(WKWebArchiveResourceRef webArchiveResource); -WK_EXPORT WKStringRef WKWebArchiveResourceCopyMIMEType(WKWebArchiveResourceRef webArchiveResource); -WK_EXPORT WKStringRef WKWebArchiveResourceCopyTextEncoding(WKWebArchiveResourceRef webArchiveResource); + void encode(IPC::ArgumentEncoder&) const; + static bool decode(IPC::ArgumentDecoder&, RefPtr<Object>&); -#ifdef __cplusplus -} -#endif +private: + explicit PageHandle(uint64_t pageID, bool isAutoconverting); + + const uint64_t m_pageID; + const bool m_isAutoconverting; +}; + +} // namespace API -#endif // WKWebArchiveResource_h +#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..077ac64c9 --- /dev/null +++ b/Source/WebKit2/Shared/API/APISecurityOrigin.h @@ -0,0 +1,70 @@ +/* + * 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 APISecurityOrigin_h +#define APISecurityOrigin_h + +#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, int 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; +}; + +} + +#endif 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..b4e7c8daa --- /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() : 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::ArgumentEncoder& encoder) const + { + encoder << m_string; + } + + static bool decode(IPC::ArgumentDecoder& 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/c/cf/WKStringCF.cpp b/Source/WebKit2/Shared/API/APIURLRequest.cpp index f5ab62908..23d535a70 100644 --- a/Source/WebKit2/Shared/API/c/cf/WKStringCF.cpp +++ b/Source/WebKit2/Shared/API/APIURLRequest.cpp @@ -24,27 +24,48 @@ */ #include "config.h" -#include "WKStringCF.h" +#include "APIURLRequest.h" -#include "WKAPICast.h" -#include <wtf/text/WTFString.h> +#include "WebCoreArgumentCoders.h" +#include "WebProcessPool.h" using namespace WebCore; using namespace WebKit; -WKStringRef WKStringCreateWithCFString(CFStringRef cfString) +namespace API { + +URLRequest::URLRequest(const ResourceRequest& request) + : m_request(request) +{ +} + +double URLRequest::defaultTimeoutInterval() { - String string(cfString); - return toCopiedAPI(string); + return ResourceRequest::defaultTimeoutInterval(); } -CFStringRef WKStringCopyCFString(CFAllocatorRef allocatorRef, WKStringRef stringRef) +// FIXME: This function should really be on WebProcessPool or WebPageProxy. +void URLRequest::setDefaultTimeoutInterval(double timeoutInterval) { - ASSERT(!toImpl(stringRef)->string().isNull()); + ResourceRequest::setDefaultTimeoutInterval(timeoutInterval); - // NOTE: This does not use StringImpl::createCFString() since that function - // expects to be called on the thread running WebCore. - if (toImpl(stringRef)->string().is8Bit()) - return CFStringCreateWithBytes(allocatorRef, reinterpret_cast<const UInt8*>(toImpl(stringRef)->string().characters8()), toImpl(stringRef)->string().length(), kCFStringEncodingISOLatin1, true); - return CFStringCreateWithCharacters(allocatorRef, reinterpret_cast<const UniChar*>(toImpl(stringRef)->string().characters16()), toImpl(stringRef)->string().length()); + for (auto* processPool : WebProcessPool::allProcessPools()) + processPool->setDefaultRequestTimeoutInterval(timeoutInterval); } + +void URLRequest::encode(IPC::ArgumentEncoder& encoder) const +{ + encoder << resourceRequest(); +} + +bool URLRequest::decode(IPC::ArgumentDecoder& 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..026cce39b --- /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 ArgumentDecoder; +class ArgumentEncoder; +} + +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::ArgumentEncoder&) const; + static bool decode(IPC::ArgumentDecoder&, RefPtr<Object>&); + +private: + explicit URLRequest(const WebCore::ResourceRequest&); + + WebCore::ResourceRequest m_request; +}; + +} // namespace API + +#endif // APIURLRequest_h diff --git a/Source/WebKit2/Shared/API/c/mac/WKURLResponseNS.mm b/Source/WebKit2/Shared/API/APIURLResponse.cpp index 9200dbb65..226d624cb 100644 --- a/Source/WebKit2/Shared/API/c/mac/WKURLResponseNS.mm +++ b/Source/WebKit2/Shared/API/APIURLResponse.cpp @@ -23,22 +23,33 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#import "config.h" -#import "WKURLResponseNS.h" +#include "config.h" +#include "APIURLResponse.h" -#import "WKAPICast.h" -#import "WebURLResponse.h" +#include "WebCoreArgumentCoders.h" -using namespace WebKit; +using namespace WebCore; -WKURLResponseRef WKURLResponseCreateWithNSURLResponse(NSURLResponse* urlResponse) +namespace API { + +URLResponse::URLResponse(const WebCore::ResourceResponse& response) + : m_response(response) { - RetainPtr<NSURLResponse> copiedURLResponse = adoptNS([urlResponse copy]); - RefPtr<WebURLResponse> response = WebURLResponse::create(copiedURLResponse.get()); - return toAPI(response.release().leakRef()); } -NSURLResponse* WKURLResponseCopyNSURLResponse(WKURLResponseRef urlResponse) +void URLResponse::encode(IPC::ArgumentEncoder& encoder) const { - return [toImpl(urlResponse)->platformResponse() copy]; + encoder << resourceResponse(); } + +bool URLResponse::decode(IPC::ArgumentDecoder& 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/c/cg/WKImageCG.h b/Source/WebKit2/Shared/API/APIURLResponse.h index 800b02eb6..db81b3f9c 100644 --- a/Source/WebKit2/Shared/API/c/cg/WKImageCG.h +++ b/Source/WebKit2/Shared/API/APIURLResponse.h @@ -23,23 +23,38 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKImageCG_h -#define WKImageCG_h +#ifndef APIURLResponse_h +#define APIURLResponse_h -#include <CoreGraphics/CGImage.h> -#include <WebKit2/WKBase.h> -#include <WebKit2/WKImage.h> +#include "APIObject.h" +#include <WebCore/ResourceResponse.h> +#include <wtf/Forward.h> -#ifdef __cplusplus -extern "C" { -#endif +namespace IPC { +class ArgumentDecoder; +class ArgumentEncoder; +} -WK_EXPORT CGImageRef WKImageCreateCGImage(WKImageRef image); +namespace API { -WK_EXPORT WKImageRef WKImageCreateFromCGImage(CGImageRef imageRef, WKImageOptions options); +class URLResponse : public ObjectImpl<Object::Type::URLResponse> { +public: + static Ref<URLResponse> create(const WebCore::ResourceResponse& response) + { + return adoptRef(*new URLResponse(response)); + } -#ifdef __cplusplus -} -#endif + const WebCore::ResourceResponse& resourceResponse() const { return m_response; } + + void encode(IPC::ArgumentEncoder&) const; + static bool decode(IPC::ArgumentDecoder&, RefPtr<Object>&); + +private: + explicit URLResponse(const WebCore::ResourceResponse&); + + WebCore::ResourceResponse m_response; +}; + +} // namespace API -#endif /* WKImageCG_h */ +#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/WKGraphicsContext.h b/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h index c9d0a522f..7ab00f53a 100644 --- a/Source/WebKit2/Shared/API/c/WKGraphicsContext.h +++ b/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * 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 @@ -23,19 +23,37 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKGraphicsContext_h -#define WKGraphicsContext_h +#ifndef WKActionMenuItemTypes_h +#define WKActionMenuItemTypes_h -#include <WebKit2/WKBase.h> +#include <stdint.h> #ifdef __cplusplus extern "C" { #endif -WK_EXPORT WKTypeID WKGraphicsContextGetTypeID(); +// 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 /* WKGraphicsContext_h */ +#endif /* WKActionMenuItemTypes_h */ diff --git a/Source/WebKit2/Shared/API/c/cf/WKStringCF.h b/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h index f94685386..4769c390d 100644 --- a/Source/WebKit2/Shared/API/c/cf/WKStringCF.h +++ b/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * 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 @@ -23,21 +23,33 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKStringCF_h -#define WKStringCF_h +#ifndef WKActionMenuTypes_h +#define WKActionMenuTypes_h -#include <CoreFoundation/CoreFoundation.h> -#include <WebKit2/WKBase.h> +#include <stdint.h> #ifdef __cplusplus extern "C" { #endif -WK_EXPORT WKStringRef WKStringCreateWithCFString(CFStringRef string); -WK_EXPORT CFStringRef WKStringCopyCFString(CFAllocatorRef alloc, WKStringRef string); +// 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 /* WKStringCF_h */ +#endif /* WKActionMenuTypes_h */ diff --git a/Source/WebKit2/Shared/API/c/WKArray.cpp b/Source/WebKit2/Shared/API/c/WKArray.cpp index 5bf35e3c3..844161124 100644 --- a/Source/WebKit2/Shared/API/c/WKArray.cpp +++ b/Source/WebKit2/Shared/API/c/WKArray.cpp @@ -26,31 +26,41 @@ #include "config.h" #include "WKArray.h" -#include "ImmutableArray.h" +#include "APIArray.h" #include "WKAPICast.h" using namespace WebKit; WKTypeID WKArrayGetTypeID() { - return toAPI(ImmutableArray::APIType); + return toAPI(API::Array::APIType); } WKArrayRef WKArrayCreate(WKTypeRef* values, size_t numberOfValues) { - RefPtr<ImmutableArray> array = ImmutableArray::create(reinterpret_cast<APIObject**>(const_cast<void**>(values)), numberOfValues); - return toAPI(array.release().leakRef()); + Vector<RefPtr<API::Object>> elements; + elements.reserveInitialCapacity(numberOfValues); + + for (size_t i = 0; i < numberOfValues; ++i) + elements.uncheckedAppend(toImpl(values[i])); + + return toAPI(&API::Array::create(WTFMove(elements)).leakRef()); } WKArrayRef WKArrayCreateAdoptingValues(WKTypeRef* values, size_t numberOfValues) { - RefPtr<ImmutableArray> array = ImmutableArray::adopt(reinterpret_cast<APIObject**>(const_cast<void**>(values)), numberOfValues); - return toAPI(array.release().leakRef()); + Vector<RefPtr<API::Object>> elements; + elements.reserveInitialCapacity(numberOfValues); + + for (size_t i = 0; i < numberOfValues; ++i) + elements.uncheckedAppend(adoptRef(toImpl(values[i]))); + + 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 ea8e2f1ba..6a88d0be1 100644 --- a/Source/WebKit2/Shared/API/c/WKBase.h +++ b/Source/WebKit2/Shared/API/c/WKBase.h @@ -27,22 +27,23 @@ #ifndef WKBase_h #define WKBase_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> +#if defined(USE_SOUP) +#include <WebKit/WKBaseSoup.h> #endif #if defined(BUILDING_EFL__) -#include <WebKit2/WKBaseEfl.h> +#include <WebKit/WKBaseEfl.h> #endif -#if defined(__APPLE__) && !defined(BUILDING_QT__) -#include <WebKit2/WKBaseMac.h> +#if defined(__APPLE__) && !defined(BUILDING_GTK__) && !defined(BUILDING_QT__) +#include <WebKit/WKBaseMac.h> #endif /* WebKit2 shared types */ @@ -81,18 +82,6 @@ typedef const struct OpaqueWKUserContentURLPattern* WKUserContentURLPatternRef; typedef const struct OpaqueWKWebArchive* WKWebArchiveRef; typedef const struct OpaqueWKWebArchiveResource* WKWebArchiveResourceRef; -enum WKUserContentInjectedFrames { - kWKInjectInAllFrames, - kWKInjectInTopFrameOnly -}; -typedef enum WKUserContentInjectedFrames WKUserContentInjectedFrames; - -enum WKUserScriptInjectionTime { - kWKInjectAtDocumentStart, - kWKInjectAtDocumentEnd -}; -typedef enum WKUserScriptInjectionTime WKUserScriptInjectionTime; - /* WebKit2 main API types */ typedef const struct OpaqueWKApplicationCacheManager* WKApplicationCacheManagerRef; @@ -105,11 +94,12 @@ 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 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 OpaqueWKFrameInfo* WKFrameInfoRef; typedef const struct OpaqueWKFrame* WKFrameRef; typedef const struct OpaqueWKFramePolicyListener* WKFramePolicyListenerRef; typedef const struct OpaqueWKGeolocationManager* WKGeolocationManagerRef; @@ -120,10 +110,12 @@ 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; @@ -131,13 +123,28 @@ typedef const struct OpaqueWKNotificationProvider* WKNotificationProviderRef; typedef const struct OpaqueWKOpenPanelParameters* WKOpenPanelParametersRef; typedef const struct OpaqueWKOpenPanelResultListener* WKOpenPanelResultListenerRef; 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 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 OpaqueWKWindowFeatures* WKWindowFeaturesRef; /* WebKit2 Bundle types */ @@ -146,6 +153,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; @@ -158,31 +166,4 @@ typedef const struct OpaqueWKBundlePageOverlay* WKBundlePageOverlayRef; typedef const struct OpaqueWKBundleRangeHandle* WKBundleRangeHandleRef; typedef const struct OpaqueWKBundleScriptWorld* WKBundleScriptWorldRef; -#undef WK_EXPORT -#if defined(WK_NO_EXPORT) -#define WK_EXPORT -#elif defined(__GNUC__) && !defined(__CC_ARM) && !defined(__ARMCC__) -#define WK_EXPORT __attribute__((visibility("default"))) -#elif defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE) || defined(__CC_ARM) || defined(__ARMCC__) -#if BUILDING_WEBKIT -#define WK_EXPORT __declspec(dllexport) -#else -#define WK_EXPORT __declspec(dllimport) -#endif -#else /* !defined(WK_NO_EXPORT) */ -#define WK_EXPORT -#endif /* defined(WK_NO_EXPORT) */ - -#if !defined(WK_INLINE) -#if defined(__cplusplus) -#define WK_INLINE static inline -#elif defined(__GNUC__) -#define WK_INLINE static __inline__ -#elif defined(__WIN32__) -#define WK_INLINE static __inline -#else -#define WK_INLINE static -#endif -#endif /* !defined(WK_INLINE) */ - #endif /* WKBase_h */ 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.cpp b/Source/WebKit2/Shared/API/c/WKConnectionRef.cpp index 6c4700f59..9fa7042c2 100644 --- a/Source/WebKit2/Shared/API/c/WKConnectionRef.cpp +++ b/Source/WebKit2/Shared/API/c/WKConnectionRef.cpp @@ -36,7 +36,7 @@ WKTypeID WKConnectionGetTypeID() return toAPI(WebConnection::APIType); } -void WKConnectionSetConnectionClient(WKConnectionRef connectionRef, const WKConnectionClient* wkClient) +void WKConnectionSetConnectionClient(WKConnectionRef connectionRef, const WKConnectionClientBase* wkClient) { toImpl(connectionRef)->initializeConnectionClient(wkClient); } diff --git a/Source/WebKit2/Shared/API/c/WKConnectionRef.h b/Source/WebKit2/Shared/API/c/WKConnectionRef.h index f6baea734..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" { @@ -35,19 +35,22 @@ extern "C" { typedef void (*WKConnectionDidReceiveMessageCallback)(WKConnectionRef connection, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo); typedef void (*WKConnectionDidCloseCallback)(WKConnectionRef connection, const void* clientInfo); -struct WKConnectionClient { +typedef struct WKConnectionClientBase { int version; const void * clientInfo; +} WKConnectionClientBase; + +typedef struct WKConnectionClientV0 { + WKConnectionClientBase base; + + // Version 0. WKConnectionDidReceiveMessageCallback didReceiveMessage; WKConnectionDidCloseCallback didClose; -}; -typedef struct WKConnectionClient WKConnectionClient; - -enum { WKConnectionClientCurrentVersion = 0 }; +} WKConnectionClientV0; WK_EXPORT WKTypeID WKConnectionGetTypeID(); -WK_EXPORT void WKConnectionSetConnectionClient(WKConnectionRef connection, const WKConnectionClient* client); +WK_EXPORT void WKConnectionSetConnectionClient(WKConnectionRef connection, const WKConnectionClientBase* client); WK_EXPORT void WKConnectionPostMessage(WKConnectionRef connection, WKStringRef messageName, WKTypeRef messageBody); #ifdef __cplusplus diff --git a/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp b/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp index 41134c971..0514f1825 100644 --- a/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp +++ b/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp @@ -26,16 +26,12 @@ #include "config.h" #include "WKContextMenuItem.h" -#include "MutableArray.h" +#include "APIArray.h" #include "WebContextMenuItem.h" #include "WebContextMenuItemData.h" #include "WKAPICast.h" #include "WKContextMenuItemTypes.h" -#if PLATFORM(MAC) -#import <mach-o/dyld.h> -#endif - using namespace WebCore; using namespace WebKit; @@ -44,15 +40,18 @@ WKTypeID WKContextMenuItemGetTypeID() #if ENABLE(CONTEXT_MENUS) return toAPI(WebContextMenuItem::APIType); #else - return toAPI(APIObject::TypeNull); + return toAPI(API::Object::Type::Null); #endif } 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); + UNUSED_PARAM(enabled); return 0; #endif } @@ -60,8 +59,12 @@ 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); + UNUSED_PARAM(enabled); + UNUSED_PARAM(checked); return 0; #endif } @@ -71,6 +74,9 @@ WKContextMenuItemRef WKContextMenuItemCreateAsSubmenu(WKStringRef title, bool en #if ENABLE(CONTEXT_MENUS) return toAPI(WebContextMenuItem::create(toImpl(title)->string(), enabled, toImpl(submenuItems)).leakRef()); #else + UNUSED_PARAM(title); + UNUSED_PARAM(enabled); + UNUSED_PARAM(submenuItems); return 0; #endif } @@ -84,37 +90,12 @@ WKContextMenuItemRef WKContextMenuItemSeparatorItem() #endif } -#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 - 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); #endif } @@ -122,8 +103,9 @@ 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); #endif } @@ -131,8 +113,9 @@ 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; #endif } @@ -140,8 +123,9 @@ 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; #endif } @@ -149,8 +133,9 @@ 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; #endif } @@ -158,8 +143,9 @@ bool WKContextMenuItemGetChecked(WKContextMenuItemRef itemRef) WKArrayRef WKContextMenuCopySubmenuItems(WKContextMenuItemRef itemRef) { #if ENABLE(CONTEXT_MENUS) - return toAPI(toImpl(itemRef)->submenuItemsAsImmutableArray().leakRef()); + return toAPI(&toImpl(itemRef)->submenuItemsAsAPIArray().leakRef()); #else + UNUSED_PARAM(itemRef); return 0; #endif } @@ -169,6 +155,7 @@ WKTypeRef WKContextMenuItemGetUserData(WKContextMenuItemRef itemRef) #if ENABLE(CONTEXT_MENUS) return toAPI(toImpl(itemRef)->userData()); #else + UNUSED_PARAM(itemRef); return 0; #endif } @@ -177,5 +164,8 @@ void WKContextMenuItemSetUserData(WKContextMenuItemRef itemRef, WKTypeRef userDa { #if ENABLE(CONTEXT_MENUS) toImpl(itemRef)->setUserData(toImpl(userDataRef)); +#else + UNUSED_PARAM(itemRef); + UNUSED_PARAM(userDataRef); #endif } 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 d4d570a95..33ef0ffa4 100644 --- a/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h +++ b/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h @@ -26,6 +26,8 @@ #ifndef WKContextMenuItemTypes_h #define WKContextMenuItemTypes_h +#include <stdint.h> + #ifdef __cplusplus extern "C" { #endif @@ -119,6 +121,7 @@ enum { kWKContextMenuItemTagSelectAll, kWKContextMenuItemTagOpenLinkInThisWindow, kWKContextMenuItemTagToggleVideoFullscreen, + kWKContextMenuItemTagShareMenu, 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 f51636914..fdbca73dc 100644 --- a/Source/WebKit2/Shared/API/c/WKData.cpp +++ b/Source/WebKit2/Shared/API/c/WKData.cpp @@ -26,20 +26,19 @@ #include "config.h" #include "WKData.h" -#include "WebData.h" +#include "APIData.h" #include "WKAPICast.h" using namespace WebKit; WKTypeID WKDataGetTypeID() { - return toAPI(WebData::APIType); + return toAPI(API::Data::APIType); } WKDataRef WKDataCreate(const unsigned char* bytes, size_t size) { - RefPtr<WebData> data = WebData::create(bytes, size); - return toAPI(data.release().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 new file mode 100644 index 000000000..2346ea692 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2010, 2011 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 + * 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 WKDeclarationSpecifiers_h +#define WKDeclarationSpecifiers_h + +#undef WK_EXPORT +#if defined(WK_NO_EXPORT) +#define WK_EXPORT +#elif defined(__GNUC__) && !defined(__CC_ARM) && !defined(__ARMCC__) +#define WK_EXPORT __attribute__((visibility("default"))) +#elif defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE) || defined(__CC_ARM) || defined(__ARMCC__) +#if BUILDING_WEBKIT +#define WK_EXPORT __declspec(dllexport) +#else +#define WK_EXPORT __declspec(dllimport) +#endif +#else /* !defined(WK_NO_EXPORT) */ +#define WK_EXPORT +#endif /* defined(WK_NO_EXPORT) */ + +#if !defined(WK_INLINE) +#if defined(__cplusplus) +#define WK_INLINE static inline +#elif defined(__GNUC__) +#define WK_INLINE static __inline__ +#elif defined(__WIN32__) +#define WK_INLINE static __inline +#else +#define WK_INLINE static +#endif +#endif /* !defined(WK_INLINE) */ + +#ifndef __has_extension +#define __has_extension(x) 0 +#endif + +#if defined(__has_extension) && __has_extension(enumerator_attributes) && __has_extension(attribute_unavailable_with_message) +#define WK_C_DEPRECATED(message) __attribute__((deprecated(message))) +#else +#define WK_C_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) +#endif + +#endif /* WKDeclarationSpecifiers_h */ diff --git a/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp b/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp new file mode 100644 index 000000000..563c87329 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp @@ -0,0 +1,165 @@ +/* + * 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 "APIDictionary.h" +#include "WKArray.h" +#include "WKContextPrivate.h" +#include "WKMutableDictionary.h" +#include "WKPreferencesRefPrivate.h" +#include "WKSharedAPICast.h" + +#if PLATFORM(MAC) +#include "WKContextPrivateMac.h" +#endif + +// 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 void WKPageSetVisibilityState(WKPageRef, WKPageVisibilityState, bool); + +WK_EXPORT bool WKDictionaryIsMutable(WKDictionaryRef dictionary); +WK_EXPORT bool WKDictionaryAddItem(WKMutableDictionaryRef dictionary, WKStringRef key, WKTypeRef item); +WK_EXPORT void WKDictionaryRemoveItem(WKMutableDictionaryRef dictionary, WKStringRef key); + +WK_EXPORT void WKPreferencesSetRegionBasedColumnsEnabled(WKPreferencesRef, bool flag); +WK_EXPORT bool WKPreferencesGetRegionBasedColumnsEnabled(WKPreferencesRef); + +WK_EXPORT void WKPreferencesSetMultithreadedWebGLEnabled(WKPreferencesRef, bool); +WK_EXPORT bool WKPreferencesGetMultithreadedWebGLEnabled(WKPreferencesRef); + +WK_EXPORT bool WKInspectorIsDebuggingJavaScript(WKInspectorRef); +WK_EXPORT void WKInspectorToggleJavaScriptDebugging(WKInspectorRef); + +WK_EXPORT bool WKInspectorIsProfilingJavaScript(WKInspectorRef); +WK_EXPORT void WKInspectorToggleJavaScriptProfiling(WKInspectorRef); + +#if PLATFORM(MAC) +WK_EXPORT CGContextRef WKGraphicsContextGetCGContext(WKGraphicsContextRef graphicsContext); +#endif +} + +bool WKArrayIsMutable(WKArrayRef) +{ + return false; +} + +void WKPageSetVisibilityState(WKPageRef, WKPageVisibilityState, bool) +{ +} + +bool WKDictionaryIsMutable(WKDictionaryRef) +{ + return true; +} + +bool WKDictionaryAddItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef, WKTypeRef itemRef) +{ + return toImpl(dictionaryRef)->add(toImpl(keyRef)->string(), toImpl(itemRef)); +} + +void WKDictionaryRemoveItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef) +{ + toImpl(dictionaryRef)->remove(toImpl(keyRef)->string()); +} + +void WKPreferencesSetRegionBasedColumnsEnabled(WKPreferencesRef, bool) +{ +} + +bool WKPreferencesGetRegionBasedColumnsEnabled(WKPreferencesRef) +{ + return true; +} + +void WKPreferencesSetMultithreadedWebGLEnabled(WKPreferencesRef, bool) +{ +} + +bool WKPreferencesGetMultithreadedWebGLEnabled(WKPreferencesRef) +{ + return false; +} + +void WKPreferencesSetScreenFontSubstitutionEnabled(WKPreferencesRef, bool) +{ +} + +bool WKPreferencesGetScreenFontSubstitutionEnabled(WKPreferencesRef) +{ + return false; +} + +bool WKInspectorIsDebuggingJavaScript(WKInspectorRef) +{ + return false; +} + +void WKInspectorToggleJavaScriptDebugging(WKInspectorRef) +{ +} + +bool WKInspectorIsProfilingJavaScript(WKInspectorRef) +{ + return false; +} + +void WKInspectorToggleJavaScriptProfiling(WKInspectorRef) +{ +} + +void WKContextSetUsesNetworkProcess(WKContextRef, bool) +{ +} + +void WKContextSetProcessModel(WKContextRef, WKProcessModel) +{ +} + +WKProcessModel WKContextGetProcessModel(WKContextRef) +{ + return kWKProcessModelMultipleSecondaryProcesses; +} + +#if PLATFORM(MAC) +CGContextRef WKGraphicsContextGetCGContext(WKGraphicsContextRef graphicsContext) +{ + return nullptr; +} + +bool WKContextGetProcessSuppressionEnabled(WKContextRef) +{ + return true; +} + +void WKContextSetProcessSuppressionEnabled(WKContextRef, bool) +{ +} +#endif diff --git a/Source/WebKit2/Shared/API/c/cf/WKErrorCF.h b/Source/WebKit2/Shared/API/c/WKDiagnosticLoggingResultType.h index 298f7c291..581c74f96 100644 --- a/Source/WebKit2/Shared/API/c/cf/WKErrorCF.h +++ b/Source/WebKit2/Shared/API/c/WKDiagnosticLoggingResultType.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * 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,21 +23,23 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKErrorCF_h -#define WKErrorCF_h - -#include <CoreFoundation/CoreFoundation.h> -#include <WebKit2/WKBase.h> +#ifndef WKDiagnosticLoggingResultType_h +#define WKDiagnosticLoggingResultType_h #ifdef __cplusplus extern "C" { #endif -WK_EXPORT WKErrorRef WKErrorCreateWithCFError(CFErrorRef error); -WK_EXPORT CFErrorRef WKErrorCopyCFError(CFAllocatorRef alloc, WKErrorRef error); +enum { + kWKDiagnosticLoggingResultPass = 0, + kWKDiagnosticLoggingResultFail = 1, + kWKDiagnosticLoggingResultNoop = 2, +}; +typedef uint32_t WKDiagnosticLoggingResultType; #ifdef __cplusplus } #endif -#endif /* WKErrorCF_h */ +#endif /* WKDiagnosticLoggingResultType_h */ + diff --git a/Source/WebKit2/Shared/API/c/WKDictionary.cpp b/Source/WebKit2/Shared/API/c/WKDictionary.cpp index a3bdcf98f..654e1e61e 100644 --- a/Source/WebKit2/Shared/API/c/WKDictionary.cpp +++ b/Source/WebKit2/Shared/API/c/WKDictionary.cpp @@ -26,20 +26,29 @@ #include "config.h" #include "WKDictionary.h" -#include "ImmutableArray.h" -#include "ImmutableDictionary.h" +#include "APIArray.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) +{ + API::Dictionary::MapType map; + for (size_t i = 0; i < numberOfValues; ++i) + map.add(toImpl(keys[i])->string(), toImpl(values[i])); + + 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) @@ -49,6 +58,5 @@ size_t WKDictionaryGetSize(WKDictionaryRef dictionaryRef) WKArrayRef WKDictionaryCopyKeys(WKDictionaryRef dictionaryRef) { - RefPtr<ImmutableArray> 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 1c3940016..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> @@ -36,6 +36,8 @@ extern "C" { WK_EXPORT WKTypeID WKDictionaryGetTypeID(); +WK_EXPORT WKDictionaryRef WKDictionaryCreate(const WKStringRef* keys, const WKTypeRef* values, size_t numberOfValues); + WK_EXPORT WKTypeRef WKDictionaryGetItemForKey(WKDictionaryRef dictionary, WKStringRef key); WK_EXPORT size_t WKDictionaryGetSize(WKDictionaryRef dictionary); diff --git a/Source/WebKit2/Shared/API/c/WKError.cpp b/Source/WebKit2/Shared/API/c/WKErrorRef.cpp index 148bd624b..c1e75eb00 100644 --- a/Source/WebKit2/Shared/API/c/WKError.cpp +++ b/Source/WebKit2/Shared/API/c/WKErrorRef.cpp @@ -24,21 +24,21 @@ */ #include "config.h" -#include "WKError.h" +#include "WKErrorRef.h" -#include "WebError.h" +#include "APIError.h" #include "WKAPICast.h" using namespace WebKit; WKTypeID WKErrorGetTypeID() { - return toAPI(WebError::APIType); + return toAPI(API::Error::APIType); } WKStringRef WKErrorCopyWKErrorDomain() { - return toCopiedAPI(WebError::webKitErrorDomain()); + return toCopiedAPI(API::Error::webKitErrorDomain()); } WKStringRef WKErrorCopyDomain(WKErrorRef errorRef) diff --git a/Source/WebKit2/Shared/API/c/WKError.h b/Source/WebKit2/Shared/API/c/WKErrorRef.h index b099b732c..bc8e294fa 100644 --- a/Source/WebKit2/Shared/API/c/WKError.h +++ b/Source/WebKit2/Shared/API/c/WKErrorRef.h @@ -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,7 @@ enum { kWKErrorCodeCannotShowURL = 101, kWKErrorCodeFrameLoadInterruptedByPolicyChange = 102, kWKErrorCodeCannotUseRestrictedPort = 103, + kWKErrorCodeFrameLoadBlockedByContentBlocker = 104, kWKErrorCodeCannotFindPlugIn = 200, kWKErrorCodeCannotLoadPlugIn = 201, kWKErrorCodeJavaUnavailable = 202, @@ -45,7 +46,6 @@ enum { kWKErrorCodeInsecurePlugInVersion = 205, kWKErrorInternal = 300, }; -typedef uint32_t WKErrorCode; WK_EXPORT WKTypeID WKErrorGetTypeID(); @@ -60,4 +60,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..05c43a58d 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" { diff --git a/Source/WebKit2/Shared/API/c/WKFindOptions.h b/Source/WebKit2/Shared/API/c/WKFindOptions.h index f2be889f5..176127abb 100644 --- a/Source/WebKit2/Shared/API/c/WKFindOptions.h +++ b/Source/WebKit2/Shared/API/c/WKFindOptions.h @@ -26,6 +26,8 @@ #ifndef WKFindOptions_h #define WKFindOptions_h +#include <stdint.h> + #ifdef __cplusplus extern "C" { #endif diff --git a/Source/WebKit2/Shared/API/c/WKGeometry.cpp b/Source/WebKit2/Shared/API/c/WKGeometry.cpp index 8ad7ff0e7..e1ea82435 100644 --- a/Source/WebKit2/Shared/API/c/WKGeometry.cpp +++ b/Source/WebKit2/Shared/API/c/WKGeometry.cpp @@ -26,42 +26,39 @@ #include "config.h" #include "WKGeometry.h" +#include "APIGeometry.h" #include "WKAPICast.h" -#include "WebGeometry.h" using namespace WebKit; WKTypeID WKSizeGetTypeID() { - return toAPI(WebSize::APIType); + return toAPI(API::Size::APIType); } WKTypeID WKPointGetTypeID() { - return toAPI(WebPoint::APIType); + return toAPI(API::Point::APIType); } WKTypeID WKRectGetTypeID() { - return toAPI(WebRect::APIType); + return toAPI(API::Rect::APIType); } WKPointRef WKPointCreate(WKPoint point) { - RefPtr<WebPoint> webPoint = WebPoint::create(point); - return toAPI(webPoint.release().leakRef()); + return toAPI(&API::Point::create(point).leakRef()); } WKSizeRef WKSizeCreate(WKSize size) { - RefPtr<WebSize> webSize = WebSize::create(size); - return toAPI(webSize.release().leakRef()); + return toAPI(&API::Size::create(size).leakRef()); } WKRectRef WKRectCreate(WKRect rect) { - RefPtr<WebRect> webRect = WebRect::create(rect); - return toAPI(webRect.release().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/WKGraphicsContext.cpp b/Source/WebKit2/Shared/API/c/WKGraphicsContext.cpp deleted file mode 100644 index 5d80dfa3f..000000000 --- a/Source/WebKit2/Shared/API/c/WKGraphicsContext.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - */ - -#include "config.h" -#include "WKGraphicsContext.h" - -#include "WKSharedAPICast.h" -#include "WebGraphicsContext.h" - -using namespace WebKit; - -WKTypeID WKGraphicsContextGetTypeID() -{ - return toAPI(WebGraphicsContext::APIType); -} 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/cairo/WKImageCairo.h b/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h index 5c1e5413f..5fdc29a9e 100644 --- a/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h +++ b/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h @@ -1,6 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * Copyright (C) 2011 Igalia S.L. + * 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 @@ -24,24 +23,30 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKImageCairo_h -#define WKImageCairo_h +#ifndef WKImmediateActionTypes_h +#define WKImmediateActionTypes_h -#include <WebKit2/WKBase.h> -#include <WebKit2/WKImage.h> - -typedef struct _cairo_surface cairo_surface_t; +#include <stdint.h> #ifdef __cplusplus extern "C" { #endif -WK_EXPORT cairo_surface_t* WKImageCreateCairoSurface(WKImageRef image); - -WK_EXPORT WKImageRef WKImageCreateFromCairoSurface(cairo_surface_t* surface, WKImageOptions options); +enum { + kWKImmediateActionNone = 0, + kWKImmediateActionLinkPreview, + kWKImmediateActionDataDetectedItem, + kWKImmediateActionLookupText, + kWKImmediateActionMailtoLink, + kWKImmediateActionTelLink +}; + +#ifndef _WKImmediateActionType +#define _WKImmediateActionType uint32_t +#endif #ifdef __cplusplus } #endif -#endif /* WKImageCairo_h */ +#endif /* WKImmediateActionTypes_h */ diff --git a/Source/WebKit2/Shared/API/c/WKMutableArray.cpp b/Source/WebKit2/Shared/API/c/WKMutableArray.cpp index 2d8c11d25..5dc85260f 100644 --- a/Source/WebKit2/Shared/API/c/WKMutableArray.cpp +++ b/Source/WebKit2/Shared/API/c/WKMutableArray.cpp @@ -26,29 +26,23 @@ #include "config.h" #include "WKMutableArray.h" -#include "MutableArray.h" +#include "APIArray.h" #include "WKAPICast.h" using namespace WebKit; WKMutableArrayRef WKMutableArrayCreate() { - RefPtr<MutableArray> array = MutableArray::create(); - return toAPI(array.release().leakRef()); -} - -bool WKArrayIsMutable(WKArrayRef arrayRef) -{ - return toImpl(arrayRef)->isMutable(); + return const_cast<WKMutableArrayRef>(toAPI(&API::Array::create().leakRef())); } void WKArrayAppendItem(WKMutableArrayRef arrayRef, WKTypeRef itemRef) { - toImpl(arrayRef)->append(toImpl(itemRef)); + toImpl(arrayRef)->elements().append(toImpl(itemRef)); } void WKArrayRemoveItemAtIndex(WKMutableArrayRef arrayRef, size_t index) { - toImpl(arrayRef)->removeItemAtIndex(index); + toImpl(arrayRef)->elements().remove(index); } diff --git a/Source/WebKit2/Shared/API/c/WKMutableArray.h b/Source/WebKit2/Shared/API/c/WKMutableArray.h index a0dc06a4f..80bd8c029 100644 --- a/Source/WebKit2/Shared/API/c/WKMutableArray.h +++ b/Source/WebKit2/Shared/API/c/WKMutableArray.h @@ -26,7 +26,8 @@ #ifndef WKMutableArray_h #define WKMutableArray_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> +#include <stddef.h> #ifndef __cplusplus #include <stdbool.h> @@ -38,8 +39,6 @@ extern "C" { WK_EXPORT WKMutableArrayRef WKMutableArrayCreate(); -WK_EXPORT bool WKArrayIsMutable(WKArrayRef array); - WK_EXPORT void WKArrayAppendItem(WKMutableArrayRef array, WKTypeRef item); WK_EXPORT void WKArrayRemoveItemAtIndex(WKMutableArrayRef array, size_t index); diff --git a/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp b/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp index b066df5e4..96b89bd45 100644 --- a/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp +++ b/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp @@ -26,25 +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()); -} - -bool WKDictionaryIsMutable(WKDictionaryRef dictionaryRef) -{ - return toImpl(dictionaryRef)->isMutable(); -} - -bool WKDictionaryAddItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef, WKTypeRef itemRef) -{ - return toImpl(dictionaryRef)->add(toImpl(keyRef)->string(), toImpl(itemRef)); + return const_cast<WKMutableDictionaryRef>(toAPI(&API::Dictionary::create().leakRef())); } bool WKDictionarySetItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef, WKTypeRef itemRef) @@ -52,7 +41,3 @@ bool WKDictionarySetItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRe return toImpl(dictionaryRef)->set(toImpl(keyRef)->string(), toImpl(itemRef)); } -void WKDictionaryRemoveItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef) -{ - toImpl(dictionaryRef)->remove(toImpl(keyRef)->string()); -} diff --git a/Source/WebKit2/Shared/API/c/WKMutableDictionary.h b/Source/WebKit2/Shared/API/c/WKMutableDictionary.h index 2459f9132..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> @@ -38,11 +38,7 @@ extern "C" { WK_EXPORT WKMutableDictionaryRef WKMutableDictionaryCreate(); -WK_EXPORT bool WKDictionaryIsMutable(WKDictionaryRef dictionary); - -WK_EXPORT bool WKDictionaryAddItem(WKMutableDictionaryRef dictionary, WKStringRef key, WKTypeRef item); WK_EXPORT bool WKDictionarySetItem(WKMutableDictionaryRef dictionary, WKStringRef key, WKTypeRef item); -WK_EXPORT void WKDictionaryRemoveItem(WKMutableDictionaryRef dictionary, WKStringRef key); #ifdef __cplusplus } diff --git a/Source/WebKit2/Shared/API/c/WKNumber.cpp b/Source/WebKit2/Shared/API/c/WKNumber.cpp index 1fc796908..11300632c 100644 --- a/Source/WebKit2/Shared/API/c/WKNumber.cpp +++ b/Source/WebKit2/Shared/API/c/WKNumber.cpp @@ -26,19 +26,19 @@ #include "config.h" #include "WKNumber.h" +#include "APINumber.h" #include "WKAPICast.h" -#include "WebNumber.h" using namespace WebKit; WKTypeID WKBooleanGetTypeID() { - return toAPI(WebBoolean::APIType); + return toAPI(API::Boolean::APIType); } WKBooleanRef WKBooleanCreate(bool value) { - RefPtr<WebBoolean> booleanObject = WebBoolean::create(value); + RefPtr<API::Boolean> booleanObject = API::Boolean::create(value); return toAPI(booleanObject.release().leakRef()); } @@ -49,12 +49,12 @@ bool WKBooleanGetValue(WKBooleanRef booleanRef) WKTypeID WKDoubleGetTypeID() { - return toAPI(WebDouble::APIType); + return toAPI(API::Double::APIType); } WKDoubleRef WKDoubleCreate(double value) { - RefPtr<WebDouble> doubleObject = WebDouble::create(value); + RefPtr<API::Double> doubleObject = API::Double::create(value); return toAPI(doubleObject.release().leakRef()); } @@ -65,12 +65,12 @@ double WKDoubleGetValue(WKDoubleRef doubleRef) WKTypeID WKUInt64GetTypeID() { - return toAPI(WebUInt64::APIType); + return toAPI(API::UInt64::APIType); } WKUInt64Ref WKUInt64Create(uint64_t value) { - RefPtr<WebUInt64> uint64Object = WebUInt64::create(value); + RefPtr<API::UInt64> uint64Object = API::UInt64::create(value); return toAPI(uint64Object.release().leakRef()); } 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/WKPageLoadTypes.h b/Source/WebKit2/Shared/API/c/WKPageLoadTypes.h index 726630150..fce79a3ad 100644 --- a/Source/WebKit2/Shared/API/c/WKPageLoadTypes.h +++ b/Source/WebKit2/Shared/API/c/WKPageLoadTypes.h @@ -26,6 +26,8 @@ #ifndef WKPageLoadTypes_h #define WKPageLoadTypes_h +#include <stdint.h> + #ifdef __cplusplus extern "C" { #endif diff --git a/Source/WebKit2/Shared/API/c/WKPageVisibilityTypes.h b/Source/WebKit2/Shared/API/c/WKPageVisibilityTypes.h index a64a3951c..2f8c6d2eb 100644 --- a/Source/WebKit2/Shared/API/c/WKPageVisibilityTypes.h +++ b/Source/WebKit2/Shared/API/c/WKPageVisibilityTypes.h @@ -26,6 +26,8 @@ #ifndef WKPageVisibilityTypes_h #define WKPageVisibilityTypes_h +#include <stdint.h> + #ifdef __cplusplus extern "C" { #endif @@ -33,8 +35,7 @@ extern "C" { enum { kWKPageVisibilityStateVisible, kWKPageVisibilityStateHidden, - kWKPageVisibilityStatePrerender, - kWKPageVisibilityStateUnloaded + kWKPageVisibilityStatePrerender }; typedef uint32_t WKPageVisibilityState; diff --git a/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp b/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp index 19435e08c..e3ae4f5f0 100644 --- a/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp +++ b/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp @@ -26,92 +26,148 @@ #include "config.h" #include "WKPluginInformation.h" +#include "APIString.h" #include "PluginInformation.h" #include "WKSharedAPICast.h" -#include "WebString.h" using namespace WebKit; WKStringRef WKPluginInformationBundleIdentifierKey() { - static WebString* key = WebString::create(pluginInformationBundleIdentifierKey()).leakRef(); - return toAPI(key); +#if ENABLE(NETSCAPE_PLUGIN_API) + static API::String& key = API::String::create(pluginInformationBundleIdentifierKey()).leakRef(); + return toAPI(&key); +#else + return 0; +#endif } WKStringRef WKPluginInformationBundleVersionKey() { - static WebString* key = WebString::create(pluginInformationBundleVersionKey()).leakRef(); - return toAPI(key); +#if ENABLE(NETSCAPE_PLUGIN_API) + static API::String& key = API::String::create(pluginInformationBundleVersionKey()).leakRef(); + return toAPI(&key); +#else + return 0; +#endif } WKStringRef WKPluginInformationBundleShortVersionKey() { - static WebString* key = WebString::create(pluginInformationBundleShortVersionKey()).leakRef(); - return toAPI(key); +#if ENABLE(NETSCAPE_PLUGIN_API) + static API::String& key = API::String::create(pluginInformationBundleShortVersionKey()).leakRef(); + return toAPI(&key); +#else + return 0; +#endif } WKStringRef WKPluginInformationPathKey() { - static WebString* key = WebString::create(pluginInformationPathKey()).leakRef(); - return toAPI(key); +#if ENABLE(NETSCAPE_PLUGIN_API) + static API::String& key = API::String::create(pluginInformationPathKey()).leakRef(); + return toAPI(&key); +#else + return 0; +#endif } WKStringRef WKPluginInformationDisplayNameKey() { - static WebString* key = WebString::create(pluginInformationDisplayNameKey()).leakRef(); - return toAPI(key); +#if ENABLE(NETSCAPE_PLUGIN_API) + static API::String& key = API::String::create(pluginInformationDisplayNameKey()).leakRef(); + return toAPI(&key); +#else + return 0; +#endif } WKStringRef WKPluginInformationDefaultLoadPolicyKey() { - static WebString* key = WebString::create(pluginInformationDefaultLoadPolicyKey()).leakRef(); - return toAPI(key); +#if ENABLE(NETSCAPE_PLUGIN_API) + static API::String& key = API::String::create(pluginInformationDefaultLoadPolicyKey()).leakRef(); + return toAPI(&key); +#else + return 0; +#endif } WKStringRef WKPluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey() { - static WebString* key = WebString::create(pluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()).leakRef(); - return toAPI(key); +#if ENABLE(NETSCAPE_PLUGIN_API) + static API::String& key = API::String::create(pluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()).leakRef(); + return toAPI(&key); +#else + return 0; +#endif } WKStringRef WKPluginInformationHasSandboxProfileKey() { - static WebString* key = WebString::create(pluginInformationHasSandboxProfileKey()).leakRef(); - return toAPI(key); +#if ENABLE(NETSCAPE_PLUGIN_API) + static API::String& key = API::String::create(pluginInformationHasSandboxProfileKey()).leakRef(); + return toAPI(&key); +#else + return 0; +#endif } WKStringRef WKPluginInformationFrameURLKey() { - static WebString* key = WebString::create(pluginInformationFrameURLKey()).leakRef(); - return toAPI(key); +#if ENABLE(NETSCAPE_PLUGIN_API) + static API::String& key = API::String::create(pluginInformationFrameURLKey()).leakRef(); + return toAPI(&key); +#else + return 0; +#endif } WKStringRef WKPluginInformationMIMETypeKey() { - static WebString* key = WebString::create(pluginInformationMIMETypeKey()).leakRef(); - return toAPI(key); +#if ENABLE(NETSCAPE_PLUGIN_API) + static API::String& key = API::String::create(pluginInformationMIMETypeKey()).leakRef(); + return toAPI(&key); +#else + return 0; +#endif } WKStringRef WKPluginInformationPageURLKey() { - static WebString* key = WebString::create(pluginInformationPageURLKey()).leakRef(); - return toAPI(key); +#if ENABLE(NETSCAPE_PLUGIN_API) + static API::String& key = API::String::create(pluginInformationPageURLKey()).leakRef(); + return toAPI(&key); +#else + return 0; +#endif } WKStringRef WKPluginInformationPluginspageAttributeURLKey() { - static WebString* key = WebString::create(pluginInformationPluginspageAttributeURLKey()).leakRef(); - return toAPI(key); +#if ENABLE(NETSCAPE_PLUGIN_API) + static API::String& key = API::String::create(pluginInformationPluginspageAttributeURLKey()).leakRef(); + return toAPI(&key); +#else + return 0; +#endif } WKStringRef WKPluginInformationPluginURLKey() { - static WebString* key = WebString::create(pluginInformationPluginURLKey()).leakRef(); - return toAPI(key); +#if ENABLE(NETSCAPE_PLUGIN_API) + static API::String& key = API::String::create(pluginInformationPluginURLKey()).leakRef(); + return toAPI(&key); +#else + return 0; +#endif } WKStringRef WKPlugInInformationReplacementObscuredKey() { - static WebString* key = WebString::create(plugInInformationReplacementObscuredKey()).leakRef(); - return toAPI(key); +#if ENABLE(NETSCAPE_PLUGIN_API) + 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 2bc9728cf..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) @@ -79,5 +93,5 @@ WKRect WKRenderObjectGetFrameRect(WKRenderObjectRef renderObjectRef) WKArrayRef WKRenderObjectGetChildren(WKRenderObjectRef renderObjectRef) { - return toAPI(toImpl(renderObjectRef)->children().get()); + return toAPI(toImpl(renderObjectRef)->children()); } 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..882867f80 100644 --- a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp +++ b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.cpp @@ -24,59 +24,57 @@ */ #include "config.h" -#include "WKSecurityOrigin.h" +#include "WKSecurityOriginRef.h" +#include "APISecurityOrigin.h" #include "WKAPICast.h" -#include "WebSecurityOrigin.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()); + return toAPI(API::SecurityOrigin::create(WebCore::SecurityOrigin::createFromDatabaseIdentifier((toImpl(identifier)->string()))).leakRef()); } WKSecurityOriginRef WKSecurityOriginCreate(WKStringRef protocol, WKStringRef host, int port) { - RefPtr<WebSecurityOrigin> securityOrigin = WebSecurityOrigin::create(toImpl(protocol)->string(), toImpl(host)->string(), port); + RefPtr<API::SecurityOrigin> securityOrigin = API::SecurityOrigin::create(toImpl(protocol)->string(), toImpl(host)->string(), port); return toAPI(securityOrigin.release().leakRef()); } WKStringRef WKSecurityOriginCopyDatabaseIdentifier(WKSecurityOriginRef securityOrigin) { - return toCopiedAPI(toImpl(securityOrigin)->databaseIdentifier()); + return toCopiedAPI(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(); } // 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..ec2ad96f5 100644 --- a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp +++ b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp @@ -27,25 +27,25 @@ #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); + RefPtr<API::SerializedScriptValue> serializedValue = API::SerializedScriptValue::create(context, value, exception); return toAPI(serializedValue.release().leakRef()); } WKSerializedScriptValueRef WKSerializedScriptValueCreateWithInternalRepresentation(void* internalRepresentation) { - RefPtr<WebSerializedScriptValue> serializedValue = WebSerializedScriptValue::create(static_cast<WebCore::SerializedScriptValue*>(internalRepresentation)); + RefPtr<API::SerializedScriptValue> serializedValue = API::SerializedScriptValue::create(static_cast<WebCore::SerializedScriptValue*>(internalRepresentation)); return toAPI(serializedValue.release().leakRef()); } 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 b354a947a..99fe397a3 100644 --- a/Source/WebKit2/Shared/API/c/WKSharedAPICast.h +++ b/Source/WebKit2/Shared/API/c/WKSharedAPICast.h @@ -26,10 +26,19 @@ #ifndef WKSharedAPICast_h #define WKSharedAPICast_h +#include "APIError.h" +#include "APINumber.h" +#include "APISecurityOrigin.h" +#include "APISession.h" +#include "APIString.h" +#include "APIURL.h" +#include "APIURLRequest.h" +#include "APIURLResponse.h" #include "ImageOptions.h" #include "SameDocumentNavigationType.h" #include "WKBase.h" #include "WKContextMenuItemTypes.h" +#include "WKDiagnosticLoggingResultType.h" #include "WKEvent.h" #include "WKFindOptions.h" #include "WKGeometry.h" @@ -37,16 +46,12 @@ #include "WKPageLoadTypes.h" #include "WKPageLoadTypesPrivate.h" #include "WKPageVisibilityTypes.h" -#include "WebError.h" +#include "WKUserContentInjectedFrames.h" +#include "WKUserScriptInjectionTime.h" #include "WebEvent.h" #include "WebFindOptions.h" -#include "WebNumber.h" -#include "WebSecurityOrigin.h" -#include "WebString.h" -#include "WebURL.h" -#include "WebURLRequest.h" -#include "WebURLResponse.h" #include <WebCore/ContextMenuItem.h> +#include <WebCore/DiagnosticLoggingResultType.h> #include <WebCore/FloatRect.h> #include <WebCore/FrameLoaderTypes.h> #include <WebCore/IntRect.h> @@ -55,72 +60,84 @@ #include <WebCore/SecurityOrigin.h> #include <WebCore/UserContentTypes.h> #include <WebCore/UserScriptTypes.h> -#include <wtf/TypeTraits.h> + +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 ImmutableArray; -class ImmutableDictionary; -class MutableArray; -class MutableDictionary; class ObjCObjectGraph; -class WebArchive; -class WebArchiveResource; class WebCertificateInfo; class WebConnection; class WebContextMenuItem; -class WebData; class WebGraphicsContext; class WebImage; -class WebPoint; -class WebRect; -class WebSecurityOrigin; -class WebSerializedScriptValue; -class WebSize; -class WebURLRequest; -class WebURLResponse; -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, ImmutableArray) -WK_ADD_API_MAPPING(WKBooleanRef, WebBoolean) +WK_ADD_API_MAPPING(WKArrayRef, API::Array) +WK_ADD_API_MAPPING(WKBooleanRef, API::Boolean) WK_ADD_API_MAPPING(WKCertificateInfoRef, WebCertificateInfo) WK_ADD_API_MAPPING(WKConnectionRef, WebConnection) WK_ADD_API_MAPPING(WKContextMenuItemRef, WebContextMenuItem) -WK_ADD_API_MAPPING(WKDataRef, WebData) -WK_ADD_API_MAPPING(WKDictionaryRef, ImmutableDictionary) -WK_ADD_API_MAPPING(WKDoubleRef, WebDouble) -WK_ADD_API_MAPPING(WKErrorRef, WebError) +WK_ADD_API_MAPPING(WKDataRef, API::Data) +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(WKMutableArrayRef, MutableArray) -WK_ADD_API_MAPPING(WKMutableDictionaryRef, MutableDictionary) -WK_ADD_API_MAPPING(WKPointRef, WebPoint) -WK_ADD_API_MAPPING(WKRectRef, WebRect) -WK_ADD_API_MAPPING(WKSecurityOriginRef, WebSecurityOrigin) -WK_ADD_API_MAPPING(WKSerializedScriptValueRef, WebSerializedScriptValue) -WK_ADD_API_MAPPING(WKSizeRef, WebSize) -WK_ADD_API_MAPPING(WKStringRef, WebString) -WK_ADD_API_MAPPING(WKTypeRef, APIObject) -WK_ADD_API_MAPPING(WKUInt64Ref, WebUInt64) -WK_ADD_API_MAPPING(WKURLRef, WebURL) -WK_ADD_API_MAPPING(WKURLRequestRef, WebURLRequest) -WK_ADD_API_MAPPING(WKURLResponseRef, WebURLResponse) -WK_ADD_API_MAPPING(WKUserContentURLPatternRef, WebUserContentURLPattern) - -#if PLATFORM(MAC) -WK_ADD_API_MAPPING(WKWebArchiveRef, WebArchive) -WK_ADD_API_MAPPING(WKWebArchiveResourceRef, WebArchiveResource) +WK_ADD_API_MAPPING(WKPointRef, API::Point) +WK_ADD_API_MAPPING(WKRectRef, API::Rect) +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) +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, API::UserContentURLPattern) +WK_ADD_API_MAPPING(WKSessionRef, API::Session) + +template<> struct APITypeInfo<WKMutableArrayRef> { typedef API::Array ImplType; }; +template<> struct APITypeInfo<WKMutableDictionaryRef> { typedef API::Dictionary ImplType; }; + +#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 ImplType, typename APIType = typename ImplTypeInfo<ImplType*>::APIType> +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 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> class ProxyingRefPtr { public: ProxyingRefPtr(PassRefPtr<ImplType> impl) @@ -128,58 +145,41 @@ 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* -> ImmutableArray* - - typedef typename WTF::RemovePointer<T>::Type PotentiallyConstValueType; - typedef typename WTF::RemoveConst<PotentiallyConstValueType>::Type NonConstValueType; - - return reinterpret_cast<typename APITypeInfo<T>::ImplType>(const_cast<NonConstValueType*>(t)); -} - -template<typename T> -inline typename ImplTypeInfo<T>::APIType toAPI(T t) -{ - return reinterpret_cast<typename ImplTypeInfo<T>::APIType>(t); -} - /* Special cases. */ -inline ProxyingRefPtr<WebString> toAPI(StringImpl* string) +inline ProxyingRefPtr<API::String> toAPI(StringImpl* string) { - return ProxyingRefPtr<WebString>(WebString::create(string)); + return ProxyingRefPtr<API::String>(API::String::create(string)); } inline WKStringRef toCopiedAPI(const String& string) { - RefPtr<WebString> webString = WebString::create(string); - return toAPI(webString.release().leakRef()); + return toAPI(&API::String::create(string).leakRef()); } -inline ProxyingRefPtr<WebURL> toURLRef(StringImpl* string) +inline ProxyingRefPtr<API::URL> toURLRef(StringImpl* string) { if (!string) - return ProxyingRefPtr<WebURL>(0); - return ProxyingRefPtr<WebURL>(WebURL::create(String(string))); + 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<WebURL> webURL = WebURL::create(string); - return toAPI(webURL.release().leakRef()); + return nullptr; + return toAPI(&API::URL::create(string).leakRef()); } inline String toWTFString(WKStringRef stringRef) @@ -196,26 +196,26 @@ inline String toWTFString(WKURLRef urlRef) return toImpl(urlRef)->string(); } -inline ProxyingRefPtr<WebError> toAPI(const WebCore::ResourceError& error) +inline ProxyingRefPtr<API::Error> toAPI(const WebCore::ResourceError& error) { - return ProxyingRefPtr<WebError>(WebError::create(error)); + return ProxyingRefPtr<API::Error>(API::Error::create(error)); } -inline ProxyingRefPtr<WebURLRequest> toAPI(const WebCore::ResourceRequest& request) +inline ProxyingRefPtr<API::URLRequest> toAPI(const WebCore::ResourceRequest& request) { - return ProxyingRefPtr<WebURLRequest>(WebURLRequest::create(request)); + return ProxyingRefPtr<API::URLRequest>(API::URLRequest::create(request)); } -inline ProxyingRefPtr<WebURLResponse> toAPI(const WebCore::ResourceResponse& response) +inline ProxyingRefPtr<API::URLResponse> toAPI(const WebCore::ResourceResponse& response) { - return ProxyingRefPtr<WebURLResponse>(WebURLResponse::create(response)); + return ProxyingRefPtr<API::URLResponse>(API::URLResponse::create(response)); } 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 */ @@ -280,7 +280,7 @@ inline WKPoint toAPI(const WebCore::IntPoint& point) /* Enum conversions */ -inline WKTypeID toAPI(APIObject::Type type) +inline WKTypeID toAPI(API::Object::Type type) { return static_cast<WKTypeID>(type); } @@ -448,10 +448,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,7 +476,7 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action) return kWKContextMenuItemTagMediaPlayPause; case WebCore::ContextMenuItemTagMediaMute: return kWKContextMenuItemTagMediaMute; -#if PLATFORM(MAC) +#if PLATFORM(COCOA) case WebCore::ContextMenuItemTagCorrectSpellingAutomatically: return kWKContextMenuItemTagCorrectSpellingAutomatically; case WebCore::ContextMenuItemTagSubstitutionsMenu: @@ -506,8 +504,12 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action) case WebCore::ContextMenuItemTagChangeBack: return kWKContextMenuItemTagChangeBack; #endif +#if PLATFORM(QT) case WebCore::ContextMenuItemTagOpenLinkInThisWindow: return kWKContextMenuItemTagOpenLinkInThisWindow; +#endif + 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); @@ -642,10 +644,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,7 +672,7 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag) return WebCore::ContextMenuItemTagMediaPlayPause; case kWKContextMenuItemTagMediaMute: return WebCore::ContextMenuItemTagMediaMute; -#if PLATFORM(MAC) +#if PLATFORM(COCOA) case kWKContextMenuItemTagCorrectSpellingAutomatically: return WebCore::ContextMenuItemTagCorrectSpellingAutomatically; case kWKContextMenuItemTagSubstitutionsMenu: @@ -699,9 +699,13 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag) return WebCore::ContextMenuItemTagCapitalize; case kWKContextMenuItemTagChangeBack: return WebCore::ContextMenuItemTagChangeBack; + case kWKContextMenuItemTagShareMenu: + return WebCore::ContextMenuItemTagShareMenu; #endif +#if PLATFORM(QT) case kWKContextMenuItemTagOpenLinkInThisWindow: return WebCore::ContextMenuItemTagOpenLinkInThisWindow; +#endif default: if (tag < kWKContextMenuItemBaseApplicationTag) LOG_ERROR("WKContextMenuItemTag %i is an unknown tag but is below the allowable custom tag value of %i", tag, kWKContextMenuItemBaseApplicationTag); @@ -755,22 +759,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; } @@ -800,6 +804,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; @@ -849,8 +913,6 @@ inline WebCore::PageVisibilityState toPageVisibilityState(WKPageVisibilityState return WebCore::PageVisibilityStateHidden; case kWKPageVisibilityStatePrerender: return WebCore::PageVisibilityStatePrerender; - case kWKPageVisibilityStateUnloaded: - return WebCore::PageVisibilityStateUnloaded; } ASSERT_NOT_REACHED(); @@ -889,11 +951,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: @@ -906,6 +974,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 cbac67dd8..305dd01b5 100644 --- a/Source/WebKit2/Shared/API/c/WKString.cpp +++ b/Source/WebKit2/Shared/API/c/WKString.cpp @@ -28,68 +28,101 @@ #include "WKStringPrivate.h" #include "WKAPICast.h" +#include <JavaScriptCore/InitializeThreading.h> +#include <JavaScriptCore/JSStringRef.h> +#include <JavaScriptCore/OpaqueJSString.h> using namespace WebKit; WKTypeID WKStringGetTypeID() { - return toAPI(WebString::APIType); + return toAPI(API::String::APIType); } WKStringRef WKStringCreateWithUTF8CString(const char* string) { - RefPtr<WebString> webString = WebString::createFromUTF8String(string); - return toAPI(webString.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(static_cast<UChar*>(buffer)); + return substring.length(); } size_t WKStringGetMaximumUTF8CStringSize(WKStringRef stringRef) { - return toImpl(stringRef)->maximumUTF8CStringSize(); + return toImpl(stringRef)->stringView().length() * 3 + 1; } size_t WKStringGetUTF8CString(WKStringRef stringRef, char* buffer, size_t bufferSize) { - return toImpl(stringRef)->getUTF8CString(buffer, 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 */ true); + } + + if (result != WTF::Unicode::conversionOK && result != WTF::Unicode::targetExhausted) + return 0; + + *p++ = '\0'; + return p - buffer; } 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<WebString> webString = WebString::create(jsStringRef); - return toAPI(webString.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 f02c455eb..fc1b71d61 100644 --- a/Source/WebKit2/Shared/API/c/WKString.h +++ b/Source/WebKit2/Shared/API/c/WKString.h @@ -26,7 +26,8 @@ #ifndef WKString_h #define WKString_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> +#include <stddef.h> #ifndef __cplusplus #include <stdbool.h> 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 f0e4ea8fb..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<APIObject*>(const_cast<void*>(typeRef))->type()); + return toAPI(toImpl(typeRef)->type()); } WKTypeRef WKRetain(WKTypeRef typeRef) { - static_cast<APIObject*>(const_cast<void*>(typeRef))->ref(); + toImpl(typeRef)->ref(); + return typeRef; } void WKRelease(WKTypeRef typeRef) { - static_cast<APIObject*>(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 24c555dc0..f1a1ea546 100644 --- a/Source/WebKit2/Shared/API/c/WKURL.cpp +++ b/Source/WebKit2/Shared/API/c/WKURL.cpp @@ -32,17 +32,17 @@ using namespace WebKit; WKTypeID WKURLGetTypeID() { - return toAPI(WebURL::APIType); + return toAPI(API::URL::APIType); } WKURLRef WKURLCreateWithUTF8CString(const char* string) { - return toAPI(WebURL::create(String::fromUTF8(string)).leakRef()); + return toAPI(&API::URL::create(String::fromUTF8(string)).leakRef()); } WKURLRef WKURLCreateWithBaseURL(WKURLRef baseURL, const char* relative) { - return toAPI(WebURL::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 114c74190..736e1f3e6 100644 --- a/Source/WebKit2/Shared/API/c/WKURLRequest.cpp +++ b/Source/WebKit2/Shared/API/c/WKURLRequest.cpp @@ -26,26 +26,27 @@ #include "config.h" #include "WKURLRequest.h" +#include "APIURLRequest.h" #include "WKAPICast.h" -#include "WebURLRequest.h" -#include <WebCore/KURL.h> +#include "WKData.h" +#include <WebCore/URL.h> using namespace WebCore; using namespace WebKit; WKTypeID WKURLRequestGetTypeID() { - return toAPI(WebURLRequest::APIType); + return toAPI(API::URLRequest::APIType); } WKURLRequestRef WKURLRequestCreateWithWKURL(WKURLRef url) { - return toAPI(WebURLRequest::create(KURL(KURL(), toImpl(url)->string())).leakRef()); + return toAPI(&API::URLRequest::create(URL(URL(), toImpl(url)->string())).leakRef()); } WKURLRef WKURLRequestCopyURL(WKURLRequestRef requestRef) { - return toCopiedURLAPI(toImpl(requestRef)->url()); + return toCopiedURLAPI(toImpl(requestRef)->resourceRequest().url()); } WKURLRef WKURLRequestCopyFirstPartyForCookies(WKURLRequestRef requestRef) @@ -58,7 +59,14 @@ 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) { - WebURLRequest::setDefaultTimeoutInterval(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.cpp b/Source/WebKit2/Shared/API/c/WKURLResponse.cpp index c5491840b..b8a8a90bc 100644 --- a/Source/WebKit2/Shared/API/c/WKURLResponse.cpp +++ b/Source/WebKit2/Shared/API/c/WKURLResponse.cpp @@ -26,15 +26,15 @@ #include "config.h" #include "WKURLResponse.h" +#include "APIURLResponse.h" #include "WKAPICast.h" -#include "WebURLResponse.h" -#include <WebCore/KURL.h> +#include <WebCore/URL.h> using namespace WebKit; WKTypeID WKURLResponseGetTypeID() { - return toAPI(WebURLResponse::APIType); + return toAPI(API::URLResponse::APIType); } WKURLRef WKURLResponseCopyURL(WKURLResponseRef responseRef) 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/soup/WKBaseSoup.h b/Source/WebKit2/Shared/API/c/WKUserContentInjectedFrames.h index 6189e4c97..06f0a7159 100644 --- a/Source/WebKit2/Shared/API/c/soup/WKBaseSoup.h +++ b/Source/WebKit2/Shared/API/c/WKUserContentInjectedFrames.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Igalia S.L. + * Copyright (C) 2012 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,13 +23,13 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKBaseSoup_h -#define WKBaseSoup_h +#ifndef WKUserContentInjectedFrames_h +#define WKUserContentInjectedFrames_h -#ifndef WKBase_h -#error "Please #include \"WKBase.h\" instead of this file directly." -#endif +enum WKUserContentInjectedFrames { + kWKInjectInAllFrames, + kWKInjectInTopFrameOnly +}; +typedef enum WKUserContentInjectedFrames WKUserContentInjectedFrames; -typedef const struct OpaqueWKSoupRequestManager* WKSoupRequestManagerRef; - -#endif /* WKBaseSoup_h */ +#endif /* WKUserContentInjectedFrames_h */ 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/mac/WKBaseMac.h b/Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h index 772bdfad5..45d241072 100644 --- a/Source/WebKit2/Shared/API/c/mac/WKBaseMac.h +++ b/Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2012 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,13 +23,13 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKBaseMac_h -#define WKBaseMac_h +#ifndef WKUserScriptInjectionTime_h +#define WKUserScriptInjectionTime_h -#ifndef WKBase_h -#error "Please #include \"WKBase.h\" instead of this file directly." -#endif +enum _WKUserScriptInjectionTime { + kWKInjectAtDocumentStart, + kWKInjectAtDocumentEnd +}; +typedef enum _WKUserScriptInjectionTime _WKUserScriptInjectionTime; -typedef const struct OpaqueWKObjCTypeWrapper* WKObjCTypeWrapperRef; - -#endif /* WKBaseMac_h */ +#endif /* WKUserScriptInjectionTime_h */ diff --git a/Source/WebKit2/Shared/API/c/cf/WKErrorCF.cpp b/Source/WebKit2/Shared/API/c/cf/WKErrorCF.cpp deleted file mode 100644 index 8c65b0a8e..000000000 --- a/Source/WebKit2/Shared/API/c/cf/WKErrorCF.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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. - */ - -#include "config.h" -#include "WKErrorCF.h" - -#include "WKAPICast.h" -#include "WebError.h" - -using namespace WebCore; -using namespace WebKit; - -WKErrorRef WKErrorCreateWithCFError(CFErrorRef cfError) -{ - RefPtr<WebError> error = WebError::create(ResourceError(cfError)); - return toAPI(error.release().leakRef()); -} - -CFErrorRef WKErrorCopyCFError(CFAllocatorRef alloc, WKErrorRef error) -{ - RetainPtr<CFErrorRef> cfError = toImpl(error)->platformError().cfError(); - return cfError.leakRef(); -} diff --git a/Source/WebKit2/Shared/API/c/cf/WKURLCF.cpp b/Source/WebKit2/Shared/API/c/cf/WKURLCF.cpp deleted file mode 100644 index f04ecfd26..000000000 --- a/Source/WebKit2/Shared/API/c/cf/WKURLCF.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 "WKURLCF.h" - -#include "WKAPICast.h" -#include <WebCore/CFURLExtras.h> -#include <wtf/PassRefPtr.h> -#include <wtf/RefPtr.h> -#include <wtf/text/CString.h> -#include <wtf/text/WTFString.h> - -using namespace WebCore; -using namespace WebKit; - -WKURLRef WKURLCreateWithCFURL(CFURLRef cfURL) -{ - if (!cfURL) - return 0; - - CString urlBytes; - getURLBytes(cfURL, urlBytes); - - return toCopiedURLAPI(urlBytes.data()); -} - -CFURLRef WKURLCopyCFURL(CFAllocatorRef allocatorRef, WKURLRef URLRef) -{ - ASSERT(!toImpl(URLRef)->string().isNull()); - - // We first create a CString and then create the CFURL from it. This will ensure that the CFURL is stored in - // UTF-8 which uses less memory and is what WebKit clients might expect. - - // This pattern of using UTF-8 and then falling back to Latin1 on failure matches KURL::createCFString with the - // major differnce being that KURL does not do a UTF-8 conversion and instead chops off the high bits of the UTF-16 - // character sequence. - - CString buffer = toImpl(URLRef)->string().utf8(); - CFURLRef result = CFURLCreateAbsoluteURLWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(buffer.data()), buffer.length(), kCFStringEncodingUTF8, 0, true); - if (!result) - result = CFURLCreateAbsoluteURLWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(buffer.data()), buffer.length(), kCFStringEncodingISOLatin1, 0, true); - return result; -} diff --git a/Source/WebKit2/Shared/API/c/cf/WKURLCF.h b/Source/WebKit2/Shared/API/c/cf/WKURLCF.h deleted file mode 100644 index 394800d73..000000000 --- a/Source/WebKit2/Shared/API/c/cf/WKURLCF.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 WKURLCF_h -#define WKURLCF_h - -#include <CoreFoundation/CoreFoundation.h> -#include <WebKit2/WKBase.h> - -#ifdef __cplusplus -extern "C" { -#endif - -WK_EXPORT WKURLRef WKURLCreateWithCFURL(CFURLRef URL); -WK_EXPORT CFURLRef WKURLCopyCFURL(CFAllocatorRef alloc, WKURLRef URL); - -#ifdef __cplusplus -} -#endif - -#endif /* WKURLCF_h */ diff --git a/Source/WebKit2/Shared/API/c/cf/WKURLRequestCF.h b/Source/WebKit2/Shared/API/c/cf/WKURLRequestCF.h deleted file mode 100644 index fb7dab2d6..000000000 --- a/Source/WebKit2/Shared/API/c/cf/WKURLRequestCF.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 WKURLRequestCF_h -#define WKURLRequestCF_h - -#include <CFNetwork/CFURLRequestPriv.h> -#include <WebKit2/WKBase.h> - -#ifdef __cplusplus -extern "C" { -#endif - -WK_EXPORT WKURLRequestRef WKURLRequestCreateWithCFURLRequest(CFURLRequestRef urlRequest); -WK_EXPORT CFURLRequestRef WKURLRequestCopyCFURLRequest(CFAllocatorRef alloc, WKURLRequestRef urlRequest); - -#ifdef __cplusplus -} -#endif - -#endif /* WKURLRequestCF_h */ diff --git a/Source/WebKit2/Shared/API/c/cf/WKURLResponseCF.h b/Source/WebKit2/Shared/API/c/cf/WKURLResponseCF.h deleted file mode 100644 index 5ce718424..000000000 --- a/Source/WebKit2/Shared/API/c/cf/WKURLResponseCF.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 WKURLResponseCF_h -#define WKURLResponseCF_h - -#include <CFNetwork/CFURLResponsePriv.h> -#include <WebKit2/WKBase.h> - -#ifdef __cplusplus -extern "C" { -#endif - -WK_EXPORT WKURLResponseRef WKURLResponseCreateWithCFURLResponse(CFURLResponseRef urlResponse); -WK_EXPORT CFURLResponseRef WKURLResponseCopyCFURLResponse(CFAllocatorRef alloc, WKURLResponseRef urlResponse); - -#ifdef __cplusplus -} -#endif - -#endif /* WKURLResponseCF_h */ diff --git a/Source/WebKit2/Shared/API/c/cg/WKGraphicsContextCG.cpp b/Source/WebKit2/Shared/API/c/cg/WKGraphicsContextCG.cpp deleted file mode 100644 index aa7a77e83..000000000 --- a/Source/WebKit2/Shared/API/c/cg/WKGraphicsContextCG.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ - - -#include "config.h" -#include "WKGraphicsContextCG.h" - -#include "WKSharedAPICast.h" -#include "WebGraphicsContext.h" - -using namespace WebKit; - -CGContextRef WKGraphicsContextGetCGContext(WKGraphicsContextRef graphicsContextRef) -{ - return toImpl(graphicsContextRef)->platformContext(); -} diff --git a/Source/WebKit2/Shared/API/c/cg/WKGraphicsContextCG.h b/Source/WebKit2/Shared/API/c/cg/WKGraphicsContextCG.h deleted file mode 100644 index 06e9df092..000000000 --- a/Source/WebKit2/Shared/API/c/cg/WKGraphicsContextCG.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 WKGraphicsContextCG_h -#define WKGraphicsContextCG_h - -#include <CoreGraphics/CGContext.h> -#include <WebKit2/WKBase.h> - -#ifdef __cplusplus -extern "C" { -#endif - -WK_EXPORT CGContextRef WKGraphicsContextGetCGContext(WKGraphicsContextRef graphicsContext); - -#ifdef __cplusplus -} -#endif - -#endif /* WKGraphicsContextCG_h */ diff --git a/Source/WebKit2/Shared/API/c/efl/WKArrayEfl.cpp b/Source/WebKit2/Shared/API/c/efl/WKArrayEfl.cpp deleted file mode 100644 index 9778a99e8..000000000 --- a/Source/WebKit2/Shared/API/c/efl/WKArrayEfl.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2013 Samsung Electronics. 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 "WKArrayEfl.h" - -#include "WKArray.h" -#include "WKString.h" -#include <Eina.h> -#include <WebKit2/WKRetainPtr.h> -#include <wtf/Vector.h> - -using namespace WebKit; - -WKArrayRef WKArrayCreateWithEinaList(Eina_List* array, WKTypeRef (*createWKType)(void*)) -{ - unsigned count = eina_list_count(array); - if (!count) - return WKArrayRef(); - - Vector<WKTypeRef> vector; - vector.reserveInitialCapacity(count); - - Eina_List* l = 0; - void* data = 0; - EINA_LIST_FOREACH(array, l, data) - vector.uncheckedAppend(createWKType(data)); - - return WKArrayCreateAdoptingValues(vector.data(), count); -} diff --git a/Source/WebKit2/Shared/API/c/efl/WKArrayEfl.h b/Source/WebKit2/Shared/API/c/efl/WKArrayEfl.h deleted file mode 100644 index bd4b9a57b..000000000 --- a/Source/WebKit2/Shared/API/c/efl/WKArrayEfl.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2013 Samsung Electronics. 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 WKArrayEfl_h -#define WKArrayEfl_h - -#include <WebKit2/WKBase.h> - -/** - * @typedef Eina_List - * Type for a generic double linked list. - */ -typedef struct _Eina_List Eina_List; - -WK_EXPORT WKArrayRef WKArrayCreateWithEinaList(Eina_List*, WKTypeRef (*createWKType)(void*)); - -#endif // WKArrayEfl_h diff --git a/Source/WebKit2/Shared/API/c/efl/WKBaseEfl.h b/Source/WebKit2/Shared/API/c/efl/WKBaseEfl.h deleted file mode 100644 index 9c07f8e0c..000000000 --- a/Source/WebKit2/Shared/API/c/efl/WKBaseEfl.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2012 Samsung Electronics - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this program; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef WKBaseEfl_h -#define WKBaseEfl_h - -#ifndef WKBase_h -#error "Please #include \"WKBase.h\" instead of this file directly." -#endif - -typedef const struct OpaqueWKView* WKViewRef; -typedef const struct OpaqueWKPopupItem* WKPopupItemRef; -typedef const struct OpaqueWKPopupMenuListener* WKPopupMenuListenerRef; -typedef const struct OpaqueWKTouchPoint* WKTouchPointRef; -typedef const struct OpaqueWKTouchEvent* WKTouchEventRef; - -#endif /* WKBaseEfl_h */ diff --git a/Source/WebKit2/Shared/API/c/gtk/WKBaseGtk.h b/Source/WebKit2/Shared/API/c/gtk/WKBaseGtk.h deleted file mode 100644 index eb88f702a..000000000 --- a/Source/WebKit2/Shared/API/c/gtk/WKBaseGtk.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. - * Copyright (C) 2011 Igalia S.L. - * - * 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 WKBaseGtk_h -#define WKBaseGtk_h - -#ifndef WKBase_h -#error "Please #include \"WKBase.h\" instead of this file directly." -#endif - -#include <stdbool.h> - -typedef const struct OpaqueWKView* WKViewRef; - -#endif /* WKBaseGtk_h */ diff --git a/Source/WebKit2/Shared/API/c/gtk/WKGraphicsContextGtk.cpp b/Source/WebKit2/Shared/API/c/gtk/WKGraphicsContextGtk.cpp deleted file mode 100644 index 69695f159..000000000 --- a/Source/WebKit2/Shared/API/c/gtk/WKGraphicsContextGtk.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2011 Igalia SL 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 "WKGraphicsContextGtk.h" - -#include "WKSharedAPICast.h" -#include "WebGraphicsContext.h" - -using namespace WebKit; - -cairo_t* WKGraphicsContextGetGtkContext(WKGraphicsContextRef graphicsContextRef) -{ - return toImpl(graphicsContextRef)->platformContext(); -} diff --git a/Source/WebKit2/Shared/API/c/gtk/WKGraphicsContextGtk.h b/Source/WebKit2/Shared/API/c/gtk/WKGraphicsContextGtk.h deleted file mode 100644 index 25fcfc424..000000000 --- a/Source/WebKit2/Shared/API/c/gtk/WKGraphicsContextGtk.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2011 Igalia SL 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 WKGraphicsContextGtk_h -#define WKGraphicsContextGtk_h - -#include <WebKit2/WKBase.h> - -#include <cairo.h> - -#ifdef __cplusplus -extern "C" { -#endif - -WK_EXPORT cairo_t* WKGraphicsContextGetGtkContext(WKGraphicsContextRef); - -#ifdef __cplusplus -} -#endif - -#endif /* WKGraphicsContextGtk_h */ diff --git a/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.h b/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.h deleted file mode 100644 index d098f34ca..000000000 --- a/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 WKCertificateInfoMac_h -#define WKCertificateInfoMac_h - -#include <CoreFoundation/CoreFoundation.h> -#include <WebKit2/WKBase.h> - -#ifdef __cplusplus -extern "C" { -#endif - -WK_EXPORT WKCertificateInfoRef WKCertificateInfoCreateWithCertficateChain(CFArrayRef certificateChain); -WK_EXPORT CFArrayRef WKCertificateInfoGetCertificateChain(WKCertificateInfoRef certificateInfo); - -#ifdef __cplusplus -} -#endif - -#endif /* WKCertificateInfoMac_h */ diff --git a/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.mm b/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.mm deleted file mode 100644 index 34dd43151..000000000 --- a/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.mm +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - */ - -#import "config.h" -#import "WKCertificateInfoMac.h" - -#import "WKAPICast.h" -#import "WebCertificateInfo.h" - -using namespace WebKit; - -WKCertificateInfoRef WKCertificateInfoCreateWithCertficateChain(CFArrayRef certificateChain) -{ - RefPtr<WebCertificateInfo> certificateInfo = WebCertificateInfo::create(PlatformCertificateInfo(certificateChain)); - return toAPI(certificateInfo.release().leakRef()); -} - -CFArrayRef WKCertificateInfoGetCertificateChain(WKCertificateInfoRef certificateInfoRef) -{ - return toImpl(certificateInfoRef)->platformCertificateInfo().certificateChain(); -} diff --git a/Source/WebKit2/Shared/API/c/mac/WKURLRequestNS.h b/Source/WebKit2/Shared/API/c/mac/WKURLRequestNS.h deleted file mode 100644 index 4cdfec847..000000000 --- a/Source/WebKit2/Shared/API/c/mac/WKURLRequestNS.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 WKURLRequestNS_h -#define WKURLRequestNS_h - -#include <Foundation/Foundation.h> -#include <WebKit2/WKBase.h> - -#ifdef __cplusplus -extern "C" { -#endif - -WK_EXPORT WKURLRequestRef WKURLRequestCreateWithNSURLRequest(NSURLRequest* urlRequest); -WK_EXPORT NSURLRequest* WKURLRequestCopyNSURLRequest(WKURLRequestRef urlRequest); - -#ifdef __cplusplus -} -#endif - -#endif /* WKURLRequestNS_h */ diff --git a/Source/WebKit2/Shared/API/c/mac/WKURLRequestNS.mm b/Source/WebKit2/Shared/API/c/mac/WKURLRequestNS.mm deleted file mode 100644 index 82dce910f..000000000 --- a/Source/WebKit2/Shared/API/c/mac/WKURLRequestNS.mm +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. - */ - -#import "config.h" -#import "WKURLRequestNS.h" - -#import "WKAPICast.h" -#import "WebURLRequest.h" - -using namespace WebKit; - -WKURLRequestRef WKURLRequestCreateWithNSURLRequest(NSURLRequest* urlRequest) -{ - RetainPtr<NSURLRequest> copiedURLRequest = adoptNS([urlRequest copy]); - RefPtr<WebURLRequest> request = WebURLRequest::create(copiedURLRequest.get()); - return toAPI(request.release().leakRef()); -} - -NSURLRequest* WKURLRequestCopyNSURLRequest(WKURLRequestRef urlRequest) -{ - return [toImpl(urlRequest)->platformRequest() copy]; -} diff --git a/Source/WebKit2/Shared/API/c/mac/WKURLResponseNS.h b/Source/WebKit2/Shared/API/c/mac/WKURLResponseNS.h deleted file mode 100644 index 0bbc14943..000000000 --- a/Source/WebKit2/Shared/API/c/mac/WKURLResponseNS.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 WKURLResponseNS_h -#define WKURLResponseNS_h - -#include <Foundation/Foundation.h> -#include <WebKit2/WKBase.h> - -#ifdef __cplusplus -extern "C" { -#endif - -WK_EXPORT WKURLResponseRef WKURLResponseCreateWithNSURLResponse(NSURLResponse* urlResponse); -WK_EXPORT NSURLResponse* WKURLResponseCopyNSURLResponse(WKURLResponseRef urlResponse); - -#ifdef __cplusplus -} -#endif - -#endif /* WKURLResponseNS_h */ diff --git a/Source/WebKit2/Shared/API/c/mac/WKWebArchive.cpp b/Source/WebKit2/Shared/API/c/mac/WKWebArchive.cpp deleted file mode 100644 index c9d4fe631..000000000 --- a/Source/WebKit2/Shared/API/c/mac/WKWebArchive.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 "WKWebArchive.h" - -#include "ImmutableArray.h" -#include "InjectedBundleRangeHandle.h" -#include "WKBundleAPICast.h" -#include "WKSharedAPICast.h" -#include "WebArchive.h" -#include "WebArchiveResource.h" -#include "WebData.h" - -using namespace WebKit; - -WKTypeID WKWebArchiveGetTypeID() -{ - return toAPI(WebArchive::APIType); -} - -WKWebArchiveRef WKWebArchiveCreate(WKWebArchiveResourceRef mainResourceRef, WKArrayRef subresourcesRef, WKArrayRef subframeArchivesRef) -{ - RefPtr<WebArchive> webArchive = WebArchive::create(toImpl(mainResourceRef), toImpl(subresourcesRef), toImpl(subframeArchivesRef)); - return toAPI(webArchive.release().leakRef()); -} - -WKWebArchiveRef WKWebArchiveCreateWithData(WKDataRef dataRef) -{ - RefPtr<WebArchive> webArchive = WebArchive::create(toImpl(dataRef)); - return toAPI(webArchive.release().leakRef()); -} - -WKWebArchiveRef WKWebArchiveCreateFromRange(WKBundleRangeHandleRef rangeHandleRef) -{ - RefPtr<WebArchive> webArchive = WebArchive::create(toImpl(rangeHandleRef)->coreRange()); - return toAPI(webArchive.release().leakRef()); -} - -WKWebArchiveResourceRef WKWebArchiveCopyMainResource(WKWebArchiveRef webArchiveRef) -{ - RefPtr<WebArchiveResource> mainResource = toImpl(webArchiveRef)->mainResource(); - return toAPI(mainResource.release().leakRef()); -} - -WKArrayRef WKWebArchiveCopySubresources(WKWebArchiveRef webArchiveRef) -{ - RefPtr<ImmutableArray> subresources = toImpl(webArchiveRef)->subresources(); - return toAPI(subresources.release().leakRef()); -} - -WKArrayRef WKWebArchiveCopySubframeArchives(WKWebArchiveRef webArchiveRef) -{ - RefPtr<ImmutableArray> subframeArchives = toImpl(webArchiveRef)->subframeArchives(); - return toAPI(subframeArchives.release().leakRef()); -} - -WKDataRef WKWebArchiveCopyData(WKWebArchiveRef webArchiveRef) -{ - RefPtr<WebData> data = toImpl(webArchiveRef)->data(); - return toAPI(data.release().leakRef()); -} diff --git a/Source/WebKit2/Shared/API/c/mac/WKWebArchiveResource.cpp b/Source/WebKit2/Shared/API/c/mac/WKWebArchiveResource.cpp deleted file mode 100644 index 7ae6d3db2..000000000 --- a/Source/WebKit2/Shared/API/c/mac/WKWebArchiveResource.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 "WKWebArchiveResource.h" - -#include "WKSharedAPICast.h" -#include "WebArchiveResource.h" -#include "WebData.h" - -using namespace WebKit; - -WKTypeID WKWebArchiveResourceGetTypeID() -{ - return toAPI(WebArchiveResource::APIType); -} - -WKWebArchiveResourceRef WKWebArchiveResourceCreate(WKDataRef dataRef, WKURLRef URLRef, WKStringRef MIMETypeRef, WKStringRef textEncodingRef) -{ - RefPtr<WebArchiveResource> webArchiveResource = WebArchiveResource::create(toImpl(dataRef), toWTFString(URLRef), toWTFString(MIMETypeRef), toWTFString(textEncodingRef)); - return toAPI(webArchiveResource.release().leakRef()); -} - -WKDataRef WKWebArchiveResourceCopyData(WKWebArchiveResourceRef webArchiveResourceRef) -{ - RefPtr<WebData> data = toImpl(webArchiveResourceRef)->data(); - return toAPI(data.release().leakRef()); -} - -WKURLRef WKWebArchiveResourceCopyURL(WKWebArchiveResourceRef webArchiveResourceRef) -{ - return toCopiedURLAPI(toImpl(webArchiveResourceRef)->URL()); -} - -WKStringRef WKWebArchiveResourceCopyMIMEType(WKWebArchiveResourceRef webArchiveResourceRef) -{ - return toCopiedAPI(toImpl(webArchiveResourceRef)->MIMEType()); -} - -WKStringRef WKWebArchiveResourceCopyTextEncoding(WKWebArchiveResourceRef webArchiveResourceRef) -{ - return toCopiedAPI(toImpl(webArchiveResourceRef)->textEncoding()); -} diff --git a/Source/WebKit2/Shared/API/c/qt/WKImageQt.cpp b/Source/WebKit2/Shared/API/c/qt/WKImageQt.cpp index 60388f4fa..6d5cc5a10 100644 --- a/Source/WebKit2/Shared/API/c/qt/WKImageQt.cpp +++ b/Source/WebKit2/Shared/API/c/qt/WKImageQt.cpp @@ -47,7 +47,7 @@ WKImageRef WKImageCreateFromQImage(const QImage& image) RefPtr<WebImage> webImage = WebImage::create(image.size(), static_cast<ImageOptions>(0)); if (!webImage->bitmap()) return 0; - OwnPtr<GraphicsContext> graphicsContext = webImage->bitmap()->createGraphicsContext(); + auto graphicsContext = webImage->bitmap()->createGraphicsContext(); QPainter* painter = graphicsContext->platformContext(); painter->drawImage(QPoint(0, 0), image); return toAPI(webImage.release().leakRef()); |