WebKit2: Add API for getting snapshots
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Dec 2010 00:01:08 +0000 (00:01 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Dec 2010 00:01:08 +0000 (00:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=51656

Reviewed by Anders Carlsson.

* Shared/API/c/WKBase.h:
* Shared/API/c/WKImage.cpp: Added.
(WKImageGetTypeID):
(WKImageCreate):
(WKImageGetSize):
* Shared/API/c/WKImage.h: Added.
* Shared/WebImage.cpp: Added.
(WebKit::WebImage::create):
(WebKit::WebImage::size):
* Shared/WebImage.h: Added.
(WebKit::WebImage::backingStore):
(WebKit::WebImage::WebImage):
(WebKit::WebImage::type):
Add a general purpose API image class.

* Shared/API/c/cg: Added.
* Shared/API/c/cg/WKImageCG.cpp: Added.
(WKImageCreateCGImage):
* Shared/API/c/cg/WKImageCG.h: Added.
Add function to convert a WKImageRef to a CGImageRef for platforms that use CG.

* Shared/API/c/WKSharedAPICast.h:
(WebKit::toFloatRect):
(WebKit::toIntSize):
(WebKit::toIntPoint):
(WebKit::toIntRect):
(WebKit::toImageOptions):
Make conversion functions that are ambiguous more explicit.

* Shared/APIObject.h:
* Shared/BackingStore.h:
(WebKit::BackingStore::isBackedBySharedMemory):
* Shared/ImageOptions.h: Added.
* Shared/UserMessageCoders.h:
(WebKit::UserMessageEncoder::baseEncode):
(WebKit::UserMessageDecoder::baseDecode):
Allow a WKImageRef to be passed in user messages.  Right now, it only
works if the image is sharable.

* UIProcess/API/C/WKPage.cpp:
(WKPageScaleWebView):
* UIProcess/WebUIClient.cpp:
(WebKit::WebUIClient::windowFrame):
Use the more explicit conversion function name.

* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageCreateSnapshotInViewCoordinates):
(WKBundlePageCreateSnapshotInDocumentCoordinates):
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp:
(WKBundlePageOverlaySetNeedsDisplay):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::snapshotInViewCoordinates):
(WebKit::WebPage::snapshotInDocumentCoordinates):
Add function to take the snapshot.

* WebProcess/WebPage/WebPage.h:
* WebKit2.pro:
* WebKit2.xcodeproj/project.pbxproj:
* win/WebKit2.vcproj:
Add new files.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@74698 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
WebKit2/ChangeLog
WebKit2/Shared/API/c/WKBase.h
WebKit2/Shared/API/c/WKImage.cpp [new file with mode: 0644]
WebKit2/Shared/API/c/WKImage.h [new file with mode: 0644]
WebKit2/Shared/API/c/WKSharedAPICast.h
WebKit2/Shared/API/c/cg/WKImageCG.cpp [new file with mode: 0644]
WebKit2/Shared/API/c/cg/WKImageCG.h [new file with mode: 0644]
WebKit2/Shared/APIObject.h
WebKit2/Shared/BackingStore.h
WebKit2/Shared/ImageOptions.h [new file with mode: 0644]
WebKit2/Shared/UserMessageCoders.h
WebKit2/Shared/WebImage.cpp [new file with mode: 0644]
WebKit2/Shared/WebImage.h [new file with mode: 0644]
WebKit2/UIProcess/API/C/WKPage.cpp
WebKit2/UIProcess/WebUIClient.cpp
WebKit2/WebKit2.pro
WebKit2/WebKit2.xcodeproj/project.pbxproj
WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp
WebKit2/WebProcess/WebPage/WebPage.cpp
WebKit2/WebProcess/WebPage/WebPage.h
WebKit2/win/WebKit2.vcproj

index 1168a6bfa2c587874accb01b12016d6eff1a2b82..66b7cc14f8c70f089728daad1add2ee4631e3241 100644 (file)
@@ -1,3 +1,72 @@
+2010-12-27  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        WebKit2: Add API for getting snapshots
+        https://bugs.webkit.org/show_bug.cgi?id=51656
+
+        * Shared/API/c/WKBase.h:
+        * Shared/API/c/WKImage.cpp: Added.
+        (WKImageGetTypeID):
+        (WKImageCreate):
+        (WKImageGetSize):
+        * Shared/API/c/WKImage.h: Added.
+        * Shared/WebImage.cpp: Added.
+        (WebKit::WebImage::create):
+        (WebKit::WebImage::size):
+        * Shared/WebImage.h: Added.
+        (WebKit::WebImage::backingStore):
+        (WebKit::WebImage::WebImage):
+        (WebKit::WebImage::type):
+        Add a general purpose API image class.
+
+        * Shared/API/c/cg: Added.
+        * Shared/API/c/cg/WKImageCG.cpp: Added.
+        (WKImageCreateCGImage):
+        * Shared/API/c/cg/WKImageCG.h: Added.
+        Add function to convert a WKImageRef to a CGImageRef for platforms that use CG.
+
+        * Shared/API/c/WKSharedAPICast.h:
+        (WebKit::toFloatRect):
+        (WebKit::toIntSize):
+        (WebKit::toIntPoint):
+        (WebKit::toIntRect):
+        (WebKit::toImageOptions):
+        Make conversion functions that are ambiguous more explicit.
+
+        * Shared/APIObject.h:
+        * Shared/BackingStore.h:
+        (WebKit::BackingStore::isBackedBySharedMemory):
+        * Shared/ImageOptions.h: Added.
+        * Shared/UserMessageCoders.h:
+        (WebKit::UserMessageEncoder::baseEncode):
+        (WebKit::UserMessageDecoder::baseDecode):
+        Allow a WKImageRef to be passed in user messages.  Right now, it only
+        works if the image is sharable.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageScaleWebView):
+        * UIProcess/WebUIClient.cpp:
+        (WebKit::WebUIClient::windowFrame):
+        Use the more explicit conversion function name.
+
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+        (WKBundlePageCreateSnapshotInViewCoordinates):
+        (WKBundlePageCreateSnapshotInDocumentCoordinates):
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
+        * WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp:
+        (WKBundlePageOverlaySetNeedsDisplay):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::snapshotInViewCoordinates):
+        (WebKit::WebPage::snapshotInDocumentCoordinates):
+        Add function to take the snapshot.
+
+        * WebProcess/WebPage/WebPage.h:
+        * WebKit2.pro:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * win/WebKit2.vcproj:
+        Add new files.
+
 2010-12-27  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Anders Carlsson.
index cf5bb5bf951259518d6f09dacaedccecea687533..0e7984a4e4c091c5528de53e249165e3a7e3b520 100644 (file)
@@ -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/WebKit2/Shared/API/c/WKImage.cpp b/WebKit2/Shared/API/c/WKImage.cpp
new file mode 100644 (file)
index 0000000..0bf21df
--- /dev/null
@@ -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/WebKit2/Shared/API/c/WKImage.h b/WebKit2/Shared/API/c/WKImage.h
new file mode 100644 (file)
index 0000000..2797cc5
--- /dev/null
@@ -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 */
index 5047c5dfe2abf91556e7ad1dedfb3fc7ed906a3c..7af434b21ca026c8fe7c0132d684343c70cd59b4 100644 (file)
 #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/WebKit2/Shared/API/c/cg/WKImageCG.cpp b/WebKit2/Shared/API/c/cg/WKImageCG.cpp
new file mode 100644 (file)
index 0000000..687415c
--- /dev/null
@@ -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/WebKit2/Shared/API/c/cg/WKImageCG.h b/WebKit2/Shared/API/c/cg/WKImageCG.h
new file mode 100644 (file)
index 0000000..7705c31
--- /dev/null
@@ -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 */
index e625b3a15b21a90527a558f75dfa48c290d186ec..6b402a352a947e403187bd2622395e26e3c4b4f2 100644 (file)
@@ -44,6 +44,7 @@ public:
         TypeData,
         TypeDictionary,
         TypeError,
+        TypeImage,
         TypeProtectionSpace,
         TypeSecurityOrigin,
         TypeSerializedScriptValue,
index 7b3c905955257da2d9eabc5bf6466eec27aa812f..f2c580d27de116223c8c39612c3f3b852b01ecac 100644 (file)
@@ -66,11 +66,12 @@ public:
     // Paint the backing store into the given context.
     void paint(WebCore::GraphicsContext&, const WebCore::IntPoint& dstPoint, const WebCore::IntRect& srcRect);
 
+    bool isBackedBySharedMemory() const { return m_sharedMemory; }
+
 private:
     BackingStore(const WebCore::IntSize&, void*);
     BackingStore(const WebCore::IntSize&, PassRefPtr<SharedMemory>);
 
-    bool isBackedBySharedMemory() const { return m_sharedMemory; }
     static size_t numBytesForSize(const WebCore::IntSize& size) { return size.width() * size.height() * 4; }
 
     void* data() const;
diff --git a/WebKit2/Shared/ImageOptions.h b/WebKit2/Shared/ImageOptions.h
new file mode 100644 (file)
index 0000000..3acc74a
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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 ImageOptions_h
+#define ImageOptions_h
+
+namespace WebKit {
+
+enum ImageOptions {
+    ImageOptionsSharable = 1 << 0,
+};
+
+} // namespace WebKit
+
+#endif // ImageOptions_h
index fff9de7a9b83bcf759765f77d63d4e7f979549b1..5cc5a9ef7bd8720755e8c1182f865d9956cd13e3 100644 (file)
@@ -28,6 +28,7 @@
 #include "ImmutableArray.h"
 #include "ImmutableDictionary.h"
 #include "WebCoreArgumentCoders.h"
+#include "WebImage.h"
 #include "WebNumber.h"
 #include "WebSerializedScriptValue.h"
 #include "WebString.h"
@@ -39,10 +40,11 @@ namespace WebKit {
 //   - Null -> Null
 //   - Array -> Array
 //   - Dictionary -> Dictionary
-//   - String -> String
 //   - SerializedScriptValue -> SerializedScriptValue
+//   - String -> String
 //   - UserContentURLPattern -> UserContentURLPattern
 //   - WebDouble -> WebDouble
+//   - WebImage -> WebImage
 //   - WebUInt64 -> WebUInt64
 //   - WebURL -> WebURL
 
@@ -115,6 +117,23 @@ public:
             encoder->encode(urlPattern->patternString());
             return true;
         }
+        case APIObject::TypeImage: {
+            WebImage* image = static_cast<WebImage*>(m_root);
+            if (!image->backingStore()->isBackedBySharedMemory()) {
+                encoder->encode(false);
+                return true;
+            }
+
+            SharedMemory::Handle handle;
+            if (!image->backingStore()->createHandle(handle))
+                return false;
+
+            encoder->encode(true);
+            
+            encoder->encode(image->size());
+            encoder->encode(handle);
+            return true;
+        }
         default:
             break;
         }
@@ -136,10 +155,11 @@ protected:
 //   - Null -> Null
 //   - Array -> Array
 //   - Dictionary -> Dictionary
-//   - String -> String
 //   - SerializedScriptValue -> SerializedScriptValue
+//   - String -> String
 //   - UserContentURLPattern -> UserContentURLPattern
 //   - WebDouble -> WebDouble
+//   - WebImage -> WebImage
 //   - WebUInt64 -> WebUInt64
 //   - WebURL -> WebURL
 
@@ -245,6 +265,25 @@ public:
             coder.m_root = WebUserContentURLPattern::create(string);
             break;
         }
+        case APIObject::TypeImage: {
+            bool didEncode = false;
+            if (!decoder->decode(didEncode))
+                return false;
+
+            if (!didEncode)
+                break;
+
+            WebCore::IntSize size;
+            if (!decoder->decode(size))
+                return false;
+
+            SharedMemory::Handle handle;
+            if (!decoder->decode(handle))
+                return false;
+
+            coder.m_root = WebImage::create(BackingStore::create(size, handle));
+            return true;
+        }
         default:
             break;
         }
diff --git a/WebKit2/Shared/WebImage.cpp b/WebKit2/Shared/WebImage.cpp
new file mode 100644 (file)
index 0000000..81f30fc
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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 "WebImage.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr<WebImage> WebImage::create(const IntSize& size, ImageOptions options)
+{
+    if (options & ImageOptionsSharable)
+        return WebImage::create(BackingStore::createSharable(size));
+    return WebImage::create(BackingStore::create(size));
+}
+
+PassRefPtr<WebImage> WebImage::create(PassRefPtr<BackingStore> backingStore)
+{
+    return adoptRef(new WebImage(backingStore));
+}
+
+const IntSize& WebImage::size() const
+{
+    return m_backingStore->size();
+}
+
+} // namespace WebKit
diff --git a/WebKit2/Shared/WebImage.h b/WebKit2/Shared/WebImage.h
new file mode 100644 (file)
index 0000000..cafbe8d
--- /dev/null
@@ -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 WebImage_h
+#define WebImage_h
+
+#include "APIObject.h"
+#include "BackingStore.h"
+#include "ImageOptions.h"
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+// WebImage - An image type suitable for vending to an API.
+
+class WebImage : public APIObject {
+public:
+    static const Type APIType = TypeImage;
+
+    static PassRefPtr<WebImage> create(const WebCore::IntSize&, ImageOptions);
+    static PassRefPtr<WebImage> create(PassRefPtr<BackingStore>);
+
+    const WebCore::IntSize& size() const;
+
+    BackingStore* backingStore() const { return m_backingStore.get(); }
+
+private:
+    WebImage(PassRefPtr<BackingStore> backingStore)
+        : m_backingStore(backingStore)
+    {
+        ASSERT(m_backingStore);
+    }
+
+    virtual Type type() const { return APIType; }
+
+    RefPtr<BackingStore> m_backingStore;
+};
+
+} // namespace WebKit
+
+#endif // WebImage_h
index 25dede209a344015e94bf2ec25c10fa37c56812b..22f52984b25cdcae25ec8aeb6edd7136963d061f 100644 (file)
@@ -252,7 +252,7 @@ void WKPageSetPageAndTextZoomFactors(WKPageRef pageRef, double pageZoomFactor, d
 
 void WKPageScaleWebView(WKPageRef pageRef, double scale, WKPoint origin)
 {
-    toImpl(pageRef)->scaleWebView(scale, toImpl(origin));
+    toImpl(pageRef)->scaleWebView(scale, toIntPoint(origin));
 }
 
 double WKPageGetViewScaleFactor(WKPageRef pageRef)
index 89c3b5e39d709428d6901f182f7658f396f7b987..661f4b7286b50cb78d3eaf64b1973118ecf34889 100644 (file)
@@ -214,7 +214,7 @@ FloatRect WebUIClient::windowFrame(WebPageProxy* page)
     if (!m_client.getWindowFrame)
         return FloatRect();
 
-    return toImpl(m_client.getWindowFrame(toAPI(page), m_client.clientInfo));
+    return toFloatRect(m_client.getWindowFrame(toAPI(page), m_client.clientInfo));
 }
 
 bool WebUIClient::canRunBeforeUnloadConfirmPanel()
index 3bda5e6075d74edeec2ca5518c7af208057bd300..cb01402a3b8450edc3d505e4c10a6775d4ea6334 100644 (file)
@@ -222,6 +222,7 @@ HEADERS += \
     Shared/API/c/WKContextMenuItem.h \
     Shared/API/c/WKContextMenuItemTypes.h \
     Shared/API/c/WKGeometry.h \
+    Shared/API/c/WKImage.h \
     Shared/API/c/WKNumber.h \
     Shared/API/c/WKPageLoadTypes.h \
     Shared/API/c/WKSecurityOrigin.h \
@@ -239,6 +240,7 @@ HEADERS += \
     Shared/ChildProcess.h \
     Shared/CoreIPCSupport/DrawingAreaMessageKinds.h \
     Shared/CoreIPCSupport/DrawingAreaProxyMessageKinds.h \
+    Shared/ImageOptions.h \
     Shared/ImmutableArray.h \
     Shared/ImmutableDictionary.h \
     Shared/MutableArray.h \
@@ -258,6 +260,7 @@ HEADERS += \
     Shared/WebEvent.h \
     Shared/WebEventConversion.h \
     Shared/WebFindOptions.h \
+    Shared/WebImage.h \
     Shared/WebNavigationDataStore.h \
     Shared/WebNumber.h \
     Shared/WebOpenPanelParameters.h \
@@ -439,6 +442,7 @@ SOURCES += \
     Shared/API/c/WKArray.cpp \
     Shared/API/c/WKCertificateInfo.cpp \
     Shared/API/c/WKContextMenuItem.cpp \
+    Shared/API/c/WKImage.cpp \
     Shared/API/c/WKNumber.cpp \
     Shared/API/c/WKSecurityOrigin.cpp \
     Shared/API/c/WKSerializedScriptValue.cpp \
@@ -465,6 +469,7 @@ SOURCES += \
     Shared/WebEvent.cpp \
     Shared/WebEventConversion.cpp \
     Shared/WebKeyboardEvent.cpp \
+    Shared/WebImage.cpp \
     Shared/WebMouseEvent.cpp \
     Shared/WebOpenPanelParameters.cpp \
     Shared/WebPageCreationParameters.cpp \
index 5643410cc8e6fdbd8f8166633136c2c82de60953..ac7269a857e037d925a46a1233d07147e7a60c12 100644 (file)
                BCCB75C61203A1CE00222D1B /* WebContextMessageKinds.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCB75C51203A1CE00222D1B /* WebContextMessageKinds.h */; };
                BCCF672D12C7EDF7008F9C35 /* OriginAndDatabases.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCF672C12C7EDF7008F9C35 /* OriginAndDatabases.h */; };
                BCCF673312C7F15C008F9C35 /* OriginAndDatabases.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCCF673212C7F15C008F9C35 /* OriginAndDatabases.cpp */; };
+               BCCF6ABC12C91EF9008F9C35 /* WebImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCCF6ABA12C91EF9008F9C35 /* WebImage.cpp */; };
+               BCCF6ABD12C91EF9008F9C35 /* WebImage.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCF6ABB12C91EF9008F9C35 /* WebImage.h */; };
+               BCCF6AC212C91F34008F9C35 /* WKImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCCF6AC012C91F34008F9C35 /* WKImage.cpp */; };
+               BCCF6AC312C91F34008F9C35 /* WKImage.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCF6AC112C91F34008F9C35 /* WKImage.h */; settings = {ATTRIBUTES = (Public, ); }; };
+               BCCF6AC912C91F59008F9C35 /* WKImageCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCCF6AC712C91F59008F9C35 /* WKImageCG.cpp */; };
+               BCCF6ACA12C91F59008F9C35 /* WKImageCG.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCF6AC812C91F59008F9C35 /* WKImageCG.h */; settings = {ATTRIBUTES = (Public, ); }; };
+               BCCF6B2512C93E7A008F9C35 /* ImageOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCF6B2312C93E7A008F9C35 /* ImageOptions.h */; };
                BCD0042D110C1E27003B8A67 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCD0042C110C1E27003B8A67 /* CoreServices.framework */; };
                BCD0139B110FA420003B8A67 /* WKFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD01397110FA420003B8A67 /* WKFrame.h */; settings = {ATTRIBUTES = (Public, ); }; };
                BCD0139C110FA420003B8A67 /* WKFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD01398110FA420003B8A67 /* WKFrame.cpp */; };
                BCCB75C51203A1CE00222D1B /* WebContextMessageKinds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContextMessageKinds.h; sourceTree = "<group>"; };
                BCCF672C12C7EDF7008F9C35 /* OriginAndDatabases.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OriginAndDatabases.h; sourceTree = "<group>"; };
                BCCF673212C7F15C008F9C35 /* OriginAndDatabases.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OriginAndDatabases.cpp; sourceTree = "<group>"; };
+               BCCF6ABA12C91EF9008F9C35 /* WebImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebImage.cpp; sourceTree = "<group>"; };
+               BCCF6ABB12C91EF9008F9C35 /* WebImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebImage.h; sourceTree = "<group>"; };
+               BCCF6AC012C91F34008F9C35 /* WKImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKImage.cpp; sourceTree = "<group>"; };
+               BCCF6AC112C91F34008F9C35 /* WKImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKImage.h; sourceTree = "<group>"; };
+               BCCF6AC712C91F59008F9C35 /* WKImageCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKImageCG.cpp; sourceTree = "<group>"; };
+               BCCF6AC812C91F59008F9C35 /* WKImageCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKImageCG.h; sourceTree = "<group>"; };
+               BCCF6B2312C93E7A008F9C35 /* ImageOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageOptions.h; sourceTree = "<group>"; };
                BCD0042C110C1E27003B8A67 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; };
                BCD01397110FA420003B8A67 /* WKFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFrame.h; sourceTree = "<group>"; };
                BCD01398110FA420003B8A67 /* WKFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKFrame.cpp; sourceTree = "<group>"; };
                        isa = PBXGroup;
                        children = (
                                BCDDB314124EBCEF0048D13C /* API */,
-                               BC111B5F112F635E00337BAB /* CoreIPCSupport */,
-                               1AAE058C1279DCD400852418 /* Plugins */,
                                1AAF0C4712B16328008E49E2 /* cf */,
                                C01A25FF12662F2100C9ED55 /* cg */,
+                               BC111B5F112F635E00337BAB /* CoreIPCSupport */,
                                BC111B5A112F628200337BAB /* mac */,
+                               1AAE058C1279DCD400852418 /* Plugins */,
                                1A3DD205125E5A2F004515E6 /* APIClient.h */,
                                BCF04C8C11FF9B7D00F86A58 /* APIObject.h */,
                                1A043D79124FEFC100FFBFB5 /* BackingStore.cpp */,
                                1A6F9F8E11E13EFC00DB1371 /* CommandLine.h */,
                                0FB659221208B4DB0044816C /* DrawingAreaInfo.h */,
                                762B7481120BBA0100819339 /* FontSmoothingLevel.h */,
+                               BCCF6B2312C93E7A008F9C35 /* ImageOptions.h */,
                                BC64696D11DBE603006455B0 /* ImmutableArray.cpp */,
                                BC64696E11DBE603006455B0 /* ImmutableArray.h */,
                                BCBCB0CC1215E33A00DE59CA /* ImmutableDictionary.cpp */,
                                BCB0AEE7122F53E300B1341E /* MutableDictionary.h */,
                                C02BFF1512514FD8009CCBEA /* NativeWebKeyboardEvent.h */,
                                BCC57161115ADB42001CCAF9 /* NotImplemented.h */,
+                               BCCF673212C7F15C008F9C35 /* OriginAndDatabases.cpp */,
+                               BCCF672C12C7EDF7008F9C35 /* OriginAndDatabases.h */,
                                BCC43AB8127B95DC00317F16 /* PlatformPopupMenuData.cpp */,
                                BCC43AB9127B95DC00317F16 /* PlatformPopupMenuData.h */,
                                BC2D021612AC41CB00E732A3 /* SameDocumentNavigationType.h */,
                                BCB0B0DF12305AB100B1341E /* UserMessageCoders.h */,
                                1A0F29C9120B37160053D1B9 /* VisitedLinkTable.cpp */,
                                1A0F29CA120B37160053D1B9 /* VisitedLinkTable.h */,
-                               BC1DD7B1114DC396005ADAF3 /* WebCoreArgumentCoders.h */,
                                BCF50726124329AA005955AE /* WebCertificateInfo.h */,
                                512935D51288D19400A4B695 /* WebContextMenuItem.cpp */,
                                512935D61288D19400A4B695 /* WebContextMenuItem.h */,
                                510FBB981288C95E00AFFDF4 /* WebContextMenuItemData.cpp */,
                                510FBB991288C95E00AFFDF4 /* WebContextMenuItemData.h */,
-                               BCCF673212C7F15C008F9C35 /* OriginAndDatabases.cpp */,
-                               BCCF672C12C7EDF7008F9C35 /* OriginAndDatabases.h */,
+                               BC1DD7B1114DC396005ADAF3 /* WebCoreArgumentCoders.h */,
                                51578B821209ECEF00A37C4A /* WebData.h */,
                                BC575612126E0138006F0F12 /* WebError.cpp */,
                                516A4A5B120A2CCD00C05B7F /* WebError.h */,
                                BC032DB010F4380F0058C15A /* WebEventConversion.cpp */,
                                BC032DB110F4380F0058C15A /* WebEventConversion.h */,
                                1A90C1ED1264FD50003E44D4 /* WebFindOptions.h */,
+                               BCCF6ABA12C91EF9008F9C35 /* WebImage.cpp */,
+                               BCCF6ABB12C91EF9008F9C35 /* WebImage.h */,
                                C0337DD2127A2A0E008FF4F4 /* WebKeyboardEvent.cpp */,
                                C0337DAF127A28D0008FF4F4 /* WebMouseEvent.cpp */,
                                BCF69F981176CED600471A52 /* WebNavigationDataStore.h */,
                                BC33DD671238464600360F3F /* WebNumber.h */,
-                               BC5744ED12638FB3006F0F12 /* WebPopupItem.cpp */,
-                               BC5744EE12638FB3006F0F12 /* WebPopupItem.h */,
                                BC857FB412B830E600EDEB2E /* WebOpenPanelParameters.cpp */,
                                BC857FB312B830E600EDEB2E /* WebOpenPanelParameters.h */,
                                C06C6093124C14430001682F /* WebPageCreationParameters.cpp */,
                                BC7B625112A43C9600D174A4 /* WebPageGroupData.cpp */,
                                BC7B625012A43C9600D174A4 /* WebPageGroupData.h */,
                                C0337DDC127A521C008FF4F4 /* WebPlatformTouchPoint.cpp */,
-                               BC306823125A6B9400E71278 /* WebProcessCreationParameters.cpp */,
-                               BC306822125A6B9400E71278 /* WebProcessCreationParameters.h */,
+                               BC5744ED12638FB3006F0F12 /* WebPopupItem.cpp */,
+                               BC5744EE12638FB3006F0F12 /* WebPopupItem.h */,
                                BCD598AB112B7FDF00EC8C23 /* WebPreferencesStore.cpp */,
                                BCD598AA112B7FDF00EC8C23 /* WebPreferencesStore.h */,
+                               BC306823125A6B9400E71278 /* WebProcessCreationParameters.cpp */,
+                               BC306822125A6B9400E71278 /* WebProcessCreationParameters.h */,
                                F634445512A885C8000612D8 /* WebSecurityOrigin.h */,
                                A72D5D7F1236CBA800A88B15 /* WebSerializedScriptValue.h */,
                                BCF04C8E11FF9F6E00F86A58 /* WebString.h */,
                        path = mac;
                        sourceTree = "<group>";
                };
+               BCCF6AC412C91F3B008F9C35 /* cg */ = {
+                       isa = PBXGroup;
+                       children = (
+                               BCCF6AC712C91F59008F9C35 /* WKImageCG.cpp */,
+                               BCCF6AC812C91F59008F9C35 /* WKImageCG.h */,
+                       );
+                       path = cg;
+                       sourceTree = "<group>";
+               };
                BCDDB314124EBCEF0048D13C /* API */ = {
                        isa = PBXGroup;
                        children = (
                        isa = PBXGroup;
                        children = (
                                BC4075D5124FEFFA0068F20A /* cf */,
+                               BCCF6AC412C91F3B008F9C35 /* cg */,
                                BC4075D6124FF0000068F20A /* mac */,
                                BC4075D7124FF0270068F20A /* WKArray.cpp */,
                                BC4075D8124FF0270068F20A /* WKArray.h */,
                                BC40783C1250FADD0068F20A /* WKEvent.h */,
                                37F623B712A57B6200E3FDF6 /* WKFindOptions.h */,
                                BCC8B373125FB69000DE46A4 /* WKGeometry.h */,
+                               BCCF6AC012C91F34008F9C35 /* WKImage.cpp */,
+                               BCCF6AC112C91F34008F9C35 /* WKImage.h */,
                                BC4075E1124FF0270068F20A /* WKMutableArray.cpp */,
                                BC4075E2124FF0270068F20A /* WKMutableArray.h */,
                                BC4075E3124FF0270068F20A /* WKMutableDictionary.cpp */,
                                1AA417CB12C00CCA002BE67B /* TextChecker.h in Headers */,
                                1AA41AB512C02EC4002BE67B /* SelectionState.h in Headers */,
                                BCCF672D12C7EDF7008F9C35 /* OriginAndDatabases.h in Headers */,
+                               BCCF6ABD12C91EF9008F9C35 /* WebImage.h in Headers */,
+                               BCCF6AC312C91F34008F9C35 /* WKImage.h in Headers */,
+                               BCCF6ACA12C91F59008F9C35 /* WKImageCG.h in Headers */,
                                BCAC111F12C92C1F00B08EEE /* WebDatabaseManagerProxyClient.h in Headers */,
+                               BCCF6B2512C93E7A008F9C35 /* ImageOptions.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BC858A2112C0357B00EDEB2E /* WebResourceLoadClient.cpp in Sources */,
                                1AA417EF12C00D87002BE67B /* TextCheckerMac.mm in Sources */,
                                BCCF673312C7F15C008F9C35 /* OriginAndDatabases.cpp in Sources */,
+                               BCCF6ABC12C91EF9008F9C35 /* WebImage.cpp in Sources */,
+                               BCCF6AC212C91F34008F9C35 /* WKImage.cpp in Sources */,
+                               BCCF6AC912C91F59008F9C35 /* WKImageCG.cpp in Sources */,
                                BCAC112012C92C1F00B08EEE /* WebDatabaseManagerProxyClient.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
index 6a70b3371c0ff27a245543644b4b01a42b797a15..79b6ad37df341d0b0a817404d9169f58c1dc0496 100644 (file)
 #include "WKBundlePagePrivate.h"
 
 #include "InjectedBundleBackForwardList.h"
+#include "WKAPICast.h"
+#include "WKBundleAPICast.h"
+#include "WebImage.h"
 #include "WebPage.h"
 #include "WebURL.h"
 #include "WebURLRequest.h"
-#include "WKAPICast.h"
-#include "WKBundleAPICast.h"
 
 #include <WebCore/KURL.h>
 
@@ -166,3 +167,15 @@ bool WKBundlePageFindString(WKBundlePageRef pageRef, WKStringRef target, WKFindO
 {
     return toImpl(pageRef)->findStringFromInjectedBundle(toImpl(target)->string(), toFindOptions(findOptions));
 }
+
+WKImageRef WKBundlePageCreateSnapshotInViewCoordinates(WKBundlePageRef pageRef, WKRect rect, WKImageOptions options)
+{
+    RefPtr<WebImage> webImage = toImpl(pageRef)->snapshotInViewCoordinates(toIntRect(rect), toImageOptions(options));
+    return toAPI(webImage.release().leakRef());
+}
+
+WKImageRef WKBundlePageCreateSnapshotInDocumentCoordinates(WKBundlePageRef pageRef, WKRect rect, WKImageOptions options)
+{
+    RefPtr<WebImage> webImage = toImpl(pageRef)->snapshotInDocumentCoordinates(toIntRect(rect), toImageOptions(options));
+    return toAPI(webImage.release().leakRef());
+}
index b4a028f4b14fd69608966dca79a473981c225def..6c700993d63e3048b026d3dabec1070676d05732 100644 (file)
@@ -29,6 +29,7 @@
 #include <WebKit2/WKBase.h>
 #include <WebKit2/WKEvent.h>
 #include <WebKit2/WKFindOptions.h>
+#include <WebKit2/WKImage.h>
 #include <WebKit2/WKPageLoadTypes.h>
 
 #ifndef __cplusplus
@@ -214,6 +215,9 @@ WK_EXPORT bool WKBundlePageCanHandleRequest(WKURLRequestRef request);
 
 WK_EXPORT bool WKBundlePageFindString(WKBundlePageRef page, WKStringRef target, WKFindOptions findOptions);
 
+WK_EXPORT WKImageRef WKBundlePageCreateSnapshotInViewCoordinates(WKBundlePageRef page, WKRect rect, WKImageOptions options);
+WK_EXPORT WKImageRef WKBundlePageCreateSnapshotInDocumentCoordinates(WKBundlePageRef page, WKRect rect, WKImageOptions options);
+
 #ifdef __cplusplus
 }
 #endif
index 7e9211e86de6b7c16b575094159b79ddd94cec42..48fcab4e01bcad1ad89a6edfaa4f8b0b42a16020 100644 (file)
@@ -134,5 +134,5 @@ WKBundlePageOverlayRef WKBundlePageOverlayCreate(WKBundlePageOverlayClient* wkCl
 
 void WKBundlePageOverlaySetNeedsDisplay(WKBundlePageOverlayRef bundlePageOverlayRef, WKRect rect)
 {
-    toImpl(bundlePageOverlayRef)->setNeedsDisplay(enclosingIntRect(toImpl(rect)));
+    toImpl(bundlePageOverlayRef)->setNeedsDisplay(enclosingIntRect(toFloatRect(rect)));
 }
index 4df97f1c7fc85d90b28f67d972e10b2725c8e380..571321c1f9fb99e8931ee0d210313eee7b1e1d1b 100644 (file)
 #include "WebContextMenuClient.h"
 #include "WebContextMessages.h"
 #include "WebCoreArgumentCoders.h"
-#include "WebOpenPanelResultListener.h"
 #include "WebDragClient.h"
 #include "WebEditorClient.h"
 #include "WebEvent.h"
 #include "WebEventConversion.h"
 #include "WebFrame.h"
+#include "WebImage.h"
 #include "WebInspector.h"
 #include "WebInspectorClient.h"
+#include "WebOpenPanelResultListener.h"
 #include "WebPageCreationParameters.h"
 #include "WebPageGroupProxy.h"
 #include "WebPageProxyMessages.h"
@@ -587,6 +588,44 @@ void WebPage::uninstallPageOverlay(PageOverlay* pageOverlay)
     m_drawingArea->setNeedsDisplay(IntRect(IntPoint(0, 0), m_viewSize));
 }
 
+PassRefPtr<WebImage> WebPage::snapshotInViewCoordinates(const IntRect& rect, ImageOptions options)
+{
+    FrameView* frameView = m_mainFrame->coreFrame()->view();
+    if (!frameView)
+        return 0;
+
+    frameView->updateLayoutAndStyleIfNeededRecursive();
+
+    RefPtr<WebImage> snapshot = WebImage::create(rect.size(), options);
+    OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->backingStore()->createGraphicsContext();
+
+    graphicsContext->save();
+    graphicsContext->translate(-rect.x(), -rect.y());
+    frameView->paint(graphicsContext.get(), rect);
+    graphicsContext->restore();
+
+    return snapshot.release();
+}
+
+PassRefPtr<WebImage> WebPage::snapshotInDocumentCoordinates(const IntRect& rect, ImageOptions options)
+{
+    FrameView* frameView = m_mainFrame->coreFrame()->view();
+    if (!frameView)
+        return 0;
+
+    frameView->updateLayoutAndStyleIfNeededRecursive();
+
+    RefPtr<WebImage> snapshot = WebImage::create(rect.size(), options);
+    OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->backingStore()->createGraphicsContext();
+
+    graphicsContext->save();
+    graphicsContext->translate(-rect.x(), -rect.y());
+    frameView->paintContents(graphicsContext.get(), rect);
+    graphicsContext->restore();
+
+    return snapshot.release();
+}
+
 void WebPage::pageDidScroll()
 {
     // Hide the find indicator.
index 1cf257c60e2c057f560bbc83962286ddbacbae01..797478e784c95969756474e0ce16e93b3e003ce8 100644 (file)
@@ -29,6 +29,7 @@
 #include "APIObject.h"
 #include "DrawingArea.h"
 #include "FindController.h"
+#include "ImageOptions.h"
 #include "InjectedBundlePageContextMenuClient.h"
 #include "InjectedBundlePageEditorClient.h"
 #include "InjectedBundlePageFormClient.h"
@@ -75,6 +76,7 @@ class WebContextMenu;
 class WebContextMenuItemData;
 class WebEvent;
 class WebFrame;
+class WebImage;
 class WebInspector;
 class WebKeyboardEvent;
 class WebMouseEvent;
@@ -206,6 +208,9 @@ public:
     void installPageOverlay(PassRefPtr<PageOverlay>);
     void uninstallPageOverlay(PageOverlay*);
 
+    PassRefPtr<WebImage> snapshotInViewCoordinates(const WebCore::IntRect&, ImageOptions);
+    PassRefPtr<WebImage> snapshotInDocumentCoordinates(const WebCore::IntRect&, ImageOptions);
+
     static const WebEvent* currentEvent();
 
     FindController& findController() { return m_findController; }
index 0c88c520dfe9867c7b6262b611d9b3da045d4da2..d4fc7d2d032c6f83087871b43850b81bc3ebe30a 100755 (executable)
                                RelativePath="..\Shared\WebFindOptions.h"
                                >
                        </File>
+                       <File
+                               RelativePath="..\Shared\WebImage.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\Shared\WebImage.h"
+                               >
+                       </File>
                        <File
                                RelativePath="..\Shared\WebKeyboardEvent.cpp"
                                >
                                        RelativePath="..\Shared\API\c\WKGeometry.h"
                                        >
                                </File>
+                               <File
+                                       RelativePath="..\Shared\API\c\WKImage.cpp"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\Shared\API\c\WKImage.h"
+                                       >
+                               </File>
                                <File
                                        RelativePath="..\Shared\API\c\WKMutableArray.cpp"
                                        >
                                                >
                                        </File>
                                </Filter>
+                               <Filter
+                                       Name="cg"
+                                       >
+                                       <File
+                                               RelativePath="..\Shared\API\c\cg\WKImageCG.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath="..\Shared\API\c\cg\WKImageCG.h"
+                                               >
+                                       </File>
+                               </Filter>
                        </Filter>
                        <Filter
                                Name="CoreIPCSupport"