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 21 matching lines...) Expand all Loading... |
32 #include "core/dom/ScriptableDocumentParser.h" | 32 #include "core/dom/ScriptableDocumentParser.h" |
33 #include "core/frame/FrameView.h" | 33 #include "core/frame/FrameView.h" |
34 #include "core/frame/LocalDOMWindow.h" | 34 #include "core/frame/LocalDOMWindow.h" |
35 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
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 <memory> | 42 #include "wtf/PassOwnPtr.h" |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 DocumentWriter* DocumentWriter::create(Document* document, ParserSynchronization
Policy parsingPolicy, const AtomicString& mimeType, const AtomicString& encoding
) | 46 DocumentWriter* DocumentWriter::create(Document* document, ParserSynchronization
Policy parsingPolicy, const AtomicString& mimeType, const AtomicString& encoding
) |
47 { | 47 { |
48 return new DocumentWriter(document, parsingPolicy, mimeType, 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) |
(...skipping 26 matching lines...) Expand all Loading... |
79 // FIXME: This should call DocumentParser::appendBytes instead of append | 79 // FIXME: This should call DocumentParser::appendBytes instead of append |
80 // to support RawDataDocumentParsers. | 80 // to support RawDataDocumentParsers. |
81 if (DocumentParser* parser = m_document->parser()) | 81 if (DocumentParser* parser = m_document->parser()) |
82 parser->append(source); | 82 parser->append(source); |
83 } | 83 } |
84 | 84 |
85 void DocumentWriter::addData(const char* bytes, size_t length) | 85 void DocumentWriter::addData(const char* bytes, size_t length) |
86 { | 86 { |
87 ASSERT(m_parser); | 87 ASSERT(m_parser); |
88 if (m_parser->needsDecoder() && 0 < length) { | 88 if (m_parser->needsDecoder() && 0 < length) { |
89 std::unique_ptr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor
(m_document); | 89 OwnPtr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor(m_docume
nt); |
90 m_parser->setDecoder(std::move(decoder)); | 90 m_parser->setDecoder(std::move(decoder)); |
91 } | 91 } |
92 // appendBytes() can result replacing DocumentLoader::m_writer. | 92 // appendBytes() can result replacing DocumentLoader::m_writer. |
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 if (!m_parser) | 100 if (!m_parser) |
101 return; | 101 return; |
102 | 102 |
103 if (m_parser->needsDecoder()) { | 103 if (m_parser->needsDecoder()) { |
104 std::unique_ptr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor
(m_document); | 104 OwnPtr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor(m_docume
nt); |
105 m_parser->setDecoder(std::move(decoder)); | 105 m_parser->setDecoder(std::move(decoder)); |
106 } | 106 } |
107 | 107 |
108 m_parser->finish(); | 108 m_parser->finish(); |
109 m_parser = nullptr; | 109 m_parser = nullptr; |
110 m_document = nullptr; | 110 m_document = nullptr; |
111 } | 111 } |
112 | 112 |
113 void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation() | 113 void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation() |
114 { | 114 { |
115 ASSERT(m_parser && !m_parser->isStopped()); | 115 ASSERT(m_parser && !m_parser->isStopped()); |
116 m_parser->setDocumentWasLoadedAsPartOfNavigation(); | 116 m_parser->setDocumentWasLoadedAsPartOfNavigation(); |
117 } | 117 } |
118 | 118 |
119 } // namespace blink | 119 } // namespace blink |
OLD | NEW |