| OLD | NEW |
| 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 Loading... |
| 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, o
verridingURL); | 454 m_writer = createWriterFor(init, mimeType, encoding, false, parsingPolicy); |
| 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(); |
| 456 m_frame->document()->maybeHandleHttpRefresh(m_response.httpHeaderField(HTTPN
ames::Refresh), Document::HttpRefreshFromHeader); | 463 m_frame->document()->maybeHandleHttpRefresh(m_response.httpHeaderField(HTTPN
ames::Refresh), Document::HttpRefreshFromHeader); |
| 457 } | 464 } |
| 458 | 465 |
| 459 void DocumentLoader::commitData(const char* bytes, size_t length) | 466 void DocumentLoader::commitData(const char* bytes, size_t length) |
| 460 { | 467 { |
| 461 ASSERT(m_state < MainResourceDone); | 468 ASSERT(m_state < MainResourceDone); |
| 462 ensureWriter(m_response.mimeType()); | 469 ensureWriter(m_response.mimeType()); |
| 463 | 470 |
| 464 // This can happen if document.close() is called by an event handler while | 471 // This can happen if document.close() is called by an event handler while |
| 465 // there's still pending incoming data. | 472 // there's still pending incoming data. |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 m_mainResource->addClient(this); | 653 m_mainResource->addClient(this); |
| 647 } | 654 } |
| 648 | 655 |
| 649 void DocumentLoader::endWriting(DocumentWriter* writer) | 656 void DocumentLoader::endWriting(DocumentWriter* writer) |
| 650 { | 657 { |
| 651 ASSERT_UNUSED(writer, m_writer == writer); | 658 ASSERT_UNUSED(writer, m_writer == writer); |
| 652 m_writer->end(); | 659 m_writer->end(); |
| 653 m_writer.clear(); | 660 m_writer.clear(); |
| 654 } | 661 } |
| 655 | 662 |
| 656 DocumentWriter* DocumentLoader::createWriterFor(const DocumentInit& init, const
AtomicString& mimeType, const AtomicString& encoding, bool dispatchWindowObjectA
vailable, ParserSynchronizationPolicy parsingPolicy, const KURL& overridingURL) | 663 DocumentWriter* DocumentLoader::createWriterFor(const DocumentInit& init, const
AtomicString& mimeType, const AtomicString& encoding, bool dispatch, ParserSynch
ronizationPolicy parsingPolicy) |
| 657 { | 664 { |
| 658 LocalFrame* frame = init.frame(); | 665 LocalFrame* frame = init.frame(); |
| 659 | 666 |
| 660 ASSERT(!frame->document() || !frame->document()->isActive()); | 667 ASSERT(!frame->document() || !frame->document()->isActive()); |
| 661 ASSERT(frame->tree().childCount() == 0); | 668 ASSERT(frame->tree().childCount() == 0); |
| 662 | 669 |
| 663 if (!init.shouldReuseDefaultView()) | 670 if (!init.shouldReuseDefaultView()) |
| 664 frame->setDOMWindow(LocalDOMWindow::create(*frame)); | 671 frame->setDOMWindow(LocalDOMWindow::create(*frame)); |
| 665 | 672 |
| 666 Document* document = frame->localDOMWindow()->installNewDocument(mimeType, i
nit); | 673 Document* document = frame->localDOMWindow()->installNewDocument(mimeType, i
nit); |
| 667 | 674 |
| 668 // This should be set before receivedFirstData(). | 675 frame->loader().didBeginDocument(dispatch); |
| 669 if (!overridingURL.isEmpty()) | |
| 670 frame->document()->setBaseURLOverride(overridingURL); | |
| 671 | |
| 672 frame->loader().didInstallNewDocument(dispatchWindowObjectAvailable); | |
| 673 | |
| 674 // This must be called before DocumentWriter is created, otherwise HTML pars
er | |
| 675 // will use stale values from HTMLParserOption. | |
| 676 if (!dispatchWindowObjectAvailable) | |
| 677 frame->loader().receivedFirstData(); | |
| 678 | |
| 679 frame->loader().didBeginDocument(); | |
| 680 | 676 |
| 681 return DocumentWriter::create(document, parsingPolicy, mimeType, encoding); | 677 return DocumentWriter::create(document, parsingPolicy, mimeType, encoding); |
| 682 } | 678 } |
| 683 | 679 |
| 684 const AtomicString& DocumentLoader::mimeType() const | 680 const AtomicString& DocumentLoader::mimeType() const |
| 685 { | 681 { |
| 686 if (m_writer) | 682 if (m_writer) |
| 687 return m_writer->mimeType(); | 683 return m_writer->mimeType(); |
| 688 return m_response.mimeType(); | 684 return m_response.mimeType(); |
| 689 } | 685 } |
| 690 | 686 |
| 691 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR
L() | 687 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR
L() |
| 692 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn
it& init, const String& source) | 688 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn
it& init, const String& source) |
| 693 { | 689 { |
| 694 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); |
| 695 if (!source.isNull()) | 691 if (!source.isNull()) |
| 696 m_writer->appendReplacingData(source); | 692 m_writer->appendReplacingData(source); |
| 697 endWriting(m_writer.get()); | 693 endWriting(m_writer.get()); |
| 698 } | 694 } |
| 699 | 695 |
| 700 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); | 696 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); |
| 701 | 697 |
| 702 } // namespace blink | 698 } // namespace blink |
| OLD | NEW |