Add ShareableBitmap::Handle
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Mar 2011 14:40:23 +0000 (14:40 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Mar 2011 14:40:23 +0000 (14:40 +0000)
This object is used for encoding/decoding a ShareableBitmap via CoreIPC. It currently just
encapsulates a SharedMemory::Handle (which is what we were using previously) and the image's
size (which means callers no longer need to deal with the size explicitly), but in the
future could be used to store more information about the bitmap.

This should cause no behavior changes.

Fixes <http://webkit.org/b/57397> ShareableBitmap needs its own Handle type

Reviewed by Anders Carlsson.

* PluginProcess/PluginControllerProxy.cpp:
(WebKit::PluginControllerProxy::geometryDidChange): No longer need to pass a size to create,
since the Handle records the size.
(WebKit::PluginControllerProxy::snapshot): No longer need the bufferSize argument, since the
Handle records the size.

* PluginProcess/PluginControllerProxy.h:
* PluginProcess/PluginControllerProxy.messages.in:
Updated Handle types and removed unnecessary size argument to Snapshot.

* Shared/PlatformPopupMenuData.cpp:
(WebKit::PlatformPopupMenuData::encode):
(WebKit::PlatformPopupMenuData::decode):
* Shared/PlatformPopupMenuData.h:
Changed to use ShareableBitmap::Handle and removed m_backingStoreSize, which is now stored
in the Handles.

* Shared/ShareableBitmap.cpp:
(WebKit::ShareableBitmap::Handle::encode):
(WebKit::ShareableBitmap::Handle::decode):
Simple encode/decode functions.

(WebKit::ShareableBitmap::create): Get the size from the Handle instead of as a separate
argument.
(WebKit::ShareableBitmap::createHandle): Store our size in the Handle.

* Shared/ShareableBitmap.h: Added ShareableBitmap::Handle and made some functions use it.

* Shared/UpdateInfo.h: Changed to use ShareableBitmap::Handle.

* Shared/UserMessageCoders.h:
(WebKit::UserMessageEncoder::baseEncode):
(WebKit::UserMessageDecoder::baseDecode):
* Shared/WebCoreArgumentCoders.cpp:
(CoreIPC::encodeImage):
(CoreIPC::decodeImage):
Use the size stored in the Handle instead of encoding/decoding one separately.

* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::setDragImage):
Removed the unnecessary imageSize argument. We can get it from the image itself.

* UIProcess/BackingStore.cpp:
(WebKit::BackingStore::incorporateUpdate):
* UIProcess/FindIndicator.cpp:
(WebKit::FindIndicator::create):
No longer need to pass a size when creating a ShareableBitmap from a Handle.

* UIProcess/FindIndicator.h: Changed to use ShareableBitmap::Handle.

* UIProcess/PageClient.h: Removed unnecessary imageSize argument from setDragImage.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setFindIndicator):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::setDragImage):
* WebProcess/Plugins/PluginProxy.cpp:
(WebKit::PluginProxy::snapshot):
(WebKit::PluginProxy::geometryDidChange):
* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
(WebKit::WebDragClient::startDrag):
Changed to use ShareableBitmap::Handle and removed now-unnecessary size arguments (since we
can get the size from the Handle).

* WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp:
(WebKit::WebPopupMenu::setUpPlatformData): Don't need to store the backing store size in the
data anymore; the Handles will make sure it reaches the other process.

* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::updateFindIndicator):
(WebKit::FindController::hideFindIndicator):
Changed to use ShareableBitmap::Handle.

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

25 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/PluginProcess/PluginControllerProxy.cpp
Source/WebKit2/PluginProcess/PluginControllerProxy.h
Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in
Source/WebKit2/Shared/PlatformPopupMenuData.cpp
Source/WebKit2/Shared/PlatformPopupMenuData.h
Source/WebKit2/Shared/ShareableBitmap.cpp
Source/WebKit2/Shared/ShareableBitmap.h
Source/WebKit2/Shared/UpdateInfo.h
Source/WebKit2/Shared/UserMessageCoders.h
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/BackingStore.cpp
Source/WebKit2/UIProcess/FindIndicator.cpp
Source/WebKit2/UIProcess/FindIndicator.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp
Source/WebKit2/WebProcess/WebPage/FindController.cpp

index 716ab17..838c493 100644 (file)
@@ -1,3 +1,94 @@
+2011-03-29  Adam Roben  <aroben@apple.com>
+
+        Add ShareableBitmap::Handle
+
+        This object is used for encoding/decoding a ShareableBitmap via CoreIPC. It currently just
+        encapsulates a SharedMemory::Handle (which is what we were using previously) and the image's
+        size (which means callers no longer need to deal with the size explicitly), but in the
+        future could be used to store more information about the bitmap.
+
+        This should cause no behavior changes.
+
+        Fixes <http://webkit.org/b/57397> ShareableBitmap needs its own Handle type
+
+        Reviewed by Anders Carlsson.
+
+        * PluginProcess/PluginControllerProxy.cpp:
+        (WebKit::PluginControllerProxy::geometryDidChange): No longer need to pass a size to create,
+        since the Handle records the size.
+        (WebKit::PluginControllerProxy::snapshot): No longer need the bufferSize argument, since the
+        Handle records the size.
+
+        * PluginProcess/PluginControllerProxy.h:
+        * PluginProcess/PluginControllerProxy.messages.in:
+        Updated Handle types and removed unnecessary size argument to Snapshot.
+
+        * Shared/PlatformPopupMenuData.cpp:
+        (WebKit::PlatformPopupMenuData::encode):
+        (WebKit::PlatformPopupMenuData::decode):
+        * Shared/PlatformPopupMenuData.h:
+        Changed to use ShareableBitmap::Handle and removed m_backingStoreSize, which is now stored
+        in the Handles.
+
+        * Shared/ShareableBitmap.cpp:
+        (WebKit::ShareableBitmap::Handle::encode):
+        (WebKit::ShareableBitmap::Handle::decode):
+        Simple encode/decode functions.
+
+        (WebKit::ShareableBitmap::create): Get the size from the Handle instead of as a separate
+        argument.
+        (WebKit::ShareableBitmap::createHandle): Store our size in the Handle.
+
+        * Shared/ShareableBitmap.h: Added ShareableBitmap::Handle and made some functions use it.
+
+        * Shared/UpdateInfo.h: Changed to use ShareableBitmap::Handle.
+
+        * Shared/UserMessageCoders.h:
+        (WebKit::UserMessageEncoder::baseEncode):
+        (WebKit::UserMessageDecoder::baseDecode):
+        * Shared/WebCoreArgumentCoders.cpp:
+        (CoreIPC::encodeImage):
+        (CoreIPC::decodeImage):
+        Use the size stored in the Handle instead of encoding/decoding one separately.
+
+        * UIProcess/API/mac/PageClientImpl.h:
+        * UIProcess/API/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::setDragImage):
+        Removed the unnecessary imageSize argument. We can get it from the image itself.
+
+        * UIProcess/BackingStore.cpp:
+        (WebKit::BackingStore::incorporateUpdate):
+        * UIProcess/FindIndicator.cpp:
+        (WebKit::FindIndicator::create):
+        No longer need to pass a size when creating a ShareableBitmap from a Handle.
+
+        * UIProcess/FindIndicator.h: Changed to use ShareableBitmap::Handle.
+
+        * UIProcess/PageClient.h: Removed unnecessary imageSize argument from setDragImage.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setFindIndicator):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::setDragImage):
+        * WebProcess/Plugins/PluginProxy.cpp:
+        (WebKit::PluginProxy::snapshot):
+        (WebKit::PluginProxy::geometryDidChange):
+        * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
+        (WebKit::WebDragClient::startDrag):
+        Changed to use ShareableBitmap::Handle and removed now-unnecessary size arguments (since we
+        can get the size from the Handle).
+
+        * WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp:
+        (WebKit::WebPopupMenu::setUpPlatformData): Don't need to store the backing store size in the
+        data anymore; the Handles will make sure it reaches the other process.
+
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::FindController::updateFindIndicator):
+        (WebKit::FindController::hideFindIndicator):
+        Changed to use ShareableBitmap::Handle.
+
 2011-03-30  Alejandro G. Castro  <alex@igalia.com>
 
         Fix GTK build after r81980.
index c48fd65..03a8aec 100644 (file)
@@ -340,7 +340,7 @@ void PluginControllerProxy::frameDidFail(uint64_t requestID, bool wasCancelled)
     m_plugin->frameDidFail(requestID, wasCancelled);
 }
 
-void PluginControllerProxy::geometryDidChange(const IntRect& frameRect, const IntRect& clipRect, const SharedMemory::Handle& backingStoreHandle)
+void PluginControllerProxy::geometryDidChange(const IntRect& frameRect, const IntRect& clipRect, const ShareableBitmap::Handle& backingStoreHandle)
 {
     m_frameRect = frameRect;
     m_clipRect = clipRect;
@@ -349,7 +349,7 @@ void PluginControllerProxy::geometryDidChange(const IntRect& frameRect, const In
 
     if (!backingStoreHandle.isNull()) {
         // Create a new backing store.
-        m_backingStore = ShareableBitmap::create(frameRect.size(), backingStoreHandle);
+        m_backingStore = ShareableBitmap::create(backingStoreHandle);
     }
 
     m_plugin->geometryDidChange(frameRect, clipRect);
@@ -448,7 +448,7 @@ void PluginControllerProxy::paintEntirePlugin()
     paint();
 }
 
-void PluginControllerProxy::snapshot(WebCore::IntSize& bufferSize, SharedMemory::Handle& backingStoreHandle)
+void PluginControllerProxy::snapshot(ShareableBitmap::Handle& backingStoreHandle)
 {
     ASSERT(m_plugin);
     RefPtr<ShareableBitmap> bitmap = m_plugin->snapshot();
@@ -456,7 +456,6 @@ void PluginControllerProxy::snapshot(WebCore::IntSize& bufferSize, SharedMemory:
         return;
 
     bitmap->createHandle(backingStoreHandle);
-    bufferSize = bitmap->size();
 }
 
 void PluginControllerProxy::setFocus(bool hasFocus)
index e470f85..65be39e 100644 (file)
@@ -32,7 +32,7 @@
 #include "Plugin.h"
 #include "PluginController.h"
 #include "RunLoop.h"
-#include "SharedMemory.h"
+#include "ShareableBitmap.h"
 #include <wtf/Noncopyable.h>
 
 #if PLATFORM(MAC)
@@ -105,7 +105,7 @@ private:
     // Message handlers.
     void frameDidFinishLoading(uint64_t requestID);
     void frameDidFail(uint64_t requestID, bool wasCancelled);
-    void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, const SharedMemory::Handle& backingStoreHandle);
+    void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, const ShareableBitmap::Handle& backingStoreHandle);
     void didEvaluateJavaScript(uint64_t requestID, const String& requestURLString, const String& result);
     void streamDidReceiveResponse(uint64_t streamID, const String& responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers);
     void streamDidReceiveData(uint64_t streamID, const CoreIPC::DataReference& data);
@@ -121,7 +121,7 @@ private:
     void handleMouseLeaveEvent(const WebMouseEvent&, bool& handled);
     void handleKeyboardEvent(const WebKeyboardEvent&, bool& handled);
     void paintEntirePlugin();
-    void snapshot(WebCore::IntSize& bufferSize, SharedMemory::Handle& backingStoreHandle);
+    void snapshot(ShareableBitmap::Handle& backingStoreHandle);
     void setFocus(bool);
     void didUpdate();
     void getPluginScriptableNPObject(uint64_t& pluginScriptableNPObjectID);
index 91cc57f..6e27b36 100644 (file)
@@ -24,7 +24,7 @@
 
 messages -> PluginControllerProxy {
     # Sent when the plug-in geometry changes.
-    GeometryDidChange(WebCore::IntRect frameRect, WebCore::IntRect clipRect, WebKit::SharedMemory::Handle backingStoreHandle)
+    GeometryDidChange(WebCore::IntRect frameRect, WebCore::IntRect clipRect, WebKit::ShareableBitmap::Handle backingStoreHandle)
 
     # Sent when a frame has finished loading.
     FrameDidFinishLoading(uint64_t requestID)
@@ -101,7 +101,7 @@ messages -> PluginControllerProxy {
 #endif
 
     # Return a snapshot of the plugin
-    Snapshot() -> (WebCore::IntSize size, WebKit::SharedMemory::Handle backingStoreHandle)
+    Snapshot() -> (WebKit::ShareableBitmap::Handle backingStoreHandle)
     
     # Sent when private browsing is enabled or disabled
     PrivateBrowsingStateChanged(bool isPrivateBrowsingEnabled)
index a5ebb45..1f56daf 100644 (file)
@@ -51,13 +51,12 @@ void PlatformPopupMenuData::encode(CoreIPC::ArgumentEncoder* encoder) const
     encoder->encode(m_clientInsetRight);
     encoder->encode(m_popupWidth);
     encoder->encode(m_itemHeight);
-    encoder->encode(m_backingStoreSize);
 
-    SharedMemory::Handle notSelectedBackingStoreHandle;
+    ShareableBitmap::Handle notSelectedBackingStoreHandle;
     m_notSelectedBackingStore->createHandle(notSelectedBackingStoreHandle);
     encoder->encode(notSelectedBackingStoreHandle);
 
-    SharedMemory::Handle selectedBackingStoreHandle;
+    ShareableBitmap::Handle selectedBackingStoreHandle;
     m_selectedBackingStore->createHandle(selectedBackingStoreHandle);
     encoder->encode(selectedBackingStoreHandle);
 #elif PLATFORM(MAC)
@@ -80,18 +79,16 @@ bool PlatformPopupMenuData::decode(CoreIPC::ArgumentDecoder* decoder, PlatformPo
         return false;
     if (!decoder->decode(data.m_itemHeight))
         return false;
-    if (!decoder->decode(data.m_backingStoreSize))
-        return false;
 
-    SharedMemory::Handle notSelectedBackingStoreHandle;
+    ShareableBitmap::Handle notSelectedBackingStoreHandle;
     if (!decoder->decode(notSelectedBackingStoreHandle))
         return false;
-    data.m_notSelectedBackingStore = ShareableBitmap::create(data.m_backingStoreSize, notSelectedBackingStoreHandle);
+    data.m_notSelectedBackingStore = ShareableBitmap::create(notSelectedBackingStoreHandle);
 
-    SharedMemory::Handle selectedBackingStoreHandle;
+    ShareableBitmap::Handle selectedBackingStoreHandle;
     if (!decoder->decode(selectedBackingStoreHandle))
         return false;
-    data.m_selectedBackingStore = ShareableBitmap::create(data.m_backingStoreSize, selectedBackingStoreHandle);
+    data.m_selectedBackingStore = ShareableBitmap::create(selectedBackingStoreHandle);
 #elif PLATFORM(MAC)
     if (!decoder->decode(data.fontInfo))
         return false;
index f79b4b2..5b3f58d 100644 (file)
@@ -50,7 +50,6 @@ struct PlatformPopupMenuData {
     int m_clientInsetRight;
     int m_popupWidth;
     int m_itemHeight;
-    WebCore::IntSize m_backingStoreSize;
     RefPtr<ShareableBitmap> m_notSelectedBackingStore;
     RefPtr<ShareableBitmap> m_selectedBackingStore;
 #elif PLATFORM(MAC)
index ab1991f..d21da12 100644 (file)
 #include "ShareableBitmap.h"
 
 #include "SharedMemory.h"
+#include "WebCoreArgumentCoders.h"
 #include <WebCore/GraphicsContext.h>
 
 using namespace WebCore;
 
 namespace WebKit {
 
+void ShareableBitmap::Handle::encode(CoreIPC::ArgumentEncoder* encoder) const
+{
+    encoder->encode(m_handle);
+    encoder->encode(m_size);
+}
+
+bool ShareableBitmap::Handle::decode(CoreIPC::ArgumentDecoder* decoder, Handle& handle)
+{
+    if (!decoder->decode(handle.m_handle))
+        return false;
+    if (!decoder->decode(handle.m_size))
+        return false;
+    return true;
+}
+
 PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size)
 {
     size_t numBytes = numBytesForSize(size);
@@ -65,21 +81,24 @@ PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size
     return adoptRef(new ShareableBitmap(size, sharedMemory));
 }
 
-PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size, const SharedMemory::Handle& handle)
+PassRefPtr<ShareableBitmap> ShareableBitmap::create(const Handle& handle)
 {
     // Create the shared memory.
-    RefPtr<SharedMemory> sharedMemory = SharedMemory::create(handle, SharedMemory::ReadWrite);
+    RefPtr<SharedMemory> sharedMemory = SharedMemory::create(handle.m_handle, SharedMemory::ReadWrite);
     if (!sharedMemory)
         return 0;
 
-    return create(size, sharedMemory.release());
+    return create(handle.m_size, sharedMemory.release());
 }
 
-bool ShareableBitmap::createHandle(SharedMemory::Handle& handle)
+bool ShareableBitmap::createHandle(Handle& handle)
 {
     ASSERT(isBackedBySharedMemory());
 
-    return m_sharedMemory->createHandle(handle, SharedMemory::ReadWrite);
+    if (!m_sharedMemory->createHandle(handle.m_handle, SharedMemory::ReadWrite))
+        return false;
+    handle.m_size = m_size;
+    return true;
 }
 
 ShareableBitmap::ShareableBitmap(const IntSize& size, void* data)
index 30fc86c..d6b71ae 100644 (file)
@@ -45,6 +45,23 @@ namespace WebKit {
     
 class ShareableBitmap : public RefCounted<ShareableBitmap> {
 public:
+    class Handle {
+        WTF_MAKE_NONCOPYABLE(Handle);
+    public:
+        Handle() { }
+
+        bool isNull() const { return m_handle.isNull(); }
+
+        void encode(CoreIPC::ArgumentEncoder*) const;
+        static bool decode(CoreIPC::ArgumentDecoder*, Handle&);
+
+    private:
+        friend class ShareableBitmap;
+
+        mutable SharedMemory::Handle m_handle;
+        WebCore::IntSize m_size;
+    };
+
     // Create a shareable bitmap that uses malloced memory.
     static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&);
 
@@ -54,11 +71,11 @@ public:
     // Create a shareable bitmap from an already existing shared memory block.
     static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&, PassRefPtr<SharedMemory>);
 
-    // Create a shareable bitmap from a shared memory handle.
-    static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&, const SharedMemory::Handle&);
+    // Create a shareable bitmap from a handle.
+    static PassRefPtr<ShareableBitmap> create(const Handle&);
 
-    // Create a shared memory handle.
-    bool createHandle(SharedMemory::Handle&);
+    // Create a handle.
+    bool createHandle(Handle&);
 
     ~ShareableBitmap();
 
index 7b5454e..8e08ed0 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef UpdateInfo_h
 #define UpdateInfo_h
 
-#include "SharedMemory.h"
+#include "ShareableBitmap.h"
 #include <WebCore/IntRect.h>
 #include <wtf/Noncopyable.h>
 
@@ -60,7 +60,7 @@ public:
     Vector<WebCore::IntRect> updateRects;
 
     // The handle of the shareable bitmap containing the updates. Will be null if there are no updates.
-    SharedMemory::Handle bitmapHandle;
+    ShareableBitmap::Handle bitmapHandle;
 };
 
 } // namespace WebKit
index 65875fa..ad72493 100644 (file)
@@ -132,13 +132,12 @@ public:
                 return true;
             }
 
-            SharedMemory::Handle handle;
+            ShareableBitmap::Handle handle;
             if (!image->bitmap()->createHandle(handle))
                 return false;
 
             encoder->encode(true);
             
-            encoder->encode(image->size());
             encoder->encode(handle);
             return true;
         }
@@ -293,15 +292,11 @@ public:
             if (!didEncode)
                 break;
 
-            WebCore::IntSize size;
-            if (!decoder->decode(size))
-                return false;
-
-            SharedMemory::Handle handle;
+            ShareableBitmap::Handle handle;
             if (!decoder->decode(handle))
                 return false;
 
-            coder.m_root = WebImage::create(ShareableBitmap::create(size, handle));
+            coder.m_root = WebImage::create(ShareableBitmap::create(handle));
             return true;
         }
         case APIObject::TypeData: {
index e97c7fd..56c7235 100644 (file)
@@ -39,23 +39,19 @@ void encodeImage(ArgumentEncoder* encoder, Image* image)
 {
     RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size());
     bitmap->createGraphicsContext()->drawImage(image, ColorSpaceDeviceRGB, IntPoint());
-    SharedMemory::Handle handle;
+    ShareableBitmap::Handle handle;
     bitmap->createHandle(handle);
 
-    encoder->encode(image->size());
     encoder->encode(handle);
 }
 
 bool decodeImage(ArgumentDecoder* decoder, RefPtr<Image>& image)
 {
-    IntSize imageSize;
-    if (!decoder->decode(imageSize))
-        return false;
-    SharedMemory::Handle handle;
+    ShareableBitmap::Handle handle;
     if (!decoder->decode(handle))
         return false;
     
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(imageSize, handle);
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle);
     if (!bitmap)
         return false;
     image = createImage(bitmap.get());
index 07b8f21..e217fc5 100644 (file)
@@ -72,7 +72,7 @@ private:
     virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
     virtual void clearAllEditCommands();
     virtual void interceptKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines);
-    virtual void setDragImage(const WebCore::IntPoint& clientPosition, const WebCore::IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag);
+    virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag);
 
     virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
     virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
index 6eb1cfe..7a0d62d 100644 (file)
@@ -297,10 +297,10 @@ void PageClientImpl::interceptKeyEvent(const NativeWebKeyboardEvent& event, Vect
     [m_wkView _getTextInputState:selectionStart selectionEnd:selectionEnd underlines:underlines];
 }
 
-void PageClientImpl::setDragImage(const IntPoint& clientPosition, const IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag)
+void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag)
 {
     RetainPtr<CGImageRef> dragCGImage = dragImage->makeCGImage();
-    RetainPtr<NSImage> dragNSImage(AdoptNS, [[NSImage alloc] initWithCGImage:dragCGImage.get() size:imageSize]);
+    RetainPtr<NSImage> dragNSImage(AdoptNS, [[NSImage alloc] initWithCGImage:dragCGImage.get() size:dragImage->size()]);
 
     [m_wkView _setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag];
 }
index f9a2672..5f024e6 100644 (file)
@@ -57,9 +57,10 @@ void BackingStore::incorporateUpdate(const UpdateInfo& updateInfo)
 {
 //    ASSERT(m_size == updateInfo.viewSize);
     
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.updateRectBounds.size(), updateInfo.bitmapHandle);
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.bitmapHandle);
     if (!bitmap)
         return;
+    ASSERT(bitmap->size() == updateInfo.updateRectBounds.size());
     
     incorporateUpdate(bitmap.get(), updateInfo);
 }
index d6ac461..d30fb8d 100644 (file)
@@ -77,11 +77,12 @@ static const int gradientLightAlpha = 255;
 
 namespace WebKit {
 
-PassRefPtr<FindIndicator> FindIndicator::create(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, const SharedMemory::Handle& contentImageHandle)
+PassRefPtr<FindIndicator> FindIndicator::create(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, const ShareableBitmap::Handle& contentImageHandle)
 {
-    RefPtr<ShareableBitmap> contentImage = ShareableBitmap::create(enclosingIntRect(selectionRectInWindowCoordinates).size(), contentImageHandle);
+    RefPtr<ShareableBitmap> contentImage = ShareableBitmap::create(contentImageHandle);
     if (!contentImage)
         return 0;
+    ASSERT(contentImage->size() == enclosingIntRect(selectionRectInWindowCoordinates).size());
 
     return adoptRef(new FindIndicator(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImage.release()));
 }
index 69088ce..49d07da 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef FindIndicator_h
 #define FindIndicator_h
 
-#include "SharedMemory.h"
+#include "ShareableBitmap.h"
 #include <WebCore/FloatRect.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
@@ -38,11 +38,9 @@ namespace WebCore {
 
 namespace WebKit {
 
-class ShareableBitmap;
-
 class FindIndicator : public RefCounted<FindIndicator> {
 public:
-    static PassRefPtr<FindIndicator> create(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, const SharedMemory::Handle& contentImageHandle);
+    static PassRefPtr<FindIndicator> create(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, const ShareableBitmap::Handle& contentImageHandle);
     ~FindIndicator();
 
     WebCore::FloatRect selectionRectInWindowCoordinates() const { return m_selectionRectInWindowCoordinates; }
index 391e466..83ce502 100644 (file)
@@ -101,7 +101,7 @@ public:
 #if PLATFORM(MAC)
     virtual void accessibilityWebProcessTokenReceived(const CoreIPC::DataReference&) = 0;
     virtual void interceptKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>& commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines) = 0;
-    virtual void setDragImage(const WebCore::IntPoint& clientPosition, const WebCore::IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) = 0;
+    virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) = 0;
 #endif
 #if PLATFORM(WIN)
     virtual void compositionSelectionChanged(bool) = 0;
index 4017d0e..72ca100 100644 (file)
@@ -2061,7 +2061,7 @@ void WebPageProxy::didCountStringMatches(const String& string, uint32_t matchCou
     m_findClient.didCountStringMatches(this, string, matchCount);
 }
 
-void WebPageProxy::setFindIndicator(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, const SharedMemory::Handle& contentImageHandle, bool fadeOut)
+void WebPageProxy::setFindIndicator(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut)
 {
     RefPtr<FindIndicator> findIndicator = FindIndicator::create(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImageHandle);
     m_pageClient->setFindIndicator(findIndicator.release(), fadeOut);
index b37ed1b..e3e62d4 100644 (file)
@@ -370,7 +370,7 @@ public:
     void didPerformDragControllerAction(uint64_t resultOperation);
     void dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation);
 #if PLATFORM(MAC)
-    void setDragImage(const WebCore::IntPoint& clientPosition, const WebCore::IntSize& imageSize, const SharedMemory::Handle& dragImageHandle, bool isLinkDrag);
+    void setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, bool isLinkDrag);
 #endif
 #if PLATFORM(WIN)
     void startDragDrop(const WebCore::IntPoint& imagePoint, const WebCore::IntPoint& dragPoint, uint64_t okEffect, const HashMap<UINT, Vector<String> >& dataMap, const WebCore::IntSize& dragImageSize, const SharedMemory::Handle& dragImageHandle, bool isLinkDrag);
@@ -586,7 +586,7 @@ private:
     
     // Find.
     void didCountStringMatches(const String&, uint32_t matchCount);
-    void setFindIndicator(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, const SharedMemory::Handle& contentImageHandle, bool fadeOut);
+    void setFindIndicator(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut);
     void didFindString(const String&, uint32_t matchCount);
     void didFailToFindString(const String&);
 
index a02b7b8..e145d82 100644 (file)
@@ -159,7 +159,7 @@ messages -> WebPageProxy {
 
     # Find messages
     DidCountStringMatches(WTF::String string, uint32_t matchCount)
-    SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, WebKit::SharedMemory::Handle contentImageHandle, bool fadeOut)
+    SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, WebKit::ShareableBitmap::Handle contentImageHandle, bool fadeOut)
     DidFindString(WTF::String string, uint32_t matchCount)
     DidFailToFindString(WTF::String string)
 
@@ -203,7 +203,7 @@ messages -> WebPageProxy {
     # Drag and drop messages
     DidPerformDragControllerAction(uint64_t resultOperation)
 #if PLATFORM(MAC)
-    SetDragImage(WebCore::IntPoint clientPosition, WebCore::IntSize imageSize, WebKit::SharedMemory::Handle dragImage, bool linkDrag)
+    SetDragImage(WebCore::IntPoint clientPosition, WebKit::ShareableBitmap::Handle dragImage, bool linkDrag)
 #endif
 #if PLATFORM(WIN)
     StartDragDrop(WebCore::IntPoint imagePoint, WebCore::IntPoint dragPoint, uint64_t okEffect, HashMap<UINT,Vector<String> > dataMap, WebCore::IntSize dragImageSize, WebKit::SharedMemory::Handle dragImage, bool linkDrag)
index ae0a8e5..90df81e 100644 (file)
@@ -169,13 +169,13 @@ bool WebPageProxy::readSelectionFromPasteboard(const String& pasteboardName)
     return result;
 }
 
-void WebPageProxy::setDragImage(const WebCore::IntPoint& clientPosition, const IntSize& imageSize, const SharedMemory::Handle& dragImageHandle, bool isLinkDrag)
+void WebPageProxy::setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, bool isLinkDrag)
 {
-    RefPtr<ShareableBitmap> dragImage = ShareableBitmap::create(imageSize, dragImageHandle);
+    RefPtr<ShareableBitmap> dragImage = ShareableBitmap::create(dragImageHandle);
     if (!dragImage)
         return;
     
-    m_pageClient->setDragImage(clientPosition, imageSize, dragImage.release(), isLinkDrag);
+    m_pageClient->setDragImage(clientPosition, dragImage.release(), isLinkDrag);
 }
 
 void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint& point)
index 7285816..8f02cf5 100644 (file)
@@ -153,11 +153,10 @@ void PluginProxy::paint(GraphicsContext* graphicsContext, const IntRect& dirtyRe
 
 PassRefPtr<ShareableBitmap> PluginProxy::snapshot()
 {
-    IntSize bufferSize;
-    SharedMemory::Handle snapshotStoreHandle;
-    m_connection->connection()->sendSync(Messages::PluginControllerProxy::Snapshot(), Messages::PluginControllerProxy::Snapshot::Reply(bufferSize, snapshotStoreHandle), m_pluginInstanceID);
+    ShareableBitmap::Handle snapshotStoreHandle;
+    m_connection->connection()->sendSync(Messages::PluginControllerProxy::Snapshot(), Messages::PluginControllerProxy::Snapshot::Reply(snapshotStoreHandle), m_pluginInstanceID);
 
-    RefPtr<ShareableBitmap> snapshotBuffer = ShareableBitmap::create(bufferSize, snapshotStoreHandle);
+    RefPtr<ShareableBitmap> snapshotBuffer = ShareableBitmap::create(snapshotStoreHandle);
     return snapshotBuffer.release();
 }
 
@@ -175,7 +174,7 @@ void PluginProxy::geometryDidChange(const IntRect& frameRect, const IntRect& cli
     m_frameRect = frameRect;
 
     if (!needsBackingStore()) {
-        SharedMemory::Handle pluginBackingStoreHandle;
+        ShareableBitmap::Handle pluginBackingStoreHandle;
         m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(frameRect, clipRect, pluginBackingStoreHandle), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
         return;
     }
@@ -192,7 +191,7 @@ void PluginProxy::geometryDidChange(const IntRect& frameRect, const IntRect& cli
         didUpdateBackingStore = true;
     }
 
-    SharedMemory::Handle pluginBackingStoreHandle;
+    ShareableBitmap::Handle pluginBackingStoreHandle;
 
     if (didUpdateBackingStore) {
         // Create a new plug-in backing store.
index a11e0c6..575e88b 100644 (file)
@@ -93,12 +93,12 @@ static PassRefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image)
 void WebDragClient::startDrag(RetainPtr<NSImage> image, const IntPoint& point, const IntPoint&, Clipboard*, Frame* frame, bool linkDrag)
 {
     RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get());
-    SharedMemory::Handle handle;
+    ShareableBitmap::Handle handle;
     if (!bitmap->createHandle(handle))
         return;
 
     // FIXME: Seems this message should be named StartDrag, not SetDragImage.
-    m_page->send(Messages::WebPageProxy::SetDragImage(frame->view()->contentsToWindow(point), bitmap->size(), handle, linkDrag));
+    m_page->send(Messages::WebPageProxy::SetDragImage(frame->view()->contentsToWindow(point), handle, linkDrag));
 }
 
 static CachedImage* cachedImage(Element* element)
index b4db406..f791fd9 100644 (file)
@@ -78,9 +78,9 @@ void WebPopupMenu::setUpPlatformData(const WebCore::IntRect& pageCoordinates, Pl
     // The backing stores should be drawn at least as wide as the control on the page to match the width of the popup window we'll create.
     int backingStoreWidth = max(pageCoordinates.width() - m_popupClient->clientInsetLeft() - m_popupClient->clientInsetRight(), popupWidth);
 
-    data.m_backingStoreSize = IntSize(backingStoreWidth, (itemCount * data.m_itemHeight));
-    data.m_notSelectedBackingStore = ShareableBitmap::createShareable(data.m_backingStoreSize);
-    data.m_selectedBackingStore = ShareableBitmap::createShareable(data.m_backingStoreSize);
+    IntSize backingStoreSize(backingStoreWidth, (itemCount * data.m_itemHeight));
+    data.m_notSelectedBackingStore = ShareableBitmap::createShareable(backingStoreSize);
+    data.m_selectedBackingStore = ShareableBitmap::createShareable(backingStoreSize);
 
     OwnPtr<GraphicsContext> notSelectedBackingStoreContext = data.m_notSelectedBackingStore->createGraphicsContext();
     OwnPtr<GraphicsContext> selectedBackingStoreContext = data.m_selectedBackingStore->createGraphicsContext();
@@ -88,7 +88,7 @@ void WebPopupMenu::setUpPlatformData(const WebCore::IntRect& pageCoordinates, Pl
     Color activeOptionBackgroundColor = RenderTheme::defaultTheme()->activeListBoxSelectionBackgroundColor();
     Color activeOptionTextColor = RenderTheme::defaultTheme()->activeListBoxSelectionForegroundColor();
 
-    for (int y = 0; y < data.m_backingStoreSize.height(); y += data.m_itemHeight) {
+    for (int y = 0; y < backingStoreSize.height(); y += data.m_itemHeight) {
         int index = y / data.m_itemHeight;
 
         PopupMenuStyle itemStyle = m_popupClient->itemStyle(index);
index aae8b25..50cf6cb 100644 (file)
@@ -182,7 +182,7 @@ bool FindController::updateFindIndicator(Frame* selectedFrame, bool isShowingOve
     selectedFrame->view()->paint(graphicsContext.get(), paintRect);
     selectedFrame->view()->setPaintBehavior(PaintBehaviorNormal);
     
-    SharedMemory::Handle handle;
+    ShareableBitmap::Handle handle;
     if (!findIndicatorTextBackingStore->createHandle(handle))
         return false;
 
@@ -207,7 +207,7 @@ void FindController::hideFindIndicator()
     if (!m_isShowingFindIndicator)
         return;
 
-    SharedMemory::Handle handle;
+    ShareableBitmap::Handle handle;
     m_webPage->send(Messages::WebPageProxy::SetFindIndicator(FloatRect(), Vector<FloatRect>(), handle, false));
     m_isShowingFindIndicator = false;
 }