Move didPerformFirstNavigation() logic to -[WebView _didCommitLoadForFrame:]
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Jan 2014 22:38:53 +0000 (22:38 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Jan 2014 22:38:53 +0000 (22:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127189

Reviewed by Dan Bernstein.

Source/WebCore:

* loader/FrameLoaderClient.h:
(WebCore::FrameLoaderClient::didPerformFirstNavigation):
Add an empty implementation of didPerformFirstNavigation() to make it easier to remove it from subclasses.

Source/WebKit/mac:

This is a first step towards completely eliminating the didPerformFirstNavigation() client callback.

* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
Remove didPerformFirstNavigation() implementation.

* WebView/WebView.mm:
(-[WebView _checkDidPerformFirstNavigation]):
Check if we have both a current item and a previous item which indicates that we've navigated once.
The old code was called before there was a current item but since this is called from _didCommitLoadForFrame
we have to check that there's a current item as well.

(-[WebView _didCommitLoadForFrame:]):
Call _didCommitLoadForFrame.

* WebView/WebViewData.h:
Add new ivar.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162224 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/loader/FrameLoaderClient.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/mac/WebView/WebViewData.h

index 1a20004..e5a2e5e 100644 (file)
@@ -1,3 +1,14 @@
+2014-01-17  Anders Carlsson  <andersca@apple.com>
+
+        Move didPerformFirstNavigation() logic to -[WebView _didCommitLoadForFrame:]
+        https://bugs.webkit.org/show_bug.cgi?id=127189
+
+        Reviewed by Dan Bernstein.
+
+        * loader/FrameLoaderClient.h:
+        (WebCore::FrameLoaderClient::didPerformFirstNavigation):
+        Add an empty implementation of didPerformFirstNavigation() to make it easier to remove it from subclasses.
+
 2014-01-17  Eric Carlson  <eric.carlson@apple.com>
 
         [iOS] HTMLMediaSession should set AudioSession category
index 09dc062..db5a17f 100644 (file)
@@ -282,7 +282,7 @@ namespace WebCore {
 
         virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld&) = 0;
         virtual void documentElementAvailable() = 0;
-        virtual void didPerformFirstNavigation() const = 0; // "Navigation" here means a transition from one page to another that ends up in the back/forward list.
+        virtual void didPerformFirstNavigation() const { }
 
         virtual void registerForIconNotification(bool listen = true) = 0;
 
index b2994ea..bc0f7c5 100644 (file)
@@ -1,3 +1,28 @@
+2014-01-17  Anders Carlsson  <andersca@apple.com>
+
+        Move didPerformFirstNavigation() logic to -[WebView _didCommitLoadForFrame:]
+        https://bugs.webkit.org/show_bug.cgi?id=127189
+
+        Reviewed by Dan Bernstein.
+
+        This is a first step towards completely eliminating the didPerformFirstNavigation() client callback.
+        
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        Remove didPerformFirstNavigation() implementation.
+
+        * WebView/WebView.mm:
+        (-[WebView _checkDidPerformFirstNavigation]):
+        Check if we have both a current item and a previous item which indicates that we've navigated once.
+        The old code was called before there was a current item but since this is called from _didCommitLoadForFrame
+        we have to check that there's a current item as well.
+
+        (-[WebView _didCommitLoadForFrame:]):
+        Call _didCommitLoadForFrame.
+
+        * WebView/WebViewData.h:
+        Add new ivar.
+
 2014-01-17  Alexey Proskuryakov  <ap@apple.com>
 
         More iOS build fix.
index f36c926..4a41ecf 100644 (file)
@@ -217,7 +217,6 @@ private:
     
     virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld&) override;
     virtual void documentElementAvailable() override;
-    virtual void didPerformFirstNavigation() const override;
 
     virtual void registerForIconNotification(bool listen) override;
 
index 418fbd3..8922c1a 100644 (file)
@@ -2381,13 +2381,6 @@ void WebFrameLoaderClient::registerForIconNotification(bool listen)
 #endif
 }
 
-void WebFrameLoaderClient::didPerformFirstNavigation() const
-{
-    WebPreferences *preferences = [[m_webFrame.get() webView] preferences];
-    if ([preferences automaticallyDetectsCacheModel] && [preferences cacheModel] < WebCacheModelDocumentBrowser)
-        [preferences setCacheModel:WebCacheModelDocumentBrowser];
-}
-
 PassRefPtr<FrameNetworkingContext> WebFrameLoaderClient::createNetworkingContext()
 {
     return WebFrameNetworkingContext::create(core(m_webFrame.get()));
index a85d050..a1ffd31 100644 (file)
 #import <WebCore/AlternativeTextUIController.h>
 #import <WebCore/AnimationController.h>
 #import <WebCore/ApplicationCacheStorage.h>
+#import <WebCore/BackForwardController.h>
 #import <WebCore/BackForwardList.h>
 #import <WebCore/MemoryCache.h>
 #import <WebCore/Chrome.h>
@@ -2857,10 +2858,33 @@ static inline IMP getMethod(id o, SEL s)
 #endif
 }
 
+- (void)_checkDidPerformFirstNavigation
+{
+    if (_private->_didPerformFirstNavigation)
+        return;
+
+    Page* page = _private->page;
+    if (!page)
+        return;
+
+    auto& backForwardController = page->backForward();
+
+    if (!backForwardController.backItem())
+        return;
+
+    _private->_didPerformFirstNavigation = YES;
+
+    if (_private->preferences.automaticallyDetectsCacheModel && _private->preferences.cacheModel < WebCacheModelDocumentBrowser)
+        _private->preferences.cacheModel = WebCacheModelDocumentBrowser;
+}
+
 - (void)_didCommitLoadForFrame:(WebFrame *)frame
 {
     if (frame == [self mainFrame])
         [self _didChangeValueForKey: _WebMainFrameURLKey];
+
+    [self _checkDidPerformFirstNavigation];
+
     [NSApp setWindowsNeedUpdate:YES];
 }
 
index d439dc4..57a07f2 100644 (file)
@@ -288,5 +288,7 @@ private:
 #endif
 
     RetainPtr<NSData> sourceApplicationAuditData;
+
+    BOOL _didPerformFirstNavigation;
 }
 @end