Title: [171045] trunk/Source/WebKit2
Revision
171045
Author
m...@apple.com
Date
2014-07-12 22:51:20 -0700 (Sat, 12 Jul 2014)

Log Message

[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.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (171044 => 171045)


--- trunk/Source/WebKit2/ChangeLog	2014-07-13 02:37:58 UTC (rev 171044)
+++ trunk/Source/WebKit2/ChangeLog	2014-07-13 05:51:20 UTC (rev 171045)
@@ -1,3 +1,38 @@
+2014-07-12  Dan Bernstein  <m...@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....@samsung.com>
 
         Unreviewed, fix EFL build break since r171034.

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h (171044 => 171045)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h	2014-07-13 02:37:58 UTC (rev 171044)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h	2014-07-13 05:51:20 UTC (rev 171045)
@@ -64,8 +64,8 @@
 - (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)_webView:(WKWebView *)webView didFinishLoadForQuickLookDocumentInMainFrame:(NSData *)documentData;

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h (171044 => 171045)


--- trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h	2014-07-13 02:37:58 UTC (rev 171044)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h	2014-07-13 05:51:20 UTC (rev 171045)
@@ -78,6 +78,7 @@
     void navigationGestureDidBegin();
     void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&);
     void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&);
+    void willRecordNavigationSnapshot(WebBackForwardListItem&);
 
 private:
     class PolicyClient : public API::PolicyClient {
@@ -166,6 +167,7 @@
         bool webViewDidBeginNavigationGesture : 1;
         bool webViewWillEndNavigationGestureWithNavigationToBackForwardListItem : 1;
         bool webViewDidEndNavigationGestureWithNavigationToBackForwardListItem : 1;
+        bool webViewWillSnapshotBackForwardListItem : 1;
 #if USE(QUICK_LOOK)
         bool webViewDidStartLoadForQuickLookDocumentInMainFrame : 1;
         bool webViewDidFinishLoadForQuickLookDocumentInMainFrame : 1;

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm (171044 => 171045)


--- trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm	2014-07-13 02:37:58 UTC (rev 171044)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm	2014-07-13 05:51:20 UTC (rev 171045)
@@ -140,6 +140,7 @@
     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:)];
@@ -290,6 +291,18 @@
     [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)
 {

Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (171044 => 171045)


--- trunk/Source/WebKit2/UIProcess/PageClient.h	2014-07-13 02:37:58 UTC (rev 171044)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h	2014-07-13 05:51:20 UTC (rev 171045)
@@ -298,6 +298,7 @@
     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

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (171044 => 171045)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-07-13 02:37:58 UTC (rev 171044)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-07-13 05:51:20 UTC (rev 171045)
@@ -5143,6 +5143,11 @@
     m_pageClient.navigationGestureDidEnd(willNavigate, item);
 }
 
+void WebPageProxy::willRecordNavigationSnapshot(WebBackForwardListItem& item)
+{
+    m_pageClient.willRecordNavigationSnapshot(item);
+}
+
 void WebPageProxy::navigationGestureSnapshotWasRemoved()
 {
     m_isShowingNavigationGestureSnapshot = false;

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (171044 => 171045)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-07-13 02:37:58 UTC (rev 171044)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2014-07-13 05:51:20 UTC (rev 171045)
@@ -901,6 +901,7 @@
     void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&);
     void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&);
     void navigationGestureSnapshotWasRemoved();
+    void willRecordNavigationSnapshot(WebBackForwardListItem&);
 
     bool isShowingNavigationGestureSnapshot() const { return m_isShowingNavigationGestureSnapshot; }
 

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (171044 => 171045)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2014-07-13 02:37:58 UTC (rev 171044)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2014-07-13 05:51:20 UTC (rev 171045)
@@ -170,6 +170,7 @@
     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;

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (171044 => 171045)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2014-07-13 02:37:58 UTC (rev 171044)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2014-07-13 05:51:20 UTC (rev 171045)
@@ -667,6 +667,11 @@
     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)

Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (171044 => 171045)


--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h	2014-07-13 02:37:58 UTC (rev 171044)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h	2014-07-13 05:51:20 UTC (rev 171045)
@@ -176,6 +176,7 @@
     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;
 

Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (171044 => 171045)


--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2014-07-13 02:37:58 UTC (rev 171044)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2014-07-13 05:51:20 UTC (rev 171045)
@@ -714,6 +714,15 @@
 #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)

Modified: trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm (171044 => 171045)


--- trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm	2014-07-13 02:37:58 UTC (rev 171044)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm	2014-07-13 05:51:20 UTC (rev 171045)
@@ -119,6 +119,8 @@
 
     pruneSnapshots(webPageProxy);
 
+    webPageProxy.willRecordNavigationSnapshot(*item);
+
     RefPtr<ViewSnapshot> snapshot = webPageProxy.takeViewSnapshot();
     if (!snapshot || !snapshot->hasImage())
         return;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to