RESOLVED FIXED Bug 209192
Add WKUIDelegatePrivate SPI _webView:printFrame:completionHandler:
https://bugs.webkit.org/show_bug.cgi?id=209192
Summary Add WKUIDelegatePrivate SPI _webView:printFrame:completionHandler:
Alex Christensen
Reported 2020-03-17 12:34:57 PDT
Add WKUIDelegatePrivate SPI _webView:printFrame:completionHandler:
Attachments
Patch (11.66 KB, patch)
2020-03-17 12:38 PDT, Alex Christensen
ggaren: review+
Alex Christensen
Comment 1 2020-03-17 12:38:04 PDT
Alex Christensen
Comment 2 2020-03-17 12:38:12 PDT
Geoffrey Garen
Comment 3 2020-03-17 12:40:56 PDT
Comment on attachment 393777 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=393777&action=review r=me > Source/WebKit/UIProcess/Cocoa/UIDelegate.mm:1099 > + auto handle = API::FrameHandle::create(webFrameProxy.frameID()); > + if (m_uiDelegate.m_delegateMethods.webViewPrintFrame) { > + [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(handle)]; > + completionHandler(); > + } else if (m_uiDelegate.m_delegateMethods.webViewPrintFrameCompletionHandler) { > + auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:printFrame:completionHandler:)); > + [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(handle) completionHandler:makeBlockPtr([checker = WTFMove(checker), completionHandler = WTFMove(completionHandler)] () mutable { > + if (checker->completionHandlerHasBeenCalled()) > + return; > + checker->didCallCompletionHandler(); > + completionHandler(); > + }).get()]; > + } else > + completionHandler(); I think you want to do the delegate method check in the opposite order, so the new API wins if implemented. That way, a client can implement both if they need to support older WebKits, without doing #ifdef stuff.
Alex Christensen
Comment 4 2020-03-17 12:47:48 PDT
They could also do crazy things with their own implementation of respondsToSelector, but you're right. I switched them. http://trac.webkit.org/r258574
Alex Christensen
Comment 5 2020-03-17 12:50:08 PDT
Ryan Haddad
Comment 6 2020-03-17 15:56:17 PDT
This change caused assertion failures with multiple layout and API tests: ASSERTION FAILED: Completion handler should always be called !m_function /Volumes/Data/slave/catalina-debug/build/WebKitBuild/Debug/usr/local/include/wtf/CompletionHandler.h(53) : WTF::CompletionHandler<void ()>::~CompletionHandler() https://build.webkit.org/builders/Apple-Catalina-Debug-WK2-Tests/builds/2971
Alex Christensen
Comment 7 2020-03-17 15:58:45 PDT
Investigating now.
Alex Christensen
Comment 8 2020-03-17 16:33:18 PDT
http://trac.webkit.org/r258610 :( Will be more careful in the future
Note You need to log in before you can comment on or make changes to this bug.