summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/WebKit2/Shared/API/c
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/WebKit/WebKit2/Shared/API/c')
-rw-r--r--third_party/WebKit/WebKit2/Shared/API/c/WKBase.h3
-rw-r--r--third_party/WebKit/WebKit2/Shared/API/c/WKImage.cpp47
-rw-r--r--third_party/WebKit/WebKit2/Shared/API/c/WKImage.h51
-rw-r--r--third_party/WebKit/WebKit2/Shared/API/c/WKSharedAPICast.h38
-rw-r--r--third_party/WebKit/WebKit2/Shared/API/c/cg/WKImageCG.cpp39
-rw-r--r--third_party/WebKit/WebKit2/Shared/API/c/cg/WKImageCG.h42
6 files changed, 216 insertions, 4 deletions
diff --git a/third_party/WebKit/WebKit2/Shared/API/c/WKBase.h b/third_party/WebKit/WebKit2/Shared/API/c/WKBase.h
index cf5bb5b..0e7984a 100644
--- a/third_party/WebKit/WebKit2/Shared/API/c/WKBase.h
+++ b/third_party/WebKit/WebKit2/Shared/API/c/WKBase.h
@@ -44,11 +44,12 @@ typedef const struct OpaqueWKDictionary* WKDictionaryRef;
typedef struct OpaqueWKDictionary* WKMutableDictionaryRef;
typedef const struct OpaqueWKBoolean* WKBooleanRef;
+typedef const struct OpaqueWKCertificateInfo* WKCertificateInfoRef;
typedef const struct OpaqueWKContextMenuItem* WKContextMenuItemRef;
typedef const struct OpaqueWKData* WKDataRef;
typedef const struct OpaqueWKDouble* WKDoubleRef;
typedef const struct OpaqueWKError* WKErrorRef;
-typedef const struct OpaqueWKCertificateInfo* WKCertificateInfoRef;
+typedef const struct OpaqueWKImage* WKImageRef;
typedef const struct OpaqueWKSecurityOrigin* WKSecurityOriginRef;
typedef const struct OpaqueWKSerializedScriptValue* WKSerializedScriptValueRef;
typedef const struct OpaqueWKString* WKStringRef;
diff --git a/third_party/WebKit/WebKit2/Shared/API/c/WKImage.cpp b/third_party/WebKit/WebKit2/Shared/API/c/WKImage.cpp
new file mode 100644
index 0000000..0bf21df1
--- /dev/null
+++ b/third_party/WebKit/WebKit2/Shared/API/c/WKImage.cpp
@@ -0,0 +1,47 @@
+/*
+ * 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 "WKImage.h"
+
+#include "WKSharedAPICast.h"
+#include "WebImage.h"
+
+using namespace WebKit;
+
+WKTypeID WKImageGetTypeID()
+{
+ return toAPI(WebImage::APIType);
+}
+
+WKImageRef WKImageCreate(WKSize size, WKImageOptions options)
+{
+ RefPtr<WebImage> webImage = WebImage::create(toIntSize(size), toImageOptions(options));
+ return toAPI(webImage.release().leakRef());
+}
+
+WKSize WKImageGetSize(WKImageRef imageRef)
+{
+ return toAPI(toImpl(imageRef)->size());
+}
diff --git a/third_party/WebKit/WebKit2/Shared/API/c/WKImage.h b/third_party/WebKit/WebKit2/Shared/API/c/WKImage.h
new file mode 100644
index 0000000..2797cc5
--- /dev/null
+++ b/third_party/WebKit/WebKit2/Shared/API/c/WKImage.h
@@ -0,0 +1,51 @@
+/*
+ * 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 WKImage_h
+#define WKImage_h
+
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKGeometry.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ kWKImageOptionsSharable = 1 << 0,
+};
+typedef uint32_t WKImageOptions;
+
+WK_EXPORT WKTypeID WKImageGetTypeID();
+
+WK_EXPORT WKImageRef WKImageCreate(WKSize size, WKImageOptions options);
+
+WK_EXPORT WKSize WKImageGetSize(WKImageRef image);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKImage_h */
diff --git a/third_party/WebKit/WebKit2/Shared/API/c/WKSharedAPICast.h b/third_party/WebKit/WebKit2/Shared/API/c/WKSharedAPICast.h
index 5047c5d..7af434b 100644
--- a/third_party/WebKit/WebKit2/Shared/API/c/WKSharedAPICast.h
+++ b/third_party/WebKit/WebKit2/Shared/API/c/WKSharedAPICast.h
@@ -26,12 +26,14 @@
#ifndef WKSharedAPICast_h
#define WKSharedAPICast_h
+#include "ImageOptions.h"
#include "SameDocumentNavigationType.h"
#include "WKBase.h"
#include "WKContextMenuItemTypes.h"
#include "WKEvent.h"
#include "WKFindOptions.h"
#include "WKGeometry.h"
+#include "WKImage.h"
#include "WKPageLoadTypes.h"
#include "WebError.h"
#include "WebEvent.h"
@@ -42,7 +44,6 @@
#include <WebCore/ContextMenuItem.h>
#include <WebCore/FloatRect.h>
#include <WebCore/FrameLoaderTypes.h>
-#include <WebCore/IntPoint.h>
#include <WebCore/IntRect.h>
#include <wtf/TypeTraits.h>
@@ -55,6 +56,7 @@ class MutableDictionary;
class WebCertificateInfo;
class WebContextMenuItem;
class WebData;
+class WebImage;
class WebSecurityOrigin;
class WebSerializedScriptValue;
class WebURLRequest;
@@ -76,6 +78,7 @@ 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(WKImageRef, WebImage)
WK_ADD_API_MAPPING(WKMutableArrayRef, MutableArray)
WK_ADD_API_MAPPING(WKMutableDictionaryRef, MutableDictionary)
WK_ADD_API_MAPPING(WKSecurityOriginRef, WebSecurityOrigin)
@@ -171,17 +174,28 @@ inline ProxyingRefPtr<WebError> toAPI(const WebCore::ResourceError& error)
/* Geometry conversions */
-inline WebCore::FloatRect toImpl(const WKRect& wkRect)
+inline WebCore::FloatRect toFloatRect(const WKRect& wkRect)
{
return WebCore::FloatRect(static_cast<float>(wkRect.origin.x), static_cast<float>(wkRect.origin.y),
static_cast<float>(wkRect.size.width), static_cast<float>(wkRect.size.height));
}
-inline WebCore::IntPoint toImpl(const WKPoint& wkPoint)
+inline WebCore::IntSize toIntSize(const WKSize& wkSize)
+{
+ return WebCore::IntSize(static_cast<int>(wkSize.width), static_cast<int>(wkSize.height));
+}
+
+inline WebCore::IntPoint toIntPoint(const WKPoint& wkPoint)
{
return WebCore::IntPoint(static_cast<int>(wkPoint.x), static_cast<int>(wkPoint.y));
}
+inline WebCore::IntRect toIntRect(const WKRect& wkRect)
+{
+ return WebCore::IntRect(static_cast<int>(wkRect.origin.x), static_cast<int>(wkRect.origin.y),
+ static_cast<int>(wkRect.size.width), static_cast<int>(wkRect.size.height));
+}
+
inline WKRect toAPI(const WebCore::FloatRect& rect)
{
WKRect wkRect;
@@ -202,6 +216,14 @@ inline WKRect toAPI(const WebCore::IntRect& rect)
return wkRect;
}
+inline WKSize toAPI(const WebCore::IntSize& size)
+{
+ WKSize wkSize;
+ wkSize.width = size.width();
+ wkSize.height = size.height();
+ return wkSize;
+}
+
inline WKPoint toAPI(const WebCore::IntPoint& point)
{
WKPoint wkPoint;
@@ -698,6 +720,16 @@ inline WKSameDocumentNavigationType toAPI(SameDocumentNavigationType type)
return wkType;
}
+inline ImageOptions toImageOptions(WKImageOptions wkImageOptions)
+{
+ unsigned imageOptions = 0;
+
+ if (wkImageOptions & kWKImageOptionsSharable)
+ imageOptions |= ImageOptionsSharable;
+
+ return static_cast<ImageOptions>(imageOptions);
+}
+
} // namespace WebKit
#endif // WKSharedAPICast_h
diff --git a/third_party/WebKit/WebKit2/Shared/API/c/cg/WKImageCG.cpp b/third_party/WebKit/WebKit2/Shared/API/c/cg/WKImageCG.cpp
new file mode 100644
index 0000000..687415c
--- /dev/null
+++ b/third_party/WebKit/WebKit2/Shared/API/c/cg/WKImageCG.cpp
@@ -0,0 +1,39 @@
+/*
+ * 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 "WKImageCG.h"
+
+#include "WKSharedAPICast.h"
+#include "WebImage.h"
+#include <WebCore/GraphicsContext.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+CGImageRef WKImageCreateCGImage(WKImageRef imageRef)
+{
+ OwnPtr<GraphicsContext> sourceContext = toImpl(imageRef)->backingStore()->createGraphicsContext();
+ return CGBitmapContextCreateImage(sourceContext->platformContext());
+}
diff --git a/third_party/WebKit/WebKit2/Shared/API/c/cg/WKImageCG.h b/third_party/WebKit/WebKit2/Shared/API/c/cg/WKImageCG.h
new file mode 100644
index 0000000..7705c31
--- /dev/null
+++ b/third_party/WebKit/WebKit2/Shared/API/c/cg/WKImageCG.h
@@ -0,0 +1,42 @@
+/*
+ * 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 WKImageCG_h
+#define WKImageCG_h
+
+#include <CoreGraphics/CGImage.h>
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT CGImageRef WKImageCreateCGImage(WKImageRef image);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKImageCG_h */