Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/WebKit/Source/core/loader/DocumentLoader.cpp

Issue 1859763003: DocumentLoader should commit the load before creating a DocumentWriter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/loader/DocumentLoader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 } 444 }
445 DocumentInit init(owner, url(), m_frame); 445 DocumentInit init(owner, url(), m_frame);
446 init.withNewRegistrationContext(); 446 init.withNewRegistrationContext();
447 m_frame->loader().clear(); 447 m_frame->loader().clear();
448 ASSERT(m_frame->page()); 448 ASSERT(m_frame->page());
449 449
450 ParserSynchronizationPolicy parsingPolicy = AllowAsynchronousParsing; 450 ParserSynchronizationPolicy parsingPolicy = AllowAsynchronousParsing;
451 if ((m_substituteData.isValid() && m_substituteData.forceSynchronousLoad()) || !Document::threadedParsingEnabledForTesting()) 451 if ((m_substituteData.isValid() && m_substituteData.forceSynchronousLoad()) || !Document::threadedParsingEnabledForTesting())
452 parsingPolicy = ForceSynchronousParsing; 452 parsingPolicy = ForceSynchronousParsing;
453 453
454 m_writer = createWriterFor(init, mimeType, encoding, false, parsingPolicy); 454 m_writer = createWriterFor(init, mimeType, encoding, false, parsingPolicy, o verridingURL);
455 m_writer->setDocumentWasLoadedAsPartOfNavigation(); 455 m_writer->setDocumentWasLoadedAsPartOfNavigation();
456
457 // This should be set before receivedFirstData().
458 if (!overridingURL.isEmpty())
459 m_frame->document()->setBaseURLOverride(overridingURL);
460
461 // Call receivedFirstData() exactly once per load.
462 frameLoader()->receivedFirstData();
463 m_frame->document()->maybeHandleHttpRefresh(m_response.httpHeaderField(HTTPN ames::Refresh), Document::HttpRefreshFromHeader); 456 m_frame->document()->maybeHandleHttpRefresh(m_response.httpHeaderField(HTTPN ames::Refresh), Document::HttpRefreshFromHeader);
464 } 457 }
465 458
466 void DocumentLoader::commitData(const char* bytes, size_t length) 459 void DocumentLoader::commitData(const char* bytes, size_t length)
467 { 460 {
468 ASSERT(m_state < MainResourceDone); 461 ASSERT(m_state < MainResourceDone);
469 ensureWriter(m_response.mimeType()); 462 ensureWriter(m_response.mimeType());
470 463
471 // This can happen if document.close() is called by an event handler while 464 // This can happen if document.close() is called by an event handler while
472 // there's still pending incoming data. 465 // there's still pending incoming data.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 m_mainResource->addClient(this); 646 m_mainResource->addClient(this);
654 } 647 }
655 648
656 void DocumentLoader::endWriting(DocumentWriter* writer) 649 void DocumentLoader::endWriting(DocumentWriter* writer)
657 { 650 {
658 ASSERT_UNUSED(writer, m_writer == writer); 651 ASSERT_UNUSED(writer, m_writer == writer);
659 m_writer->end(); 652 m_writer->end();
660 m_writer.clear(); 653 m_writer.clear();
661 } 654 }
662 655
663 DocumentWriter* DocumentLoader::createWriterFor(const DocumentInit& init, const AtomicString& mimeType, const AtomicString& encoding, bool dispatch, ParserSynch ronizationPolicy parsingPolicy) 656 DocumentWriter* DocumentLoader::createWriterFor(const DocumentInit& init, const AtomicString& mimeType, const AtomicString& encoding, bool dispatch, ParserSynch ronizationPolicy parsingPolicy, const KURL& overridingURL)
664 { 657 {
665 LocalFrame* frame = init.frame(); 658 LocalFrame* frame = init.frame();
666 659
667 ASSERT(!frame->document() || !frame->document()->isActive()); 660 ASSERT(!frame->document() || !frame->document()->isActive());
668 ASSERT(frame->tree().childCount() == 0); 661 ASSERT(frame->tree().childCount() == 0);
669 662
670 if (!init.shouldReuseDefaultView()) 663 if (!init.shouldReuseDefaultView())
671 frame->setDOMWindow(LocalDOMWindow::create(*frame)); 664 frame->setDOMWindow(LocalDOMWindow::create(*frame));
672 665
673 Document* document = frame->localDOMWindow()->installNewDocument(mimeType, i nit); 666 Document* document = frame->localDOMWindow()->installNewDocument(mimeType, i nit);
674 667
675 frame->loader().didBeginDocument(dispatch); 668 frame->loader().didBeginDocument(dispatch);
676 669
670 // This should be set before receivedFirstData().
671 if (!overridingURL.isEmpty())
672 frame->document()->setBaseURLOverride(overridingURL);
673
674 if (!dispatch)
675 frame->loader().receivedFirstData();
jochen (gone - plz use gerrit) 2016/04/20 14:23:25 this is still after didBeginDocument. Why not move
meacer 2016/04/20 23:51:00 Had to divide didBeginDocument into two: CSP and s
676
677 return DocumentWriter::create(document, parsingPolicy, mimeType, encoding); 677 return DocumentWriter::create(document, parsingPolicy, mimeType, encoding);
678 } 678 }
679 679
680 const AtomicString& DocumentLoader::mimeType() const 680 const AtomicString& DocumentLoader::mimeType() const
681 { 681 {
682 if (m_writer) 682 if (m_writer)
683 return m_writer->mimeType(); 683 return m_writer->mimeType();
684 return m_response.mimeType(); 684 return m_response.mimeType();
685 } 685 }
686 686
687 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR L() 687 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR L()
688 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn it& init, const String& source) 688 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn it& init, const String& source)
689 { 689 {
690 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing); 690 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing);
691 if (!source.isNull()) 691 if (!source.isNull())
692 m_writer->appendReplacingData(source); 692 m_writer->appendReplacingData(source);
693 endWriting(m_writer.get()); 693 endWriting(m_writer.get());
694 } 694 }
695 695
696 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); 696 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader);
697 697
698 } // namespace blink 698 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/DocumentLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698