Title: [235157] trunk
Revision
235157
Author
[email protected]
Date
2018-08-21 20:51:52 -0700 (Tue, 21 Aug 2018)

Log Message

Roll out r235139 and r235146
https://bugs.webkit.org/show_bug.cgi?id=188805

Source/WebKit:

It turns out shouldKeepCurrentBackForwardListItemInList has one use left.

* UIProcess/API/APILoaderClient.h:
(API::LoaderClient::shouldKeepCurrentBackForwardListItemInList):
* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageLoaderClient):
* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::addItem):
(WebKit::WebBackForwardList::goToItem):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::shouldKeepCurrentBackForwardListItemInList):
* UIProcess/WebPageProxy.h:

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/ShouldKeepCurrentBackForwardListItemInList.cpp:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (235156 => 235157)


--- trunk/Source/WebKit/ChangeLog	2018-08-22 03:21:56 UTC (rev 235156)
+++ trunk/Source/WebKit/ChangeLog	2018-08-22 03:51:52 UTC (rev 235157)
@@ -1,3 +1,21 @@
+2018-08-21  Alex Christensen  <[email protected]>
+
+        Roll out r235139 and r235146
+        https://bugs.webkit.org/show_bug.cgi?id=188805
+
+        It turns out shouldKeepCurrentBackForwardListItemInList has one use left.
+
+        * UIProcess/API/APILoaderClient.h:
+        (API::LoaderClient::shouldKeepCurrentBackForwardListItemInList):
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetPageLoaderClient):
+        * UIProcess/WebBackForwardList.cpp:
+        (WebKit::WebBackForwardList::addItem):
+        (WebKit::WebBackForwardList::goToItem):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::shouldKeepCurrentBackForwardListItemInList):
+        * UIProcess/WebPageProxy.h:
+
 2018-08-21  Wenson Hsieh  <[email protected]>
 
         [Attachment Support] Remove _WKAttachments and notify the UI client upon mainframe navigation

Modified: trunk/Source/WebKit/UIProcess/API/APILoaderClient.h (235156 => 235157)


--- trunk/Source/WebKit/UIProcess/API/APILoaderClient.h	2018-08-22 03:21:56 UTC (rev 235156)
+++ trunk/Source/WebKit/UIProcess/API/APILoaderClient.h	2018-08-22 03:51:52 UTC (rev 235157)
@@ -90,6 +90,7 @@
     virtual bool processDidCrash(WebKit::WebPageProxy&) { return false; }
 
     virtual void didChangeBackForwardList(WebKit::WebPageProxy&, WebKit::WebBackForwardListItem*, Vector<Ref<WebKit::WebBackForwardListItem>>&&) { }
+    virtual bool shouldKeepCurrentBackForwardListItemInList(WebKit::WebPageProxy&, WebKit::WebBackForwardListItem&) { return true; }
     virtual void willGoToBackForwardListItem(WebKit::WebPageProxy&, WebKit::WebBackForwardListItem&, API::Object*) { }
 
     virtual void didNavigateWithNavigationData(WebKit::WebPageProxy&, const WebKit::WebNavigationDataStore&, WebKit::WebFrameProxy&) { }

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (235156 => 235157)


--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp	2018-08-22 03:21:56 UTC (rev 235156)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp	2018-08-22 03:51:52 UTC (rev 235157)
@@ -1042,7 +1042,6 @@
         explicit LoaderClient(const WKPageLoaderClientBase* client)
         {
             initialize(client);
-            ASSERT(!m_client.shouldKeepCurrentBackForwardListItemInList);
         }
 
     private:
@@ -1249,6 +1248,14 @@
             m_client.didChangeBackForwardList(toAPI(&page), toAPI(addedItem), toAPI(removedItemsArray.get()), m_client.base.clientInfo);
         }
 
+        bool shouldKeepCurrentBackForwardListItemInList(WebKit::WebPageProxy& page, WebKit::WebBackForwardListItem& item) override
+        {
+            if (!m_client.shouldKeepCurrentBackForwardListItemInList)
+                return true;
+
+            return m_client.shouldKeepCurrentBackForwardListItemInList(toAPI(&page), toAPI(&item), m_client.base.clientInfo);
+        }
+
         void willGoToBackForwardListItem(WebPageProxy& page, WebBackForwardListItem& item, API::Object* userData) override
         {
             if (m_client.willGoToBackForwardListItem)

Modified: trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp (235156 => 235157)


--- trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp	2018-08-22 03:21:56 UTC (rev 235156)
+++ trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp	2018-08-22 03:51:52 UTC (rev 235157)
@@ -141,8 +141,11 @@
         ASSERT(m_entries.isEmpty());
         m_currentIndex = 0;
         m_hasCurrentIndex = true;
-    } else
-        m_currentIndex++;
+    } else {
+        shouldKeepCurrentItem = m_page->shouldKeepCurrentBackForwardListItemInList(m_entries[m_currentIndex]);
+        if (shouldKeepCurrentItem)
+            m_currentIndex++;
+    }
 
     auto* newItemPtr = newItem.ptr();
     if (!shouldKeepCurrentItem) {
@@ -195,13 +198,31 @@
     // If we're going to an item different from the current item, ask the client if the current
     // item should remain in the list.
     auto& currentItem = m_entries[m_currentIndex];
-    if (currentItem.ptr() != &item)
+    bool shouldKeepCurrentItem = true;
+    if (currentItem.ptr() != &item) {
         m_page->recordAutomaticNavigationSnapshot();
+        shouldKeepCurrentItem = m_page->shouldKeepCurrentBackForwardListItemInList(m_entries[m_currentIndex]);
+    }
 
+    // If the client said to remove the current item, remove it and then update the target index.
+    Vector<Ref<WebBackForwardListItem>> removedItems;
+    if (!shouldKeepCurrentItem) {
+        removedItems.append(currentItem.copyRef());
+        m_entries.remove(m_currentIndex);
+        targetIndex = notFound;
+        for (size_t i = 0; i < m_entries.size(); ++i) {
+            if (m_entries[i].ptr() == &item) {
+                targetIndex = i;
+                break;
+            }
+        }
+        ASSERT(targetIndex != notFound);
+    }
+
     m_currentIndex = targetIndex;
 
     LOG(BackForward, "(Back/Forward) WebBackForwardList %p going to item %s, is now at index %zu", this, item.itemID().logString(), targetIndex);
-    m_page->didChangeBackForwardList(nullptr, { });
+    m_page->didChangeBackForwardList(nullptr, WTFMove(removedItems));
 }
 
 WebBackForwardListItem* WebBackForwardList::currentItem() const

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (235156 => 235157)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-08-22 03:21:56 UTC (rev 235156)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-08-22 03:51:52 UTC (rev 235157)
@@ -1290,6 +1290,13 @@
     }
 }
 
+bool WebPageProxy::shouldKeepCurrentBackForwardListItemInList(WebBackForwardListItem& item)
+{
+    PageClientProtector protector(m_pageClient);
+
+    return m_loaderClient->shouldKeepCurrentBackForwardListItemInList(*this, item);
+}
+
 bool WebPageProxy::canShowMIMEType(const String& mimeType)
 {
     if (MIMETypeRegistry::canShowMIMEType(mimeType))

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (235156 => 235157)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-08-22 03:21:56 UTC (rev 235156)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-08-22 03:51:52 UTC (rev 235157)
@@ -468,6 +468,8 @@
     void didChangeBackForwardList(WebBackForwardListItem* addedItem, Vector<Ref<WebBackForwardListItem>>&& removed);
     void willGoToBackForwardListItem(const WebCore::BackForwardItemIdentifier&, bool inPageCache, const UserData&);
 
+    bool shouldKeepCurrentBackForwardListItemInList(WebBackForwardListItem&);
+
     bool willHandleHorizontalScrollEvents() const;
 
     void updateWebsitePolicies(WebsitePoliciesData&&);

Modified: trunk/Tools/ChangeLog (235156 => 235157)


--- trunk/Tools/ChangeLog	2018-08-22 03:21:56 UTC (rev 235156)
+++ trunk/Tools/ChangeLog	2018-08-22 03:51:52 UTC (rev 235157)
@@ -1,3 +1,11 @@
+2018-08-21  Alex Christensen  <[email protected]>
+
+        Roll out r235139 and r235146
+        https://bugs.webkit.org/show_bug.cgi?id=188805
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit/ShouldKeepCurrentBackForwardListItemInList.cpp:
+
 2018-08-21  Wenson Hsieh  <[email protected]>
 
         [Attachment Support] Remove _WKAttachments and notify the UI client upon mainframe navigation

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (235156 => 235157)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-08-22 03:21:56 UTC (rev 235156)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-08-22 03:51:52 UTC (rev 235157)
@@ -533,6 +533,7 @@
 		7CCE7F111A411AE600447C4C /* RestoreSessionStateContainingFormData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0ADBE8212FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp */; };
 		7CCE7F121A411AE600447C4C /* ScrollPinningBehaviors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D640B5417875DFF00BFAF99 /* ScrollPinningBehaviors.cpp */; };
 		7CCE7F131A411AE600447C4C /* ShouldGoToBackForwardListItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51FCF7981534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp */; };
+		7CCE7F141A411AE600447C4C /* ShouldKeepCurrentBackForwardListItemInList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51E5C7041919EA5F00D8B3E1 /* ShouldKeepCurrentBackForwardListItemInList.cpp */; };
 		7CCE7F151A411AE600447C4C /* SpacebarScrolling.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C02B77F1126612140026BF0F /* SpacebarScrolling.cpp */; };
 		7CCE7F161A411AE600447C4C /* TerminateTwice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE72F47173EB214006362F0 /* TerminateTwice.cpp */; };
 		7CCE7F171A411AE600447C4C /* UserMedia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A410F4B19AF7BD6002EBAB5 /* UserMedia.cpp */; };
@@ -1497,6 +1498,7 @@
 		51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "modal-alerts-in-new-about-blank-window.html"; sourceTree = "<group>"; };
 		51D124971E763AF8002B2820 /* WKHTTPCookieStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKHTTPCookieStore.mm; sourceTree = "<group>"; };
 		51DB16CD1F085047001FA4C5 /* WebViewIconLoading.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewIconLoading.mm; sourceTree = "<group>"; };
+		51E5C7041919EA5F00D8B3E1 /* ShouldKeepCurrentBackForwardListItemInList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShouldKeepCurrentBackForwardListItemInList.cpp; sourceTree = "<group>"; };
 		51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalStorageClear.mm; sourceTree = "<group>"; };
 		51E6A8951D2F1C7700C004B6 /* LocalStorageClear.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = LocalStorageClear.html; sourceTree = "<group>"; };
 		51E780361919AFF8001829A2 /* simple2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = simple2.html; sourceTree = "<group>"; };
@@ -2933,6 +2935,7 @@
 				2D640B5417875DFF00BFAF99 /* ScrollPinningBehaviors.cpp */,
 				51FCF7981534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp */,
 				51FCF7971534AC6D00104491 /* ShouldGoToBackForwardListItem_Bundle.cpp */,
+				51E5C7041919EA5F00D8B3E1 /* ShouldKeepCurrentBackForwardListItemInList.cpp */,
 				C02B77F1126612140026BF0F /* SpacebarScrolling.cpp */,
 				76734997193016DC00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad.cpp */,
 				7673499A1930182E00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp */,
@@ -3940,6 +3943,7 @@
 				A17991881E1C994E00A505ED /* SharedBuffer.mm in Sources */,
 				A179918B1E1CA24100A505ED /* SharedBufferTest.cpp in Sources */,
 				7CCE7F131A411AE600447C4C /* ShouldGoToBackForwardListItem.cpp in Sources */,
+				7CCE7F141A411AE600447C4C /* ShouldKeepCurrentBackForwardListItemInList.cpp in Sources */,
 				37BCA61C1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm in Sources */,
 				7C83E0C51D0A654600FEBCF3 /* ShrinkToFit.mm in Sources */,
 				7CCE7ECD1A411A7E00447C4C /* SimplifyMarkup.mm in Sources */,

Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit/ShouldKeepCurrentBackForwardListItemInList.cpp (from rev 235138, trunk/Tools/TestWebKitAPI/Tests/WebKit/ShouldKeepCurrentBackForwardListItemInList.cpp) (0 => 235157)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/ShouldKeepCurrentBackForwardListItemInList.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/ShouldKeepCurrentBackForwardListItemInList.cpp	2018-08-22 03:51:52 UTC (rev 235157)
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if WK_HAVE_C_SPI
+
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+
+// This test navigates from simple.html, to simple2.html, to simple3.html
+// When navigating from simple2 to simple3, it disallows the simple2 back/forward list item from staying in the list
+// It then navigates back from simple3, expecting to land at simple.
+
+namespace TestWebKitAPI {
+
+static bool finished = false;
+static bool successfulSoFar = true;
+static int navigationNumber = 0;
+
+static bool itemURLLastComponentIsString(WKBackForwardListItemRef item, const char* string)
+{
+    WKRetainPtr<WKURLRef> url = ""
+    WKRetainPtr<WKStringRef> path = adoptWK(WKURLCopyLastPathComponent(url.get()));
+
+    return WKStringIsEqualToUTF8CString(path.get(), string);
+}
+
+static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef, const void*)
+{
+    // Only mark finished when the main frame loads
+    if (!WKFrameIsMainFrame(frame))
+        return;
+
+    finished = true;
+    navigationNumber++;
+
+    WKBackForwardListRef list = WKPageGetBackForwardList(page);
+    WKBackForwardListItemRef currentItem = WKBackForwardListGetCurrentItem(list);
+    WKBackForwardListItemRef backItem = WKBackForwardListGetBackItem(list);
+    WKBackForwardListItemRef forwardItem = WKBackForwardListGetForwardItem(list);
+    unsigned forwardCount = WKBackForwardListGetForwardListCount(list);
+
+    // This test should never have a forward list.
+    if (forwardCount)
+        successfulSoFar = false;
+
+    if (navigationNumber == 1) {
+        // We've only performed 1 navigation, we should only have a current item.
+        if (!currentItem || !itemURLLastComponentIsString(currentItem, "simple.html"))
+            successfulSoFar = false;
+        if (backItem || forwardItem)
+            successfulSoFar = false;
+    } else if (navigationNumber == 2) {
+        // On the second navigation, simple2 should be current and simple should be the back item.
+        if (!currentItem || !itemURLLastComponentIsString(currentItem, "simple2.html"))
+            successfulSoFar = false;
+        if (!backItem || !itemURLLastComponentIsString(backItem, "simple.html"))
+            successfulSoFar = false;
+        if (forwardItem)
+            successfulSoFar = false;
+    } else if (navigationNumber == 3) {
+        // On the third navigation the item for simple2 should have been removed.
+        // So simple3 should be current and simple should still be the back item.
+        if (!currentItem || !itemURLLastComponentIsString(currentItem, "simple3.html"))
+            successfulSoFar = false;
+        if (!backItem || !itemURLLastComponentIsString(backItem, "simple.html"))
+            successfulSoFar = false;
+        if (forwardItem)
+            successfulSoFar = false;
+    } else if (navigationNumber == 4) {
+        // After the fourth navigation (which was a "back" navigation), the item for simple3 should have been removed.
+        // So simple should be current and there should be no other items.
+        if (!currentItem || !itemURLLastComponentIsString(currentItem, "simple.html"))
+            successfulSoFar = false;
+        if (backItem || forwardItem)
+            successfulSoFar = false;
+    }
+}
+
+static void willGoToBackForwardListItem(WKPageRef, WKBackForwardListItemRef item, WKTypeRef userData, const void*)
+{
+    if (!itemURLLastComponentIsString(item, "simple.html"))
+        successfulSoFar = false;
+}
+
+static bool shouldKeepCurrentBackForwardListItemInList(WKPageRef page, WKBackForwardListItemRef item, const void*)
+{
+    // We make sure the item for "simple2.html" is removed when we navigate to "simple3.html"
+    // We also want to make sure the item for "simple3.html" is removed when we go back to "simple.html"
+    // So we only want to keep "simple.html"
+    return itemURLLastComponentIsString(item, "simple.html");
+}
+
+static void setPageLoaderClient(WKPageRef page)
+{
+    WKPageLoaderClientV5 loaderClient;
+    memset(&loaderClient, 0, sizeof(loaderClient));
+
+    loaderClient.base.version = 5;
+    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+    loaderClient.shouldKeepCurrentBackForwardListItemInList = shouldKeepCurrentBackForwardListItemInList;
+    loaderClient.willGoToBackForwardListItem = willGoToBackForwardListItem;
+
+    WKPageSetPageLoaderClient(page, &loaderClient.base);
+}
+
+TEST(WebKit, ShouldKeepCurrentBackForwardListItemInList)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+
+    PlatformWebView webView(context.get());
+    setPageLoaderClient(webView.page());
+
+    WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple", "html")).get());
+    Util::run(&finished);
+    EXPECT_EQ(successfulSoFar, true);
+
+    finished = false;
+    WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple2", "html")).get());
+    Util::run(&finished);
+    EXPECT_EQ(successfulSoFar, true);
+
+    finished = false;
+    WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple3", "html")).get());
+    Util::run(&finished);
+    EXPECT_EQ(successfulSoFar, true);
+
+    finished = false;
+    WKPageGoBack(webView.page());
+    Util::run(&finished);
+
+    EXPECT_EQ(successfulSoFar, true);
+    EXPECT_EQ(navigationNumber, 4);
+}
+
+} // namespace TestWebKitAPI
+
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to