Title: [211310] trunk/Source/WebKit2
Revision
211310
Author
beid...@apple.com
Date
2017-01-27 16:10:55 -0800 (Fri, 27 Jan 2017)

Log Message

IconLoadingClient API doesn't work asynchronously.
<rdar://problem/30243429> and https://bugs.webkit.org/show_bug.cgi?id=167532

Reviewed by Alex Christensen.

Make a WTF::Function (inherently not compatible with ObjC blocks as they must be copyable)
into a std::function, which is copyable.

* UIProcess/API/APIIconLoadingClient.h:
(API::IconLoadingClient::getLoadDecisionForIcon):

* UIProcess/API/mac/WKView.mm:
(-[WKView maybeInstallIconLoadingClient]):

* UIProcess/Cocoa/IconLoadingDelegate.h:
* UIProcess/Cocoa/IconLoadingDelegate.mm:
(WebKit::IconLoadingDelegate::IconLoadingClient::getLoadDecisionForIcon):

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::getLoadDecisionForIcon):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (211309 => 211310)


--- trunk/Source/WebKit2/ChangeLog	2017-01-28 00:03:36 UTC (rev 211309)
+++ trunk/Source/WebKit2/ChangeLog	2017-01-28 00:10:55 UTC (rev 211310)
@@ -1,3 +1,26 @@
+2017-01-27  Brady Eidson  <beid...@apple.com>
+
+        IconLoadingClient API doesn't work asynchronously.
+        <rdar://problem/30243429> and https://bugs.webkit.org/show_bug.cgi?id=167532
+
+        Reviewed by Alex Christensen.
+
+        Make a WTF::Function (inherently not compatible with ObjC blocks as they must be copyable)
+        into a std::function, which is copyable.
+
+        * UIProcess/API/APIIconLoadingClient.h:
+        (API::IconLoadingClient::getLoadDecisionForIcon):
+        
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView maybeInstallIconLoadingClient]):
+        
+        * UIProcess/Cocoa/IconLoadingDelegate.h:
+        * UIProcess/Cocoa/IconLoadingDelegate.mm:
+        (WebKit::IconLoadingDelegate::IconLoadingClient::getLoadDecisionForIcon):
+        
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::getLoadDecisionForIcon):
+
 2017-01-27  Chris Dumez  <cdu...@apple.com>
 
         Fix remaining bad uses of logDiagnosticMessageWithValue()

Modified: trunk/Source/WebKit2/UIProcess/API/APIIconLoadingClient.h (211309 => 211310)


--- trunk/Source/WebKit2/UIProcess/API/APIIconLoadingClient.h	2017-01-28 00:03:36 UTC (rev 211309)
+++ trunk/Source/WebKit2/UIProcess/API/APIIconLoadingClient.h	2017-01-28 00:10:55 UTC (rev 211310)
@@ -39,7 +39,7 @@
 public:
     virtual ~IconLoadingClient() { }
 
-    virtual void getLoadDecisionForIcon(const WebCore::LinkIcon&, Function<void (std::function<void (API::Data*, WebKit::CallbackBase::Error)>)>&& completionHandler) {
+    virtual void getLoadDecisionForIcon(const WebCore::LinkIcon&, std::function<void (std::function<void (API::Data*, WebKit::CallbackBase::Error)>)> completionHandler) {
         completionHandler(nullptr);
     }
 };

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (211309 => 211310)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2017-01-28 00:03:36 UTC (rev 211309)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2017-01-28 00:10:55 UTC (rev 211310)
@@ -871,10 +871,10 @@
     private:
         typedef void (^IconLoadCompletionHandler)(NSData*);
 
-        void getLoadDecisionForIcon(const WebCore::LinkIcon& linkIcon, Function<void (std::function<void (API::Data*, WebKit::CallbackBase::Error)>)>&& completionHandler) override {
+        void getLoadDecisionForIcon(const WebCore::LinkIcon& linkIcon, std::function<void (std::function<void (API::Data*, WebKit::CallbackBase::Error)>)> completionHandler) override {
             RetainPtr<_WKLinkIconParameters> parameters = adoptNS([[_WKLinkIconParameters alloc] _initWithLinkIcon:linkIcon]);
 
-            [m_wkView performSelector:delegateSelector() withObject:parameters.get() withObject:^void (IconLoadCompletionHandler loadCompletionHandler) {
+            [m_wkView performSelector:delegateSelector() withObject:parameters.get() withObject:[completionHandler = WTFMove(completionHandler)](IconLoadCompletionHandler loadCompletionHandler) {
                 if (loadCompletionHandler) {
                     completionHandler([loadCompletionHandler = BlockPtr<void (NSData *)>(loadCompletionHandler)](API::Data* data, WebKit::CallbackBase::Error error) {
                         if (error != CallbackBase::Error::None || !data)

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/IconLoadingDelegate.h (211309 => 211310)


--- trunk/Source/WebKit2/UIProcess/Cocoa/IconLoadingDelegate.h	2017-01-28 00:03:36 UTC (rev 211309)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/IconLoadingDelegate.h	2017-01-28 00:10:55 UTC (rev 211310)
@@ -55,7 +55,7 @@
         ~IconLoadingClient();
 
     private:
-        void getLoadDecisionForIcon(const WebCore::LinkIcon&, Function<void (std::function<void (API::Data*, WebKit::CallbackBase::Error)>)>&& completionHandler) override;
+        void getLoadDecisionForIcon(const WebCore::LinkIcon&, std::function<void (std::function<void (API::Data*, WebKit::CallbackBase::Error)>)> completionHandler) override;
 
         IconLoadingDelegate& m_iconLoadingDelegate;
     };

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/IconLoadingDelegate.mm (211309 => 211310)


--- trunk/Source/WebKit2/UIProcess/Cocoa/IconLoadingDelegate.mm	2017-01-28 00:03:36 UTC (rev 211309)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/IconLoadingDelegate.mm	2017-01-28 00:10:55 UTC (rev 211310)
@@ -71,7 +71,7 @@
 
 typedef void (^IconLoadCompletionHandler)(NSData*);
 
-void IconLoadingDelegate::IconLoadingClient::getLoadDecisionForIcon(const WebCore::LinkIcon& linkIcon, Function<void (std::function<void (API::Data*, WebKit::CallbackBase::Error)>)>&& completionHandler)
+void IconLoadingDelegate::IconLoadingClient::getLoadDecisionForIcon(const WebCore::LinkIcon& linkIcon, std::function<void (std::function<void (API::Data*, WebKit::CallbackBase::Error)>)> completionHandler)
 {
     if (!m_iconLoadingDelegate.m_delegateMethods.webViewShouldLoadIconWithParametersCompletionHandler) {
         completionHandler(nullptr);

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (211309 => 211310)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2017-01-28 00:03:36 UTC (rev 211309)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2017-01-28 00:10:55 UTC (rev 211310)
@@ -6728,7 +6728,7 @@
     if (!m_iconLoadingClient)
         return;
 
-    m_iconLoadingClient->getLoadDecisionForIcon(icon, [this, protectedThis = Ref<WebPageProxy>(*this), loadIdentifier](std::function<void (API::Data*, CallbackBase::Error)> callbackFunction) {
+    m_iconLoadingClient->getLoadDecisionForIcon(icon, [this, protectedThis = RefPtr<WebPageProxy>(this), loadIdentifier](std::function<void (API::Data*, CallbackBase::Error)> callbackFunction) {
         if (!isValid()) {
             if (callbackFunction)
                 callbackFunction(nullptr, CallbackBase::Error::Unknown);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to