Diff
Modified: trunk/Source/WebKit/ChangeLog (221502 => 221503)
--- trunk/Source/WebKit/ChangeLog 2017-09-01 22:19:26 UTC (rev 221502)
+++ trunk/Source/WebKit/ChangeLog 2017-09-01 22:25:20 UTC (rev 221503)
@@ -1,5 +1,27 @@
2017-09-01 Alex Christensen <achristen...@webkit.org>
+ Add WKUIDelegatePrivate equivalent of WKPageUIClient's toolbarsAreVisible
+ https://bugs.webkit.org/show_bug.cgi?id=176246
+ <rdar://problem/29270035>
+
+ Reviewed by Tim Horton.
+
+ * UIProcess/API/APIUIClient.h:
+ (API::UIClient::toolbarsAreVisible):
+ * UIProcess/API/C/WKPage.cpp:
+ (WKPageSetPageUIClient):
+ * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+ * UIProcess/Cocoa/UIDelegate.h:
+ * UIProcess/Cocoa/UIDelegate.mm:
+ (WebKit::UIDelegate::setDelegate):
+ (WebKit::UIDelegate::UIClient::toolbarsAreVisible):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::getToolbarsAreVisible):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+
+2017-09-01 Alex Christensen <achristen...@webkit.org>
+
Make PageClientImplCocoa a proper superclass of PageClientImpls for Mac and iOS
https://bugs.webkit.org/show_bug.cgi?id=176239
Modified: trunk/Source/WebKit/UIProcess/API/APIUIClient.h (221502 => 221503)
--- trunk/Source/WebKit/UIProcess/API/APIUIClient.h 2017-09-01 22:19:26 UTC (rev 221502)
+++ trunk/Source/WebKit/UIProcess/API/APIUIClient.h 2017-09-01 22:25:20 UTC (rev 221503)
@@ -99,7 +99,7 @@
virtual void didNotHandleKeyEvent(WebKit::WebPageProxy*, const WebKit::NativeWebKeyboardEvent&) { }
virtual void didNotHandleWheelEvent(WebKit::WebPageProxy*, const WebKit::NativeWebWheelEvent&) { }
- virtual bool toolbarsAreVisible(WebKit::WebPageProxy*) { return true; }
+ virtual void toolbarsAreVisible(WebKit::WebPageProxy&, Function<void(bool)>&& completionHandler) { completionHandler(true); }
virtual void setToolbarsAreVisible(WebKit::WebPageProxy*, bool) { }
virtual bool menuBarIsVisible(WebKit::WebPageProxy*) { return true; }
virtual void setMenuBarIsVisible(WebKit::WebPageProxy*, bool) { }
Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (221502 => 221503)
--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp 2017-09-01 22:19:26 UTC (rev 221502)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp 2017-09-01 22:25:20 UTC (rev 221503)
@@ -1832,11 +1832,11 @@
m_client.didNotHandleWheelEvent(toAPI(page), event.nativeEvent(), m_client.base.clientInfo);
}
- bool toolbarsAreVisible(WebPageProxy* page) final
+ void toolbarsAreVisible(WebPageProxy& page, Function<void(bool)>&& completionHandler) final
{
if (!m_client.toolbarsAreVisible)
- return true;
- return m_client.toolbarsAreVisible(toAPI(page), m_client.base.clientInfo);
+ return completionHandler(true);
+ completionHandler(m_client.toolbarsAreVisible(toAPI(&page), m_client.base.clientInfo));
}
void setToolbarsAreVisible(WebPageProxy* page, bool visible) final
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (221502 => 221503)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2017-09-01 22:19:26 UTC (rev 221502)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2017-09-01 22:25:20 UTC (rev 221503)
@@ -150,6 +150,7 @@
- (void)_webView:(WKWebView *)webView didNotHandleWheelEvent:(NSEvent *)event WK_API_AVAILABLE(macosx(WK_MAC_TBA));
- (void)_webView:(WKWebView *)webView handleAutoplayEvent:(_WKAutoplayEvent)event withFlags:(_WKAutoplayEventFlags)flags WK_API_AVAILABLE(macosx(WK_MAC_TBA));
- (void)_webView:(WKWebView *)webView didClickAutoFillButtonWithUserInfo:(id <NSSecureCoding>)userInfo WK_API_AVAILABLE(macosx(WK_MAC_TBA));
+- (void)_webView:(WKWebView *)webView getToolbarsAreVisibleWithCompletionHandler:(void(^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA));
- (void)_webView:(WKWebView *)webView saveDataToFile:(NSData *)data suggestedFilename:(NSString *)suggestedFilename mimeType:(NSString *)mimeType originatingURL:(NSURL *)url WK_API_AVAILABLE(macosx(WK_MAC_TBA));
- (void)_webView:(WKWebView *)webView didExceedBackgroundResourceLimitWhileInForeground:(_WKResourceLimit)limit WK_API_AVAILABLE(macosx(WK_MAC_TBA));
- (NSMenu *)_webView:(WKWebView *)webView contextMenu:(NSMenu *)menu forElement:(_WKContextMenuElementInfo *)element WK_API_AVAILABLE(macosx(10.12));
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp (221502 => 221503)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp 2017-09-01 22:19:26 UTC (rev 221502)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp 2017-09-01 22:25:20 UTC (rev 221503)
@@ -97,9 +97,9 @@
webkitWebViewMouseTargetChanged(m_webView, data, modifiers);
}
- bool toolbarsAreVisible(WebPageProxy*) override
+ void toolbarsAreVisible(WebPageProxy&, Function<void(bool)>&& completionHandler) override
{
- return webkit_window_properties_get_toolbar_visible(webkit_web_view_get_window_properties(m_webView));
+ completionHandler(webkit_window_properties_get_toolbar_visible(webkit_web_view_get_window_properties(m_webView)));
}
void setToolbarsAreVisible(WebPageProxy*, bool visible) override
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h (221502 => 221503)
--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h 2017-09-01 22:19:26 UTC (rev 221502)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h 2017-09-01 22:25:20 UTC (rev 221503)
@@ -103,6 +103,7 @@
void didNotHandleWheelEvent(WebPageProxy*, const NativeWebWheelEvent&) final;
void handleAutoplayEvent(WebPageProxy&, WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) final;
void didClickAutoFillButton(WebPageProxy&, API::Object*) final;
+ void toolbarsAreVisible(WebKit::WebPageProxy&, Function<void(bool)>&&) final;
bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebCore::SecurityOriginData&, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) final;
void didExceedBackgroundResourceLimitWhileInForeground(WebPageProxy&, WKResourceLimit) final;
void saveDataToFileInDownloadsFolder(WebPageProxy*, const WTF::String&, const WTF::String&, const WebCore::URL&, API::Data&) final;
@@ -152,6 +153,7 @@
bool webViewDidNotHandleWheelEvent : 1;
bool webViewHandleAutoplayEventWithFlags : 1;
bool webViewDidClickAutoFillButtonWithUserInfo : 1;
+ bool webViewGetToolbarsAreVisibleWithCompletionHandler : 1;
bool webViewDidExceedBackgroundResourceLimitWhileInForeground : 1;
bool webViewSaveDataToFileSuggestedFilenameMimeTypeOriginatingURL : 1;
bool webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler : 1;
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm (221502 => 221503)
--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm 2017-09-01 22:19:26 UTC (rev 221502)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm 2017-09-01 22:25:20 UTC (rev 221503)
@@ -106,6 +106,7 @@
m_delegateMethods.focusWebView = [delegate respondsToSelector:@selector(_focusWebView:)];
m_delegateMethods.unfocusWebView = [delegate respondsToSelector:@selector(_unfocusWebView:)];
m_delegateMethods.webViewTakeFocus = [delegate respondsToSelector:@selector(_webView:takeFocus:)];
+ m_delegateMethods.webViewGetToolbarsAreVisibleWithCompletionHandler = [delegate respondsToSelector:@selector(_webView:getToolbarsAreVisibleWithCompletionHandler:)];
m_delegateMethods.webViewDidNotHandleWheelEvent = [delegate respondsToSelector:@selector(_webView:didNotHandleWheelEvent:)];
m_delegateMethods.webViewHandleAutoplayEventWithFlags = [delegate respondsToSelector:@selector(_webView:handleAutoplayEvent:withFlags:)];
m_delegateMethods.webViewDidClickAutoFillButtonWithUserInfo = [delegate respondsToSelector:@selector(_webView:didClickAutoFillButtonWithUserInfo:)];
@@ -490,6 +491,23 @@
return _WKAutoplayEventDidPlayMediaPreventedFromAutoplaying;
}
+void UIDelegate::UIClient::toolbarsAreVisible(WebKit::WebPageProxy&, Function<void(bool)>&& completionHandler)
+{
+ if (!m_uiDelegate.m_delegateMethods.webViewGetToolbarsAreVisibleWithCompletionHandler)
+ return completionHandler(true);
+
+ auto delegate = m_uiDelegate.m_delegate.get();
+ if (!delegate)
+ return completionHandler(true);
+
+ [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView getToolbarsAreVisibleWithCompletionHandler:BlockPtr<void(BOOL)>::fromCallable([completionHandler = WTFMove(completionHandler), checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:getToolbarsAreVisibleWithCompletionHandler:))](BOOL visible) {
+ if (checker->completionHandlerHasBeenCalled())
+ return;
+ checker->didCallCompletionHandler();
+ completionHandler(visible);
+ }).get()];
+}
+
void UIDelegate::UIClient::didClickAutoFillButton(WebPageProxy&, API::Object* userInfo)
{
if (!m_uiDelegate.m_delegateMethods.webViewDidClickAutoFillButtonWithUserInfo)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (221502 => 221503)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2017-09-01 22:19:26 UTC (rev 221502)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2017-09-01 22:25:20 UTC (rev 221503)
@@ -4066,9 +4066,11 @@
m_uiClient->setToolbarsAreVisible(this, toolbarsAreVisible);
}
-void WebPageProxy::getToolbarsAreVisible(bool& toolbarsAreVisible)
+void WebPageProxy::getToolbarsAreVisible(Ref<Messages::WebPageProxy::GetToolbarsAreVisible::DelayedReply>&& reply)
{
- toolbarsAreVisible = m_uiClient->toolbarsAreVisible(this);
+ m_uiClient->toolbarsAreVisible(*this, [reply = WTFMove(reply)](bool visible) {
+ reply->send(visible);
+ });
}
void WebPageProxy::setMenuBarIsVisible(bool menuBarIsVisible)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (221502 => 221503)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2017-09-01 22:19:26 UTC (rev 221502)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2017-09-01 22:25:20 UTC (rev 221503)
@@ -1306,7 +1306,7 @@
void resolveWebGLPolicyForURL(WebCore::URL&&, Ref<Messages::WebPageProxy::ResolveWebGLPolicyForURL::DelayedReply>&&);
#endif // ENABLE(WEBGL)
void setToolbarsAreVisible(bool toolbarsAreVisible);
- void getToolbarsAreVisible(bool& toolbarsAreVisible);
+ void getToolbarsAreVisible(Ref<Messages::WebPageProxy::GetToolbarsAreVisible::DelayedReply>&&);
void setMenuBarIsVisible(bool menuBarIsVisible);
void getMenuBarIsVisible(bool& menuBarIsVisible);
void setStatusBarIsVisible(bool statusBarIsVisible);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (221502 => 221503)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2017-09-01 22:19:26 UTC (rev 221502)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2017-09-01 22:25:20 UTC (rev 221503)
@@ -51,7 +51,7 @@
FrameSetLargestFrameChanged(uint64_t frameID)
SetRenderTreeSize(uint64_t treeSize)
SetToolbarsAreVisible(bool toolbarsAreVisible)
- GetToolbarsAreVisible() -> (bool toolbarsAreVisible)
+ GetToolbarsAreVisible() -> (bool toolbarsAreVisible) Delayed
SetMenuBarIsVisible(bool menuBarIsVisible);
GetMenuBarIsVisible() -> (bool menuBarIsVisible);
SetStatusBarIsVisible(bool statusBarIsVisible)
Modified: trunk/Tools/ChangeLog (221502 => 221503)
--- trunk/Tools/ChangeLog 2017-09-01 22:19:26 UTC (rev 221502)
+++ trunk/Tools/ChangeLog 2017-09-01 22:25:20 UTC (rev 221503)
@@ -1,3 +1,16 @@
+2017-09-01 Alex Christensen <achristen...@webkit.org>
+
+ Add WKUIDelegatePrivate equivalent of WKPageUIClient's toolbarsAreVisible
+ https://bugs.webkit.org/show_bug.cgi?id=176246
+ <rdar://problem/29270035>
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
+ (-[ToolbarDelegate _webView:getToolbarsAreVisibleWithCompletionHandler:]):
+ (-[ToolbarDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
+ (TEST):
+
2017-09-01 Eric Carlson <eric.carl...@apple.com>
Switch HTMLMediaElement to release logging
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm (221502 => 221503)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm 2017-09-01 22:19:26 UTC (rev 221502)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm 2017-09-01 22:25:20 UTC (rev 221503)
@@ -122,6 +122,41 @@
ASSERT_EQ(webViewFromDelegateCallback, createdWebView);
}
+bool firstToolbarDone;
+
+@interface ToolbarDelegate : NSObject <WKUIDelegatePrivate>
+@end
+
+@implementation ToolbarDelegate
+
+- (void)_webView:(WKWebView *)webView getToolbarsAreVisibleWithCompletionHandler:(void(^)(BOOL))completionHandler
+{
+ completionHandler(firstToolbarDone);
+}
+
+- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
+{
+ if (firstToolbarDone) {
+ EXPECT_STREQ(message.UTF8String, "visible:true");
+ done = true;
+ } else {
+ EXPECT_STREQ(message.UTF8String, "visible:false");
+ firstToolbarDone = true;
+ }
+ completionHandler();
+}
+
+@end
+
+TEST(WebKit2, ToolbarVisible)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:[[[WKWebViewConfiguration alloc] init] autorelease]]);
+ auto delegate = adoptNS([[ToolbarDelegate alloc] init]);
+ [webView setUIDelegate:delegate.get()];
+ [webView synchronouslyLoadHTMLString:@"<script>alert('visible:' + window.toolbar.visible);alert('visible:' + window.toolbar.visible)</script>"];
+ TestWebKitAPI::Util::run(&done);
+}
+
static bool readyForClick;
@interface AutoFillDelegate : NSObject <WKUIDelegatePrivate>