diff options
author | Feng Qian <> | 2009-04-10 18:11:29 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-04-10 18:11:29 -0700 |
commit | 8f72e70a9fd78eec56623b3a62e68f16b7b27e28 (patch) | |
tree | 181bf9a400c30a1bf34ea6d72560e8d00111d549 /WebCore/loader/TextDocument.cpp | |
parent | 7ed56f225e0ade046e1c2178977f72b2d896f196 (diff) | |
download | external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.zip external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.tar.gz external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.tar.bz2 |
AI 145796: Land the WebKit merge @r42026.
Automated import of CL 145796
Diffstat (limited to 'WebCore/loader/TextDocument.cpp')
-rw-r--r-- | WebCore/loader/TextDocument.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/WebCore/loader/TextDocument.cpp b/WebCore/loader/TextDocument.cpp index bd2c446..0d86c1b 100644 --- a/WebCore/loader/TextDocument.cpp +++ b/WebCore/loader/TextDocument.cpp @@ -41,9 +41,10 @@ using namespace HTMLNames; class TextTokenizer : public Tokenizer { public: TextTokenizer(Document*); + virtual ~TextTokenizer(); TextTokenizer(HTMLViewSourceDocument*); - virtual bool write(const SegmentedString&, bool appendData); + virtual void write(const SegmentedString&, bool appendData); virtual void finish(); virtual bool isWaitingForScripts() const; @@ -91,9 +92,15 @@ TextTokenizer::TextTokenizer(HTMLViewSourceDocument* doc) m_size = 254; m_buffer = static_cast<UChar*>(fastMalloc(sizeof(UChar) * m_size)); m_dest = m_buffer; -} +} + +TextTokenizer::~TextTokenizer() +{ + // finish() should have been called to prevent any leaks + ASSERT(!m_buffer); +} -bool TextTokenizer::write(const SegmentedString& s, bool) +void TextTokenizer::write(const SegmentedString& s, bool) { ExceptionCode ec; @@ -125,13 +132,13 @@ bool TextTokenizer::write(const SegmentedString& s, bool) } if (!m_preElement && !inViewSourceMode()) { - RefPtr<Element> rootElement = m_doc->createElementNS(xhtmlNamespaceURI, "html", ec); + RefPtr<Element> rootElement = m_doc->createElement(htmlTag, false); m_doc->appendChild(rootElement, ec); - RefPtr<Element> body = m_doc->createElementNS(xhtmlNamespaceURI, "body", ec); + RefPtr<Element> body = m_doc->createElement(bodyTag, false); rootElement->appendChild(body, ec); - RefPtr<Element> preElement = m_doc->createElementNS(xhtmlNamespaceURI, "pre", ec); + RefPtr<Element> preElement = m_doc->createElement(preTag, false); preElement->setAttribute("style", "word-wrap: break-word; white-space: pre-wrap;", ec); body->appendChild(preElement, ec); @@ -142,7 +149,7 @@ bool TextTokenizer::write(const SegmentedString& s, bool) String string = String(m_buffer, m_dest - m_buffer); if (inViewSourceMode()) { static_cast<HTMLViewSourceDocument*>(m_doc)->addViewSourceText(string); - return false; + return; } unsigned charsLeft = string.length(); @@ -151,15 +158,15 @@ bool TextTokenizer::write(const SegmentedString& s, bool) RefPtr<Text> text = Text::createWithLengthLimit(m_doc, string, charsLeft); m_preElement->appendChild(text, ec); } - - return false; } void TextTokenizer::finish() { m_preElement = 0; fastFree(m_buffer); - + m_buffer = 0; + m_dest = 0; + m_doc->finishedParsing(); } |