Title: [177748] trunk/Source/WebKit2
Revision
177748
Author
[email protected]
Date
2014-12-26 11:26:53 -0800 (Fri, 26 Dec 2014)

Log Message

Add the notion of auto-converting page and frame handles
https://bugs.webkit.org/show_bug.cgi?id=139954

Reviewed by Dan Bernstein.

This makes it possible to tell the difference between page and frame handles that
should be converted to their respective UI or web process object representations
and handles that should stay the same (for the modern API for example).

* Shared/API/APIFrameHandle.cpp:
(API::FrameHandle::create):
(API::FrameHandle::createAutoconverting):
(API::FrameHandle::FrameHandle):
* Shared/API/APIFrameHandle.h:
(API::FrameHandle::isAutoconverting):
* Shared/API/APIPageHandle.cpp:
(API::PageHandle::create):
(API::PageHandle::createAutoconverting):
(API::PageHandle::PageHandle):
* Shared/API/APIPageHandle.h:
(API::PageHandle::isAutoconverting):
* Shared/API/Cocoa/_WKFrameHandle.mm:
(-[_WKFrameHandle initWithCoder:]):
* Shared/UserData.cpp:
(WebKit::shouldTransform):
* Shared/UserData.h:
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::UIClient::printFrame):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::transformHandlesToObjects):
(WebKit::WebProcessProxy::transformObjectsToHandles):
* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm:
(-[WKWebProcessPlugInFrame handle]):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::transformHandlesToObjects):
(WebKit::WebProcess::transformObjectsToHandles):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (177747 => 177748)


--- trunk/Source/WebKit2/ChangeLog	2014-12-26 19:18:49 UTC (rev 177747)
+++ trunk/Source/WebKit2/ChangeLog	2014-12-26 19:26:53 UTC (rev 177748)
@@ -1,3 +1,42 @@
+2014-12-26  Anders Carlsson  <[email protected]>
+
+        Add the notion of auto-converting page and frame handles
+        https://bugs.webkit.org/show_bug.cgi?id=139954
+
+        Reviewed by Dan Bernstein.
+
+        This makes it possible to tell the difference between page and frame handles that
+        should be converted to their respective UI or web process object representations
+        and handles that should stay the same (for the modern API for example).
+        
+        * Shared/API/APIFrameHandle.cpp:
+        (API::FrameHandle::create):
+        (API::FrameHandle::createAutoconverting):
+        (API::FrameHandle::FrameHandle):
+        * Shared/API/APIFrameHandle.h:
+        (API::FrameHandle::isAutoconverting):
+        * Shared/API/APIPageHandle.cpp:
+        (API::PageHandle::create):
+        (API::PageHandle::createAutoconverting):
+        (API::PageHandle::PageHandle):
+        * Shared/API/APIPageHandle.h:
+        (API::PageHandle::isAutoconverting):
+        * Shared/API/Cocoa/_WKFrameHandle.mm:
+        (-[_WKFrameHandle initWithCoder:]):
+        * Shared/UserData.cpp:
+        (WebKit::shouldTransform):
+        * Shared/UserData.h:
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::UIDelegate::UIClient::printFrame):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::transformHandlesToObjects):
+        (WebKit::WebProcessProxy::transformObjectsToHandles):
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm:
+        (-[WKWebProcessPlugInFrame handle]):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::transformHandlesToObjects):
+        (WebKit::WebProcess::transformObjectsToHandles):
+
 2014-12-26  Dan Bernstein  <[email protected]>
 
         [Cocoa] Some modern SPI changes have missing or incorrect availability annotations

Modified: trunk/Source/WebKit2/Shared/API/APIFrameHandle.cpp (177747 => 177748)


--- trunk/Source/WebKit2/Shared/API/APIFrameHandle.cpp	2014-12-26 19:18:49 UTC (rev 177747)
+++ trunk/Source/WebKit2/Shared/API/APIFrameHandle.cpp	2014-12-26 19:26:53 UTC (rev 177748)
@@ -28,13 +28,19 @@
 
 namespace API {
 
-PassRefPtr<FrameHandle> FrameHandle::create(uint64_t frameID)
+Ref<FrameHandle> FrameHandle::create(uint64_t frameID)
 {
-    return adoptRef(new FrameHandle(frameID));
+    return adoptRef(*new FrameHandle(frameID, false));
 }
 
-FrameHandle::FrameHandle(uint64_t frameID)
+Ref<FrameHandle> FrameHandle::createAutoconverting(uint64_t frameID)
+{
+    return adoptRef(*new FrameHandle(frameID, true));
+}
+
+FrameHandle::FrameHandle(uint64_t frameID, bool isAutoconverting)
     : m_frameID(frameID)
+    , m_isAutoconverting(isAutoconverting)
 {
 }
 

Modified: trunk/Source/WebKit2/Shared/API/APIFrameHandle.h (177747 => 177748)


--- trunk/Source/WebKit2/Shared/API/APIFrameHandle.h	2014-12-26 19:18:49 UTC (rev 177747)
+++ trunk/Source/WebKit2/Shared/API/APIFrameHandle.h	2014-12-26 19:26:53 UTC (rev 177748)
@@ -27,21 +27,24 @@
 #define APIFrameHandle_h
 
 #include "APIObject.h"
-#include <wtf/RefPtr.h>
+#include <wtf/Ref.h>
 
 namespace API {
 
 class FrameHandle : public ObjectImpl<Object::Type::FrameHandle> {
 public:
-    explicit FrameHandle(uint64_t frameID);
+    static Ref<FrameHandle> create(uint64_t frameID);
+    static Ref<FrameHandle> createAutoconverting(uint64_t frameID);
+    explicit FrameHandle(uint64_t frameID, bool isAutoconverting);
 
-    static PassRefPtr<FrameHandle> create(uint64_t frameID);
     virtual ~FrameHandle();
 
     uint64_t frameID() const { return m_frameID; }
+    bool isAutoconverting() const { return m_isAutoconverting; }
 
 private:
-    uint64_t m_frameID;
+    const uint64_t m_frameID;
+    const bool m_isAutoconverting;
 };
 
 } // namespace API

Modified: trunk/Source/WebKit2/Shared/API/APIPageHandle.cpp (177747 => 177748)


--- trunk/Source/WebKit2/Shared/API/APIPageHandle.cpp	2014-12-26 19:18:49 UTC (rev 177747)
+++ trunk/Source/WebKit2/Shared/API/APIPageHandle.cpp	2014-12-26 19:26:53 UTC (rev 177748)
@@ -28,13 +28,19 @@
 
 namespace API {
 
-RefPtr<PageHandle> PageHandle::create(uint64_t pageID)
+Ref<PageHandle> PageHandle::create(uint64_t pageID)
 {
-    return adoptRef(new PageHandle(pageID));
+    return adoptRef(*new PageHandle(pageID, false));
 }
 
-PageHandle::PageHandle(uint64_t pageID)
+Ref<PageHandle> PageHandle::createAutoconverting(uint64_t pageID)
+{
+    return adoptRef(*new PageHandle(pageID, true));
+}
+
+PageHandle::PageHandle(uint64_t pageID, bool isAutoconverting)
     : m_pageID(pageID)
+    , m_isAutoconverting(isAutoconverting)
 {
 }
 

Modified: trunk/Source/WebKit2/Shared/API/APIPageHandle.h (177747 => 177748)


--- trunk/Source/WebKit2/Shared/API/APIPageHandle.h	2014-12-26 19:18:49 UTC (rev 177747)
+++ trunk/Source/WebKit2/Shared/API/APIPageHandle.h	2014-12-26 19:26:53 UTC (rev 177748)
@@ -27,21 +27,24 @@
 #define APIPageHandle_h
 
 #include "APIObject.h"
-#include <wtf/RefPtr.h>
+#include <wtf/Ref.h>
 
 namespace API {
 
 class PageHandle : public ObjectImpl<Object::Type::PageHandle> {
 public:
-    static RefPtr<PageHandle> create(uint64_t pageID);
+    static Ref<PageHandle> create(uint64_t pageID);
+    static Ref<PageHandle> createAutoconverting(uint64_t pageID);
     virtual ~PageHandle();
 
     uint64_t pageID() const { return m_pageID; }
+    bool isAutoconverting() const { return m_isAutoconverting; }
 
 private:
-    explicit PageHandle(uint64_t pageID);
+    explicit PageHandle(uint64_t pageID, bool isAutoconverting);
 
-    uint64_t m_pageID;
+    const uint64_t m_pageID;
+    const bool m_isAutoconverting;
 };
 
 } // namespace API

Modified: trunk/Source/WebKit2/Shared/API/Cocoa/_WKFrameHandle.mm (177747 => 177748)


--- trunk/Source/WebKit2/Shared/API/Cocoa/_WKFrameHandle.mm	2014-12-26 19:18:49 UTC (rev 177747)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/_WKFrameHandle.mm	2014-12-26 19:26:53 UTC (rev 177748)
@@ -87,7 +87,7 @@
         return nil;
     }
 
-    API::Object::constructInWrapper<API::FrameHandle>(self, frameID.unsignedLongLongValue);
+    API::Object::constructInWrapper<API::FrameHandle>(self, frameID.unsignedLongLongValue, false);
 
     return self;
 }

Modified: trunk/Source/WebKit2/Shared/UserData.cpp (177747 => 177748)


--- trunk/Source/WebKit2/Shared/UserData.cpp	2014-12-26 19:18:49 UTC (rev 177747)
+++ trunk/Source/WebKit2/Shared/UserData.cpp	2014-12-26 19:26:53 UTC (rev 177748)
@@ -83,7 +83,7 @@
         }
     }
 
-    return transformer.shouldTransformObjectOfType(object.type());
+    return transformer.shouldTransformObject(object);
 }
 
 static RefPtr<API::Object> transformGraph(API::Object& object, const UserData::Transformer& transformer)

Modified: trunk/Source/WebKit2/Shared/UserData.h (177747 => 177748)


--- trunk/Source/WebKit2/Shared/UserData.h	2014-12-26 19:18:49 UTC (rev 177747)
+++ trunk/Source/WebKit2/Shared/UserData.h	2014-12-26 19:26:53 UTC (rev 177748)
@@ -44,7 +44,7 @@
 
     struct Transformer {
         virtual ~Transformer() { }
-        virtual bool shouldTransformObjectOfType(API::Object::Type) const = 0;
+        virtual bool shouldTransformObject(const API::Object&) const = 0;
         virtual RefPtr<API::Object> transformObject(API::Object&) const = 0;
     };
     static RefPtr<API::Object> transform(API::Object*, const Transformer&);

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm (177747 => 177748)


--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm	2014-12-26 19:18:49 UTC (rev 177747)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm	2014-12-26 19:26:53 UTC (rev 177748)
@@ -229,7 +229,7 @@
     if (!delegate)
         return;
 
-    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(*API::FrameHandle::create(webFrameProxy->frameID()))];
+    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(API::FrameHandle::create(webFrameProxy->frameID()))];
 }
 
 void UIDelegate::UIClient::close(WebKit::WebPageProxy*)

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (177747 => 177748)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2014-12-26 19:18:49 UTC (rev 177747)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2014-12-26 19:26:53 UTC (rev 177748)
@@ -659,11 +659,15 @@
         {
         }
 
-        virtual bool shouldTransformObjectOfType(API::Object::Type type) const
+        virtual bool shouldTransformObject(const API::Object& object) const override
         {
-            switch (type) {
+            switch (object.type()) {
             case API::Object::Type::FrameHandle:
+                return static_cast<const API::FrameHandle&>(object).isAutoconverting();
+
             case API::Object::Type::PageHandle:
+                return static_cast<const API::PageHandle&>(object).isAutoconverting();
+
             case API::Object::Type::PageGroupHandle:
 #if PLATFORM(COCOA)
             case API::Object::Type::ObjCObjectGraph:
@@ -679,12 +683,14 @@
         {
             switch (object.type()) {
             case API::Object::Type::FrameHandle:
+                ASSERT(static_cast<API::FrameHandle&>(object).isAutoconverting());
                 return m_webProcessProxy.webFrame(static_cast<API::FrameHandle&>(object).frameID());
 
             case API::Object::Type::PageGroupHandle:
                 return WebPageGroup::get(static_cast<API::PageGroupHandle&>(object).webPageGroupData().pageGroupID);
 
             case API::Object::Type::PageHandle:
+                ASSERT(static_cast<API::PageHandle&>(object).isAutoconverting());
                 return m_webProcessProxy.webPage(static_cast<API::PageHandle&>(object).pageID());
 
 #if PLATFORM(COCOA)
@@ -705,9 +711,9 @@
 RefPtr<API::Object> WebProcessProxy::transformObjectsToHandles(API::Object* object)
 {
     struct Transformer final : UserData::Transformer {
-        virtual bool shouldTransformObjectOfType(API::Object::Type type) const
+        virtual bool shouldTransformObject(const API::Object& object) const
         {
-            switch (type) {
+            switch (object.type()) {
             case API::Object::Type::Frame:
             case API::Object::Type::Page:
             case API::Object::Type::PageGroup:
@@ -725,10 +731,10 @@
         {
             switch (object.type()) {
             case API::Object::Type::Frame:
-                return API::FrameHandle::create(static_cast<const WebFrameProxy&>(object).frameID());
+                return API::FrameHandle::createAutoconverting(static_cast<const WebFrameProxy&>(object).frameID());
 
             case API::Object::Type::Page:
-                return API::PageHandle::create(static_cast<const WebPageProxy&>(object).pageID());
+                return API::PageHandle::createAutoconverting(static_cast<const WebPageProxy&>(object).pageID());
 
             case API::Object::Type::PageGroup:
                 return API::PageGroupHandle::create(WebPageGroupData(static_cast<const WebPageGroup&>(object).data()));

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm (177747 => 177748)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm	2014-12-26 19:18:49 UTC (rev 177747)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm	2014-12-26 19:26:53 UTC (rev 177748)
@@ -100,7 +100,7 @@
 
 - (_WKFrameHandle *)handle
 {
-    return [wrapper(*API::FrameHandle::create(_frame->frameID()).leakRef()) autorelease];
+    return [wrapper(API::FrameHandle::create(_frame->frameID()).leakRef()) autorelease];
 }
 
 - (BOOL)_hasCustomContentProvider

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (177747 => 177748)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2014-12-26 19:18:49 UTC (rev 177747)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2014-12-26 19:26:53 UTC (rev 177748)
@@ -1233,11 +1233,15 @@
         {
         }
 
-        virtual bool shouldTransformObjectOfType(API::Object::Type type) const
+        virtual bool shouldTransformObject(const API::Object& object) const override
         {
-            switch (type) {
+            switch (object.type()) {
             case API::Object::Type::FrameHandle:
+                return static_cast<const API::FrameHandle&>(object).isAutoconverting();
+
             case API::Object::Type::PageHandle:
+                return static_cast<const API::PageHandle&>(object).isAutoconverting();
+
             case API::Object::Type::PageGroupHandle:
 #if PLATFORM(COCOA)
             case API::Object::Type::ObjCObjectGraph:
@@ -1279,9 +1283,9 @@
 RefPtr<API::Object> WebProcess::transformObjectsToHandles(API::Object* object)
 {
     struct Transformer final : UserData::Transformer {
-        virtual bool shouldTransformObjectOfType(API::Object::Type type) const override
+        virtual bool shouldTransformObject(const API::Object& object) const override
         {
-            switch (type) {
+            switch (object.type()) {
             case API::Object::Type::BundleFrame:
             case API::Object::Type::BundlePage:
             case API::Object::Type::BundlePageGroup:
@@ -1299,10 +1303,10 @@
         {
             switch (object.type()) {
             case API::Object::Type::BundleFrame:
-                return API::FrameHandle::create(static_cast<const WebFrame&>(object).frameID());
+                return API::FrameHandle::createAutoconverting(static_cast<const WebFrame&>(object).frameID());
 
             case API::Object::Type::BundlePage:
-                return API::PageHandle::create(static_cast<const WebPage&>(object).pageID());
+                return API::PageHandle::createAutoconverting(static_cast<const WebPage&>(object).pageID());
 
             case API::Object::Type::BundlePageGroup: {
                 WebPageGroupData pageGroupData;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to