| 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 24 matching lines...) Expand all Loading... |
| 35 #include "core/dom/DocumentParser.h" | 35 #include "core/dom/DocumentParser.h" |
| 36 #include "core/events/Event.h" | 36 #include "core/events/Event.h" |
| 37 #include "core/fetch/MemoryCache.h" | 37 #include "core/fetch/MemoryCache.h" |
| 38 #include "core/fetch/ResourceFetcher.h" | 38 #include "core/fetch/ResourceFetcher.h" |
| 39 #include "core/fetch/ResourceLoader.h" | 39 #include "core/fetch/ResourceLoader.h" |
| 40 #include "core/frame/FrameHost.h" | 40 #include "core/frame/FrameHost.h" |
| 41 #include "core/frame/LocalDOMWindow.h" | 41 #include "core/frame/LocalDOMWindow.h" |
| 42 #include "core/frame/LocalFrame.h" | 42 #include "core/frame/LocalFrame.h" |
| 43 #include "core/frame/csp/ContentSecurityPolicy.h" | 43 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 44 #include "core/html/HTMLFrameOwnerElement.h" | 44 #include "core/html/HTMLFrameOwnerElement.h" |
| 45 #include "core/html/parser/HTMLDocumentParser.h" |
| 45 #include "core/html/parser/TextResourceDecoder.h" | 46 #include "core/html/parser/TextResourceDecoder.h" |
| 46 #include "core/inspector/InspectorInstrumentation.h" | 47 #include "core/inspector/InspectorInstrumentation.h" |
| 47 #include "core/loader/FrameLoader.h" | 48 #include "core/loader/FrameLoader.h" |
| 48 #include "core/loader/FrameLoaderClient.h" | 49 #include "core/loader/FrameLoaderClient.h" |
| 49 #include "core/loader/UniqueIdentifier.h" | 50 #include "core/loader/UniqueIdentifier.h" |
| 50 #include "core/loader/appcache/ApplicationCacheHost.h" | 51 #include "core/loader/appcache/ApplicationCacheHost.h" |
| 51 #include "core/page/FrameTree.h" | 52 #include "core/page/FrameTree.h" |
| 52 #include "core/page/Page.h" | 53 #include "core/page/Page.h" |
| 53 #include "core/frame/Settings.h" | 54 #include "core/frame/Settings.h" |
| 54 #include "core/inspector/ConsoleMessage.h" | 55 #include "core/inspector/ConsoleMessage.h" |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 | 514 |
| 514 const AtomicString& encoding = m_frame->host()->overrideEncoding().isNull()
? response().textEncodingName() : m_frame->host()->overrideEncoding(); | 515 const AtomicString& encoding = m_frame->host()->overrideEncoding().isNull()
? response().textEncodingName() : m_frame->host()->overrideEncoding(); |
| 515 | 516 |
| 516 // Prepare a DocumentInit before clearing the frame, because it may need to | 517 // Prepare a DocumentInit before clearing the frame, because it may need to |
| 517 // inherit an aliased security context. | 518 // inherit an aliased security context. |
| 518 DocumentInit init(url(), m_frame); | 519 DocumentInit init(url(), m_frame); |
| 519 init.withNewRegistrationContext(); | 520 init.withNewRegistrationContext(); |
| 520 m_frame->loader().clear(); | 521 m_frame->loader().clear(); |
| 521 ASSERT(m_frame->page()); | 522 ASSERT(m_frame->page()); |
| 522 | 523 |
| 523 m_writer = createWriterFor(0, init, mimeType, encoding, false); | 524 ParserSynchronizationPolicy parsingPolicy = (m_substituteData.isValid() && m
_substituteData.forceSynchronousLoad()) ? ForceSynchronousParsing : AllowAsynchr
onousParsing; |
| 525 m_writer = createWriterFor(0, init, mimeType, encoding, false, parsingPolicy
); |
| 524 m_writer->setDocumentWasLoadedAsPartOfNavigation(); | 526 m_writer->setDocumentWasLoadedAsPartOfNavigation(); |
| 525 | 527 |
| 526 if (m_substituteData.isValid() && m_substituteData.forceSynchronousLoad()) | |
| 527 m_writer->forceSynchronousParse(); | |
| 528 | |
| 529 // This should be set before receivedFirstData(). | 528 // This should be set before receivedFirstData(). |
| 530 if (!overridingURL.isEmpty()) | 529 if (!overridingURL.isEmpty()) |
| 531 m_frame->document()->setBaseURLOverride(overridingURL); | 530 m_frame->document()->setBaseURLOverride(overridingURL); |
| 532 | 531 |
| 533 // Call receivedFirstData() exactly once per load. | 532 // Call receivedFirstData() exactly once per load. |
| 534 frameLoader()->receivedFirstData(); | 533 frameLoader()->receivedFirstData(); |
| 535 m_frame->document()->maybeHandleHttpRefresh(m_response.httpHeaderField("Refr
esh"), Document::HttpRefreshFromHeader); | 534 m_frame->document()->maybeHandleHttpRefresh(m_response.httpHeaderField("Refr
esh"), Document::HttpRefreshFromHeader); |
| 536 } | 535 } |
| 537 | 536 |
| 538 void DocumentLoader::commitData(const char* bytes, size_t length) | 537 void DocumentLoader::commitData(const char* bytes, size_t length) |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 mainResourceLoader()->attachThreadedDataReceiver(threadedDataReceiver); | 789 mainResourceLoader()->attachThreadedDataReceiver(threadedDataReceiver); |
| 791 } | 790 } |
| 792 | 791 |
| 793 void DocumentLoader::endWriting(DocumentWriter* writer) | 792 void DocumentLoader::endWriting(DocumentWriter* writer) |
| 794 { | 793 { |
| 795 ASSERT_UNUSED(writer, m_writer == writer); | 794 ASSERT_UNUSED(writer, m_writer == writer); |
| 796 m_writer->end(); | 795 m_writer->end(); |
| 797 m_writer.clear(); | 796 m_writer.clear(); |
| 798 } | 797 } |
| 799 | 798 |
| 800 PassRefPtrWillBeRawPtr<DocumentWriter> DocumentLoader::createWriterFor(const Doc
ument* ownerDocument, const DocumentInit& init, const AtomicString& mimeType, co
nst AtomicString& encoding, bool dispatch) | 799 PassRefPtrWillBeRawPtr<DocumentWriter> DocumentLoader::createWriterFor(const Doc
ument* ownerDocument, const DocumentInit& init, const AtomicString& mimeType, co
nst AtomicString& encoding, bool dispatch, ParserSynchronizationPolicy parsingPo
licy) |
| 801 { | 800 { |
| 802 LocalFrame* frame = init.frame(); | 801 LocalFrame* frame = init.frame(); |
| 803 | 802 |
| 804 if (frame->document()) | 803 if (frame->document()) |
| 805 frame->document()->prepareForDestruction(); | 804 frame->document()->prepareForDestruction(); |
| 806 | 805 |
| 807 if (!init.shouldReuseDefaultView()) | 806 if (!init.shouldReuseDefaultView()) |
| 808 frame->setDOMWindow(LocalDOMWindow::create(*frame)); | 807 frame->setDOMWindow(LocalDOMWindow::create(*frame)); |
| 809 | 808 |
| 810 RefPtrWillBeRawPtr<Document> document = frame->localDOMWindow()->installNewD
ocument(mimeType, init); | 809 RefPtrWillBeRawPtr<Document> document = frame->localDOMWindow()->installNewD
ocument(mimeType, init); |
| 811 if (ownerDocument) { | 810 if (ownerDocument) { |
| 812 document->setCookieURL(ownerDocument->cookieURL()); | 811 document->setCookieURL(ownerDocument->cookieURL()); |
| 813 document->setSecurityOrigin(ownerDocument->securityOrigin()); | 812 document->setSecurityOrigin(ownerDocument->securityOrigin()); |
| 814 if (ownerDocument->isTransitionDocument()) | 813 if (ownerDocument->isTransitionDocument()) |
| 815 document->setIsTransitionDocument(); | 814 document->setIsTransitionDocument(); |
| 816 } | 815 } |
| 817 | 816 |
| 818 frame->loader().didBeginDocument(dispatch); | 817 frame->loader().didBeginDocument(dispatch); |
| 819 | 818 |
| 820 return DocumentWriter::create(document.get(), mimeType, encoding); | 819 return DocumentWriter::create(document.get(), parsingPolicy, mimeType, encod
ing); |
| 821 } | 820 } |
| 822 | 821 |
| 823 const AtomicString& DocumentLoader::mimeType() const | 822 const AtomicString& DocumentLoader::mimeType() const |
| 824 { | 823 { |
| 825 if (m_writer) | 824 if (m_writer) |
| 826 return m_writer->mimeType(); | 825 return m_writer->mimeType(); |
| 827 return m_response.mimeType(); | 826 return m_response.mimeType(); |
| 828 } | 827 } |
| 829 | 828 |
| 830 void DocumentLoader::setUserChosenEncoding(const String& charset) | 829 void DocumentLoader::setUserChosenEncoding(const String& charset) |
| 831 { | 830 { |
| 832 if (m_writer) | 831 if (m_writer) |
| 833 m_writer->setUserChosenEncoding(charset); | 832 m_writer->setUserChosenEncoding(charset); |
| 834 } | 833 } |
| 835 | 834 |
| 836 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR
L() | 835 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR
L() |
| 837 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn
it& init, const String& source, Document* ownerDocument) | 836 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn
it& init, const String& source, Document* ownerDocument) |
| 838 { | 837 { |
| 839 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri
ter->encoding() : emptyAtom, true); | 838 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri
ter->encoding() : emptyAtom, true, ForceSynchronousParsing); |
| 840 if (!source.isNull()) | 839 if (!source.isNull()) |
| 841 m_writer->appendReplacingData(source); | 840 m_writer->appendReplacingData(source); |
| 842 endWriting(m_writer.get()); | 841 endWriting(m_writer.get()); |
| 843 } | 842 } |
| 844 | 843 |
| 845 } // namespace blink | 844 } // namespace blink |
| OLD | NEW |