| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010. Adam Barth. All rights reserved. | 2 * Copyright (C) 2010. Adam Barth. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "core/frame/Settings.h" | 36 #include "core/frame/Settings.h" |
| 37 #include "core/html/parser/TextResourceDecoder.h" | 37 #include "core/html/parser/TextResourceDecoder.h" |
| 38 #include "core/loader/FrameLoader.h" | 38 #include "core/loader/FrameLoader.h" |
| 39 #include "core/loader/FrameLoaderStateMachine.h" | 39 #include "core/loader/FrameLoaderStateMachine.h" |
| 40 #include "platform/weborigin/KURL.h" | 40 #include "platform/weborigin/KURL.h" |
| 41 #include "platform/weborigin/SecurityOrigin.h" | 41 #include "platform/weborigin/SecurityOrigin.h" |
| 42 #include "wtf/PassOwnPtr.h" | 42 #include "wtf/PassOwnPtr.h" |
| 43 | 43 |
| 44 namespace blink { | 44 namespace blink { |
| 45 | 45 |
| 46 PassRefPtrWillBeRawPtr<DocumentWriter> DocumentWriter::create(Document* document
, ParserSynchronizationPolicy parsingPolicy, const AtomicString& mimeType, const
AtomicString& encoding) | 46 RawPtr<DocumentWriter> DocumentWriter::create(Document* document, ParserSynchron
izationPolicy parsingPolicy, const AtomicString& mimeType, const AtomicString& e
ncoding) |
| 47 { | 47 { |
| 48 return adoptRefWillBeNoop(new DocumentWriter(document, parsingPolicy, mimeTy
pe, encoding)); | 48 return new DocumentWriter(document, parsingPolicy, mimeType, encoding); |
| 49 } | 49 } |
| 50 | 50 |
| 51 DocumentWriter::DocumentWriter(Document* document, ParserSynchronizationPolicy p
arserSyncPolicy, const AtomicString& mimeType, const AtomicString& encoding) | 51 DocumentWriter::DocumentWriter(Document* document, ParserSynchronizationPolicy p
arserSyncPolicy, const AtomicString& mimeType, const AtomicString& encoding) |
| 52 : m_document(document) | 52 : m_document(document) |
| 53 , m_decoderBuilder(mimeType, encoding) | 53 , m_decoderBuilder(mimeType, encoding) |
| 54 // We grab a reference to the parser so that we'll always send data to the | 54 // We grab a reference to the parser so that we'll always send data to the |
| 55 // original parser, even if the document acquires a new parser (e.g., via | 55 // original parser, even if the document acquires a new parser (e.g., via |
| 56 // document.open). | 56 // document.open). |
| 57 , m_parser(m_document->implicitOpen(parserSyncPolicy)) | 57 , m_parser(m_document->implicitOpen(parserSyncPolicy)) |
| 58 { | 58 { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 m_parser->appendBytes(bytes, length); | 93 m_parser->appendBytes(bytes, length); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void DocumentWriter::end() | 96 void DocumentWriter::end() |
| 97 { | 97 { |
| 98 ASSERT(m_document); | 98 ASSERT(m_document); |
| 99 | 99 |
| 100 // http://bugs.webkit.org/show_bug.cgi?id=10854 | 100 // http://bugs.webkit.org/show_bug.cgi?id=10854 |
| 101 // The frame's last ref may be removed and it can be deleted by checkComplet
ed(), | 101 // The frame's last ref may be removed and it can be deleted by checkComplet
ed(), |
| 102 // so we'll add a protective refcount | 102 // so we'll add a protective refcount |
| 103 RefPtrWillBeRawPtr<LocalFrame> protect(m_document->frame()); | 103 RawPtr<LocalFrame> protect(m_document->frame()); |
| 104 | 104 |
| 105 if (!m_parser) | 105 if (!m_parser) |
| 106 return; | 106 return; |
| 107 | 107 |
| 108 if (m_parser->needsDecoder()) { | 108 if (m_parser->needsDecoder()) { |
| 109 OwnPtr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor(m_docume
nt); | 109 OwnPtr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor(m_docume
nt); |
| 110 m_parser->setDecoder(decoder.release()); | 110 m_parser->setDecoder(decoder.release()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 // finish() can result replacing DocumentLoader::m_writer. | 113 // finish() can result replacing DocumentLoader::m_writer. |
| 114 RefPtrWillBeRawPtr<DocumentWriter> protectingThis(this); | 114 RawPtr<DocumentWriter> protectingThis(this); |
| 115 m_parser->finish(); | 115 m_parser->finish(); |
| 116 m_parser = nullptr; | 116 m_parser = nullptr; |
| 117 m_document = nullptr; | 117 m_document = nullptr; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation() | 120 void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation() |
| 121 { | 121 { |
| 122 ASSERT(m_parser && !m_parser->isStopped()); | 122 ASSERT(m_parser && !m_parser->isStopped()); |
| 123 m_parser->setDocumentWasLoadedAsPartOfNavigation(); | 123 m_parser->setDocumentWasLoadedAsPartOfNavigation(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace blink | 126 } // namespace blink |
| OLD | NEW |