https://bugs.webkit.org/show_bug.cgi?id=134865
Reviewed by Sam Weinig.
* UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h: Declared new delegate method.
* UIProcess/Cocoa/NavigationState.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::setNavigationDelegate): Initialize new flag in
m_navigationDelegateMethods.
(WebKit::NavigationState::willRecordNavigationSnapshot): Added. Calls the new
WKNavigationDelegate method.
* UIProcess/PageClient.h: Declared new client function.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::willRecordNavigationSnapshot): Added. Calls the new client function.
* UIProcess/WebPageProxy.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::willRecordNavigationSnapshot): Override that calls
NavigationState::willRecordNavigationSnapshot.
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::willRecordNavigationSnapshot): Ditto.
* UIProcess/mac/ViewSnapshotStore.mm:
(WebKit::ViewSnapshotStore::recordSnapshot): Added a call to
WebPageProxy::willRecordNavigationSnapshot.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@171045
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-07-12 Dan Bernstein <mitz@apple.com>
+
+ [Cocoa] Notify the client when a navigation snapshot is taken
+ https://bugs.webkit.org/show_bug.cgi?id=134865
+
+ Reviewed by Sam Weinig.
+
+ * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h: Declared new delegate method.
+
+ * UIProcess/Cocoa/NavigationState.h:
+ * UIProcess/Cocoa/NavigationState.mm:
+ (WebKit::NavigationState::setNavigationDelegate): Initialize new flag in
+ m_navigationDelegateMethods.
+ (WebKit::NavigationState::willRecordNavigationSnapshot): Added. Calls the new
+ WKNavigationDelegate method.
+
+ * UIProcess/PageClient.h: Declared new client function.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::willRecordNavigationSnapshot): Added. Calls the new client function.
+ * UIProcess/WebPageProxy.h:
+
+ * UIProcess/ios/PageClientImplIOS.h:
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::willRecordNavigationSnapshot): Override that calls
+ NavigationState::willRecordNavigationSnapshot.
+
+ * UIProcess/mac/PageClientImpl.h:
+ * UIProcess/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::willRecordNavigationSnapshot): Ditto.
+
+ * UIProcess/mac/ViewSnapshotStore.mm:
+ (WebKit::ViewSnapshotStore::recordSnapshot): Added a call to
+ WebPageProxy::willRecordNavigationSnapshot.
+
2014-07-12 Gyuyoung Kim <gyuyoung.kim@samsung.com>
Unreviewed, fix EFL build break since r171034.
- (void)_webViewDidEndNavigationGesture:(WKWebView *)webView withNavigationToBackForwardListItem:(WKBackForwardListItem *)item;
// Only called if how the gesture will end (with or without navigation) is known before it ends.
- (void)_webViewWillEndNavigationGesture:(WKWebView *)webView withNavigationToBackForwardListItem:(WKBackForwardListItem *)item;
-
+- (void)_webView:(WKWebView *)webView willSnapshotBackForwardListItem:(WKBackForwardListItem *)item;
#if TARGET_OS_IPHONE
- (void)_webView:(WKWebView *)webView didStartLoadForQuickLookDocumentInMainFrameWithFileName:(NSString *)fileName uti:(NSString *)uti;
void navigationGestureDidBegin();
void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&);
void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&);
+ void willRecordNavigationSnapshot(WebBackForwardListItem&);
private:
class PolicyClient : public API::PolicyClient {
bool webViewDidBeginNavigationGesture : 1;
bool webViewWillEndNavigationGestureWithNavigationToBackForwardListItem : 1;
bool webViewDidEndNavigationGestureWithNavigationToBackForwardListItem : 1;
+ bool webViewWillSnapshotBackForwardListItem : 1;
#if USE(QUICK_LOOK)
bool webViewDidStartLoadForQuickLookDocumentInMainFrame : 1;
bool webViewDidFinishLoadForQuickLookDocumentInMainFrame : 1;
m_navigationDelegateMethods.webViewDidBeginNavigationGesture = [delegate respondsToSelector:@selector(_webViewDidBeginNavigationGesture:)];
m_navigationDelegateMethods.webViewWillEndNavigationGestureWithNavigationToBackForwardListItem = [delegate respondsToSelector:@selector(_webViewWillEndNavigationGesture:withNavigationToBackForwardListItem:)];
m_navigationDelegateMethods.webViewDidEndNavigationGestureWithNavigationToBackForwardListItem = [delegate respondsToSelector:@selector(_webViewDidEndNavigationGesture:withNavigationToBackForwardListItem:)];
+ m_navigationDelegateMethods.webViewWillSnapshotBackForwardListItem = [delegate respondsToSelector:@selector(_webView:willSnapshotBackForwardListItem:)];
#if USE(QUICK_LOOK)
m_navigationDelegateMethods.webViewDidStartLoadForQuickLookDocumentInMainFrame = [delegate respondsToSelector:@selector(_webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:)];
m_navigationDelegateMethods.webViewDidFinishLoadForQuickLookDocumentInMainFrame = [delegate respondsToSelector:@selector(_webView:didFinishLoadForQuickLookDocumentInMainFrame:)];
[static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate) _webViewDidEndNavigationGesture:m_webView withNavigationToBackForwardListItem:willNavigate ? wrapper(item) : nil];
}
+void NavigationState::willRecordNavigationSnapshot(WebBackForwardListItem& item)
+{
+ if (!m_navigationDelegateMethods.webViewWillSnapshotBackForwardListItem)
+ return;
+
+ auto navigationDelegate = m_navigationDelegate.get();
+ if (!navigationDelegate)
+ return;
+
+ [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate) _webView:m_webView willSnapshotBackForwardListItem:wrapper(item)];
+}
+
NavigationState::PolicyClient::PolicyClient(NavigationState& navigationState)
: m_navigationState(navigationState)
{
virtual void navigationGestureDidBegin() = 0;
virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) = 0;
virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) = 0;
+ virtual void willRecordNavigationSnapshot(WebBackForwardListItem&) = 0;
};
} // namespace WebKit
m_pageClient.navigationGestureDidEnd(willNavigate, item);
}
+void WebPageProxy::willRecordNavigationSnapshot(WebBackForwardListItem& item)
+{
+ m_pageClient.willRecordNavigationSnapshot(item);
+}
+
void WebPageProxy::navigationGestureSnapshotWasRemoved()
{
m_isShowingNavigationGestureSnapshot = false;
void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&);
void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&);
void navigationGestureSnapshotWasRemoved();
+ void willRecordNavigationSnapshot(WebBackForwardListItem&);
bool isShowingNavigationGestureSnapshot() const { return m_isShowingNavigationGestureSnapshot; }
virtual void navigationGestureDidBegin() override;
virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
+ virtual void willRecordNavigationSnapshot(WebBackForwardListItem&) override;
WKContentView *m_contentView;
WKWebView *m_webView;
NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidEnd(willNavigate, item);
}
+void PageClientImpl::willRecordNavigationSnapshot(WebBackForwardListItem& item)
+{
+ NavigationState::fromWebPage(*m_webView->_page).willRecordNavigationSnapshot(item);
+}
+
} // namespace WebKit
#endif // PLATFORM(IOS)
virtual void navigationGestureDidBegin() override;
virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
+ virtual void willRecordNavigationSnapshot(WebBackForwardListItem&) override;
NSView *activeView() const;
#endif
}
+void PageClientImpl::willRecordNavigationSnapshot(WebBackForwardListItem& item)
+{
+#if WK_API_ENABLED
+ NavigationState::fromWebPage(*m_webView->_page).willRecordNavigationSnapshot(item);
+#else
+ UNUSED_PARAM(item);
+#endif
+}
+
} // namespace WebKit
#endif // PLATFORM(MAC)
pruneSnapshots(webPageProxy);
+ webPageProxy.willRecordNavigationSnapshot(*item);
+
RefPtr<ViewSnapshot> snapshot = webPageProxy.takeViewSnapshot();
if (!snapshot || !snapshot->hasImage())
return;