summaryrefslogtreecommitdiffstats
path: root/WebCore/loader/TextDocument.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
commit1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch)
tree4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebCore/loader/TextDocument.cpp
parent9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff)
downloadexternal_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebCore/loader/TextDocument.cpp')
-rw-r--r--WebCore/loader/TextDocument.cpp43
1 files changed, 40 insertions, 3 deletions
diff --git a/WebCore/loader/TextDocument.cpp b/WebCore/loader/TextDocument.cpp
index b5124b4..6b06ede 100644
--- a/WebCore/loader/TextDocument.cpp
+++ b/WebCore/loader/TextDocument.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -38,6 +38,38 @@ namespace WebCore {
using namespace HTMLNames;
+class TextTokenizer : public Tokenizer {
+public:
+ TextTokenizer(Document*);
+ TextTokenizer(HTMLViewSourceDocument*);
+
+ virtual bool write(const SegmentedString&, bool appendData);
+ virtual void finish();
+ virtual bool isWaitingForScripts() const;
+
+ inline void checkBuffer(int len = 10)
+ {
+ if ((m_dest - m_buffer) > m_size - len) {
+ // Enlarge buffer
+ int newSize = std::max(m_size * 2, m_size + len);
+ int oldOffset = m_dest - m_buffer;
+ m_buffer = static_cast<UChar*>(fastRealloc(m_buffer, newSize * sizeof(UChar)));
+ m_dest = m_buffer + oldOffset;
+ m_size = newSize;
+ }
+ }
+
+private:
+ Document* m_doc;
+ Element* m_preElement;
+
+ bool m_skipLF;
+
+ int m_size;
+ UChar* m_buffer;
+ UChar* m_dest;
+};
+
TextTokenizer::TextTokenizer(Document* doc)
: m_doc(doc)
, m_preElement(0)
@@ -137,8 +169,8 @@ bool TextTokenizer::isWaitingForScripts() const
return false;
}
-TextDocument::TextDocument(DOMImplementation* implementation, Frame* frame)
- : HTMLDocument(implementation, frame)
+TextDocument::TextDocument(Frame* frame)
+ : HTMLDocument(frame)
{
}
@@ -147,4 +179,9 @@ Tokenizer* TextDocument::createTokenizer()
return new TextTokenizer(this);
}
+Tokenizer* createTextTokenizer(HTMLViewSourceDocument* document)
+{
+ return new TextTokenizer(document);
+}
+
}