Diff
Modified: trunk/Source/WebKit/ChangeLog (222943 => 222944)
--- trunk/Source/WebKit/ChangeLog 2017-10-05 23:14:20 UTC (rev 222943)
+++ trunk/Source/WebKit/ChangeLog 2017-10-05 23:18:36 UTC (rev 222944)
@@ -1,5 +1,37 @@
2017-10-05 Alex Christensen <[email protected]>
+ Add ObjC equivalent of WKPageNavigationClient.didChangeBackForwardList
+ https://bugs.webkit.org/show_bug.cgi?id=177966
+ <rdar://problem/22387135>
+
+ Reviewed by Tim Horton.
+
+ * UIProcess/API/APINavigationClient.h:
+ (API::NavigationClient::didChangeBackForwardList):
+ * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
+ * UIProcess/Cocoa/NavigationState.h:
+ * UIProcess/Cocoa/NavigationState.mm:
+ (WebKit::NavigationState::setNavigationDelegate):
+ (WebKit::NavigationState::NavigationClient::didFailToInitializePlugIn):
+ (WebKit::NavigationState::NavigationClient::didChangeBackForwardList):
+ (WebKit::NavigationState::NavigationClient::willPerformClientRedirect):
+ (WebKit::NavigationState::NavigationClient::didCancelClientRedirect):
+ (WebKit::NavigationState::NavigationClient::renderingProgressDidChange):
+ (WebKit::NavigationState::NavigationClient::canAuthenticateAgainstProtectionSpace):
+ (WebKit::NavigationState::NavigationClient::processDidTerminate):
+ (WebKit::NavigationState::NavigationClient::processDidBecomeResponsive):
+ (WebKit::NavigationState::NavigationClient::processDidBecomeUnresponsive):
+ (WebKit::NavigationState::NavigationClient::webCryptoMasterKey):
+ (WebKit::NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame):
+ (WebKit::NavigationState::HistoryClient::didNavigateWithNavigationData):
+ (WebKit::NavigationState::HistoryClient::didPerformClientRedirect):
+ (WebKit::NavigationState::HistoryClient::didPerformServerRedirect):
+ (WebKit::NavigationState::HistoryClient::didUpdateHistoryTitle):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::didChangeBackForwardList):
+
+2017-10-05 Alex Christensen <[email protected]>
+
Add ObjC SPI with userInfo corresponding to WKPageNavigationClient's decidePolicyForNavigationAction, didStartProvisionalNavigation, and didFailNavigation
https://bugs.webkit.org/show_bug.cgi?id=177974
<rdar://problem/22888802>
Modified: trunk/Source/WebKit/UIProcess/API/APINavigationClient.h (222943 => 222944)
--- trunk/Source/WebKit/UIProcess/API/APINavigationClient.h 2017-10-05 23:14:20 UTC (rev 222943)
+++ trunk/Source/WebKit/UIProcess/API/APINavigationClient.h 2017-10-05 23:18:36 UTC (rev 222944)
@@ -127,6 +127,7 @@
virtual void willEndNavigationGesture(WebKit::WebPageProxy&, bool willNavigate, WebKit::WebBackForwardListItem&) { }
virtual void didEndNavigationGesture(WebKit::WebPageProxy&, bool willNavigate, WebKit::WebBackForwardListItem&) { }
virtual void didRemoveNavigationGestureSnapshot(WebKit::WebPageProxy&) { }
+ virtual bool didChangeBackForwardList(WebKit::WebPageProxy&, WebKit::WebBackForwardListItem*, const Vector<Ref<WebKit::WebBackForwardListItem>>&) { return false; }
};
} // namespace API
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h (222943 => 222944)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h 2017-10-05 23:14:20 UTC (rev 222943)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h 2017-10-05 23:18:36 UTC (rev 222944)
@@ -92,6 +92,7 @@
- (void)_webView:(WKWebView *)webView resolveWebGLLoadPolicyForURL:(NSURL *)url decisionHandler:(void (^)(_WKWebGLLoadPolicy))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA));
- (void)_webView:(WKWebView *)webView willGoToBackForwardListItem:(WKBackForwardListItem *)item inPageCache:(BOOL)inPageCache WK_API_AVAILABLE(macosx(WK_MAC_TBA));
- (void)_webView:(WKWebView *)webView didFailToInitializePlugInWithInfo:(NSDictionary *)info WK_API_AVAILABLE(macosx(WK_MAC_TBA));
+- (void)_webView:(WKWebView *)webView backForwardListItemAdded:(WKBackForwardListItem *)itemAdded removed:(NSArray<WKBackForwardListItem *> *)itemsRemoved WK_API_AVAILABLE(macosx(WK_MAC_TBA));
#endif
@end
Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h (222943 => 222944)
--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h 2017-10-05 23:14:20 UTC (rev 222943)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h 2017-10-05 23:18:36 UTC (rev 222944)
@@ -120,7 +120,8 @@
void webGLLoadPolicy(WebPageProxy&, const WebCore::URL&, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const final;
void resolveWebGLLoadPolicy(WebPageProxy&, const WebCore::URL&, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const final;
bool willGoToBackForwardListItem(WebPageProxy&, WebBackForwardListItem&, bool inPageCache, API::Object*) final;
- bool didFailToInitializePlugIn(WebKit::WebPageProxy&, API::Dictionary&) final;
+ bool didFailToInitializePlugIn(WebPageProxy&, API::Dictionary&) final;
+ bool didChangeBackForwardList(WebPageProxy&, WebBackForwardListItem*, const Vector<Ref<WebBackForwardListItem>>&) final;
#endif
void contentRuleListNotification(WebPageProxy&, WebCore::URL&&, Vector<String>&&, Vector<String>&&) final;
@@ -217,6 +218,7 @@
#if PLATFORM(MAC)
bool webViewWebGLLoadPolicyForURL : 1;
bool webViewResolveWebGLLoadPolicyForURL : 1;
+ bool webViewBackForwardListItemAddedRemoved : 1;
bool webViewDidFailToInitializePlugInWithInfo : 1;
bool webViewWillGoToBackForwardListItemInPageCache : 1;
#endif
Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm (222943 => 222944)
--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm 2017-10-05 23:14:20 UTC (rev 222943)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm 2017-10-05 23:18:36 UTC (rev 222944)
@@ -183,6 +183,7 @@
m_navigationDelegateMethods.webViewResolveWebGLLoadPolicyForURL = [delegate respondsToSelector:@selector(_webView:resolveWebGLLoadPolicyForURL:decisionHandler:)];
m_navigationDelegateMethods.webViewWillGoToBackForwardListItemInPageCache = [delegate respondsToSelector:@selector(_webView:willGoToBackForwardListItem:inPageCache:)];
m_navigationDelegateMethods.webViewDidFailToInitializePlugInWithInfo = [delegate respondsToSelector:@selector(_webView:didFailToInitializePlugInWithInfo:)];
+ m_navigationDelegateMethods.webViewBackForwardListItemAddedRemoved = [delegate respondsToSelector:@selector(_webView:backForwardListItemAdded:removed:)];
#endif
}
@@ -297,7 +298,7 @@
}
#if PLATFORM(MAC)
-bool NavigationState::NavigationClient::didFailToInitializePlugIn(WebKit::WebPageProxy&, API::Dictionary& info)
+bool NavigationState::NavigationClient::didFailToInitializePlugIn(WebPageProxy&, API::Dictionary& info)
{
if (!m_navigationState.m_navigationDelegateMethods.webViewDidFailToInitializePlugInWithInfo)
return false;
@@ -359,6 +360,25 @@
}).get()];
}
+bool NavigationState::NavigationClient::didChangeBackForwardList(WebPageProxy&, WebBackForwardListItem* added, const Vector<Ref<WebBackForwardListItem>>& removed)
+{
+ if (!m_navigationState.m_navigationDelegateMethods.webViewBackForwardListItemAddedRemoved)
+ return false;
+
+ auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
+ if (!navigationDelegate)
+ return false;
+
+ NSMutableArray<WKBackForwardListItem *> *removedItems = nil;
+ if (removed.size()) {
+ removedItems = [[[NSMutableArray alloc] initWithCapacity:removed.size()] autorelease];
+ for (auto& removedItem : removed)
+ [removedItems addObject:wrapper(removedItem.get())];
+ }
+ [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState.m_webView backForwardListItemAdded:added ? wrapper(*added) : nil removed:removedItems];
+ return true;
+}
+
bool NavigationState::NavigationClient::willGoToBackForwardListItem(WebPageProxy&, WebBackForwardListItem& item, bool inPageCache, API::Object*)
{
if (!m_navigationState.m_navigationDelegateMethods.webViewWillGoToBackForwardListItemInPageCache)
@@ -606,7 +626,7 @@
[navigationDelegate webView:m_navigationState.m_webView didReceiveServerRedirectForProvisionalNavigation:wkNavigation];
}
-void NavigationState::NavigationClient::willPerformClientRedirect(WebKit::WebPageProxy& page, const WTF::String& urlString, double delay)
+void NavigationState::NavigationClient::willPerformClientRedirect(WebPageProxy& page, const WTF::String& urlString, double delay)
{
if (!m_navigationState.m_navigationDelegateMethods.webViewWillPerformClientRedirect)
return;
@@ -620,7 +640,7 @@
[static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate) _webView:m_navigationState.m_webView willPerformClientRedirectToURL:url delay:delay];
}
-void NavigationState::NavigationClient::didCancelClientRedirect(WebKit::WebPageProxy& page)
+void NavigationState::NavigationClient::didCancelClientRedirect(WebPageProxy& page)
{
if (!m_navigationState.m_navigationDelegateMethods.webViewDidCancelClientRedirect)
return;
@@ -775,7 +795,7 @@
[static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView navigation:wkNavigation didSameDocumentNavigation:toWKSameDocumentNavigationType(navigationType)];
}
-void NavigationState::NavigationClient::renderingProgressDidChange(WebKit::WebPageProxy&, WebCore::LayoutMilestones layoutMilestones)
+void NavigationState::NavigationClient::renderingProgressDidChange(WebPageProxy&, WebCore::LayoutMilestones layoutMilestones)
{
if (!m_navigationState.m_navigationDelegateMethods.webViewRenderingProgressDidChange)
return;
@@ -787,7 +807,7 @@
[static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView renderingProgressDidChange:renderingProgressEvents(layoutMilestones)];
}
-bool NavigationState::NavigationClient::canAuthenticateAgainstProtectionSpace(WebKit::WebPageProxy&, WebKit::WebProtectionSpace* protectionSpace)
+bool NavigationState::NavigationClient::canAuthenticateAgainstProtectionSpace(WebPageProxy&, WebProtectionSpace* protectionSpace)
{
if (m_navigationState.m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallengeCompletionHandler)
return true;
@@ -859,7 +879,7 @@
[static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView didReceiveAuthenticationChallenge:wrapper(*authenticationChallenge)];
}
-void NavigationState::NavigationClient::processDidTerminate(WebKit::WebPageProxy& page, WebKit::ProcessTerminationReason)
+void NavigationState::NavigationClient::processDidTerminate(WebPageProxy& page, ProcessTerminationReason)
{
if (!m_navigationState.m_navigationDelegateMethods.webViewWebContentProcessDidTerminate && !m_navigationState.m_navigationDelegateMethods.webViewWebProcessDidCrash)
return;
@@ -878,7 +898,7 @@
[static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webViewWebProcessDidCrash:m_navigationState.m_webView];
}
-void NavigationState::NavigationClient::processDidBecomeResponsive(WebKit::WebPageProxy& page)
+void NavigationState::NavigationClient::processDidBecomeResponsive(WebPageProxy& page)
{
if (!m_navigationState.m_navigationDelegateMethods.webViewWebProcessDidBecomeResponsive)
return;
@@ -890,7 +910,7 @@
[static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webViewWebProcessDidBecomeResponsive:m_navigationState.m_webView];
}
-void NavigationState::NavigationClient::processDidBecomeUnresponsive(WebKit::WebPageProxy& page)
+void NavigationState::NavigationClient::processDidBecomeUnresponsive(WebPageProxy& page)
{
if (!m_navigationState.m_navigationDelegateMethods.webViewWebProcessDidBecomeUnresponsive)
return;
@@ -902,7 +922,7 @@
[static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webViewWebProcessDidBecomeUnresponsive:m_navigationState.m_webView];
}
-RefPtr<API::Data> NavigationState::NavigationClient::webCryptoMasterKey(WebKit::WebPageProxy&)
+RefPtr<API::Data> NavigationState::NavigationClient::webCryptoMasterKey(WebPageProxy&)
{
if (!m_navigationState.m_navigationDelegateMethods.webCryptoMasterKeyForWebView) {
Vector<uint8_t> masterKey;
@@ -936,7 +956,7 @@
[static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView didStartLoadForQuickLookDocumentInMainFrameWithFileName:fileName uti:uti];
}
-void NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame(const WebKit::QuickLookDocumentData& data)
+void NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData& data)
{
if (!m_navigationState.m_navigationDelegateMethods.webViewDidFinishLoadForQuickLookDocumentInMainFrame)
return;
@@ -960,7 +980,7 @@
{
}
-void NavigationState::HistoryClient::didNavigateWithNavigationData(WebKit::WebPageProxy&, const WebKit::WebNavigationDataStore& navigationDataStore)
+void NavigationState::HistoryClient::didNavigateWithNavigationData(WebPageProxy&, const WebNavigationDataStore& navigationDataStore)
{
if (!m_navigationState.m_historyDelegateMethods.webViewDidNavigateWithNavigationData)
return;
@@ -972,7 +992,7 @@
[historyDelegate _webView:m_navigationState.m_webView didNavigateWithNavigationData:wrapper(API::NavigationData::create(navigationDataStore))];
}
-void NavigationState::HistoryClient::didPerformClientRedirect(WebKit::WebPageProxy&, const WTF::String& sourceURL, const WTF::String& destinationURL)
+void NavigationState::HistoryClient::didPerformClientRedirect(WebPageProxy&, const WTF::String& sourceURL, const WTF::String& destinationURL)
{
if (!m_navigationState.m_historyDelegateMethods.webViewDidPerformClientRedirectFromURLToURL)
return;
@@ -984,7 +1004,7 @@
[historyDelegate _webView:m_navigationState.m_webView didPerformClientRedirectFromURL:[NSURL _web_URLWithWTFString:sourceURL] toURL:[NSURL _web_URLWithWTFString:destinationURL]];
}
-void NavigationState::HistoryClient::didPerformServerRedirect(WebKit::WebPageProxy&, const WTF::String& sourceURL, const WTF::String& destinationURL)
+void NavigationState::HistoryClient::didPerformServerRedirect(WebPageProxy&, const WTF::String& sourceURL, const WTF::String& destinationURL)
{
if (!m_navigationState.m_historyDelegateMethods.webViewDidPerformServerRedirectFromURLToURL)
return;
@@ -996,7 +1016,7 @@
[historyDelegate _webView:m_navigationState.m_webView didPerformServerRedirectFromURL:[NSURL _web_URLWithWTFString:sourceURL] toURL:[NSURL _web_URLWithWTFString:destinationURL]];
}
-void NavigationState::HistoryClient::didUpdateHistoryTitle(WebKit::WebPageProxy&, const WTF::String& title, const WTF::String& url)
+void NavigationState::HistoryClient::didUpdateHistoryTitle(WebPageProxy&, const WTF::String& title, const WTF::String& url)
{
if (!m_navigationState.m_historyDelegateMethods.webViewDidUpdateHistoryTitleForURL)
return;
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (222943 => 222944)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2017-10-05 23:14:20 UTC (rev 222943)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2017-10-05 23:18:36 UTC (rev 222944)
@@ -1196,7 +1196,8 @@
{
PageClientProtector protector(m_pageClient);
- m_loaderClient->didChangeBackForwardList(*this, added, WTFMove(removed));
+ if (!m_navigationClient || !m_navigationClient->didChangeBackForwardList(*this, added, removed))
+ m_loaderClient->didChangeBackForwardList(*this, added, WTFMove(removed));
auto transaction = m_pageLoadState.transaction();
Modified: trunk/Tools/ChangeLog (222943 => 222944)
--- trunk/Tools/ChangeLog 2017-10-05 23:14:20 UTC (rev 222943)
+++ trunk/Tools/ChangeLog 2017-10-05 23:18:36 UTC (rev 222944)
@@ -1,3 +1,16 @@
+2017-10-05 Alex Christensen <[email protected]>
+
+ Add ObjC equivalent of WKPageNavigationClient.didChangeBackForwardList
+ https://bugs.webkit.org/show_bug.cgi?id=177966
+ <rdar://problem/22387135>
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm:
+ (-[ListItemDelegate _webView:backForwardListItemAdded:removed:]):
+ (-[ListItemDelegate webView:didFinishNavigation:]):
+ (TEST):
+
2017-10-04 Megan Gardner <[email protected]>
check-webkit-style erroneously requires a space between the carrot and brace in obj-c blocks.
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm (222943 => 222944)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm 2017-10-05 23:14:20 UTC (rev 222943)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm 2017-10-05 23:18:36 UTC (rev 222944)
@@ -25,6 +25,7 @@
#include "config.h"
+#import <WebKit/WKBackForwardListPrivate.h>
#import <WebKit/WKNavigationDelegatePrivate.h>
#import <WebKit/WKNavigationPrivate.h>
#import <WebKit/WKWebView.h>
@@ -328,6 +329,61 @@
TestWebKitAPI::Util::run(&isDone);
}
+RetainPtr<WKBackForwardListItem> firstItem;
+RetainPtr<WKBackForwardListItem> secondItem;
+
+@interface ListItemDelegate : NSObject<WKNavigationDelegatePrivate>
+@end
+@implementation ListItemDelegate
+- (void)_webView:(WKWebView *)webView backForwardListItemAdded:(WKBackForwardListItem *)itemAdded removed:(NSArray<WKBackForwardListItem *> *)itemsRemoved
+{
+ NSString *firstURL = [[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"].absoluteString;
+ NSString *secondURL = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"].absoluteString;
+
+ if (!firstItem) {
+ EXPECT_NULL(firstItem);
+ EXPECT_NULL(secondItem);
+ EXPECT_NULL(itemsRemoved);
+ EXPECT_NOT_NULL(itemAdded);
+ EXPECT_STREQ(firstURL.UTF8String, itemAdded.URL.absoluteString.UTF8String);
+ firstItem = itemAdded;
+ } else if (!secondItem) {
+ EXPECT_NOT_NULL(firstItem);
+ EXPECT_NULL(secondItem);
+ EXPECT_NULL(itemsRemoved);
+ EXPECT_NOT_NULL(itemAdded);
+ EXPECT_STREQ(secondURL.UTF8String, itemAdded.URL.absoluteString.UTF8String);
+ secondItem = itemAdded;
+ } else {
+ EXPECT_NOT_NULL(firstItem);
+ EXPECT_NOT_NULL(secondItem);
+ EXPECT_NOT_NULL(itemsRemoved);
+ EXPECT_NULL(itemAdded);
+ EXPECT_EQ([itemsRemoved count], 2u);
+ EXPECT_STREQ(firstURL.UTF8String, [itemsRemoved objectAtIndex:0].URL.absoluteString.UTF8String);
+ EXPECT_STREQ(secondURL.UTF8String, [itemsRemoved objectAtIndex:1].URL.absoluteString.UTF8String);
+ isDone = true;
+ }
+}
+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
+{
+ navigationComplete = true;
+}
+@end
+
+TEST(WKNavigation, ListItemAddedRemoved)
+{
+ auto webView = adoptNS([[WKWebView alloc] init]);
+ auto delegate = adoptNS([[ListItemDelegate alloc] init]);
+ [webView setNavigationDelegate:delegate.get()];
+ [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+ TestWebKitAPI::Util::run(&navigationComplete);
+ navigationComplete = false;
+ [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+ TestWebKitAPI::Util::run(&navigationComplete);
+ [[webView backForwardList] _removeAllItems];
+ TestWebKitAPI::Util::run(&isDone);
+}
#endif // PLATFORM(MAC)
#endif // WK_API_ENABLED