Changeset 222944 in webkit
- Timestamp:
- Oct 5, 2017, 4:18:36 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r222942 r222944 1 2017-10-05 Alex Christensen <achristensen@webkit.org> 2 3 Add ObjC equivalent of WKPageNavigationClient.didChangeBackForwardList 4 https://bugs.webkit.org/show_bug.cgi?id=177966 5 <rdar://problem/22387135> 6 7 Reviewed by Tim Horton. 8 9 * UIProcess/API/APINavigationClient.h: 10 (API::NavigationClient::didChangeBackForwardList): 11 * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h: 12 * UIProcess/Cocoa/NavigationState.h: 13 * UIProcess/Cocoa/NavigationState.mm: 14 (WebKit::NavigationState::setNavigationDelegate): 15 (WebKit::NavigationState::NavigationClient::didFailToInitializePlugIn): 16 (WebKit::NavigationState::NavigationClient::didChangeBackForwardList): 17 (WebKit::NavigationState::NavigationClient::willPerformClientRedirect): 18 (WebKit::NavigationState::NavigationClient::didCancelClientRedirect): 19 (WebKit::NavigationState::NavigationClient::renderingProgressDidChange): 20 (WebKit::NavigationState::NavigationClient::canAuthenticateAgainstProtectionSpace): 21 (WebKit::NavigationState::NavigationClient::processDidTerminate): 22 (WebKit::NavigationState::NavigationClient::processDidBecomeResponsive): 23 (WebKit::NavigationState::NavigationClient::processDidBecomeUnresponsive): 24 (WebKit::NavigationState::NavigationClient::webCryptoMasterKey): 25 (WebKit::NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame): 26 (WebKit::NavigationState::HistoryClient::didNavigateWithNavigationData): 27 (WebKit::NavigationState::HistoryClient::didPerformClientRedirect): 28 (WebKit::NavigationState::HistoryClient::didPerformServerRedirect): 29 (WebKit::NavigationState::HistoryClient::didUpdateHistoryTitle): 30 * UIProcess/WebPageProxy.cpp: 31 (WebKit::WebPageProxy::didChangeBackForwardList): 32 1 33 2017-10-05 Alex Christensen <achristensen@webkit.org> 2 34 -
trunk/Source/WebKit/UIProcess/API/APINavigationClient.h
r222802 r222944 128 128 virtual void didEndNavigationGesture(WebKit::WebPageProxy&, bool willNavigate, WebKit::WebBackForwardListItem&) { } 129 129 virtual void didRemoveNavigationGestureSnapshot(WebKit::WebPageProxy&) { } 130 virtual bool didChangeBackForwardList(WebKit::WebPageProxy&, WebKit::WebBackForwardListItem*, const Vector<Ref<WebKit::WebBackForwardListItem>>&) { return false; } 130 131 }; 131 132 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h
r222942 r222944 93 93 - (void)_webView:(WKWebView *)webView willGoToBackForwardListItem:(WKBackForwardListItem *)item inPageCache:(BOOL)inPageCache WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 94 94 - (void)_webView:(WKWebView *)webView didFailToInitializePlugInWithInfo:(NSDictionary *)info WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 95 - (void)_webView:(WKWebView *)webView backForwardListItemAdded:(WKBackForwardListItem *)itemAdded removed:(NSArray<WKBackForwardListItem *> *)itemsRemoved WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 95 96 #endif 96 97 -
trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h
r222942 r222944 121 121 void resolveWebGLLoadPolicy(WebPageProxy&, const WebCore::URL&, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const final; 122 122 bool willGoToBackForwardListItem(WebPageProxy&, WebBackForwardListItem&, bool inPageCache, API::Object*) final; 123 bool didFailToInitializePlugIn(WebKit::WebPageProxy&, API::Dictionary&) final; 123 bool didFailToInitializePlugIn(WebPageProxy&, API::Dictionary&) final; 124 bool didChangeBackForwardList(WebPageProxy&, WebBackForwardListItem*, const Vector<Ref<WebBackForwardListItem>>&) final; 124 125 #endif 125 126 … … 218 219 bool webViewWebGLLoadPolicyForURL : 1; 219 220 bool webViewResolveWebGLLoadPolicyForURL : 1; 221 bool webViewBackForwardListItemAddedRemoved : 1; 220 222 bool webViewDidFailToInitializePlugInWithInfo : 1; 221 223 bool webViewWillGoToBackForwardListItemInPageCache : 1; -
trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm
r222942 r222944 184 184 m_navigationDelegateMethods.webViewWillGoToBackForwardListItemInPageCache = [delegate respondsToSelector:@selector(_webView:willGoToBackForwardListItem:inPageCache:)]; 185 185 m_navigationDelegateMethods.webViewDidFailToInitializePlugInWithInfo = [delegate respondsToSelector:@selector(_webView:didFailToInitializePlugInWithInfo:)]; 186 m_navigationDelegateMethods.webViewBackForwardListItemAddedRemoved = [delegate respondsToSelector:@selector(_webView:backForwardListItemAdded:removed:)]; 186 187 #endif 187 188 } … … 298 299 299 300 #if PLATFORM(MAC) 300 bool NavigationState::NavigationClient::didFailToInitializePlugIn(Web Kit::WebPageProxy&, API::Dictionary& info)301 bool NavigationState::NavigationClient::didFailToInitializePlugIn(WebPageProxy&, API::Dictionary& info) 301 302 { 302 303 if (!m_navigationState.m_navigationDelegateMethods.webViewDidFailToInitializePlugInWithInfo) … … 358 359 completionHandler(toWebCoreWebGLLoadPolicy(policy)); 359 360 }).get()]; 361 } 362 363 bool NavigationState::NavigationClient::didChangeBackForwardList(WebPageProxy&, WebBackForwardListItem* added, const Vector<Ref<WebBackForwardListItem>>& removed) 364 { 365 if (!m_navigationState.m_navigationDelegateMethods.webViewBackForwardListItemAddedRemoved) 366 return false; 367 368 auto navigationDelegate = m_navigationState.m_navigationDelegate.get(); 369 if (!navigationDelegate) 370 return false; 371 372 NSMutableArray<WKBackForwardListItem *> *removedItems = nil; 373 if (removed.size()) { 374 removedItems = [[[NSMutableArray alloc] initWithCapacity:removed.size()] autorelease]; 375 for (auto& removedItem : removed) 376 [removedItems addObject:wrapper(removedItem.get())]; 377 } 378 [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState.m_webView backForwardListItemAdded:added ? wrapper(*added) : nil removed:removedItems]; 379 return true; 360 380 } 361 381 … … 607 627 } 608 628 609 void NavigationState::NavigationClient::willPerformClientRedirect(Web Kit::WebPageProxy& page, const WTF::String& urlString, double delay)629 void NavigationState::NavigationClient::willPerformClientRedirect(WebPageProxy& page, const WTF::String& urlString, double delay) 610 630 { 611 631 if (!m_navigationState.m_navigationDelegateMethods.webViewWillPerformClientRedirect) … … 621 641 } 622 642 623 void NavigationState::NavigationClient::didCancelClientRedirect(Web Kit::WebPageProxy& page)643 void NavigationState::NavigationClient::didCancelClientRedirect(WebPageProxy& page) 624 644 { 625 645 if (!m_navigationState.m_navigationDelegateMethods.webViewDidCancelClientRedirect) … … 776 796 } 777 797 778 void NavigationState::NavigationClient::renderingProgressDidChange(Web Kit::WebPageProxy&, WebCore::LayoutMilestones layoutMilestones)798 void NavigationState::NavigationClient::renderingProgressDidChange(WebPageProxy&, WebCore::LayoutMilestones layoutMilestones) 779 799 { 780 800 if (!m_navigationState.m_navigationDelegateMethods.webViewRenderingProgressDidChange) … … 788 808 } 789 809 790 bool NavigationState::NavigationClient::canAuthenticateAgainstProtectionSpace(Web Kit::WebPageProxy&, WebKit::WebProtectionSpace* protectionSpace)810 bool NavigationState::NavigationClient::canAuthenticateAgainstProtectionSpace(WebPageProxy&, WebProtectionSpace* protectionSpace) 791 811 { 792 812 if (m_navigationState.m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallengeCompletionHandler) … … 860 880 } 861 881 862 void NavigationState::NavigationClient::processDidTerminate(Web Kit::WebPageProxy& page, WebKit::ProcessTerminationReason)882 void NavigationState::NavigationClient::processDidTerminate(WebPageProxy& page, ProcessTerminationReason) 863 883 { 864 884 if (!m_navigationState.m_navigationDelegateMethods.webViewWebContentProcessDidTerminate && !m_navigationState.m_navigationDelegateMethods.webViewWebProcessDidCrash) … … 879 899 } 880 900 881 void NavigationState::NavigationClient::processDidBecomeResponsive(Web Kit::WebPageProxy& page)901 void NavigationState::NavigationClient::processDidBecomeResponsive(WebPageProxy& page) 882 902 { 883 903 if (!m_navigationState.m_navigationDelegateMethods.webViewWebProcessDidBecomeResponsive) … … 891 911 } 892 912 893 void NavigationState::NavigationClient::processDidBecomeUnresponsive(Web Kit::WebPageProxy& page)913 void NavigationState::NavigationClient::processDidBecomeUnresponsive(WebPageProxy& page) 894 914 { 895 915 if (!m_navigationState.m_navigationDelegateMethods.webViewWebProcessDidBecomeUnresponsive) … … 903 923 } 904 924 905 RefPtr<API::Data> NavigationState::NavigationClient::webCryptoMasterKey(Web Kit::WebPageProxy&)925 RefPtr<API::Data> NavigationState::NavigationClient::webCryptoMasterKey(WebPageProxy&) 906 926 { 907 927 if (!m_navigationState.m_navigationDelegateMethods.webCryptoMasterKeyForWebView) { … … 937 957 } 938 958 939 void NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame(const WebKit::QuickLookDocumentData& data)959 void NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData& data) 940 960 { 941 961 if (!m_navigationState.m_navigationDelegateMethods.webViewDidFinishLoadForQuickLookDocumentInMainFrame) … … 961 981 } 962 982 963 void NavigationState::HistoryClient::didNavigateWithNavigationData(Web Kit::WebPageProxy&, const WebKit::WebNavigationDataStore& navigationDataStore)983 void NavigationState::HistoryClient::didNavigateWithNavigationData(WebPageProxy&, const WebNavigationDataStore& navigationDataStore) 964 984 { 965 985 if (!m_navigationState.m_historyDelegateMethods.webViewDidNavigateWithNavigationData) … … 973 993 } 974 994 975 void NavigationState::HistoryClient::didPerformClientRedirect(Web Kit::WebPageProxy&, const WTF::String& sourceURL, const WTF::String& destinationURL)995 void NavigationState::HistoryClient::didPerformClientRedirect(WebPageProxy&, const WTF::String& sourceURL, const WTF::String& destinationURL) 976 996 { 977 997 if (!m_navigationState.m_historyDelegateMethods.webViewDidPerformClientRedirectFromURLToURL) … … 985 1005 } 986 1006 987 void NavigationState::HistoryClient::didPerformServerRedirect(Web Kit::WebPageProxy&, const WTF::String& sourceURL, const WTF::String& destinationURL)1007 void NavigationState::HistoryClient::didPerformServerRedirect(WebPageProxy&, const WTF::String& sourceURL, const WTF::String& destinationURL) 988 1008 { 989 1009 if (!m_navigationState.m_historyDelegateMethods.webViewDidPerformServerRedirectFromURLToURL) … … 997 1017 } 998 1018 999 void NavigationState::HistoryClient::didUpdateHistoryTitle(Web Kit::WebPageProxy&, const WTF::String& title, const WTF::String& url)1019 void NavigationState::HistoryClient::didUpdateHistoryTitle(WebPageProxy&, const WTF::String& title, const WTF::String& url) 1000 1020 { 1001 1021 if (!m_navigationState.m_historyDelegateMethods.webViewDidUpdateHistoryTitleForURL) -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r222941 r222944 1197 1197 PageClientProtector protector(m_pageClient); 1198 1198 1199 m_loaderClient->didChangeBackForwardList(*this, added, WTFMove(removed)); 1199 if (!m_navigationClient || !m_navigationClient->didChangeBackForwardList(*this, added, removed)) 1200 m_loaderClient->didChangeBackForwardList(*this, added, WTFMove(removed)); 1200 1201 1201 1202 auto transaction = m_pageLoadState.transaction(); -
trunk/Tools/ChangeLog
r222937 r222944 1 2017-10-05 Alex Christensen <achristensen@webkit.org> 2 3 Add ObjC equivalent of WKPageNavigationClient.didChangeBackForwardList 4 https://bugs.webkit.org/show_bug.cgi?id=177966 5 <rdar://problem/22387135> 6 7 Reviewed by Tim Horton. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm: 10 (-[ListItemDelegate _webView:backForwardListItemAdded:removed:]): 11 (-[ListItemDelegate webView:didFinishNavigation:]): 12 (TEST): 13 1 14 2017-10-04 Megan Gardner <megan_gardner@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm
r222794 r222944 26 26 #include "config.h" 27 27 28 #import <WebKit/WKBackForwardListPrivate.h> 28 29 #import <WebKit/WKNavigationDelegatePrivate.h> 29 30 #import <WebKit/WKNavigationPrivate.h> … … 329 330 } 330 331 332 RetainPtr<WKBackForwardListItem> firstItem; 333 RetainPtr<WKBackForwardListItem> secondItem; 334 335 @interface ListItemDelegate : NSObject<WKNavigationDelegatePrivate> 336 @end 337 @implementation ListItemDelegate 338 - (void)_webView:(WKWebView *)webView backForwardListItemAdded:(WKBackForwardListItem *)itemAdded removed:(NSArray<WKBackForwardListItem *> *)itemsRemoved 339 { 340 NSString *firstURL = [[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"].absoluteString; 341 NSString *secondURL = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"].absoluteString; 342 343 if (!firstItem) { 344 EXPECT_NULL(firstItem); 345 EXPECT_NULL(secondItem); 346 EXPECT_NULL(itemsRemoved); 347 EXPECT_NOT_NULL(itemAdded); 348 EXPECT_STREQ(firstURL.UTF8String, itemAdded.URL.absoluteString.UTF8String); 349 firstItem = itemAdded; 350 } else if (!secondItem) { 351 EXPECT_NOT_NULL(firstItem); 352 EXPECT_NULL(secondItem); 353 EXPECT_NULL(itemsRemoved); 354 EXPECT_NOT_NULL(itemAdded); 355 EXPECT_STREQ(secondURL.UTF8String, itemAdded.URL.absoluteString.UTF8String); 356 secondItem = itemAdded; 357 } else { 358 EXPECT_NOT_NULL(firstItem); 359 EXPECT_NOT_NULL(secondItem); 360 EXPECT_NOT_NULL(itemsRemoved); 361 EXPECT_NULL(itemAdded); 362 EXPECT_EQ([itemsRemoved count], 2u); 363 EXPECT_STREQ(firstURL.UTF8String, [itemsRemoved objectAtIndex:0].URL.absoluteString.UTF8String); 364 EXPECT_STREQ(secondURL.UTF8String, [itemsRemoved objectAtIndex:1].URL.absoluteString.UTF8String); 365 isDone = true; 366 } 367 } 368 - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation 369 { 370 navigationComplete = true; 371 } 372 @end 373 374 TEST(WKNavigation, ListItemAddedRemoved) 375 { 376 auto webView = adoptNS([[WKWebView alloc] init]); 377 auto delegate = adoptNS([[ListItemDelegate alloc] init]); 378 [webView setNavigationDelegate:delegate.get()]; 379 [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]]; 380 TestWebKitAPI::Util::run(&navigationComplete); 381 navigationComplete = false; 382 [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]]; 383 TestWebKitAPI::Util::run(&navigationComplete); 384 [[webView backForwardList] _removeAllItems]; 385 TestWebKitAPI::Util::run(&isDone); 386 } 331 387 #endif // PLATFORM(MAC) 332 388
Note:
See TracChangeset
for help on using the changeset viewer.