Changeset 115654 in webkit
- Timestamp:
- Apr 30, 2012 11:51:27 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r115652 r115654 1 2012-04-30 Nate Chapin <japhet@chromium.org> 2 3 Move more of committing and starting to write a Document 4 to DocumentLoader. 5 https://bugs.webkit.org/show_bug.cgi?id=83908 6 7 Reviewed by Adam Barth. 8 9 No new tests, refactor only. 10 11 * loader/DocumentLoader.cpp: 12 (WebCore::DocumentLoader::commitIfReady): Ignore m_gotFirstByte here, since 13 it was always true here anyway. 14 (WebCore::DocumentLoader::finishedLoading): If we are finishing an empty 15 document, create the document now, so that FrameLoaderClient doesn't 16 have to do it later (FrameLoaderClient code will be removed in a later 17 patch). 18 (WebCore::DocumentLoader::commitData): Call receivedFirstData() directly and 19 do some work receivedFirstData() used to do, setEncoding() only once per 20 load. 21 (WebCore::DocumentLoader::receivedData): 22 (WebCore::DocumentLoader::maybeCreateArchive): 23 * loader/DocumentLoader.h: 24 * loader/DocumentWriter.cpp: 25 (WebCore::DocumentWriter::setEncoding): 26 * loader/FrameLoader.cpp: 27 (WebCore::FrameLoader::receivedFirstData): Move DocumentLoader calls 28 to DocumentLoader. 29 * loader/FrameLoader.h: Remove m_hasReceivedFirstData and willSetEncoding(), 30 allow hasReceivedData() to be called directly. 31 (FrameLoader): 32 1 33 2012-04-30 Kentaro Hara <haraken@chromium.org> 2 34 -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r114016 r115654 277 277 void DocumentLoader::commitIfReady() 278 278 { 279 if ( m_gotFirstByte &&!m_committed) {279 if (!m_committed) { 280 280 m_committed = true; 281 281 frameLoader()->commitProvisionalLoad(); … … 285 285 void DocumentLoader::finishedLoading() 286 286 { 287 m_gotFirstByte = true;288 287 commitIfReady(); 289 288 if (!frameLoader() || frameLoader()->stateMachine()->creatingInitialEmptyDocument()) … … 291 290 if (!maybeCreateArchive()) 292 291 frameLoader()->client()->finishedLoading(this); 292 293 // If this is an empty document, it will not have actually been created yet. Commit dummy data so that 294 // DocumentWriter::begin() gets called and creates the Document. 295 if (!m_gotFirstByte) 296 commitData(0, 0); 297 293 298 m_writer.end(); 294 299 if (!m_mainDocumentError.isNull()) … … 318 323 void DocumentLoader::commitData(const char* bytes, size_t length) 319 324 { 320 // Set the text encoding. This is safe to call multiple times. 321 bool userChosen = true; 322 String encoding = overrideEncoding(); 323 if (encoding.isNull()) { 324 userChosen = false; 325 encoding = response().textEncodingName(); 326 } 327 m_writer.setEncoding(encoding, userChosen); 325 if (!m_gotFirstByte) { 326 m_gotFirstByte = true; 327 m_writer.begin(documentURL(), false); 328 m_writer.setDocumentWasLoadedAsPartOfNavigation(); 329 330 #if ENABLE(MHTML) 331 // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so 332 // relative URLs are resolved properly. 333 if (m_archive && m_archive->type() == Archive::MHTML) 334 m_frame->document()->setBaseURLOverride(m_archive->mainResource()->url()); 335 #endif 336 337 frameLoader()->receivedFirstData(); 338 339 bool userChosen = true; 340 String encoding = overrideEncoding(); 341 if (encoding.isNull()) { 342 userChosen = false; 343 encoding = response().textEncodingName(); 344 } 345 m_writer.setEncoding(encoding, userChosen); 346 } 328 347 ASSERT(m_frame->document()->parsing()); 329 348 m_writer.addData(bytes, length); … … 336 355 337 356 void DocumentLoader::receivedData(const char* data, int length) 338 { 339 m_gotFirstByte = true; 357 { 340 358 if (doesProgressiveLoad(m_response.mimeType())) 341 359 commitLoad(data, length); … … 462 480 463 481 ASSERT(m_frame->document()); 464 String userChosenEncoding = overrideEncoding(); 465 bool encodingIsUserChosen = !userChosenEncoding.isNull(); 466 m_writer.setEncoding(encodingIsUserChosen ? userChosenEncoding : mainResource->textEncoding(), encodingIsUserChosen); 467 m_writer.addData(mainResource->data()->data(), mainResource->data()->size()); 482 commitData(mainResource->data()->data(), mainResource->data()->size()); 468 483 return true; 469 484 #endif // !ENABLE(WEB_ARCHIVE) && !ENABLE(MHTML) -
trunk/Source/WebCore/loader/DocumentLoader.h
r114016 r115654 133 133 134 134 #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML) 135 Archive* archive() const { return m_archive.get(); }136 135 void setArchive(PassRefPtr<Archive>); 137 136 void addAllArchiveResources(Archive*); -
trunk/Source/WebCore/loader/DocumentWriter.cpp
r114062 r115654 245 245 void DocumentWriter::setEncoding(const String& name, bool userChosen) 246 246 { 247 m_frame->loader()->willSetEncoding();248 247 m_encoding = name; 249 248 m_encodingWasChosenByUser = userChosen; -
trunk/Source/WebCore/loader/FrameLoader.cpp
r115549 r115654 185 185 , m_pageDismissalEventBeingDispatched(NoDismissal) 186 186 , m_isComplete(false) 187 , m_hasReceivedFirstData(false)188 187 , m_needsClear(false) 189 188 , m_checkTimer(this, &FrameLoader::checkTimerFired) … … 410 409 } 411 410 412 m_hasReceivedFirstData = true;413 414 411 if (Document* doc = m_frame->document()) { 415 412 // FIXME: HTML5 doesn't tell us to set the state to complete when aborting, but we do anyway to match legacy behavior. … … 476 473 } 477 474 } 478 m_hasReceivedFirstData = false;479 475 480 476 started(); … … 562 558 void FrameLoader::receivedFirstData() 563 559 { 564 KURL workingURL = activeDocumentLoader()->documentURL();565 activeDocumentLoader()->writer()->begin(workingURL, false);566 activeDocumentLoader()->writer()->setDocumentWasLoadedAsPartOfNavigation();567 568 #if ENABLE(MHTML)569 // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so570 // relative URLs are resolved properly.571 if (activeDocumentLoader()->archive() && activeDocumentLoader()->archive()->type() == Archive::MHTML)572 m_frame->document()->setBaseURLOverride(activeDocumentLoader()->archive()->mainResource()->url());573 #endif574 575 560 dispatchDidCommitLoad(); 576 561 dispatchDidClearWindowObjectsInAllWorlds(); … … 583 568 m_client->dispatchDidReceiveTitle(ptitle); 584 569 } 585 586 m_hasReceivedFirstData = true;587 570 588 571 if (!m_documentLoader) … … 972 955 { 973 956 m_submittedFormURL = KURL(); 974 }975 976 void FrameLoader::willSetEncoding()977 {978 if (!m_hasReceivedFirstData)979 receivedFirstData();980 957 } 981 958 … … 1934 1911 if (url.protocolIsInHTTPFamily() && !url.host().isEmpty() && url.path().isEmpty()) 1935 1912 url.setPath("/"); 1936 1937 m_hasReceivedFirstData = false;1938 1913 1939 1914 started(); -
trunk/Source/WebCore/loader/FrameLoader.h
r115083 r115654 200 200 // Callbacks from DocumentWriter 201 201 void didBeginDocument(bool dispatchWindowObjectAvailable); 202 void willSetEncoding(); 202 203 void receivedFirstData(); 203 204 204 205 void handledOnloadEvents(); … … 292 293 void loadProvisionalItemFromCachedPage(); 293 294 294 void receivedFirstData();295 296 295 void updateFirstPartyForCookies(); 297 296 void setFirstPartyForCookies(const KURL&); … … 405 404 406 405 RefPtr<SerializedScriptValue> m_pendingStateObject; 407 408 bool m_hasReceivedFirstData;409 406 410 407 bool m_needsClear;
Note: See TracChangeset
for help on using the changeset viewer.