- Revision
- 115654
- Author
- [email protected]
- Date
- 2012-04-30 11:51:27 -0700 (Mon, 30 Apr 2012)
Log Message
Move more of committing and starting to write a Document
to DocumentLoader.
https://bugs.webkit.org/show_bug.cgi?id=83908
Reviewed by Adam Barth.
No new tests, refactor only.
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::commitIfReady): Ignore m_gotFirstByte here, since
it was always true here anyway.
(WebCore::DocumentLoader::finishedLoading): If we are finishing an empty
document, create the document now, so that FrameLoaderClient doesn't
have to do it later (FrameLoaderClient code will be removed in a later
patch).
(WebCore::DocumentLoader::commitData): Call receivedFirstData() directly and
do some work receivedFirstData() used to do, setEncoding() only once per
load.
(WebCore::DocumentLoader::receivedData):
(WebCore::DocumentLoader::maybeCreateArchive):
* loader/DocumentLoader.h:
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::setEncoding):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::receivedFirstData): Move DocumentLoader calls
to DocumentLoader.
* loader/FrameLoader.h: Remove m_hasReceivedFirstData and willSetEncoding(),
allow hasReceivedData() to be called directly.
(FrameLoader):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (115653 => 115654)
--- trunk/Source/WebCore/ChangeLog 2012-04-30 18:30:00 UTC (rev 115653)
+++ trunk/Source/WebCore/ChangeLog 2012-04-30 18:51:27 UTC (rev 115654)
@@ -1,3 +1,35 @@
+2012-04-30 Nate Chapin <[email protected]>
+
+ Move more of committing and starting to write a Document
+ to DocumentLoader.
+ https://bugs.webkit.org/show_bug.cgi?id=83908
+
+ Reviewed by Adam Barth.
+
+ No new tests, refactor only.
+
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::commitIfReady): Ignore m_gotFirstByte here, since
+ it was always true here anyway.
+ (WebCore::DocumentLoader::finishedLoading): If we are finishing an empty
+ document, create the document now, so that FrameLoaderClient doesn't
+ have to do it later (FrameLoaderClient code will be removed in a later
+ patch).
+ (WebCore::DocumentLoader::commitData): Call receivedFirstData() directly and
+ do some work receivedFirstData() used to do, setEncoding() only once per
+ load.
+ (WebCore::DocumentLoader::receivedData):
+ (WebCore::DocumentLoader::maybeCreateArchive):
+ * loader/DocumentLoader.h:
+ * loader/DocumentWriter.cpp:
+ (WebCore::DocumentWriter::setEncoding):
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::receivedFirstData): Move DocumentLoader calls
+ to DocumentLoader.
+ * loader/FrameLoader.h: Remove m_hasReceivedFirstData and willSetEncoding(),
+ allow hasReceivedData() to be called directly.
+ (FrameLoader):
+
2012-04-30 Kentaro Hara <[email protected]>
Unreviewed. Fix test crashes in Win/Linux debug builds.
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (115653 => 115654)
--- trunk/Source/WebCore/loader/DocumentLoader.cpp 2012-04-30 18:30:00 UTC (rev 115653)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp 2012-04-30 18:51:27 UTC (rev 115654)
@@ -276,7 +276,7 @@
void DocumentLoader::commitIfReady()
{
- if (m_gotFirstByte && !m_committed) {
+ if (!m_committed) {
m_committed = true;
frameLoader()->commitProvisionalLoad();
}
@@ -284,12 +284,17 @@
void DocumentLoader::finishedLoading()
{
- m_gotFirstByte = true;
commitIfReady();
if (!frameLoader() || frameLoader()->stateMachine()->creatingInitialEmptyDocument())
return;
if (!maybeCreateArchive())
frameLoader()->client()->finishedLoading(this);
+
+ // If this is an empty document, it will not have actually been created yet. Commit dummy data so that
+ // DocumentWriter::begin() gets called and creates the Document.
+ if (!m_gotFirstByte)
+ commitData(0, 0);
+
m_writer.end();
if (!m_mainDocumentError.isNull())
return;
@@ -317,14 +322,28 @@
void DocumentLoader::commitData(const char* bytes, size_t length)
{
- // Set the text encoding. This is safe to call multiple times.
- bool userChosen = true;
- String encoding = overrideEncoding();
- if (encoding.isNull()) {
- userChosen = false;
- encoding = response().textEncodingName();
+ if (!m_gotFirstByte) {
+ m_gotFirstByte = true;
+ m_writer.begin(documentURL(), false);
+ m_writer.setDocumentWasLoadedAsPartOfNavigation();
+
+#if ENABLE(MHTML)
+ // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so
+ // relative URLs are resolved properly.
+ if (m_archive && m_archive->type() == Archive::MHTML)
+ m_frame->document()->setBaseURLOverride(m_archive->mainResource()->url());
+#endif
+
+ frameLoader()->receivedFirstData();
+
+ bool userChosen = true;
+ String encoding = overrideEncoding();
+ if (encoding.isNull()) {
+ userChosen = false;
+ encoding = response().textEncodingName();
+ }
+ m_writer.setEncoding(encoding, userChosen);
}
- m_writer.setEncoding(encoding, userChosen);
ASSERT(m_frame->document()->parsing());
m_writer.addData(bytes, length);
}
@@ -335,8 +354,7 @@
}
void DocumentLoader::receivedData(const char* data, int length)
-{
- m_gotFirstByte = true;
+{
if (doesProgressiveLoad(m_response.mimeType()))
commitLoad(data, length);
}
@@ -461,10 +479,7 @@
m_writer.setMIMEType(mainResource->mimeType());
ASSERT(m_frame->document());
- String userChosenEncoding = overrideEncoding();
- bool encodingIsUserChosen = !userChosenEncoding.isNull();
- m_writer.setEncoding(encodingIsUserChosen ? userChosenEncoding : mainResource->textEncoding(), encodingIsUserChosen);
- m_writer.addData(mainResource->data()->data(), mainResource->data()->size());
+ commitData(mainResource->data()->data(), mainResource->data()->size());
return true;
#endif // !ENABLE(WEB_ARCHIVE) && !ENABLE(MHTML)
}
Modified: trunk/Source/WebCore/loader/DocumentLoader.h (115653 => 115654)
--- trunk/Source/WebCore/loader/DocumentLoader.h 2012-04-30 18:30:00 UTC (rev 115653)
+++ trunk/Source/WebCore/loader/DocumentLoader.h 2012-04-30 18:51:27 UTC (rev 115654)
@@ -132,7 +132,6 @@
#endif
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
- Archive* archive() const { return m_archive.get(); }
void setArchive(PassRefPtr<Archive>);
void addAllArchiveResources(Archive*);
void addArchiveResource(PassRefPtr<ArchiveResource>);
Modified: trunk/Source/WebCore/loader/DocumentWriter.cpp (115653 => 115654)
--- trunk/Source/WebCore/loader/DocumentWriter.cpp 2012-04-30 18:30:00 UTC (rev 115653)
+++ trunk/Source/WebCore/loader/DocumentWriter.cpp 2012-04-30 18:51:27 UTC (rev 115654)
@@ -244,7 +244,6 @@
void DocumentWriter::setEncoding(const String& name, bool userChosen)
{
- m_frame->loader()->willSetEncoding();
m_encoding = name;
m_encodingWasChosenByUser = userChosen;
}
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (115653 => 115654)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2012-04-30 18:30:00 UTC (rev 115653)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2012-04-30 18:51:27 UTC (rev 115654)
@@ -184,7 +184,6 @@
, m_wasUnloadEventEmitted(false)
, m_pageDismissalEventBeingDispatched(NoDismissal)
, m_isComplete(false)
- , m_hasReceivedFirstData(false)
, m_needsClear(false)
, m_checkTimer(this, &FrameLoader::checkTimerFired)
, m_shouldCallCheckCompleted(false)
@@ -409,8 +408,6 @@
m_frame->document()->setParsing(false);
}
- m_hasReceivedFirstData = true;
-
if (Document* doc = m_frame->document()) {
// FIXME: HTML5 doesn't tell us to set the state to complete when aborting, but we do anyway to match legacy behavior.
// http://www.w3.org/Bugs/Public/show_bug.cgi?id=10537
@@ -475,7 +472,6 @@
window->setDefaultStatus(String());
}
}
- m_hasReceivedFirstData = false;
started();
@@ -561,17 +557,6 @@
void FrameLoader::receivedFirstData()
{
- KURL workingURL = activeDocumentLoader()->documentURL();
- activeDocumentLoader()->writer()->begin(workingURL, false);
- activeDocumentLoader()->writer()->setDocumentWasLoadedAsPartOfNavigation();
-
-#if ENABLE(MHTML)
- // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so
- // relative URLs are resolved properly.
- if (activeDocumentLoader()->archive() && activeDocumentLoader()->archive()->type() == Archive::MHTML)
- m_frame->document()->setBaseURLOverride(activeDocumentLoader()->archive()->mainResource()->url());
-#endif
-
dispatchDidCommitLoad();
dispatchDidClearWindowObjectsInAllWorlds();
dispatchGlobalObjectAvailableInAllWorlds();
@@ -583,8 +568,6 @@
m_client->dispatchDidReceiveTitle(ptitle);
}
- m_hasReceivedFirstData = true;
-
if (!m_documentLoader)
return;
if (m_frame->document()->isViewSource())
@@ -973,12 +956,6 @@
m_submittedFormURL = KURL();
}
-void FrameLoader::willSetEncoding()
-{
- if (!m_hasReceivedFirstData)
- receivedFirstData();
-}
-
void FrameLoader::updateFirstPartyForCookies()
{
if (m_frame->tree()->parent())
@@ -1934,8 +1911,6 @@
if (url.protocolIsInHTTPFamily() && !url.host().isEmpty() && url.path().isEmpty())
url.setPath("/");
- m_hasReceivedFirstData = false;
-
started();
clear(true, true, cachedFrame.isMainFrame());
Modified: trunk/Source/WebCore/loader/FrameLoader.h (115653 => 115654)
--- trunk/Source/WebCore/loader/FrameLoader.h 2012-04-30 18:30:00 UTC (rev 115653)
+++ trunk/Source/WebCore/loader/FrameLoader.h 2012-04-30 18:51:27 UTC (rev 115654)
@@ -199,8 +199,9 @@
// Callbacks from DocumentWriter
void didBeginDocument(bool dispatchWindowObjectAvailable);
- void willSetEncoding();
+ void receivedFirstData();
+
void handledOnloadEvents();
String userAgent(const KURL&) const;
@@ -291,8 +292,6 @@
void loadProvisionalItemFromCachedPage();
- void receivedFirstData();
-
void updateFirstPartyForCookies();
void setFirstPartyForCookies(const KURL&);
@@ -405,8 +404,6 @@
RefPtr<SerializedScriptValue> m_pendingStateObject;
- bool m_hasReceivedFirstData;
-
bool m_needsClear;
KURL m_submittedFormURL;