2008-02-04 Matt Perry <mpComplete@gmail.com>
authormrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Feb 2008 08:16:17 +0000 (08:16 +0000)
committermrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Feb 2008 08:16:17 +0000 (08:16 +0000)
        Reviewed by Darin Adler.

        Fix for http://bugs.webkit.org/show_bug.cgi?id=14959
        No back forward entry added for pages created in javascript

        A new HistoryItem is created for calls to Document::open.  Calls to
        Document::write save the written data to a SharedBuffer that is also
        stored on the HistoryItem.  When the user navigates back to a
        HistoryItem that has a valid buffer, that data is used for the page
        content.

        Tests: http/tests/navigation/document-open-adds-history-item.html
               http/tests/navigation/document-open-delayed-adds-history-item.html
               http/tests/navigation/document-open-new-window-adds-history-item.html
               http/tests/navigation/document-open-replace-no-history-item.html

        * bindings/js/JSHTMLDocumentCustom.cpp:
        (WebCore::JSHTMLDocument::open):
        * dom/Document.cpp:
        (WebCore::Document::open):
        (WebCore::Document::write):
        (WebCore::Document::clear):
        * dom/Document.h:
        * history/HistoryItem.cpp:
        (WebCore::HistoryItem::HistoryItem):
        (WebCore::HistoryItem::substituteData):
        (WebCore::HistoryItem::setSubstituteData):
        * history/HistoryItem.h:
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::didExplicitOpen):
        (WebCore::FrameLoader::load):
        (WebCore::FrameLoader::reloadAllowingStaleData):
        (WebCore::FrameLoader::reload):
        (WebCore::FrameLoader::shouldTreatURLAsSameAsCurrent):
        (WebCore::FrameLoader::loadItem):
        * loader/FrameLoader.h:

2008-02-04  Matt Perry  <mpComplete@gmail.com>

        Reviewed by Darin Adler.

        Test cases for fix to http://bugs.webkit.org/show_bug.cgi?id=14959
        No back forward entry added for pages created in javascript.

        * http/tests/navigation/document-open-adds-history-item-expected.txt: Added.
        * http/tests/navigation/document-open-adds-history-item.html: Added.
        * http/tests/navigation/document-open-delayed-adds-history-item-expected.txt: Added.
        * http/tests/navigation/document-open-delayed-adds-history-item.html: Added.
        * http/tests/navigation/document-open-new-window-adds-history-item-expected.txt: Added.
        * http/tests/navigation/document-open-new-window-adds-history-item.html: Added.
        * http/tests/navigation/document-open-replace-no-history-item-expected.txt: Added.
        * http/tests/navigation/document-open-replace-no-history-item.html: Added.

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

19 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/navigation/document-open-adds-history-item-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/document-open-adds-history-item.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/document-open-delayed-adds-history-item-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/document-open-delayed-adds-history-item.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/document-open-new-window-adds-history-item-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/document-open-new-window-adds-history-item.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/document-open-replace-no-history-item-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/document-open-replace-no-history-item.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/resources/document-open-page-2.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/resources/document-open.js [new file with mode: 0644]
WebCore/ChangeLog
WebCore/bindings/js/JSHTMLDocumentCustom.cpp
WebCore/dom/Document.cpp
WebCore/dom/Document.h
WebCore/history/HistoryItem.cpp
WebCore/history/HistoryItem.h
WebCore/loader/FrameLoader.cpp
WebCore/loader/FrameLoader.h

index ebd2504..e80e470 100644 (file)
@@ -1,3 +1,19 @@
+2008-02-04  Matt Perry  <mpComplete@gmail.com>
+
+        Reviewed by Darin Adler.
+
+        Test cases for fix to http://bugs.webkit.org/show_bug.cgi?id=14959
+        No back forward entry added for pages created in javascript.
+
+        * http/tests/navigation/document-open-adds-history-item-expected.txt: Added.
+        * http/tests/navigation/document-open-adds-history-item.html: Added.
+        * http/tests/navigation/document-open-delayed-adds-history-item-expected.txt: Added.
+        * http/tests/navigation/document-open-delayed-adds-history-item.html: Added.
+        * http/tests/navigation/document-open-new-window-adds-history-item-expected.txt: Added.
+        * http/tests/navigation/document-open-new-window-adds-history-item.html: Added.
+        * http/tests/navigation/document-open-replace-no-history-item-expected.txt: Added.
+        * http/tests/navigation/document-open-replace-no-history-item.html: Added.
+
 2008-02-04  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
 
         Reviewed by Oliver Hunt.
diff --git a/LayoutTests/http/tests/navigation/document-open-adds-history-item-expected.txt b/LayoutTests/http/tests/navigation/document-open-adds-history-item-expected.txt
new file mode 100644 (file)
index 0000000..5bfa065
--- /dev/null
@@ -0,0 +1,7 @@
+This generated document and its contents should be in the back/forward list.
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/navigation/document-open-adds-history-item.html  **nav target**
+curr->  http://127.0.0.1:8000/navigation/document-open-adds-history-item.html  **nav target**
+        http://127.0.0.1:8000/navigation/resources/document-open-page-2.html  **nav target**
+===============================================
diff --git a/LayoutTests/http/tests/navigation/document-open-adds-history-item.html b/LayoutTests/http/tests/navigation/document-open-adds-history-item.html
new file mode 100644 (file)
index 0000000..3619f3d
--- /dev/null
@@ -0,0 +1,20 @@
+<html>
+<head>
+<script src="resources/document-open.js"></script>
+<script>
+    function runTest()
+    {
+        window.firstVisit = true;
+        document.open();
+        document.writeln("<script>" + window.stopTest + "<" + "/script>");
+        document.writeln("<body onload='stopTest();'>");
+        document.writeln("This generated document and its contents should be in the back/forward list.");
+        document.writeln("</body>");
+        document.close();
+    }
+</script>
+</head>
+<body onload="startTest()">
+This tests that document.open creates a back/forward item.
+</body>
+</html>
diff --git a/LayoutTests/http/tests/navigation/document-open-delayed-adds-history-item-expected.txt b/LayoutTests/http/tests/navigation/document-open-delayed-adds-history-item-expected.txt
new file mode 100644 (file)
index 0000000..164e21f
--- /dev/null
@@ -0,0 +1,7 @@
+This generated document and its contents should be in the back/forward list... even with a delayed close.
+
+============== Back Forward List ==============
+        http://127.0.0.1:8000/navigation/document-open-delayed-adds-history-item.html  **nav target**
+curr->  http://127.0.0.1:8000/navigation/document-open-delayed-adds-history-item.html  **nav target**
+        http://127.0.0.1:8000/navigation/resources/document-open-page-2.html  **nav target**
+===============================================
diff --git a/LayoutTests/http/tests/navigation/document-open-delayed-adds-history-item.html b/LayoutTests/http/tests/navigation/document-open-delayed-adds-history-item.html
new file mode 100644 (file)
index 0000000..929820b
--- /dev/null
@@ -0,0 +1,26 @@
+<html>
+<head>
+<script src="resources/document-open.js"></script>
+<script>
+    function runTest()
+    {
+        window.firstVisit = true;
+        document.open();
+        document.writeln("<script>" + window.stopTest + "<" + "/script>");
+        document.writeln("<body onload='stopTest();'>");
+        document.writeln("This generated document and its contents should be in the back/forward list...");
+        setTimeout("runTest2();", 0);
+    }
+    function runTest2()
+    {
+        document.writeln("even with a delayed close.");
+        document.writeln("</body>");
+        document.close();
+    }
+</script>
+</head>
+<body onload="startTest()">
+This tests that document.open creates a back/forward item, and the page loads
+correctly even when writes are split across a timeout.
+</body>
+</html>
diff --git a/LayoutTests/http/tests/navigation/document-open-new-window-adds-history-item-expected.txt b/LayoutTests/http/tests/navigation/document-open-new-window-adds-history-item-expected.txt
new file mode 100644 (file)
index 0000000..660351c
--- /dev/null
@@ -0,0 +1,10 @@
+This tests that document.open in a new window creates a back/forward item.
+
+============== Back Forward List ==============
+curr->  http://127.0.0.1:8000/navigation/document-open-new-window-adds-history-item.html  **nav target**
+===============================================
+
+============== Back Forward List ==============
+curr->  about:blank  **nav target**
+        http://127.0.0.1:8000/navigation/resources/document-open-page-2.html  **nav target**
+===============================================
diff --git a/LayoutTests/http/tests/navigation/document-open-new-window-adds-history-item.html b/LayoutTests/http/tests/navigation/document-open-new-window-adds-history-item.html
new file mode 100644 (file)
index 0000000..d2b2953
--- /dev/null
@@ -0,0 +1,25 @@
+<html>
+<head>
+<script src="resources/document-open.js"></script>
+<script>
+    function runTest()
+    {
+        if (window.layoutTestController) {
+            layoutTestController.setCanOpenWindows();
+        }
+        w = window.open('');
+        w.firstVisit = true;
+        w.focus();
+        w.document.open();
+        w.document.writeln("<script>" + window.stopTest + "<" + "/script>");
+        w.document.writeln("<body onload='stopTest();'>");
+        w.document.writeln("This generated document and its contents should be in the back/forward list.");
+        w.document.writeln("</body>");
+        w.document.close();
+    }
+</script>
+</head>
+<body onload="startTest()">
+This tests that document.open in a new window creates a back/forward item.
+</body>
+</html>
diff --git a/LayoutTests/http/tests/navigation/document-open-replace-no-history-item-expected.txt b/LayoutTests/http/tests/navigation/document-open-replace-no-history-item-expected.txt
new file mode 100644 (file)
index 0000000..2128d62
--- /dev/null
@@ -0,0 +1,6 @@
+This generated document and its contents should be in the back/forward list. This page should have replaced the originating page as well.
+
+============== Back Forward List ==============
+curr->  http://127.0.0.1:8000/navigation/document-open-replace-no-history-item.html  **nav target**
+        http://127.0.0.1:8000/navigation/resources/document-open-page-2.html  **nav target**
+===============================================
diff --git a/LayoutTests/http/tests/navigation/document-open-replace-no-history-item.html b/LayoutTests/http/tests/navigation/document-open-replace-no-history-item.html
new file mode 100644 (file)
index 0000000..749d180
--- /dev/null
@@ -0,0 +1,22 @@
+<html>
+<head>
+<script src="resources/document-open.js"></script>
+<script>
+    function runTest()
+    {
+        window.firstVisit = true;
+        document.open("text/html", "replace");
+        document.writeln("<script>" + window.stopTest + "<" + "/script>");
+        document.writeln("<body onload='stopTest();'>");
+        document.writeln("This generated document and its contents should be in the back/forward list.");
+        document.writeln("This page should have replaced the originating page as well.");
+        document.writeln("</body>");
+        document.close();
+    }
+</script>
+</head>
+<body onload="startTest()">
+This tests that document.open does not create a back/forward item if "replace"
+is specified.
+</body>
+</html>
diff --git a/LayoutTests/http/tests/navigation/resources/document-open-page-2.html b/LayoutTests/http/tests/navigation/resources/document-open-page-2.html
new file mode 100644 (file)
index 0000000..41d0237
--- /dev/null
@@ -0,0 +1,11 @@
+<head>
+<script>
+    function goBack()
+    {
+        window.history.back();
+    }
+</script>
+</head>
+<body onload="goBack()">
+Just navigates back to where it came from.
+</body>
diff --git a/LayoutTests/http/tests/navigation/resources/document-open.js b/LayoutTests/http/tests/navigation/resources/document-open.js
new file mode 100644 (file)
index 0000000..ac8b4de
--- /dev/null
@@ -0,0 +1,28 @@
+// Common testing functions for document-open history tests.
+
+function startTest()
+{
+    if (window.layoutTestController) {
+        layoutTestController.dumpBackForwardList();
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+        setTimeout("runTest()", 0);
+    }
+}
+
+function stopTest()
+{
+    // We expect the test to set window.firstVisit to true before it open
+    // the document.  When we navigate away, this variable will be cleared.
+    if (window.firstVisit) {
+        // This is the first time we loaded this page.
+        // Navigate away and back to ensure the generated contents remain intact. 
+        window.location = "resources/document-open-page-2.html";
+        window.firstVisit = false;  // just to be explicit.
+    } else {
+        // We are now returning from page-2.  End the test.
+        if (window.layoutTestController) {
+            layoutTestController.notifyDone();
+        }
+    }
+}
index a38a392..90f2121 100644 (file)
@@ -1,3 +1,42 @@
+2008-02-04  Matt Perry  <mpComplete@gmail.com>
+
+        Reviewed by Darin Adler.
+
+        Fix for http://bugs.webkit.org/show_bug.cgi?id=14959
+        No back forward entry added for pages created in javascript
+
+        A new HistoryItem is created for calls to Document::open.  Calls to
+        Document::write save the written data to a SharedBuffer that is also
+        stored on the HistoryItem.  When the user navigates back to a
+        HistoryItem that has a valid buffer, that data is used for the page
+        content.
+
+        Tests: http/tests/navigation/document-open-adds-history-item.html
+               http/tests/navigation/document-open-delayed-adds-history-item.html
+               http/tests/navigation/document-open-new-window-adds-history-item.html
+               http/tests/navigation/document-open-replace-no-history-item.html
+
+        * bindings/js/JSHTMLDocumentCustom.cpp:
+        (WebCore::JSHTMLDocument::open):
+        * dom/Document.cpp:
+        (WebCore::Document::open):
+        (WebCore::Document::write):
+        (WebCore::Document::clear):
+        * dom/Document.h:
+        * history/HistoryItem.cpp:
+        (WebCore::HistoryItem::HistoryItem):
+        (WebCore::HistoryItem::substituteData):
+        (WebCore::HistoryItem::setSubstituteData):
+        * history/HistoryItem.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::didExplicitOpen):
+        (WebCore::FrameLoader::load):
+        (WebCore::FrameLoader::reloadAllowingStaleData):
+        (WebCore::FrameLoader::reload):
+        (WebCore::FrameLoader::shouldTreatURLAsSameAsCurrent):
+        (WebCore::FrameLoader::loadItem):
+        * loader/FrameLoader.h:
+
 2008-02-04  Mark Rowe  <mrowe@apple.com>
 
         Unreviewed Gtk build fix.
index 5455617..0a72190 100644 (file)
@@ -109,7 +109,19 @@ JSValue* JSHTMLDocument::open(ExecState* exec, const List& args)
     }
 
     // In the case of two parameters or fewer, do a normal document open.
-    static_cast<HTMLDocument*>(impl())->open();
+
+    String mimeType;
+    if (!args[0]->isUndefined()) {
+        mimeType = String(args[0]->toString(exec)).lower();
+        // Anything other than text/html is treated as plaintext.
+        if (mimeType != "text/html")
+            mimeType = "text/plain";
+    } else
+        mimeType = "text/html";
+
+    bool replace = equalIgnoringCase("replace", String(args[1]->toString(exec)));
+
+    static_cast<HTMLDocument*>(impl())->open(mimeType, replace);
     return jsUndefined();
 }
 
index f526485..fa9d4ea 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "AXObjectCache.h"
 #include "CDATASection.h"
+#include "CString.h"
 #include "CSSHelper.h"
 #include "CSSStyleSelector.h"
 #include "CSSStyleSheet.h"
@@ -53,6 +54,7 @@
 #include "FrameLoader.h"
 #include "FrameTree.h"
 #include "FrameView.h"
+#include "HistoryItem.h"
 #include "HTMLBodyElement.h"
 #include "HTMLDocument.h"
 #include "HTMLElementFactory.h"
@@ -1349,6 +1351,18 @@ Tokenizer* Document::createTokenizer()
 
 void Document::open()
 {
+    // This method is called by various places in the WebCore code.  Arguments
+    // chosen for legacy reasons.
+    open("text/html", true);
+}
+
+void Document::open(const String& mimeType, bool replace)
+{
+    // Calling open() during an onload handler is like a redirect, so we should not add a new
+    // history item.
+    if (m_processingLoadEvent)
+        replace = true;
+
     // This is work that we should probably do in clear(), but we can't have it
     // happen when implicitOpen() is called unless we reorganize Frame code.
     if (Document *parent = parentDocument()) {
@@ -1365,11 +1379,13 @@ void Document::open()
         if (m_frame->loader()->state() == FrameStateProvisional)
             m_frame->loader()->stopAllLoaders();
     }
-    
+
     implicitOpen();
 
-    if (m_frame)
-        m_frame->loader()->didExplicitOpen();
+    if (m_frame) {
+        m_textWrittenByScript = new SharedBuffer;
+        m_frame->loader()->didExplicitOpen(mimeType, replace, m_textWrittenByScript.get());
+    }
 }
 
 void Document::cancelParsing()
@@ -1596,20 +1612,24 @@ void Document::write(const String& text)
     if (!ownerElement())
         printf("Beginning a document.write at %d\n", elapsedTime());
 #endif
-    
+
     if (!m_tokenizer) {
-        open();
+        open("text/html", false);
         ASSERT(m_tokenizer);
         if (!m_tokenizer)
             return;
         write("<html>");
     }
     m_tokenizer->write(text, false);
-    
+
+    if (m_textWrittenByScript)
+        m_textWrittenByScript->append(reinterpret_cast<const char*>(text.characters()),
+                                      text.length() * sizeof(UChar));
+
 #ifdef INSTRUMENT_LAYOUT_SCHEDULING
     if (!ownerElement())
         printf("Ending a document.write at %d\n", elapsedTime());
-#endif    
+#endif
 }
 
 void Document::writeln(const String& text)
@@ -1639,6 +1659,8 @@ void Document::clear()
     delete m_tokenizer;
     m_tokenizer = 0;
 
+    m_textWrittenByScript = 0; 
+
     removeChildren();
 
     m_windowEventListeners.clear();
index 734a622..22b7be0 100644 (file)
@@ -32,6 +32,7 @@
 #include "DocumentMarker.h"
 #include "HTMLCollection.h"
 #include "HTMLFormElement.h"
+#include "SharedBuffer.h"
 #include "StringHash.h"
 #include "Timer.h"
 #include <wtf/HashCountedSet.h>
@@ -349,6 +350,7 @@ public:
     void setVisuallyOrdered();
 
     void open();
+    void open(const String& mimeType, bool replace);
     void implicitOpen();
     void close();
     void implicitClose();
@@ -926,6 +928,9 @@ private:
 
     bool m_isXHTML;
 
+    // Contains the text written to the document by script, eg through document.write().
+    RefPtr<SharedBuffer> m_textWrittenByScript;
+
     unsigned m_numNodeLists;
 
 #if ENABLE(DATABASE)
index 3f900af..806acb6 100644 (file)
@@ -121,6 +121,7 @@ HistoryItem::HistoryItem(const HistoryItem& item)
     , m_formContentType(item.m_formContentType)
     , m_formReferrer(item.m_formReferrer)
     , m_rssFeedReferrer(item.m_rssFeedReferrer)
+    , m_substituteData(item.m_substituteData)
 {
     if (item.m_formData)
         m_formData = item.m_formData->copy();
@@ -365,6 +366,16 @@ void HistoryItem::setRSSFeedReferrer(const String& referrer)
     m_rssFeedReferrer = referrer;
 }
 
+const SubstituteData& HistoryItem::substituteData() const
+{
+    return m_substituteData;
+}
+
+void HistoryItem::setSubstituteData(const SubstituteData& substituteData)
+{
+    m_substituteData = substituteData;
+}
+
 void HistoryItem::setFormInfoFromRequest(const ResourceRequest& request)
 {
     if (equalIgnoringCase(request.httpMethod(), "POST")) {
index 87c1b41..0252455 100644 (file)
@@ -33,6 +33,7 @@
 #include "PlatformString.h"
 #include <wtf/RefCounted.h>
 #include "StringHash.h"
+#include "SubstituteData.h"
 #include <wtf/HashMap.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/RefPtr.h>
@@ -93,6 +94,7 @@ public:
     String formContentType() const;
     String formReferrer() const;
     String rssFeedReferrer() const;
+    const SubstituteData& substituteData() const;
     
     int visitCount() const;
 
@@ -117,6 +119,7 @@ public:
 
     void setRSSFeedReferrer(const String&);
     void setVisitCount(int);
+    void setSubstituteData(const SubstituteData&);
 
     void addChildItem(PassRefPtr<HistoryItem>);
     HistoryItem* childItemWithName(const String&) const;
@@ -175,6 +178,8 @@ private:
     // info used to support RSS feeds
     String m_rssFeedReferrer;
 
+    SubstituteData m_substituteData;
+
     // PageCache controls these fields.
     HistoryItem* m_next;
     HistoryItem* m_prev;
index 0daae80..53d30e0 100644 (file)
@@ -696,7 +696,7 @@ bool FrameLoader::didOpenURL(const KURL& url)
     return true;
 }
 
-void FrameLoader::didExplicitOpen()
+void FrameLoader::didExplicitOpen(const String& mimeType, bool replace, SharedBuffer* buffer)
 {
     m_isComplete = false;
     m_didCallImplicitClose = false;
@@ -711,6 +711,29 @@ void FrameLoader::didExplicitOpen()
     cancelRedirection(); 
     if (m_frame->document()->url() != "about:blank")
         m_URL = m_frame->document()->url();
+    bool isItemNew = false;
+
+    // Add a HistoryItem for this open.
+    RefPtr<HistoryItem> item;
+    if (replace && m_currentHistoryItem) 
+        item = m_currentHistoryItem;
+    else {
+        isItemNew = true;
+        item = new HistoryItem(m_URL, m_frame->tree()->name(), m_frame->tree()->parent() ? m_frame->tree()->parent()->tree()->name() : "", "");
+        item->setIsTargetItem(true);
+        m_previousHistoryItem = m_currentHistoryItem;
+        m_currentHistoryItem = item;
+    }
+
+    // Create an alternate URL to distinguish this as a generated page.
+    KURL generatedURL("webkitgenerated:" + m_frame->document()->url());
+
+    item->setSubstituteData(SubstituteData(buffer, mimeType, "UTF-16", m_URL, generatedURL));
+
+    if (isItemNew)
+        if (Page* page = m_frame->page())
+            page->backForwardList()->addItem(item);
 }
 
 bool FrameLoader::executeIfJavaScriptURL(const KURL& url, bool userGesture, bool replaceDocument)
@@ -2077,7 +2100,12 @@ void FrameLoader::load(const ResourceRequest& request, const String& frameName)
 
 void FrameLoader::load(const ResourceRequest& request, const NavigationAction& action, FrameLoadType type, PassRefPtr<FormState> formState)
 {
-    RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request, SubstituteData());
+    load(request, action, type, formState, SubstituteData());
+}
+
+void FrameLoader::load(const ResourceRequest& request, const NavigationAction& action, FrameLoadType type, PassRefPtr<FormState> formState, const SubstituteData& substituteData)
+{
+    RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request, substituteData);
 
     loader->setTriggeringAction(action);
     if (m_documentLoader)
@@ -2278,7 +2306,9 @@ void FrameLoader::reloadAllowingStaleData(const String& encoding)
 
     request.setCachePolicy(ReturnCacheDataElseLoad);
 
-    RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request, SubstituteData());
+    RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request, m_currentHistoryItem->substituteData());
+    setProvisionalHistoryItem(m_currentHistoryItem);
+
     setPolicyDocumentLoader(loader.get());
 
     loader->setOverrideEncoding(encoding);
@@ -2303,7 +2333,8 @@ void FrameLoader::reload()
     if (!unreachableURL.isEmpty())
         initialRequest = ResourceRequest(unreachableURL);
     
-    RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(initialRequest, SubstituteData());
+    RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(initialRequest, m_currentHistoryItem->substituteData());
+    setProvisionalHistoryItem(m_currentHistoryItem);
 
     ResourceRequest& request = loader->request();
 
@@ -3789,6 +3820,8 @@ bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const
 {
     if (!m_currentHistoryItem)
         return false;
+    if (m_currentHistoryItem->substituteData().isValid())
+        return url == m_currentHistoryItem->substituteData().responseURL();
     return url == m_currentHistoryItem->url() || url == m_currentHistoryItem->originalURL();
 }
 
@@ -4098,7 +4131,7 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
                 action = NavigationAction(itemOriginalURL, loadType, false);
             }
 
-            load(request, action, loadType, 0);
+            load(request, action, loadType, 0, item->substituteData());
         }
     }
 }
index 725e5f3..6856979 100644 (file)
@@ -154,6 +154,7 @@ namespace WebCore {
         void load(const ResourceRequest&, const SubstituteData&);
         void load(const ResourceRequest&, const String& frameName);
         void load(const ResourceRequest&, const NavigationAction&, FrameLoadType, PassRefPtr<FormState>);
+        void load(const ResourceRequest&, const NavigationAction&, FrameLoadType, PassRefPtr<FormState>, const SubstituteData&);
         
         void load(DocumentLoader*);
         void load(DocumentLoader*, FrameLoadType, PassRefPtr<FormState>);
@@ -288,7 +289,7 @@ namespace WebCore {
         void stopLoading(bool sendUnload);
         bool closeURL();
 
-        void didExplicitOpen();
+        void didExplicitOpen(const String& mimeType, bool replace, SharedBuffer*);
 
         KURL iconURL();
         void commitIconURLToIconDatabase(const KURL&);