Reviewed and tweaked quite a bit by Darin.
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): Pass a MIME type of either "text/html" or
"text/plain" and a boolean for "replace" in rather than always setting replace
to true and the MIME type to "text/html".
* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createHTMLDocument): Pass in MIME type and
replace boolean explicitly, since we don't want to rely on Document::open()'s
default.
* dom/Document.cpp:
(WebCore::Document::open): Correctly determine the "replace" boolean.
Pass along the MIME type, replace boolean, and shared buffer to the
frame loader's didExplicitOpen function.
(WebCore::Document::write): Pass MIME type and replace boolean explicitly
to the open function so we don't do treat it as replace if you write without
an open. Store text written by the script so it can be used later for history.
(WebCore::Document::clear): Drop the text written byt he script.
* dom/Document.h: Added MIME type and replace boolean parameters for open.
Had to keep the old version for the sake of DOM bindings. Added the shared
buffer used for text written by script.
* history/HistoryItem.cpp:
(WebCore::HistoryItem::HistoryItem): Copy m_substituteData.
(WebCore::HistoryItem::substituteData): Added.
(WebCore::HistoryItem::setSubstituteData): Added.
* history/HistoryItem.h: Added m_substituteData, getter, and setter.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::didExplicitOpen): Added code to create or update the
history item, including attaching the shared buffer that will contain all
the data written by script.
(WebCore::FrameLoader::load): Added a SubstituteData parameter, passed through
when creating the document loader.
(WebCore::FrameLoader::reloadAllowingStaleData): Create the document loader
with the substitute data from the current history item.
(WebCore::FrameLoader::reload): Ditto.
(WebCore::FrameLoader::shouldTreatURLAsSameAsCurrent): If the current history
item has substitute data, then consider the URL from the substitute data
rather than the one in the history item itself.
(WebCore::FrameLoader::loadItem): Pass in the history item's substitute data.
* loader/FrameLoader.h: Added parameters to load and didExplicitOpen.
* platform/text/CharacterNames.h: Added byteOrderMark, and also added it under
its other official name, zeroWidthNoBreakSpace.
* xml/DOMParser.cpp:
(WebCore::DOMParser::parseFromString): Pass in MIME type and replace boolean
explicitly, since we don't want to rely on Document::open()'s default.
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::getResponseXML): Ditto.
* xml/XSLTProcessor.cpp:
(WebCore::XSLTProcessor::createDocumentFromSource): Ditto.
LayoutTests:
Reviewed by Darin.
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@29816
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-01-27 Matt Perry <mpComplete@gmail.com>
+
+ Reviewed by Darin.
+
+ 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-01-26 Darin Adler <darin@apple.com>
Reviewed by Oliver.
* platform/mac/svg/custom/foreignObject-crash-on-hover-expected.txt: Added.
* svg/custom/foreignObject-crash-on-hover.xml: Added.
+>>>>>>> .r29342
2007-12-21 Sam Weinig <sam@webkit.org>
Reviewed by Adele.
--- /dev/null
+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**
+===============================================
--- /dev/null
+<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>
--- /dev/null
+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**
+===============================================
--- /dev/null
+<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>
--- /dev/null
+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**
+===============================================
--- /dev/null
+<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>
--- /dev/null
+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**
+===============================================
--- /dev/null
+<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>
--- /dev/null
+<head>
+<script>
+ function goBack()
+ {
+ window.history.back();
+ }
+</script>
+</head>
+<body onload="goBack()">
+Just navigates back to where it came from.
+</body>
--- /dev/null
+// 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();
+ }
+ }
+}
+2008-01-27 Matt Perry <mpComplete@gmail.com>
+
+ Reviewed and tweaked quite a bit by Darin.
+
+ 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): Pass a MIME type of either "text/html" or
+ "text/plain" and a boolean for "replace" in rather than always setting replace
+ to true and the MIME type to "text/html".
+
+ * dom/DOMImplementation.cpp:
+ (WebCore::DOMImplementation::createHTMLDocument): Pass in MIME type and
+ replace boolean explicitly, since we don't want to rely on Document::open()'s
+ default.
+
+ * dom/Document.cpp:
+ (WebCore::Document::open): Correctly determine the "replace" boolean.
+ Pass along the MIME type, replace boolean, and shared buffer to the
+ frame loader's didExplicitOpen function.
+ (WebCore::Document::write): Pass MIME type and replace boolean explicitly
+ to the open function so we don't do treat it as replace if you write without
+ an open. Store text written by the script so it can be used later for history.
+ (WebCore::Document::clear): Drop the text written byt he script.
+
+ * dom/Document.h: Added MIME type and replace boolean parameters for open.
+ Had to keep the old version for the sake of DOM bindings. Added the shared
+ buffer used for text written by script.
+
+ * history/HistoryItem.cpp:
+ (WebCore::HistoryItem::HistoryItem): Copy m_substituteData.
+ (WebCore::HistoryItem::substituteData): Added.
+ (WebCore::HistoryItem::setSubstituteData): Added.
+ * history/HistoryItem.h: Added m_substituteData, getter, and setter.
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::didExplicitOpen): Added code to create or update the
+ history item, including attaching the shared buffer that will contain all
+ the data written by script.
+ (WebCore::FrameLoader::load): Added a SubstituteData parameter, passed through
+ when creating the document loader.
+ (WebCore::FrameLoader::reloadAllowingStaleData): Create the document loader
+ with the substitute data from the current history item.
+ (WebCore::FrameLoader::reload): Ditto.
+ (WebCore::FrameLoader::shouldTreatURLAsSameAsCurrent): If the current history
+ item has substitute data, then consider the URL from the substitute data
+ rather than the one in the history item itself.
+ (WebCore::FrameLoader::loadItem): Pass in the history item's substitute data.
+ * loader/FrameLoader.h: Added parameters to load and didExplicitOpen.
+
+ * platform/text/CharacterNames.h: Added byteOrderMark, and also added it under
+ its other official name, zeroWidthNoBreakSpace.
+
+ * xml/DOMParser.cpp:
+ (WebCore::DOMParser::parseFromString): Pass in MIME type and replace boolean
+ explicitly, since we don't want to rely on Document::open()'s default.
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::XMLHttpRequest::getResponseXML): Ditto.
+ * xml/XSLTProcessor.cpp:
+ (WebCore::XSLTProcessor::createDocumentFromSource): Ditto.
+
2008-01-25 Eric Seidel <eric@webkit.org>
Reviewed by Sam and Darin.
__ZN7WebCore11FrameLoader4loadEPNS_14DocumentLoaderENS_13FrameLoadTypeEN3WTF10PassRefPtrINS_9FormStateEEE
__ZN7WebCore11FrameLoader4loadERKNS_15ResourceRequestE
__ZN7WebCore11FrameLoader4loadERKNS_15ResourceRequestERKNS_14SubstituteDataE
-__ZN7WebCore11FrameLoader4loadERKNS_15ResourceRequestERKNS_16NavigationActionENS_13FrameLoadTypeEN3WTF10PassRefPtrINS_9FormStateEEE
__ZN7WebCore11FrameLoader4loadERKNS_15ResourceRequestERKNS_6StringE
__ZN7WebCore11FrameLoader4loadERKNS_4KURLEPNS_5EventE
__ZN7WebCore11FrameLoader4loadERKNS_4KURLERKNS_6StringENS_13FrameLoadTypeES6_PNS_5EventEN3WTF10PassRefPtrINS_9FormStateEEE
}
// In the case of two parameters or fewer, do a normal document open.
- static_cast<HTMLDocument*>(impl())->open();
+
+ // Anything other than undefined or text/html is treated as plain text.
+ const char* mimeType;
+ if (args[0]->isUndefined() || equalIgnoringCase(String(args[0]->toString(exec)), "text/html"))
+ mimeType = "text/html";
+ else
+ mimeType = "text/plain";
+ if (exec->hadException())
+ return jsUndefined();
+
+ bool replace = equalIgnoringCase(String(args[1]->toString(exec)), "replace");
+ if (exec->hadException())
+ return jsUndefined();
+
+ static_cast<HTMLDocument*>(impl())->open(mimeType, replace);
return jsUndefined();
}
PassRefPtr<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title)
{
RefPtr<HTMLDocument> d = new HTMLDocument(this, 0);
- d->open();
+ d->open("text/html", false);
d->write("<html><head><title>" + title + "</title></head><body></body></html>");
return d.release();
}
#include "AXObjectCache.h"
#include "CDATASection.h"
+#include "CString.h"
#include "CSSHelper.h"
#include "CSSStyleSelector.h"
#include "CSSStyleSheet.h"
#include "FrameLoader.h"
#include "FrameTree.h"
#include "FrameView.h"
+#include "HistoryItem.h"
#include "HTMLBodyElement.h"
#include "HTMLDocument.h"
#include "HTMLElementFactory.h"
_style->ref();
_style->setDisplay(BLOCK);
_style->setVisuallyOrdered(visuallyOrdered);
- // ### make the font stuff _really_ work!!!!
FontDescription fontDescription;
fontDescription.setUsePrinterFont(printing());
void Document::open()
{
+ // Parameters here match the description in the DOM Level 2 specification.
+ // Note that this function is currently only used in non-JavaScript DOM
+ // bindings for the HTMLDocument class, and should not be used elsewhere.
+ 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()) {
+ if (Document* parent = parentDocument()) {
if (m_url.isEmpty() || m_url == "about:blank")
setURL(parent->baseURL());
if (m_baseURL.isEmpty() || m_baseURL == "about:blank")
if (m_frame) {
if (m_frame->loader()->isLoadingMainResource() || (tokenizer() && tokenizer()->executingScript()))
return;
-
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()
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());
delete m_tokenizer;
m_tokenizer = 0;
+ m_textWrittenByScript.clear();
+
removeChildren();
m_windowEventListeners.clear();
class RegisteredEventListener;
class RenderArena;
class Settings;
+ class SharedBuffer;
class StyleSheet;
class StyleSheetList;
class Text;
// to get visually ordered hebrew and arabic pages right
void setVisuallyOrdered();
- void open();
+ void open(const String& mimeType, bool replace);
+ void open(); // Deprecated.
void implicitOpen();
void close();
void implicitClose();
void cancelParsing();
- void write(const String& text);
- void writeln(const String& text);
+ void write(const String&);
+ void writeln(const String&);
void finishParsing();
void clear();
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)
, 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();
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")) {
#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>
String formContentType() const;
String formReferrer() const;
String rssFeedReferrer() const;
+ const SubstituteData& substituteData() const;
int visitCount() const;
void setRSSFeedReferrer(const String&);
void setVisitCount(int);
+ void setSubstituteData(const SubstituteData&);
void addChildItem(PassRefPtr<HistoryItem>);
HistoryItem* childItemWithName(const String&) const;
// info used to support RSS feeds
String m_rssFeedReferrer;
+ SubstituteData m_substituteData;
+
// PageCache controls these fields.
HistoryItem* m_next;
HistoryItem* m_prev;
#include "CString.h"
#include "Cache.h"
#include "CachedPage.h"
+#include "CharacterNames.h"
#include "Chrome.h"
#include "DOMImplementation.h"
#include "DocLoader.h"
return true;
}
-void FrameLoader::didExplicitOpen()
+void FrameLoader::didExplicitOpen(const String& mimeType, bool replace, SharedBuffer* buffer)
{
m_isComplete = false;
m_didCallImplicitClose = false;
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.
+ // FIXME: This may need a bit of refinement. If no one can ever detect this URL, then
+ // why does this need to be generated? But if the value or uniqueness of this URL does
+ // matter, then why is it OK to use the same URL for anything generated from a document
+ // with the same URL (since we just prepend a scheme)?
+ KURL generatedURL("webkitgenerated:" + m_frame->document()->url());
+
+ // Write a BOM so that decoding will work on big-endian as well as little-endian systems.
+ ASSERT(buffer->isEmpty());
+ buffer->append(reinterpret_cast<const char*>(&byteOrderMark), sizeof(UChar));
+
+ item->setSubstituteData(SubstituteData(buffer, mimeType, "UTF-16", m_URL, generatedURL));
+
+ if (isItemNew)
+ if (Page* page = m_frame->page())
+ page->backForwardList()->addItem(item.release());
}
bool FrameLoader::executeIfJavaScriptURL(const KURL& url, bool userGesture, bool replaceDocument)
} else {
// must grab this now, since this load may stop the previous load and clear this flag
bool isRedirect = m_quickRedirectComing;
- load(request, action, newLoadType, formState);
+ load(request, action, newLoadType, formState, SubstituteData());
if (isRedirect) {
m_quickRedirectComing = false;
if (m_provisionalDocumentLoader)
checkNewWindowPolicy(NavigationAction(request.url(), NavigationTypeOther), request, 0, frameName);
}
-void FrameLoader::load(const ResourceRequest& request, const NavigationAction& action, FrameLoadType type, PassRefPtr<FormState> formState)
+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());
+ RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request, substituteData);
loader->setTriggeringAction(action);
if (m_documentLoader)
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);
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();
if (!frameName.isEmpty()) {
if (Frame* targetFrame = findFrameForNavigation(frameName))
- targetFrame->loader()->load(request, action, FrameLoadTypeStandard, formState.release());
+ targetFrame->loader()->load(request, action, FrameLoadTypeStandard, formState.release(), SubstituteData());
else
checkNewWindowPolicy(action, request, formState.release(), frameName);
} else
- load(request, action, FrameLoadTypeStandard, formState.release());
+ load(request, action, FrameLoadTypeStandard, formState.release(), SubstituteData());
}
bool FrameLoader::isReloading() const
mainFrame->loader()->setOpenedByDOM();
mainFrame->loader()->m_client->dispatchShow();
mainFrame->loader()->setOpener(frame.get());
- mainFrame->loader()->load(request, NavigationAction(), FrameLoadTypeStandard, formState);
+ mainFrame->loader()->load(request, NavigationAction(), FrameLoadTypeStandard, formState, SubstituteData());
}
void FrameLoader::sendRemainingDelegateMessages(unsigned long identifier, const ResourceResponse& response, int length, const ResourceError& error)
{
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();
}
action = NavigationAction(itemOriginalURL, loadType, false);
}
- load(request, action, loadType, 0);
+ load(request, action, loadType, 0, item->substituteData());
}
}
}
void load(const ResourceRequest&);
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>);
void stopLoading(bool sendUnload);
bool closeURL();
- void didExplicitOpen();
+ void didExplicitOpen(const String& mimeType, bool replace, SharedBuffer*);
KURL iconURL();
void commitIconURLToIconDatabase(const KURL&);
/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
const UChar blackSquare = 0x25A0;
const UChar bullet = 0x2022;
+ const UChar byteOrderMark = 0xFEFF;
const UChar horizontalEllipsis = 0x2026;
const UChar ideographicSpace = 0x3000;
const UChar leftToRightMark = 0x200E;
const UChar rightToLeftOverride = 0x202E;
const UChar softHyphen = 0x00AD;
const UChar whiteBullet = 0x25E6;
+ const UChar zeroWidthNoBreakSpace = 0xFEFF;
const UChar zeroWidthSpace = 0x200B;
}
/*
- * This file is part of the KDE libraries
- * Copyright (C) 2003, 2006 Apple Computer, Inc.
+ * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
RefPtr<Document> doc = DOMImplementation::instance()->createDocument(contentType, 0, false);
- doc->open();
+ doc->open(contentType, false);
doc->write(str);
doc->finishParsing();
doc->close();
m_responseXML = 0;
} else {
m_responseXML = m_doc->implementation()->createDocument(0);
- m_responseXML->open();
+ m_responseXML->open(responseMIMEType(), false);
m_responseXML->setURL(m_url.deprecatedString());
- // FIXME: set Last-Modified and cookies (currently, those are only available for HTMLDocuments).
- m_responseXML->write(String(m_responseText));
+ // FIXME: Set Last-Modified and cookies (currently, those are only available for HTMLDocument).
+ m_responseXML->write(m_responseText);
m_responseXML->finishParsing();
m_responseXML->close();
String documentSource = sourceString;
RefPtr<Document> result;
+ String resultMIMEType;
if (sourceMIMEType == "text/plain") {
result = ownerDocument->implementation()->createDocument(frame);
transformTextStringToXHTMLDocumentString(documentSource);
- } else
+ resultMIMEType = "application/xhtml+xml";
+ } else {
result = ownerDocument->implementation()->createDocument(sourceMIMEType, frame, false);
+ resultMIMEType = sourceMIMEType;
+ }
// Before parsing, we need to save & detach the old document and get the new document
// in place. We have to do this only if we're rendering the result document.
frame->setDocument(result);
}
- result->open();
+ result->open(resultMIMEType, false);
if (sourceIsDocument) {
result->setURL(ownerDocument->url());
result->setBaseURL(ownerDocument->baseURL());