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 |
11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
14 * its contributors may be used to endorse or promote products derived | 14 * its contributors may be used to endorse or promote products derived |
15 * from this software without specific prior written permission. | 15 * from this software without specific prior written permission. |
16 * | 16 * |
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 m_hasReceivedSomeData = true; | 74 m_hasReceivedSomeData = true; |
75 m_document->setCompatibilityMode(Document::NoQuirksMode); | 75 m_document->setCompatibilityMode(Document::NoQuirksMode); |
76 | 76 |
77 // FIXME: This should call DocumentParser::appendBytes instead of append | 77 // FIXME: This should call DocumentParser::appendBytes instead of append |
78 // to support RawDataDocumentParsers. | 78 // to support RawDataDocumentParsers. |
79 if (DocumentParser* parser = m_document->parser()) { | 79 if (DocumentParser* parser = m_document->parser()) { |
80 parser->pinToMainThread(); | 80 parser->pinToMainThread(); |
81 // Because we're pinned to the main thread we don't need to worry about | 81 // Because we're pinned to the main thread we don't need to worry about |
82 // passing ownership of the source string. | 82 // passing ownership of the source string. |
83 parser->append(source.impl()); | 83 parser->append(source.impl()); |
| 84 // NOTE: Even though we're pinned to the main thread, script execution |
| 85 // may still cause the parser to yield. We may not be done parsing |
| 86 // the new source yet! |
84 } | 87 } |
85 } | 88 } |
86 | 89 |
87 void DocumentWriter::reportDataReceived() | 90 void DocumentWriter::reportDataReceived() |
88 { | 91 { |
89 ASSERT(m_decoder); | 92 ASSERT(m_decoder); |
90 if (m_hasReceivedSomeData) | 93 if (m_hasReceivedSomeData) |
91 return; | 94 return; |
92 m_hasReceivedSomeData = true; | 95 m_hasReceivedSomeData = true; |
93 if (m_decoder->encoding().usesVisualOrdering()) | 96 if (m_decoder->encoding().usesVisualOrdering()) |
(...skipping 10 matching lines...) Expand all Loading... |
104 size_t consumedChars = m_parser->appendBytes(bytes, length); | 107 size_t consumedChars = m_parser->appendBytes(bytes, length); |
105 if (consumedChars) | 108 if (consumedChars) |
106 reportDataReceived(); | 109 reportDataReceived(); |
107 } | 110 } |
108 | 111 |
109 void DocumentWriter::end() | 112 void DocumentWriter::end() |
110 { | 113 { |
111 ASSERT(m_document); | 114 ASSERT(m_document); |
112 | 115 |
113 // http://bugs.webkit.org/show_bug.cgi?id=10854 | 116 // http://bugs.webkit.org/show_bug.cgi?id=10854 |
114 // The frame's last ref may be removed and it can be deleted by checkComplet
ed(), | 117 // The frame's last ref may be removed and it can be deleted by checkComplet
ed(), |
115 // so we'll add a protective refcount | 118 // so we'll add a protective refcount |
116 RefPtr<Frame> protector(m_document->frame()); | 119 RefPtr<Frame> protector(m_document->frame()); |
117 | 120 |
118 if (!m_parser) | 121 if (!m_parser) |
119 return; | 122 return; |
120 | 123 |
121 if (!m_decoder && m_parser->needsDecoder()) | 124 if (!m_decoder && m_parser->needsDecoder()) |
122 m_decoder = m_decoderBuilder.buildFor(m_document); | 125 m_decoder = m_decoderBuilder.buildFor(m_document); |
123 // flush() can result replacing DocumentLoader::m_writer. | 126 // flush() can result replacing DocumentLoader::m_writer. |
124 RefPtr<DocumentWriter> protectingThis(this); | 127 RefPtr<DocumentWriter> protectingThis(this); |
125 size_t consumedChars = m_parser->flush(); | 128 size_t consumedChars = m_parser->flush(); |
126 if (consumedChars) | 129 if (consumedChars) |
127 reportDataReceived(); | 130 reportDataReceived(); |
128 if (!m_parser) | 131 if (!m_parser) |
129 return; | 132 return; |
130 | 133 |
131 m_parser->finish(); | 134 m_parser->finish(); |
132 m_parser = 0; | 135 m_parser = 0; |
133 m_document = 0; | 136 m_document = 0; |
134 } | 137 } |
135 | 138 |
136 void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation() | 139 void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation() |
137 { | 140 { |
138 ASSERT(m_parser && !m_parser->isStopped()); | 141 ASSERT(m_parser && !m_parser->isStopped()); |
139 m_parser->setDocumentWasLoadedAsPartOfNavigation(); | 142 m_parser->setDocumentWasLoadedAsPartOfNavigation(); |
140 } | 143 } |
141 | 144 |
142 } // namespace WebCore | 145 } // namespace WebCore |
OLD | NEW |