Title: [160047] trunk/Source/WebKit2
Revision
160047
Author
[email protected]
Date
2013-12-03 15:19:40 -0800 (Tue, 03 Dec 2013)

Log Message

PageBannerClientImpl should be an API::Client
https://bugs.webkit.org/show_bug.cgi?id=125190

Reviewed by Tim Horton.

* WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.mm:
(PageBannerClientImpl::PageBannerClientImpl):
(PageBannerClientImpl::~PageBannerClientImpl):
(WKBundlePageBannerCreateBannerWithCALayer):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (160046 => 160047)


--- trunk/Source/WebKit2/ChangeLog	2013-12-03 23:03:09 UTC (rev 160046)
+++ trunk/Source/WebKit2/ChangeLog	2013-12-03 23:19:40 UTC (rev 160047)
@@ -1,3 +1,15 @@
+2013-12-03  Anders Carlsson  <[email protected]>
+
+        PageBannerClientImpl should be an API::Client
+        https://bugs.webkit.org/show_bug.cgi?id=125190
+
+        Reviewed by Tim Horton.
+
+        * WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.mm:
+        (PageBannerClientImpl::PageBannerClientImpl):
+        (PageBannerClientImpl::~PageBannerClientImpl):
+        (WKBundlePageBannerCreateBannerWithCALayer):
+
 2013-12-03  Dan Bernstein  <[email protected]>
 
         [Cocoa] Give two load delegate methods more conventional names

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.mm (160046 => 160047)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.mm	2013-12-03 23:03:09 UTC (rev 160046)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.mm	2013-12-03 23:19:40 UTC (rev 160047)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "WKBundlePageBannerMac.h"
 
+#include "APIClient.h"
 #include "PageBanner.h"
 #include "WKAPICast.h"
 #include "WKBundleAPICast.h"
@@ -34,66 +35,71 @@
 using namespace WebCore;
 using namespace WebKit;
 
-class PageBannerClientImpl : public PageBanner::Client {
+namespace API {
+template<> struct ClientTraits<WKBundlePageBannerClientBase> {
+    typedef std::tuple<WKBundlePageBannerClientV0> Versions;
+};
+}
+
+class PageBannerClientImpl : API::Client<WKBundlePageBannerClientBase>, public PageBanner::Client {
 public:
-    explicit PageBannerClientImpl(WKBundlePageBannerClient* client)
-        : m_client()
+    explicit PageBannerClientImpl(WKBundlePageBannerClientBase* client)
     {
-        if (client)
-            m_client = *client;
     }
 
+    virtual ~PageBannerClientImpl()
+    {
+    }
+
 private:
     // PageBanner::Client.
-    virtual void pageBannerDestroyed(PageBanner*)
+    virtual void pageBannerDestroyed(PageBanner*) OVERRIDE
     {
         delete this;
     }
     
-    virtual bool mouseEvent(PageBanner* pageBanner, WebEvent::Type type, WebMouseEvent::Button button, const WebCore::IntPoint& position)
+    virtual bool mouseEvent(PageBanner* pageBanner, WebEvent::Type type, WebMouseEvent::Button button, const IntPoint& position) OVERRIDE
     {
         switch (type) {
         case WebEvent::MouseDown: {
             if (!m_client.mouseDown)
                 return false;
 
-            return m_client.mouseDown(toAPI(pageBanner), toAPI(position), toAPI(button), m_client.clientInfo);
+            return m_client.mouseDown(toAPI(pageBanner), toAPI(position), toAPI(button), m_client.base.clientInfo);
         }
         case WebEvent::MouseUp: {
             if (!m_client.mouseUp)
                 return false;
 
-            return m_client.mouseUp(toAPI(pageBanner), toAPI(position), toAPI(button), m_client.clientInfo);
+            return m_client.mouseUp(toAPI(pageBanner), toAPI(position), toAPI(button), m_client.base.clientInfo);
         }
         case WebEvent::MouseMove: {
             if (button == WebMouseEvent::NoButton) {
                 if (!m_client.mouseMoved)
                     return false;
 
-                return m_client.mouseMoved(toAPI(pageBanner), toAPI(position), m_client.clientInfo);
+                return m_client.mouseMoved(toAPI(pageBanner), toAPI(position), m_client.base.clientInfo);
             }
 
             // This is a MouseMove event with a mouse button pressed. Call mouseDragged.
             if (!m_client.mouseDragged)
                 return false;
 
-            return m_client.mouseDragged(toAPI(pageBanner), toAPI(position), toAPI(button), m_client.clientInfo);
+            return m_client.mouseDragged(toAPI(pageBanner), toAPI(position), toAPI(button), m_client.base.clientInfo);
         }
 
         default:
             return false;
         }
     }
-    
-    WKBundlePageBannerClient m_client;
 };
 
-WKBundlePageBannerRef WKBundlePageBannerCreateBannerWithCALayer(CALayer *layer, int height, WKBundlePageBannerClient * wkClient)
+WKBundlePageBannerRef WKBundlePageBannerCreateBannerWithCALayer(CALayer *layer, int height, WKBundlePageBannerClient* wkClient)
 {
     if (wkClient && wkClient->version)
         return 0;
 
-    auto clientImpl = std::make_unique<PageBannerClientImpl>(wkClient);
+    auto clientImpl = std::make_unique<PageBannerClientImpl>(reinterpret_cast<WKBundlePageBannerClientBase*>(wkClient));
     return toAPI(PageBanner::create(layer, height, clientImpl.release()).leakRef());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to