diff options
Diffstat (limited to 'WebCore/loader/DocumentWriter.cpp')
-rw-r--r-- | WebCore/loader/DocumentWriter.cpp | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/WebCore/loader/DocumentWriter.cpp b/WebCore/loader/DocumentWriter.cpp index 2ea1afd..d99f340 100644 --- a/WebCore/loader/DocumentWriter.cpp +++ b/WebCore/loader/DocumentWriter.cpp @@ -38,12 +38,14 @@ #include "FrameView.h" #include "PlaceholderDocument.h" #include "PluginDocument.h" +#include "RawDataDocumentParser.h" +#include "ScriptableDocumentParser.h" #include "SecurityOrigin.h" #include "SegmentedString.h" #include "Settings.h" #include "SinkDocument.h" #include "TextResourceDecoder.h" -#include "DocumentParser.h" + namespace WebCore { @@ -73,10 +75,10 @@ void DocumentWriter::replaceDocument(const String& source) m_frame->document()->setParseMode(Document::Strict); } - // FIXME: If we wanted to support the <img src='javascript:'imagedata'> - // case then we would need to call addData(char*, int) instead. + // FIXME: This should call DocumentParser::appendBytes instead of append + // to support RawDataDocumentParsers. if (DocumentParser* parser = m_frame->document()->parser()) - parser->write(source, true); + parser->append(source); } end(); @@ -143,21 +145,8 @@ void DocumentWriter::begin(const KURL& url, bool dispatch, SecurityOrigin* origi m_frame->view()->setContentsSize(IntSize()); } -void DocumentWriter::addData(const char* str, int len, bool flush) +TextResourceDecoder* DocumentWriter::createDecoderIfNeeded() { - if (len == 0 && !flush) - return; - - if (len == -1) - len = strlen(str); - - DocumentParser* parser = m_frame->document()->parser(); - if (parser && parser->wantsRawData()) { - if (len > 0) - parser->writeRawData(str, len); - return; - } - if (!m_decoder) { if (Settings* settings = m_frame->settings()) { m_decoder = TextResourceDecoder::create(m_mimeType, @@ -187,24 +176,28 @@ void DocumentWriter::addData(const char* str, int len, bool flush) } m_frame->document()->setDecoder(m_decoder.get()); } + return m_decoder.get(); +} - String decoded = m_decoder->decode(str, len); - if (flush) - decoded += m_decoder->flush(); - if (decoded.isEmpty()) - return; - +void DocumentWriter::reportDataRecieved() +{ + ASSERT(m_decoder); if (!m_receivedData) { m_receivedData = true; if (m_decoder->encoding().usesVisualOrdering()) m_frame->document()->setVisuallyOrdered(); m_frame->document()->recalcStyle(Node::Force); } +} - if (parser) { - ASSERT(!parser->wantsRawData()); - parser->write(decoded, true); - } +void DocumentWriter::addData(const char* str, int len, bool flush) +{ + if (len == -1) + len = strlen(str); + + DocumentParser* parser = m_frame->document()->parser(); + if (parser) + parser->appendBytes(this, str, len, flush); } void DocumentWriter::end() |