Changeset 221982 in webkit
- Timestamp:
- Sep 13, 2017 11:38:04 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r221977 r221982 1 2017-09-13 Alex Christensen <achristensen@webkit.org> 2 3 Add WKUIDelegatePrivate equivalent of WKPageUIClient's setIsResizable, getWindowFrame, and setWindowFrame 4 https://bugs.webkit.org/show_bug.cgi?id=176857 5 <rdar://problem/29270035> 6 7 Reviewed by Tim Horton. 8 9 isResizable is unreachable code because nothing sends Messages::WebPageProxy::GetIsResizable, so I removed it. 10 11 * UIProcess/API/APIUIClient.h: 12 (API::UIClient::setStatusBarIsVisible): 13 (API::UIClient::isResizable): Deleted. 14 * UIProcess/API/C/WKPage.cpp: 15 (WKPageSetPageUIClient): 16 * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: 17 * UIProcess/API/glib/WebKitUIClient.cpp: 18 * UIProcess/Cocoa/UIDelegate.h: 19 * UIProcess/Cocoa/UIDelegate.mm: 20 (WebKit::UIDelegate::setDelegate): 21 (WebKit::UIDelegate::UIClient::setIsResizable): 22 (WebKit::UIDelegate::UIClient::setWindowFrame): 23 (WebKit::UIDelegate::UIClient::windowFrame): 24 * UIProcess/WebPageProxy.cpp: 25 (WebKit::WebPageProxy::getIsResizable): Deleted. 26 * UIProcess/WebPageProxy.h: 27 * UIProcess/WebPageProxy.messages.in: 28 1 29 2017-09-13 Youenn Fablet <youenn@apple.com> 2 30 -
trunk/Source/WebKit/UIProcess/API/APIUIClient.h
r221922 r221982 103 103 virtual void statusBarIsVisible(WebKit::WebPageProxy&, Function<void(bool)>&& completionHandler) { completionHandler(true); } 104 104 virtual void setStatusBarIsVisible(WebKit::WebPageProxy&, bool) { } 105 virtual void isResizable(WebKit::WebPageProxy&, Function<void(bool)>&& completionHandler) { completionHandler(true); }106 105 virtual void setIsResizable(WebKit::WebPageProxy&, bool) { } 107 106 -
trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp
r221922 r221982 1875 1875 } 1876 1876 1877 void isResizable(WebPageProxy& page, Function<void(bool)>&& completionHandler) final1878 {1879 if (!m_client.isResizable)1880 return completionHandler(true);1881 completionHandler(m_client.isResizable(toAPI(&page), m_client.base.clientInfo));1882 }1883 1884 1877 void setIsResizable(WebPageProxy& page, bool resizable) final 1885 1878 { -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
r221930 r221982 165 165 - (void)_webView:(WKWebView *)webview mouseDidMoveOverElement:(_WKHitTestResult *)hitTestResult withFlags:(NSEventModifierFlags)flags userInfo:(id <NSSecureCoding>)userInfo; 166 166 - (void)_webView:(WKWebView *)webView didExceedBackgroundResourceLimitWhileInForeground:(_WKResourceLimit)limit WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 167 - (void)_webView:(WKWebView *)webView setResizable:(BOOL)isResizable WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 168 - (void)_webView:(WKWebView *)webView getWindowFrameWithCompletionHandler:(void (^)(CGRect))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 169 - (void)_webView:(WKWebView *)webView setWindowFrame:(CGRect)frame WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 167 170 - (void)_webView:(WKWebView *)webView unavailablePlugInButtonClickedWithReason:(_WKPlugInUnavailabilityReason)reason plugInInfo:(NSDictionary *)plugInInfo; 168 171 - (NSMenu *)_webView:(WKWebView *)webView contextMenu:(NSMenu *)menu forElement:(_WKContextMenuElementInfo *)element WK_API_AVAILABLE(macosx(10.12)); -
trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp
r221922 r221982 128 128 } 129 129 130 void isResizable(WebPageProxy&, Function<void(bool)>&& completionHandler) final131 {132 completionHandler(webkit_window_properties_get_resizable(webkit_web_view_get_window_properties(m_webView)));133 }134 135 130 void setIsResizable(WebPageProxy&, bool resizable) final 136 131 { -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h
r221922 r221982 102 102 void runModal(WebPageProxy&) final; 103 103 void pageDidScroll(WebPageProxy*) final; 104 void setIsResizable(WebPageProxy&, bool) final; 105 void setWindowFrame(WebPageProxy&, const WebCore::FloatRect&) final; 106 void windowFrame(WebPageProxy&, Function<void(WebCore::FloatRect)>&&) final; 104 107 void didNotHandleWheelEvent(WebPageProxy*, const NativeWebWheelEvent&) final; 105 108 void decidePolicyForNotificationPermissionRequest(WebPageProxy&, API::SecurityOrigin&, Function<void(bool)>&&) final; … … 158 161 bool webViewTakeFocus : 1; 159 162 bool webViewDidScroll : 1; 163 bool webViewSetResizable : 1; 164 bool webViewSetWindowFrame : 1; 160 165 bool webViewDidNotHandleWheelEvent : 1; 161 166 bool webViewHandleAutoplayEventWithFlags : 1; 162 167 bool webViewUnavailablePlugInButtonClicked : 1; 163 168 bool webViewDidClickAutoFillButtonWithUserInfo : 1; 169 bool webViewGetWindowFrameWithCompletionHandler : 1; 164 170 bool webViewMouseDidMoveOverElementWithFlagsUserInfo : 1; 165 171 bool webViewGetToolbarsAreVisibleWithCompletionHandler : 1; -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
r221922 r221982 115 115 m_delegateMethods.webViewGetToolbarsAreVisibleWithCompletionHandler = [delegate respondsToSelector:@selector(_webView:getToolbarsAreVisibleWithCompletionHandler:)]; 116 116 m_delegateMethods.webViewDidNotHandleWheelEvent = [delegate respondsToSelector:@selector(_webView:didNotHandleWheelEvent:)]; 117 m_delegateMethods.webViewSetResizable = [delegate respondsToSelector:@selector(_webView:setResizable:)]; 118 m_delegateMethods.webViewGetWindowFrameWithCompletionHandler = [delegate respondsToSelector:@selector(_webView:getWindowFrameWithCompletionHandler:)]; 119 m_delegateMethods.webViewSetWindowFrame = [delegate respondsToSelector:@selector(_webView:setWindowFrame:)]; 117 120 m_delegateMethods.webViewUnavailablePlugInButtonClicked = [delegate respondsToSelector:@selector(_webView:unavailablePlugInButtonClickedWithReason:plugInInfo:)]; 118 121 m_delegateMethods.webViewHandleAutoplayEventWithFlags = [delegate respondsToSelector:@selector(_webView:handleAutoplayEvent:withFlags:)]; … … 517 520 518 521 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView didNotHandleWheelEvent:event.nativeEvent()]; 522 } 523 524 void UIDelegate::UIClient::setIsResizable(WebKit::WebPageProxy&, bool resizable) 525 { 526 if (!m_uiDelegate.m_delegateMethods.webViewSetResizable) 527 return; 528 529 auto delegate = m_uiDelegate.m_delegate.get(); 530 if (!delegate) 531 return; 532 533 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView setResizable:resizable]; 534 } 535 536 void UIDelegate::UIClient::setWindowFrame(WebKit::WebPageProxy&, const WebCore::FloatRect& frame) 537 { 538 if (!m_uiDelegate.m_delegateMethods.webViewSetWindowFrame) 539 return; 540 541 auto delegate = m_uiDelegate.m_delegate.get(); 542 if (!delegate) 543 return; 544 545 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView setWindowFrame:frame]; 546 } 547 548 void UIDelegate::UIClient::windowFrame(WebKit::WebPageProxy&, Function<void(WebCore::FloatRect)>&& completionHandler) 549 { 550 if (!m_uiDelegate.m_delegateMethods.webViewGetWindowFrameWithCompletionHandler) 551 return completionHandler({ }); 552 553 auto delegate = m_uiDelegate.m_delegate.get(); 554 if (!delegate) 555 return completionHandler({ }); 556 557 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView getWindowFrameWithCompletionHandler:BlockPtr<void(CGRect)>::fromCallable([completionHandler = WTFMove(completionHandler), checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:getWindowFrameWithCompletionHandler:))](CGRect frame) { 558 if (checker->completionHandlerHasBeenCalled()) 559 return; 560 checker->didCallCompletionHandler(); 561 completionHandler(frame); 562 }).get()]; 519 563 } 520 564 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r221922 r221982 4093 4093 } 4094 4094 4095 void WebPageProxy::getIsResizable(Ref<Messages::WebPageProxy::GetIsResizable::DelayedReply>&& reply)4096 {4097 m_uiClient->isResizable(*this, [reply = WTFMove(reply)] (bool resizable) {4098 reply->send(resizable);4099 });4100 }4101 4102 4095 void WebPageProxy::setWindowFrame(const FloatRect& newWindowFrame) 4103 4096 { -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r221899 r221982 1316 1316 void getStatusBarIsVisible(Ref<Messages::WebPageProxy::GetStatusBarIsVisible::DelayedReply>&&); 1317 1317 void setIsResizable(bool isResizable); 1318 void getIsResizable(Ref<Messages::WebPageProxy::GetIsResizable::DelayedReply>&&);1319 1318 void screenToRootView(const WebCore::IntPoint& screenPoint, Ref<Messages::WebPageProxy::ScreenToRootView::DelayedReply>&&); 1320 1319 void rootViewToScreen(const WebCore::IntRect& viewRect, Ref<Messages::WebPageProxy::RootViewToScreen::DelayedReply>&&); -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r221887 r221982 58 58 GetStatusBarIsVisible() -> (bool statusBarIsVisible) Delayed 59 59 SetIsResizable(bool isResizable) 60 GetIsResizable() -> (bool isResizable) Delayed61 60 SetWindowFrame(WebCore::FloatRect windowFrame) 62 61 GetWindowFrame() -> (WebCore::FloatRect windowFrame) Delayed -
trunk/Tools/ChangeLog
r221977 r221982 1 2017-09-13 Alex Christensen <achristensen@webkit.org> 2 3 Add WKUIDelegatePrivate equivalent of WKPageUIClient's setIsResizable, getWindowFrame, and setWindowFrame 4 https://bugs.webkit.org/show_bug.cgi?id=176857 5 <rdar://problem/29270035> 6 7 Reviewed by Tim Horton. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm: 10 (-[ModalDelegate _webViewRunModal:]): 11 (-[ModalDelegate _webView:setResizable:]): 12 (-[WindowFrameDelegate _webView:setWindowFrame:]): 13 (-[WindowFrameDelegate _webView:getWindowFrameWithCompletionHandler:]): 14 (-[WindowFrameDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): 15 (TEST): 16 (-[ResizableDelegate _webView:setResizable:]): 17 (-[ResizableDelegate _webView:getIsResizableWithCompletionHandler:]): 18 (-[ResizableDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): 19 1 20 2017-09-13 Youenn Fablet <youenn@apple.com> 2 21 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm
r221923 r221982 202 202 } 203 203 204 static bool resizableSet; 205 204 206 @interface ModalDelegate : NSObject <WKUIDelegatePrivate> 205 207 @end … … 209 211 - (void)_webViewRunModal:(WKWebView *)webView 210 212 { 213 EXPECT_TRUE(resizableSet); 211 214 EXPECT_EQ(webView, createdWebView.get()); 212 215 done = true; 216 } 217 218 - (void)_webView:(WKWebView *)webView setResizable:(BOOL)isResizable 219 { 220 EXPECT_FALSE(isResizable); 221 resizableSet = true; 213 222 } 214 223 … … 231 240 [webView synchronouslyLoadHTMLString:html]; 232 241 [webView sendClicksAtPoint:NSMakePoint(20, 600 - 20) numberOfClicks:1]; 242 TestWebKitAPI::Util::run(&done); 243 } 244 245 static bool receivedWindowFrame; 246 247 @interface WindowFrameDelegate : NSObject <WKUIDelegatePrivate> 248 @end 249 250 @implementation WindowFrameDelegate 251 252 - (void)_webView:(WKWebView *)webView setWindowFrame:(CGRect)frame 253 { 254 EXPECT_EQ(frame.origin.x, 160); 255 EXPECT_EQ(frame.origin.y, 230); 256 EXPECT_EQ(frame.size.width, 350); 257 EXPECT_EQ(frame.size.height, 450); 258 receivedWindowFrame = true; 259 } 260 261 - (void)_webView:(WKWebView *)webView getWindowFrameWithCompletionHandler:(void (^)(CGRect))completionHandler 262 { 263 completionHandler(CGRectMake(150, 250, 350, 450)); 264 } 265 266 - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler 267 { 268 EXPECT_STREQ("350", message.UTF8String); 269 completionHandler(); 270 done = true; 271 } 272 273 @end 274 275 TEST(WebKit, WindowFrame) 276 { 277 auto delegate = adoptNS([[WindowFrameDelegate alloc] init]); 278 auto webView = adoptNS([[WKWebView alloc] init]); 279 [webView setUIDelegate:delegate.get()]; 280 [webView loadHTMLString:@"<script>moveBy(10,20);alert(outerWidth);</script>" baseURL:nil]; 281 TestWebKitAPI::Util::run(&receivedWindowFrame); 233 282 TestWebKitAPI::Util::run(&done); 234 283 }
Note: See TracChangeset
for help on using the changeset viewer.