Title: [171574] trunk/Source
Revision
171574
Author
[email protected]
Date
2014-07-24 18:31:40 -0700 (Thu, 24 Jul 2014)

Log Message

Source/WebCore: WebCore part of <rdar://problem/17593701> Assertion failure in WebPage::reload (!m_pendingNavigationID) when reloading after a same-document back navigation
https://bugs.webkit.org/show_bug.cgi?id=135129

Reviewed by Darin Adler.

* WebCore.exp.in: Exported equalIgnoringFragmentIdentifier(const URL&, const URL&).

Source/WebKit2: WebKit2 part of <rdar://problem/17593701> Assertion failure in WebPage::reload (!m_pendingNavigationID) when reloading after a same-document back navigation
https://bugs.webkit.org/show_bug.cgi?id=135129

Reviewed by Darin Adler.

* Shared/WebBackForwardListItem.cpp:
(WebKit::childItemWithDocumentSequenceNumber): New helper function based on
WebCore::HistoryItem::childItemWithDocumentSequenceNumber.
(WebKit::documentTreesAreEqual): New helper function based on
WebCore::HistoryItem::hasSameDocumentTree.
(WebKit::WebBackForwardListItem::itemIsInSameDocument): Added. Based on
WebCore::HistoryItem::shouldDoSameDocumentNavigationTo.
* Shared/WebBackForwardListItem.h:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::goForward): Don’t assign a new navigation ID if the back-forward
navigation is a same-document navigation.
(WebKit::WebPageProxy::goBack): Ditto.
(WebKit::WebPageProxy::goToBackForwardItem): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (171573 => 171574)


--- trunk/Source/WebCore/ChangeLog	2014-07-25 01:18:23 UTC (rev 171573)
+++ trunk/Source/WebCore/ChangeLog	2014-07-25 01:31:40 UTC (rev 171574)
@@ -1,3 +1,12 @@
+2014-07-24  Dan Bernstein  <[email protected]>
+
+        WebCore part of <rdar://problem/17593701> Assertion failure in WebPage::reload (!m_pendingNavigationID) when reloading after a same-document back navigation
+        https://bugs.webkit.org/show_bug.cgi?id=135129
+
+        Reviewed by Darin Adler.
+
+        * WebCore.exp.in: Exported equalIgnoringFragmentIdentifier(const URL&, const URL&).
+
 2014-07-24  Simon Fraser  <[email protected]>
 
         [iOS WK1] CSS viewport units use the wrong viewport size in WebKit1

Modified: trunk/Source/WebCore/WebCore.exp.in (171573 => 171574)


--- trunk/Source/WebCore/WebCore.exp.in	2014-07-25 01:18:23 UTC (rev 171573)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-07-25 01:31:40 UTC (rev 171574)
@@ -1059,6 +1059,7 @@
 __ZN7WebCore30overrideUserPreferredLanguagesERKN3WTF6VectorINS0_6StringELm0ENS0_15CrashOnOverflowEEE
 __ZN7WebCore31CrossOriginPreflightResultCache5emptyEv
 __ZN7WebCore31CrossOriginPreflightResultCache6sharedEv
+__ZN7WebCore31equalIgnoringFragmentIdentifierERKNS_3URLES2_
 __ZN7WebCore33deleteAllCookiesModifiedAfterDateERKNS_21NetworkStorageSessionEd
 __ZN7WebCore33stripLeadingAndTrailingHTMLSpacesERKN3WTF6StringE
 __ZN7WebCore36standardUserAgentWithApplicationNameERKN3WTF6StringES3_

Modified: trunk/Source/WebKit2/ChangeLog (171573 => 171574)


--- trunk/Source/WebKit2/ChangeLog	2014-07-25 01:18:23 UTC (rev 171573)
+++ trunk/Source/WebKit2/ChangeLog	2014-07-25 01:31:40 UTC (rev 171574)
@@ -1,3 +1,25 @@
+2014-07-24  Dan Bernstein  <[email protected]>
+
+        WebKit2 part of <rdar://problem/17593701> Assertion failure in WebPage::reload (!m_pendingNavigationID) when reloading after a same-document back navigation
+        https://bugs.webkit.org/show_bug.cgi?id=135129
+
+        Reviewed by Darin Adler.
+
+        * Shared/WebBackForwardListItem.cpp:
+        (WebKit::childItemWithDocumentSequenceNumber): New helper function based on
+        WebCore::HistoryItem::childItemWithDocumentSequenceNumber.
+        (WebKit::documentTreesAreEqual): New helper function based on
+        WebCore::HistoryItem::hasSameDocumentTree.
+        (WebKit::WebBackForwardListItem::itemIsInSameDocument): Added. Based on
+        WebCore::HistoryItem::shouldDoSameDocumentNavigationTo.
+        * Shared/WebBackForwardListItem.h:
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::goForward): Don’t assign a new navigation ID if the back-forward
+        navigation is a same-document navigation.
+        (WebKit::WebPageProxy::goBack): Ditto.
+        (WebKit::WebPageProxy::goToBackForwardItem): Ditto.
+
 2014-07-24  Tim Horton  <[email protected]>
 
         Sometimes WKWebView is blank after resuming the app, until you scroll

Modified: trunk/Source/WebKit2/Shared/WebBackForwardListItem.cpp (171573 => 171574)


--- trunk/Source/WebKit2/Shared/WebBackForwardListItem.cpp	2014-07-25 01:18:23 UTC (rev 171573)
+++ trunk/Source/WebKit2/Shared/WebBackForwardListItem.cpp	2014-07-25 01:31:40 UTC (rev 171574)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WebBackForwardListItem.h"
 
+#include <WebCore/URL.h>
+
 namespace WebKit {
 
 static uint64_t highestUsedItemID = 0;
@@ -47,6 +49,55 @@
 {
 }
 
+static const FrameState* childItemWithDocumentSequenceNumber(const FrameState& frameState, int64_t number)
+{
+    for (const auto& child : frameState.children) {
+        if (child.documentSequenceNumber == number)
+            return &child;
+    }
+
+    return nullptr;
+}
+
+static bool documentTreesAreEqual(const FrameState& a, const FrameState& b)
+{
+    if (a.documentSequenceNumber != b.documentSequenceNumber)
+        return false;
+
+    if (a.children.size() != b.children.size())
+        return false;
+
+    for (const auto& child : a.children) {
+        const FrameState* otherChild = childItemWithDocumentSequenceNumber(b, child.documentSequenceNumber);
+        if (!otherChild || !documentTreesAreEqual(child, *otherChild))
+            return false;
+    }
+
+    return true;
+}
+
+bool WebBackForwardListItem::itemIsInSameDocument(const WebBackForwardListItem& other) const
+{
+    if (m_pageID != other.m_pageID)
+        return false;
+
+    // The following logic must be kept in sync with WebCore::HistoryItem::shouldDoSameDocumentNavigationTo.
+
+    const FrameState& mainFrameState = m_itemState.pageState.mainFrameState;
+    const FrameState& otherMainFrameState = other.m_itemState.pageState.mainFrameState;
+
+    if (mainFrameState.stateObjectData || otherMainFrameState.stateObjectData)
+        return mainFrameState.documentSequenceNumber == otherMainFrameState.documentSequenceNumber;
+
+    WebCore::URL url = "" mainFrameState.urlString);
+    WebCore::URL otherURL = WebCore::URL(WebCore::ParsedURLString, otherMainFrameState.urlString);
+
+    if ((url.hasFragmentIdentifier() || otherURL.hasFragmentIdentifier()) && equalIgnoringFragmentIdentifier(url, otherURL))
+        return mainFrameState.documentSequenceNumber == otherMainFrameState.documentSequenceNumber;
+
+    return documentTreesAreEqual(mainFrameState, otherMainFrameState);
+}
+
 uint64_t WebBackForwardListItem::highedUsedItemID()
 {
     return highestUsedItemID;

Modified: trunk/Source/WebKit2/Shared/WebBackForwardListItem.h (171573 => 171574)


--- trunk/Source/WebKit2/Shared/WebBackForwardListItem.h	2014-07-25 01:18:23 UTC (rev 171573)
+++ trunk/Source/WebKit2/Shared/WebBackForwardListItem.h	2014-07-25 01:31:40 UTC (rev 171574)
@@ -57,6 +57,8 @@
     const String& url() const { return m_itemState.pageState.mainFrameState.urlString; }
     const String& title() const { return m_itemState.pageState.title; }
 
+    bool itemIsInSameDocument(const WebBackForwardListItem&) const;
+
 #if PLATFORM(COCOA)
     ViewSnapshot* snapshot() const { return m_itemState.snapshot.get(); }
     void setSnapshot(PassRefPtr<ViewSnapshot> snapshot) { m_itemState.snapshot = snapshot; }

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (171573 => 171574)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-07-25 01:18:23 UTC (rev 171573)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-07-25 01:31:40 UTC (rev 171574)
@@ -900,7 +900,7 @@
     if (!isValid())
         return reattachToWebProcessWithItem(forwardItem);
 
-    uint64_t navigationID = generateNavigationID();
+    uint64_t navigationID = m_backForwardList->currentItem()->itemIsInSameDocument(*forwardItem) ? 0 : generateNavigationID();
 
     m_process->send(Messages::WebPage::GoForward(navigationID, forwardItem->itemID()), m_pageID);
     m_process->responsivenessTimer()->start();
@@ -921,7 +921,7 @@
     if (!isValid())
         return reattachToWebProcessWithItem(backItem);
 
-    uint64_t navigationID = generateNavigationID();
+    uint64_t navigationID = m_backForwardList->currentItem()->itemIsInSameDocument(*backItem) ? 0 : generateNavigationID();
 
     m_process->send(Messages::WebPage::GoBack(navigationID, backItem->itemID()), m_pageID);
     m_process->responsivenessTimer()->start();
@@ -938,7 +938,7 @@
 
     m_pageLoadState.setPendingAPIRequestURL(transaction, item->url());
 
-    uint64_t navigationID = generateNavigationID();
+    uint64_t navigationID = m_backForwardList->currentItem()->itemIsInSameDocument(*item) ? 0 : generateNavigationID();
 
     m_process->send(Messages::WebPage::GoToBackForwardItem(navigationID, item->itemID()), m_pageID);
     m_process->responsivenessTimer()->start();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to