[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
hyatt
hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:25:40 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 3b4f6d4c6fe4e72fb3ac263860d30b42b4b7056d
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Feb 7 01:19:44 2004 +0000
Implemented a TokenizerString that can walk a list of substrings, so that data can be enqueued
in the list without having to do a copy. Speeds up voodooextreme by 20% or so, giving the overall
page-load tests get a 2% boost.
Reviewed by darin
* WebCore.pbproj/project.pbxproj:
* khtml/html/html_documentimpl.h:
* khtml/html/htmltokenizer.cpp:
(khtml::HTMLTokenizer::begin):
(khtml::HTMLTokenizer::processListing):
(khtml::HTMLTokenizer::parseSpecial):
(khtml::HTMLTokenizer::scriptHandler):
(khtml::HTMLTokenizer::parseComment):
(khtml::HTMLTokenizer::parseServer):
(khtml::HTMLTokenizer::parseProcessingInstruction):
(khtml::HTMLTokenizer::parseText):
(khtml::HTMLTokenizer::parseEntity):
(khtml::HTMLTokenizer::parseTag):
(khtml::HTMLTokenizer::write):
(khtml::HTMLTokenizer::notifyFinished):
(khtml::HTMLTokenizer::setSrc):
(khtml::HTMLTokenizer::setOnHold):
* khtml/html/htmltokenizer.h:
(khtml::Token::Token):
(khtml::Token::~Token):
(khtml::Token::addAttribute):
(khtml::Token::reset):
* khtml/khtml_part.cpp:
(KHTMLPart::handleMousePressEventDoubleClick):
* khtml/khtml_part.h:
* khtml/misc/stringit.cpp: Added.
(khtml::TokenizerString::length):
(khtml::TokenizerString::clear):
(khtml::TokenizerString::append):
(khtml::TokenizerString::prepend):
(khtml::TokenizerString::advanceSubstring):
(khtml::TokenizerString::toString):
* khtml/misc/stringit.h:
(khtml::TokenizerSubstring::TokenizerSubstring):
(khtml::TokenizerSubstring::clear):
(khtml::TokenizerSubstring::appendTo):
(khtml::TokenizerString::TokenizerString):
(khtml::TokenizerString::push):
(khtml::TokenizerString::isEmpty):
(khtml::TokenizerString::advance):
(khtml::TokenizerString::escaped):
(khtml::TokenizerString::lineCount):
(khtml::TokenizerString::resetLineCount):
(khtml::TokenizerString::operator++):
(khtml::TokenizerString::operator*):
(khtml::TokenizerString::operator->):
(khtml::TokenizerString::current):
* khtml/xbl/xbl_docimpl.cpp:
* khtml/xbl/xbl_docimpl.h:
(XBL::):
* khtml/xbl/xbl_tokenizer.h:
(XBL::):
* khtml/xml/dom_docimpl.h:
(DOM::DocumentImpl::tokenizer):
* khtml/xml/xml_tokenizer.cpp:
(khtml::XMLTokenizer::write):
* khtml/xml/xml_tokenizer.h:
* kwq/KWQSignalStubs.mm:
* kwq/KWQValueList.h:
(QValueList::insert):
(QValueList::fromLast):
* kwq/KWQValueListImpl.h:
* kwq/KWQValueListImpl.mm:
(KWQValueListImpl::clear):
(KWQValueListImpl::insert):
(KWQValueListImpl::fromLast):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6045 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index c17fe40..100e0a5 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,78 @@
+2004-02-06 David Hyatt <hyatt at apple.com>
+
+ Implemented a TokenizerString that can walk a list of substrings, so that data can be enqueued
+ in the list without having to do a copy. Speeds up voodooextreme by 20% or so, giving the overall
+ page-load tests get a 2% boost.
+
+ Reviewed by darin
+
+ * WebCore.pbproj/project.pbxproj:
+ * khtml/html/html_documentimpl.h:
+ * khtml/html/htmltokenizer.cpp:
+ (khtml::HTMLTokenizer::begin):
+ (khtml::HTMLTokenizer::processListing):
+ (khtml::HTMLTokenizer::parseSpecial):
+ (khtml::HTMLTokenizer::scriptHandler):
+ (khtml::HTMLTokenizer::parseComment):
+ (khtml::HTMLTokenizer::parseServer):
+ (khtml::HTMLTokenizer::parseProcessingInstruction):
+ (khtml::HTMLTokenizer::parseText):
+ (khtml::HTMLTokenizer::parseEntity):
+ (khtml::HTMLTokenizer::parseTag):
+ (khtml::HTMLTokenizer::write):
+ (khtml::HTMLTokenizer::notifyFinished):
+ (khtml::HTMLTokenizer::setSrc):
+ (khtml::HTMLTokenizer::setOnHold):
+ * khtml/html/htmltokenizer.h:
+ (khtml::Token::Token):
+ (khtml::Token::~Token):
+ (khtml::Token::addAttribute):
+ (khtml::Token::reset):
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::handleMousePressEventDoubleClick):
+ * khtml/khtml_part.h:
+ * khtml/misc/stringit.cpp: Added.
+ (khtml::TokenizerString::length):
+ (khtml::TokenizerString::clear):
+ (khtml::TokenizerString::append):
+ (khtml::TokenizerString::prepend):
+ (khtml::TokenizerString::advanceSubstring):
+ (khtml::TokenizerString::toString):
+ * khtml/misc/stringit.h:
+ (khtml::TokenizerSubstring::TokenizerSubstring):
+ (khtml::TokenizerSubstring::clear):
+ (khtml::TokenizerSubstring::appendTo):
+ (khtml::TokenizerString::TokenizerString):
+ (khtml::TokenizerString::push):
+ (khtml::TokenizerString::isEmpty):
+ (khtml::TokenizerString::advance):
+ (khtml::TokenizerString::escaped):
+ (khtml::TokenizerString::lineCount):
+ (khtml::TokenizerString::resetLineCount):
+ (khtml::TokenizerString::operator++):
+ (khtml::TokenizerString::operator*):
+ (khtml::TokenizerString::operator->):
+ (khtml::TokenizerString::current):
+ * khtml/xbl/xbl_docimpl.cpp:
+ * khtml/xbl/xbl_docimpl.h:
+ (XBL::):
+ * khtml/xbl/xbl_tokenizer.h:
+ (XBL::):
+ * khtml/xml/dom_docimpl.h:
+ (DOM::DocumentImpl::tokenizer):
+ * khtml/xml/xml_tokenizer.cpp:
+ (khtml::XMLTokenizer::write):
+ * khtml/xml/xml_tokenizer.h:
+ * kwq/KWQSignalStubs.mm:
+ * kwq/KWQValueList.h:
+ (QValueList::insert):
+ (QValueList::fromLast):
+ * kwq/KWQValueListImpl.h:
+ * kwq/KWQValueListImpl.mm:
+ (KWQValueListImpl::clear):
+ (KWQValueListImpl::insert):
+ (KWQValueListImpl::fromLast):
+
=== Safari-127 ===
2004-02-06 Ken Kocienda <kocienda at apple.com>
diff --git a/WebCore/WebCore.pbproj/project.pbxproj b/WebCore/WebCore.pbproj/project.pbxproj
index aa5bcac..d8086a9 100644
--- a/WebCore/WebCore.pbproj/project.pbxproj
+++ b/WebCore/WebCore.pbproj/project.pbxproj
@@ -800,6 +800,7 @@
BEB1DD3D05C1982000DD1F43,
BC7FDE3305C1D9AB0070A902,
BC3B364805C9D5E200E42902,
+ BC433AD005D3046F003A5A14,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -1949,6 +1950,20 @@
settings = {
};
};
+ BC433ACF05D3046F003A5A14 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ path = stringit.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ BC433AD005D3046F003A5A14 = {
+ fileRef = BC433ACF05D3046F003A5A14;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
BC7294F703804B3C00A80166 = {
fileEncoding = 30;
isa = PBXFileReference;
@@ -5118,6 +5133,7 @@
F523D28502DE43D7018635CA,
F523D28602DE43D7018635CA,
F523D28802DE43D7018635CA,
+ BC433ACF05D3046F003A5A14,
F523D28902DE43D7018635CA,
BC7294F703804B3C00A80166,
BC7294F803804B3C00A80166,
diff --git a/WebCore/khtml/html/html_documentimpl.h b/WebCore/khtml/html/html_documentimpl.h
index 7f45d4b..065f6a3 100644
--- a/WebCore/khtml/html/html_documentimpl.h
+++ b/WebCore/khtml/html/html_documentimpl.h
@@ -70,7 +70,7 @@ public:
void setBody(HTMLElementImpl *_body, int& exceptioncode);
- virtual Tokenizer *createTokenizer();
+ virtual khtml::Tokenizer *createTokenizer();
virtual bool childAllowed( NodeImpl *newChild );
diff --git a/WebCore/khtml/html/htmltokenizer.cpp b/WebCore/khtml/html/htmltokenizer.cpp
index 36f6fac..7f88a69 100644
--- a/WebCore/khtml/html/htmltokenizer.cpp
+++ b/WebCore/khtml/html/htmltokenizer.cpp
@@ -63,7 +63,7 @@
#include "kentities.c"
#undef __inline
-using namespace khtml;
+namespace khtml {
static const char commentStart [] = "<!--";
static const char scriptEnd [] = "</script";
@@ -304,7 +304,7 @@ void HTMLTokenizer::begin()
Entity = NoEntity;
loadingExtScript = false;
scriptSrc = QString::null;
- pendingSrc = QString::null;
+ pendingSrc.clear();
noMoreData = false;
brokenComments = false;
brokenServer = false;
@@ -313,7 +313,7 @@ void HTMLTokenizer::begin()
tagStartLineno = 0;
}
-void HTMLTokenizer::processListing(DOMStringIt list)
+void HTMLTokenizer::processListing(TokenizerString list)
{
bool old_pre = pre;
// This function adds the listing 'list' as
@@ -322,7 +322,7 @@ void HTMLTokenizer::processListing(DOMStringIt list)
if(!style) pre = true;
prePos = 0;
- while ( list.length() )
+ while ( !list.isEmpty() )
{
checkBuffer(3*TAB_SIZE);
@@ -390,7 +390,7 @@ void HTMLTokenizer::processListing(DOMStringIt list)
pre = old_pre;
}
-void HTMLTokenizer::parseSpecial(DOMStringIt &src)
+void HTMLTokenizer::parseSpecial(TokenizerString &src)
{
assert( textarea || title || !Entity );
assert( !tag );
@@ -400,7 +400,7 @@ void HTMLTokenizer::parseSpecial(DOMStringIt &src)
if ( comment ) parseComment( src );
- while ( src.length() ) {
+ while ( !src.isEmpty() ) {
checkScriptBuffer();
unsigned char ch = src->latin1();
if ( !scriptCodeResync && !brokenComments && !textarea && !xmp && !title && ch == '-' && scriptCodeSize >= 3 && !src.escaped() && scriptCode[scriptCodeSize-3] == '<' && scriptCode[scriptCodeSize-2] == '!' && scriptCode[scriptCodeSize-1] == '-' ) {
@@ -416,7 +416,7 @@ void HTMLTokenizer::parseSpecial(DOMStringIt &src)
if ( script )
scriptHandler();
else {
- processListing(DOMStringIt(scriptCode, scriptCodeSize));
+ processListing(TokenizerString(scriptCode, scriptCodeSize));
processToken();
if ( style ) { currToken.id = ID_STYLE + ID_CLOSE_TAG; }
else if ( textarea ) { currToken.id = ID_TEXTAREA + ID_CLOSE_TAG; }
@@ -484,24 +484,20 @@ void HTMLTokenizer::scriptHandler()
// Parse scriptCode containing <script> info
doScriptExec = true;
}
- processListing(DOMStringIt(scriptCode, scriptCodeSize));
+ processListing(TokenizerString(scriptCode, scriptCodeSize));
QString exScript( buffer, dest-buffer );
processToken();
currToken.id = ID_SCRIPT + ID_CLOSE_TAG;
processToken();
- QString prependingSrc;
+ TokenizerString prependingSrc;
if ( !parser->skipMode() ) {
if (cs) {
//kdDebug( 6036 ) << "cachedscript extern!" << endl;
//kdDebug( 6036 ) << "src: *" << QString( src.current(), src.length() ).latin1() << "*" << endl;
//kdDebug( 6036 ) << "pending: *" << pendingSrc.latin1() << "*" << endl;
-#if APPLE_CHANGES
- pendingSrc.prepend(src.current(), src.length());
-#else
- pendingSrc.prepend( QString(src.current(), src.length() ) );
-#endif
- setSrc(QString::null);
+ pendingSrc.prepend(src);
+ setSrc(TokenizerString());
scriptCodeSize = scriptCodeResync = 0;
cs->ref(this);
// will be 0 if script was already loaded and ref() executed it
@@ -509,19 +505,11 @@ void HTMLTokenizer::scriptHandler()
loadingExtScript = true;
}
else if (view && doScriptExec && javascript ) {
-#if APPLE_CHANGES
if (!m_executingScript)
- pendingSrc.prepend(src.current(), src.length());
+ pendingSrc.prepend(src);
else
- prependingSrc.setUnicode(src.current(), src.length());
-#else
- if ( !m_executingScript )
- pendingSrc.prepend( QString( src.current(), src.length() ) ); // deep copy - again
- else
- prependingSrc = QString( src.current(), src.length() ); // deep copy
-#endif
-
- setSrc(QString::null);
+ prependingSrc = src;
+ setSrc(TokenizerString());
scriptCodeSize = scriptCodeResync = 0;
//QTime dt;
//dt.start();
@@ -535,15 +523,10 @@ void HTMLTokenizer::scriptHandler()
if ( !m_executingScript && !loadingExtScript ) {
// kdDebug( 6036 ) << "adding pending Output to parsed string" << endl;
-#if APPLE_CHANGES
- pendingSrc.prepend(src.current(), src.length());
-#else
- pendingSrc.prepend(QString(src.current(), src.length()));
-#endif
- setSrc(pendingSrc);
- pendingSrc = QString::null;
- } else if ( !prependingSrc.isEmpty() ) {
- write( prependingSrc, false );
+ src.append(pendingSrc);
+ pendingSrc.clear();
+ } else {
+ write(prependingSrc, false);
}
}
@@ -568,10 +551,10 @@ void HTMLTokenizer::scriptExecution( const QString& str, QString scriptURL,
script = oldscript;
}
-void HTMLTokenizer::parseComment(DOMStringIt &src)
+void HTMLTokenizer::parseComment(TokenizerString &src)
{
checkScriptBuffer(src.length());
- while ( src.length() ) {
+ while ( !src.isEmpty() ) {
scriptCode[ scriptCodeSize++ ] = *src;
#if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 1
qDebug("comment is now: *%s*",
@@ -593,7 +576,7 @@ void HTMLTokenizer::parseComment(DOMStringIt &src)
scriptCode[ scriptCodeSize ] = 0;
scriptCode[ scriptCodeSize + 1 ] = 0;
currToken.id = ID_COMMENT;
- processListing(DOMStringIt(scriptCode, scriptCodeSize - 2));
+ processListing(TokenizerString(scriptCode, scriptCodeSize - 2));
processToken();
currToken.id = ID_COMMENT + ID_CLOSE_TAG;
processToken();
@@ -607,10 +590,10 @@ void HTMLTokenizer::parseComment(DOMStringIt &src)
}
}
-void HTMLTokenizer::parseServer(DOMStringIt &src)
+void HTMLTokenizer::parseServer(TokenizerString &src)
{
checkScriptBuffer(src.length());
- while ( src.length() ) {
+ while ( !src.isEmpty() ) {
scriptCode[ scriptCodeSize++ ] = *src;
if (src->unicode() == '>' &&
scriptCodeSize > 1 && scriptCode[scriptCodeSize-2] == '%') {
@@ -623,10 +606,10 @@ void HTMLTokenizer::parseServer(DOMStringIt &src)
}
}
-void HTMLTokenizer::parseProcessingInstruction(DOMStringIt &src)
+void HTMLTokenizer::parseProcessingInstruction(TokenizerString &src)
{
char oldchar = 0;
- while ( src.length() )
+ while ( !src.isEmpty() )
{
unsigned char chbegin = src->latin1();
if(chbegin == '\'') {
@@ -651,9 +634,9 @@ void HTMLTokenizer::parseProcessingInstruction(DOMStringIt &src)
}
}
-void HTMLTokenizer::parseText(DOMStringIt &src)
+void HTMLTokenizer::parseText(TokenizerString &src)
{
- while ( src.length() )
+ while ( !src.isEmpty() )
{
// do we need to enlarge the buffer?
checkBuffer();
@@ -689,7 +672,7 @@ void HTMLTokenizer::parseText(DOMStringIt &src)
}
-void HTMLTokenizer::parseEntity(DOMStringIt &src, QChar *&dest, bool start)
+void HTMLTokenizer::parseEntity(TokenizerString &src, QChar *&dest, bool start)
{
if( start )
{
@@ -698,7 +681,7 @@ void HTMLTokenizer::parseEntity(DOMStringIt &src, QChar *&dest, bool start)
EntityUnicodeValue = 0;
}
- while( src.length() )
+ while( !src.isEmpty() )
{
ushort cc = src->unicode();
switch(Entity) {
@@ -841,11 +824,11 @@ void HTMLTokenizer::parseEntity(DOMStringIt &src, QChar *&dest, bool start)
}
}
-void HTMLTokenizer::parseTag(DOMStringIt &src)
+void HTMLTokenizer::parseTag(TokenizerString &src)
{
assert(!Entity );
- while ( src.length() )
+ while ( !src.isEmpty() )
{
checkBuffer();
#if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 1
@@ -943,7 +926,7 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
// Look up the tagID for the specified tag name (now that we've shaved off any
// invalid / that might have followed the name).
- uint tagID = khtml::getTagID(ptr, len);
+ uint tagID = getTagID(ptr, len);
if (!tagID) {
#ifdef TOKEN_DEBUG
QCString tmp(ptr, len+1);
@@ -972,7 +955,7 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
#endif
bool atespace = false;
ushort curchar;
- while(src.length()) {
+ while(!src.isEmpty()) {
curchar = *src;
if(curchar > ' ') {
if (curchar == '<' || curchar == '>')
@@ -1009,7 +992,7 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
if(curchar <= ' ' || curchar == '=' || curchar == '>') {
unsigned int a;
cBuffer[cBufferPos] = '\0';
- a = khtml::getAttrID(cBuffer, cBufferPos);
+ a = getAttrID(cBuffer, cBufferPos);
if (a)
attrNamePresent = true;
else {
@@ -1062,7 +1045,7 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
#endif
ushort curchar;
bool atespace = false;
- while(src.length()) {
+ while(!src.isEmpty()) {
curchar = src->unicode();
if(curchar > ' ') {
if(curchar == '=') {
@@ -1094,7 +1077,7 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
case SearchValue:
{
ushort curchar;
- while(src.length()) {
+ while(!src.isEmpty()) {
curchar = src->unicode();
if(curchar > ' ') {
if(( curchar == '\'' || curchar == '\"' )) {
@@ -1116,7 +1099,7 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
qDebug("QuotedValue");
#endif
ushort curchar;
- while(src.length()) {
+ while(!src.isEmpty()) {
checkBuffer();
curchar = src->unicode();
@@ -1178,7 +1161,7 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
qDebug("Value");
#endif
ushort curchar;
- while(src.length()) {
+ while(!src.isEmpty()) {
checkBuffer();
curchar = src->unicode();
if(curchar <= '>' && !src.escaped()) {
@@ -1213,7 +1196,7 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
#if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 1
qDebug("SearchEnd");
#endif
- while(src.length()) {
+ while(!src.isEmpty()) {
if (*src == '>' || *src == '<')
break;
@@ -1222,7 +1205,7 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
++src;
}
- if (!src.length() && *src != '>' && *src != '<') break;
+ if (src.isEmpty()) break;
searchCount = 0; // Stop looking for '<!--' sequence
tag = NoTag;
@@ -1252,7 +1235,7 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
view /* are we a regular tokenizer or just for innerHTML ? */
) {
if ( ( a = currToken.attrs->getAttributeItem( ATTR_SRC ) ) )
- scriptSrc = parser->doc()->completeURL(khtml::parseURL( a->value() ).string() );
+ scriptSrc = parser->doc()->completeURL(parseURL( a->value() ).string() );
if ( ( a = currToken.attrs->getAttributeItem( ATTR_CHARSET ) ) )
scriptSrcCharset = a->value().string().stripWhiteSpace();
if ( scriptSrcCharset.isEmpty() )
@@ -1401,7 +1384,7 @@ void HTMLTokenizer::addPending()
pending = NonePending;
}
-void HTMLTokenizer::write( const QString &str, bool appendData )
+void HTMLTokenizer::write(const TokenizerString &str, bool appendData)
{
#ifdef TOKEN_DEBUG
kdDebug( 6036 ) << this << " Tokenizer::write(\"" << str << "\"," << appendData << ")" << endl;
@@ -1413,18 +1396,16 @@ void HTMLTokenizer::write( const QString &str, bool appendData )
if ( ( m_executingScript && appendData ) ||
( !m_executingScript && loadingExtScript ) ) {
// don't parse; we will do this later
- pendingSrc += str;
+ pendingSrc.append(str);
return;
}
if ( onHold ) {
- QString rest = QString( src.current(), src.length() );
- rest += str;
- setSrc(rest);
+ src.append(str);
return;
}
- else
- setSrc(str);
+
+ setSrc(str);
#ifndef NDEBUG
inWrite = true;
@@ -1433,8 +1414,7 @@ void HTMLTokenizer::write( const QString &str, bool appendData )
// if (Entity)
// parseEntity(src, dest);
- while ( src.length() )
- {
+ while (!src.isEmpty()) {
// do we need to enlarge the buffer?
checkBuffer();
@@ -1642,7 +1622,6 @@ void HTMLTokenizer::write( const QString &str, bool appendData )
++src;
}
}
- _src = QString::null;
#ifndef NDEBUG
inWrite = false;
@@ -1812,7 +1791,7 @@ void HTMLTokenizer::notifyFinished(CachedObject */*finishedObj*/)
#ifdef TOKEN_DEBUG
kdDebug( 6036 ) << "External script is:" << endl << scriptSource.string() << endl;
#endif
- setSrc(QString::null);
+ setSrc(TokenizerString());
// make sure we forget about the script before we execute the new one
// infinite recursion might happen otherwise
@@ -1829,8 +1808,8 @@ void HTMLTokenizer::notifyFinished(CachedObject */*finishedObj*/)
// parseScript(). In that case parseScript() will take care
// of 'scriptOutput'.
if ( !script ) {
- QString rest = pendingSrc;
- pendingSrc = "";
+ TokenizerString rest = pendingSrc;
+ pendingSrc.clear();
write(rest, false);
// we might be deleted at this point, do not
// access any members.
@@ -1843,18 +1822,17 @@ bool HTMLTokenizer::isWaitingForScripts()
return loadingExtScript;
}
-void HTMLTokenizer::setSrc(const QString &source)
+void HTMLTokenizer::setSrc(const TokenizerString &source)
{
lineno += src.lineCount();
- _src = source;
- src = DOMStringIt(_src);
+ src = source;
+ src.resetLineCount();
}
void HTMLTokenizer::setOnHold(bool _onHold)
{
if (onHold == _onHold) return;
onHold = _onHold;
- if (onHold)
- setSrc(QString(src.current(), src.length())); // ### deep copy
}
+}
diff --git a/WebCore/khtml/html/htmltokenizer.h b/WebCore/khtml/html/htmltokenizer.h
index c111403..97f24dd 100644
--- a/WebCore/khtml/html/htmltokenizer.h
+++ b/WebCore/khtml/html/htmltokenizer.h
@@ -29,17 +29,12 @@
#ifndef HTMLTOKENIZER_H
#define HTMLTOKENIZER_H
-class KCharsets;
-class StringTokenizer;
-class HTMLTokenizer;
-
#include <qstring.h>
#include <qobject.h>
#include <qptrqueue.h>
#include "misc/loader_client.h"
#include "misc/htmltags.h"
-#include "misc/stringit.h"
#include "xml/dom_stringimpl.h"
#include "xml/xml_tokenizer.h"
#include "html/html_elementimpl.h"
@@ -51,6 +46,7 @@ class HTMLTokenizer;
#endif
#endif
+class KCharsets;
class KHTMLParser;
class KHTMLView;
@@ -60,64 +56,64 @@ namespace DOM {
}
namespace khtml {
- class CachedScript;
+class CachedScript;
- /**
- * @internal
- * represents one HTML tag. Consists of a numerical id, and the list
- * of attributes. Can also represent text. In this case the id = 0 and
- * text contains the text.
- */
- class Token
+
+/**
+ * @internal
+ * represents one HTML tag. Consists of a numerical id, and the list
+ * of attributes. Can also represent text. In this case the id = 0 and
+ * text contains the text.
+ */
+class Token
+{
+public:
+ Token() {
+ id = 0;
+ attrs = 0;
+ text = 0;
+ flat = false;
+ //qDebug("new token, creating %08lx", attrs);
+ }
+ ~Token() {
+ if(attrs) attrs->deref();
+ if(text) text->deref();
+ }
+ void addAttribute(DOM::DocumentImpl* doc, QChar* buffer, const QString& attrName, const DOM::AtomicString& v)
{
- public:
- Token() {
- id = 0;
- attrs = 0;
- text = 0;
- flat = false;
- //qDebug("new token, creating %08lx", attrs);
- }
- ~Token() {
- if(attrs) attrs->deref();
- if(text) text->deref();
- }
- void addAttribute(DOM::DocumentImpl* doc, QChar* buffer, const QString& attrName, const DOM::AtomicString& v)
- {
- DOM::AttributeImpl* a = 0;
- if(buffer->unicode())
- a = new DOM::AttributeImpl(buffer->unicode(), v);
- else if ( !attrName.isEmpty() && attrName != "/" )
- a = new DOM::AttributeImpl(doc->attrId(0, DOM::DOMString(attrName).implementation(), false),
- v);
-
- if (a) {
- if(!attrs) {
- attrs = new DOM::HTMLNamedAttrMapImpl(0);
- attrs->ref();
- }
- attrs->insertAttribute(a);
+ DOM::AttributeImpl* a = 0;
+ if(buffer->unicode())
+ a = new DOM::AttributeImpl(buffer->unicode(), v);
+ else if ( !attrName.isEmpty() && attrName != "/" )
+ a = new DOM::AttributeImpl(doc->attrId(0, DOM::DOMString(attrName).implementation(), false),
+ v);
+
+ if (a) {
+ if(!attrs) {
+ attrs = new DOM::HTMLNamedAttrMapImpl(0);
+ attrs->ref();
}
+ attrs->insertAttribute(a);
}
- void reset()
- {
- if(attrs) {
- attrs->deref();
- attrs = 0;
- }
- id = 0;
- if(text) {
- text->deref();
- text = 0;
- }
- flat = false;
+ }
+ void reset()
+ {
+ if(attrs) {
+ attrs->deref();
+ attrs = 0;
}
- DOM::HTMLNamedAttrMapImpl* attrs;
- DOM::DOMStringImpl* text;
- ushort id;
- bool flat;
- };
+ id = 0;
+ if(text) {
+ text->deref();
+ text = 0;
+ }
+ flat = false;
+ }
+ DOM::HTMLNamedAttrMapImpl* attrs;
+ DOM::DOMStringImpl* text;
+ ushort id;
+ bool flat;
};
// The count of spaces used for each tab.
@@ -125,7 +121,7 @@ namespace khtml {
//-----------------------------------------------------------------------------
-class HTMLTokenizer : public Tokenizer, public khtml::CachedObjectClient
+class HTMLTokenizer : public Tokenizer, public CachedObjectClient
{
public:
HTMLTokenizer(DOM::DocumentPtr *, KHTMLView * = 0);
@@ -133,7 +129,7 @@ public:
virtual ~HTMLTokenizer();
void begin();
- void write( const QString &str, bool appendData );
+ void write(const TokenizerString &str, bool appendData);
void end();
void finish();
virtual void setOnHold(bool _onHold);
@@ -142,20 +138,20 @@ protected:
void reset();
void addPending();
void processToken();
- void processListing(khtml::DOMStringIt list);
-
- void parseComment(khtml::DOMStringIt &str);
- void parseServer(khtml::DOMStringIt &str);
- void parseText(khtml::DOMStringIt &str);
- void parseListing(khtml::DOMStringIt &str);
- void parseSpecial(khtml::DOMStringIt &str);
- void parseTag(khtml::DOMStringIt &str);
- void parseEntity(khtml::DOMStringIt &str, QChar *&dest, bool start = false);
- void parseProcessingInstruction(khtml::DOMStringIt &str);
+ void processListing(TokenizerString list);
+
+ void parseComment(TokenizerString &str);
+ void parseServer(TokenizerString &str);
+ void parseText(TokenizerString &str);
+ void parseListing(TokenizerString &str);
+ void parseSpecial(TokenizerString &str);
+ void parseTag(TokenizerString &str);
+ void parseEntity(TokenizerString &str, QChar *&dest, bool start = false);
+ void parseProcessingInstruction(TokenizerString &str);
void scriptHandler();
void scriptExecution(const QString& script, QString scriptURL = QString(),
int baseLine = 0);
- void setSrc(const QString &source);
+ void setSrc(const TokenizerString &source);
// check if we have enough space in the buffer.
// if not enlarge it
@@ -174,7 +170,7 @@ protected:
void enlargeScriptBuffer(int len);
// from CachedObjectClient
- void notifyFinished(khtml::CachedObject *finishedObj);
+ void notifyFinished(CachedObject *finishedObj);
virtual bool isWaitingForScripts();
protected:
@@ -183,7 +179,7 @@ protected:
QChar *buffer;
QChar *dest;
- khtml::Token currToken;
+ Token currToken;
// the size of buffer
int size;
@@ -325,11 +321,11 @@ protected:
QString scriptSrcCharset;
bool javascript;
// the HTML code we will parse after the external script we are waiting for has loaded
- QString pendingSrc;
+ TokenizerString pendingSrc;
// true if we are executing a script while parsing a document. This causes the parsing of
// the output of the script to be postponed until after the script has finished executing
int m_executingScript;
- QPtrQueue<khtml::CachedScript> cachedScript;
+ QPtrQueue<CachedScript> cachedScript;
// you can pause the tokenizer if you need to display a dialog or something
bool onHold;
@@ -349,8 +345,7 @@ protected:
char cBuffer[CBUFLEN+2];
unsigned int cBufferPos;
- QString _src;
- khtml::DOMStringIt src;
+ TokenizerString src;
KCharsets *charsets;
KHTMLParser *parser;
@@ -362,9 +357,10 @@ protected:
#endif
};
+}
+
#if APPLE_CHANGES
#undef id
#endif
#endif // HTMLTOKENIZER
-
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index e808a65..4c59078 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -100,9 +100,10 @@ using namespace DOM;
using khtml::Decoder;
using khtml::EditCommand;
+using khtml::InlineTextBox;
using khtml::RenderObject;
using khtml::RenderText;
-using khtml::InlineTextBox;
+using khtml::Tokenizer;
using KParts::BrowserInterface;
@@ -4480,7 +4481,7 @@ void KHTMLPart::handleMousePressEventDoubleClick(khtml::MousePressEvent *event)
selection.expandToElement(KHTMLSelection::WORD);
}
}
-
+
if (selection.state() != KHTMLSelection::CARET) {
d->m_textElement = KHTMLSelection::WORD;
}
diff --git a/WebCore/khtml/khtml_part.h b/WebCore/khtml/khtml_part.h
index 5f305d5..1d0531a 100644
--- a/WebCore/khtml/khtml_part.h
+++ b/WebCore/khtml/khtml_part.h
@@ -61,27 +61,29 @@ namespace DOM
class Node;
class HTMLEventListener;
class EventListener;
-};
+}
using DOM::TristateFlag;
namespace khtml
{
- class DocLoader;
- class RenderPart;
- class RenderPartObject;
+ class CachedObject;
struct ChildFrame;
- class MouseEvent;
- class MousePressEvent;
+ class CSSStyleSelector;
+ class DocLoader;
+ class DrawContentsEvent;
+ class EditCommand;
+ class HTMLTokenizer;
class MouseDoubleClickEvent;
+ class MouseEvent;
class MouseMoveEvent;
+ class MousePressEvent;
class MouseReleaseEvent;
- class DrawContentsEvent;
- class CachedObject;
+ class RenderPart;
+ class RenderPartObject;
class RenderWidget;
- class CSSStyleSelector;
- class EditCommand;
-};
+ class XMLTokenizer;
+}
namespace KJS {
class Window;
@@ -158,8 +160,8 @@ class KHTMLPart : public KParts::ReadOnlyPart
friend class DOM::DocumentImpl;
friend class DOM::HTMLDocumentImpl;
friend class KHTMLPartBrowserHostExtension;
- friend class HTMLTokenizer;
- friend class XMLTokenizer;
+ friend class khtml::HTMLTokenizer;
+ friend class khtml::XMLTokenizer;
friend class khtml::RenderWidget;
friend class khtml::CSSStyleSelector;
friend class KHTMLPartIface;
diff --git a/WebCore/khtml/misc/stringit.cpp b/WebCore/khtml/misc/stringit.cpp
new file mode 100644
index 0000000..6362693
--- /dev/null
+++ b/WebCore/khtml/misc/stringit.cpp
@@ -0,0 +1,135 @@
+/*
+ This file is part of the KDE libraries
+
+ Copyright (C) 2004 Apple Computer
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "stringit.h"
+
+namespace khtml {
+
+uint TokenizerString::length() const
+{
+ uint length = m_currentString.m_length;
+ if (!m_pushedChar1.isNull()) {
+ ++length;
+ if (!m_pushedChar2.isNull())
+ ++length;
+ }
+ if (m_composite) {
+ QValueListConstIterator<TokenizerSubstring> i = m_substrings.begin();
+ QValueListConstIterator<TokenizerSubstring> e = m_substrings.end();
+ for (; i != e; ++i)
+ length += (*i).m_length;
+ }
+ return length;
+}
+
+void TokenizerString::clear()
+{
+ m_pushedChar1 = 0;
+ m_pushedChar2 = 0;
+ m_currentString.clear();
+ m_substrings.clear();
+ m_lines = 0;
+ m_composite = false;
+}
+
+void TokenizerString::append(const TokenizerSubstring &s)
+{
+ if (s.m_length) {
+ if (!m_currentString.m_length)
+ m_currentString = s;
+ else {
+ m_substrings.append(s);
+ m_composite = true;
+ }
+ }
+}
+
+void TokenizerString::prepend(const TokenizerSubstring &s)
+{
+ assert(!escaped());
+ if (s.m_length) {
+ if (!m_currentString.m_length)
+ m_currentString = s;
+ else {
+ // Shift our m_currentString into our list.
+ m_substrings.prepend(m_currentString);
+ m_currentString = s;
+ m_composite = true;
+ }
+ }
+}
+
+void TokenizerString::append(const TokenizerString &s)
+{
+ assert(!s.escaped());
+ append(s.m_currentString);
+ if (s.m_composite) {
+ QValueListConstIterator<TokenizerSubstring> i = s.m_substrings.begin();
+ QValueListConstIterator<TokenizerSubstring> e = s.m_substrings.end();
+ for (; i != e; ++i)
+ append(*i);
+ }
+}
+
+void TokenizerString::prepend(const TokenizerString &s)
+{
+ assert(!escaped());
+ assert(!s.escaped());
+ if (s.m_composite) {
+ QValueListConstIterator<TokenizerSubstring> i = s.m_substrings.fromLast();
+ QValueListConstIterator<TokenizerSubstring> e = s.m_substrings.end();
+ for (; i != e; --i)
+ prepend(*i);
+ }
+ prepend(s.m_currentString);
+}
+
+void TokenizerString::advanceSubstring()
+{
+ if (m_composite) {
+ m_currentString = m_substrings.first();
+ m_substrings.remove(m_substrings.begin());
+ if (m_substrings.isEmpty())
+ m_composite = false;
+ } else {
+ m_currentString.clear();
+ }
+}
+
+QString TokenizerString::toString() const
+{
+ QString result;
+ if (!m_pushedChar1.isNull()) {
+ result.append(m_pushedChar1);
+ if (!m_pushedChar2.isNull())
+ result.append(m_pushedChar2);
+ }
+ m_currentString.appendTo(result);
+ if (m_composite) {
+ QValueListConstIterator<TokenizerSubstring> i = m_substrings.begin();
+ QValueListConstIterator<TokenizerSubstring> e = m_substrings.end();
+ for (; i != e; ++i)
+ (*i).appendTo(result);
+ }
+ return result;
+}
+
+}
diff --git a/WebCore/khtml/misc/stringit.h b/WebCore/khtml/misc/stringit.h
index 51f36fa..bfc6678 100644
--- a/WebCore/khtml/misc/stringit.h
+++ b/WebCore/khtml/misc/stringit.h
@@ -28,68 +28,101 @@
#include "dom/dom_string.h"
#include <qstring.h>
+#include <qvaluelist.h>
#include <assert.h>
namespace khtml
{
-class DOMStringIt
+class TokenizerString;
+
+class TokenizerSubstring
{
-public:
- DOMStringIt()
- { s = 0, l = 0; lines = 0; }
- DOMStringIt(QChar *str, uint len)
- { s = str, l = len; lines = 0; }
- DOMStringIt(const QString &str)
- { s = str.unicode(); l = str.length(); lines = 0; }
- DOMStringIt(const DOM::DOMString &str)
- { s = str.unicode(); l = str.length(); lines = 0; }
-
- DOMStringIt *operator++()
- {
- if (!pushedChar1.isNull()) {
- pushedChar1 = pushedChar2;
- pushedChar2 = 0;
- } else if (l > 0) {
- if (*s == '\n')
- lines++;
- s++, l--;
+private:
+ friend class TokenizerString;
+
+ TokenizerSubstring() : m_length(0), m_current(0) {}
+ TokenizerSubstring(const QString &str) : m_string(str), m_length(str.length()), m_current(m_length == 0 ? 0 : str.unicode()) {}
+ TokenizerSubstring(const QChar *str, int length) : m_length(length), m_current(length == 0 ? 0 : str) {}
+
+ void clear() { m_length = 0; m_current = 0; }
+
+ void appendTo(QString &str) const {
+ if (m_string.unicode() == m_current) {
+ if (str.isEmpty())
+ str = m_string;
+ else
+ str.append(m_string);
+ } else {
+ str.insert(str.length(), m_current, m_length);
}
- return this;
}
- void push(const QChar& c) {
- if (pushedChar1.isNull())
- pushedChar1 = c;
+ QString m_string;
+ int m_length;
+ const QChar *m_current;
+};
+
+class TokenizerString
+{
+public:
+ TokenizerString() : m_lines(0), m_composite(false) {}
+ TokenizerString(const QChar *str, int length) : m_currentString(str, length), m_lines(0), m_composite(false) {}
+ TokenizerString(const QString &str) : m_currentString(str), m_lines(0), m_composite(false) {}
+
+ void clear();
+
+ void append(const TokenizerString &);
+ void prepend(const TokenizerString &);
+
+ void push(QChar c) {
+ if (m_pushedChar1.isNull())
+ m_pushedChar1 = c;
else {
- assert(pushedChar2.isNull());
- pushedChar2 = c;
+ assert(m_pushedChar2.isNull());
+ m_pushedChar2 = c;
}
}
-
- const QChar *current() const {
- if (!pushedChar1.isNull())
- return &pushedChar1;
- if (!pushedChar2.isNull())
- return &pushedChar2;
- return s;
+
+ bool isEmpty() const { return !current(); }
+ uint length() const;
+
+ void advance() {
+ if (!m_pushedChar1.isNull()) {
+ m_pushedChar1 = m_pushedChar2;
+ m_pushedChar2 = 0;
+ } else if (m_currentString.m_current) {
+ m_lines += *m_currentString.m_current++ == '\n';
+ if (--m_currentString.m_length == 0)
+ advanceSubstring();
+ }
}
- const QChar& operator*() const { return *current(); }
- const QChar* operator->() const { return current(); }
-
- bool escaped() const { return !pushedChar1.isNull(); }
- uint length() const { return l + !pushedChar1.isNull() + !pushedChar2.isNull(); }
+ bool escaped() const { return !m_pushedChar1.isNull(); }
- int lineCount() const { return lines; }
+ int lineCount() const { return m_lines; }
+ void resetLineCount() { m_lines = 0; }
+
+ QString toString() const;
-protected:
- QChar pushedChar1;
- QChar pushedChar2;
- const QChar *s;
- int l;
- int lines;
+ void operator++() { advance(); }
+ const QChar &operator*() const { return *current(); }
+ const QChar *operator->() const { return current(); }
+
+private:
+ void append(const TokenizerSubstring &);
+ void prepend(const TokenizerSubstring &);
+
+ void advanceSubstring();
+ const QChar *current() const { return m_pushedChar1.isNull() ? m_currentString.m_current : &m_pushedChar1; }
+
+ QChar m_pushedChar1;
+ QChar m_pushedChar2;
+ TokenizerSubstring m_currentString;
+ QValueList<TokenizerSubstring> m_substrings;
+ int m_lines;
+ bool m_composite;
};
}
diff --git a/WebCore/khtml/xbl/xbl_docimpl.cpp b/WebCore/khtml/xbl/xbl_docimpl.cpp
index 4b557da..747b6d3 100644
--- a/WebCore/khtml/xbl/xbl_docimpl.cpp
+++ b/WebCore/khtml/xbl/xbl_docimpl.cpp
@@ -5,6 +5,7 @@
#include "xbl_protobinding.h"
using DOM::DocumentImpl;
+using khtml::XMLHandler;
namespace XBL {
diff --git a/WebCore/khtml/xbl/xbl_docimpl.h b/WebCore/khtml/xbl/xbl_docimpl.h
index 4bdecd3..19a990a 100644
--- a/WebCore/khtml/xbl/xbl_docimpl.h
+++ b/WebCore/khtml/xbl/xbl_docimpl.h
@@ -17,7 +17,7 @@ public:
XBLDocumentImpl();
~XBLDocumentImpl();
- virtual XMLHandler* createTokenHandler();
+ virtual khtml::XMLHandler* createTokenHandler();
void setPrototypeBinding(const DOM::DOMString& id, XBLPrototypeBinding* binding);
XBLPrototypeBinding* prototypeBinding(const DOM::DOMString& id);
diff --git a/WebCore/khtml/xbl/xbl_tokenizer.h b/WebCore/khtml/xbl/xbl_tokenizer.h
index ea97a41..8b2bc63 100644
--- a/WebCore/khtml/xbl/xbl_tokenizer.h
+++ b/WebCore/khtml/xbl/xbl_tokenizer.h
@@ -16,7 +16,7 @@ class XBLDocument;
// This class is used to handle tokens returned from an XML parser for the purpose of building the
// custom data structures required by an XBL document.
-class XBLTokenHandler: public XMLHandler
+class XBLTokenHandler: public khtml::XMLHandler
{
typedef enum {
eXBL_InDocument,
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 360964e..c5457d9 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -50,8 +50,6 @@ class QPaintDeviceMetrics;
class KHTMLView;
class KHTMLPart;
class KHTMLSelection;
-class Tokenizer;
-class XMLHandler;
class RenderArena;
#if APPLE_CHANGES
@@ -61,8 +59,10 @@ class KWQAccObjectCache;
namespace khtml {
class CSSStyleSelector;
class DocLoader;
- class RenderImage;
class EditCommand;
+ class RenderImage;
+ class Tokenizer;
+ class XMLHandler;
}
#ifndef KHTML_NO_XBL
@@ -300,9 +300,9 @@ public:
QString printStyleSheet() const { return m_printSheet; }
CSSStyleSheetImpl* elementSheet();
- virtual Tokenizer *createTokenizer();
- Tokenizer *tokenizer() { return m_tokenizer; }
- virtual XMLHandler* createTokenHandler();
+ virtual khtml::Tokenizer *createTokenizer();
+ khtml::Tokenizer *tokenizer() { return m_tokenizer; }
+ virtual khtml::XMLHandler* createTokenHandler();
QPaintDeviceMetrics *paintDeviceMetrics() { return m_paintDeviceMetrics; }
QPaintDevice *paintDevice() const { return m_paintDevice; }
@@ -508,7 +508,7 @@ protected:
QStringList m_state;
khtml::DocLoader *m_docLoader;
- Tokenizer *m_tokenizer;
+ khtml::Tokenizer *m_tokenizer;
QString m_url;
QString m_baseURL;
QString m_baseTarget;
diff --git a/WebCore/khtml/xml/xml_tokenizer.cpp b/WebCore/khtml/xml/xml_tokenizer.cpp
index 480b127..fdf73da 100644
--- a/WebCore/khtml/xml/xml_tokenizer.cpp
+++ b/WebCore/khtml/xml/xml_tokenizer.cpp
@@ -38,7 +38,8 @@
#include <klocale.h>
using namespace DOM;
-using namespace khtml;
+
+namespace khtml {
const int maxErrors = 25;
@@ -387,9 +388,9 @@ void XMLTokenizer::begin()
{
}
-void XMLTokenizer::write( const QString &str, bool /*appendData*/ )
+void XMLTokenizer::write(const TokenizerString &s, bool /*appendData*/ )
{
- m_xmlCode += str;
+ m_xmlCode += s.toString();
}
void XMLTokenizer::end()
@@ -539,5 +540,6 @@ bool XMLTokenizer::isWaitingForScripts()
return m_cachedScript != 0;
}
-#include "xml_tokenizer.moc"
+}
+#include "xml_tokenizer.moc"
diff --git a/WebCore/khtml/xml/xml_tokenizer.h b/WebCore/khtml/xml/xml_tokenizer.h
index e0c2f2b..20e78ff 100644
--- a/WebCore/khtml/xml/xml_tokenizer.h
+++ b/WebCore/khtml/xml/xml_tokenizer.h
@@ -28,6 +28,7 @@
#include <qptrlist.h>
#include <qobject.h>
#include "misc/loader_client.h"
+#include "misc/stringit.h"
#if APPLE_CHANGES
#include "KWQSignal.h"
@@ -35,11 +36,6 @@
class KHTMLView;
-namespace khtml {
- class CachedObject;
- class CachedScript;
-};
-
namespace DOM {
class DocumentImpl;
class NodeImpl;
@@ -48,6 +44,11 @@ namespace DOM {
class HTMLScriptElementImpl;
};
+namespace khtml {
+
+class CachedObject;
+class CachedScript;
+
class XMLHandler : public QXmlDefaultHandler
{
public:
@@ -117,7 +118,7 @@ public:
// received during executing a script must be appended, hence the
// extra bool to be able to distinguish between both cases. document.write()
// always uses false, while khtmlpart uses true
- virtual void write( const QString &str, bool appendData) = 0;
+ virtual void write(const TokenizerString &str, bool appendData) = 0;
virtual void end() = 0;
virtual void finish() = 0;
virtual void setOnHold(bool /*_onHold*/) {}
@@ -134,18 +135,18 @@ private:
#endif
};
-class XMLTokenizer : public Tokenizer, public khtml::CachedObjectClient
+class XMLTokenizer : public Tokenizer, public CachedObjectClient
{
public:
XMLTokenizer(DOM::DocumentPtr *, KHTMLView * = 0);
virtual ~XMLTokenizer();
virtual void begin();
- virtual void write( const QString &str, bool );
+ virtual void write(const TokenizerString &str, bool);
virtual void end();
virtual void finish();
// from CachedObjectClient
- void notifyFinished(khtml::CachedObject *finishedObj);
+ void notifyFinished(CachedObject *finishedObj);
virtual bool isWaitingForScripts();
protected:
@@ -158,7 +159,9 @@ protected:
QString m_xmlCode;
QPtrList<DOM::HTMLScriptElementImpl> m_scripts;
QPtrListIterator<DOM::HTMLScriptElementImpl> *m_scriptsIt;
- khtml::CachedScript *m_cachedScript;
+ CachedScript *m_cachedScript;
};
+}
+
#endif
diff --git a/WebCore/kwq/KWQSignalStubs.mm b/WebCore/kwq/KWQSignalStubs.mm
index 9acac84..87b3904 100644
--- a/WebCore/kwq/KWQSignalStubs.mm
+++ b/WebCore/kwq/KWQSignalStubs.mm
@@ -32,6 +32,7 @@
using khtml::CachedObject;
using khtml::DocLoader;
using khtml::Loader;
+using khtml::Tokenizer;
void KHTMLView::cleared()
{
diff --git a/WebCore/kwq/KWQValueList.h b/WebCore/kwq/KWQValueList.h
index 06390e0..76447fc 100644
--- a/WebCore/kwq/KWQValueList.h
+++ b/WebCore/kwq/KWQValueList.h
@@ -105,6 +105,7 @@ public:
void remove(const T &val) { QValueListNode<T> node(val); impl.removeEqualNodes(&node, nodesEqual); }
uint contains(const T &val) const { QValueListNode<T> node(val); return impl.containsEqualNodes(&node, nodesEqual); }
+ Iterator insert(Iterator iter, const T& val) { return impl.insert(iter.impl, new QValueListNode<T>(val)); }
Iterator remove(Iterator iter) { return impl.removeIterator(iter.impl); }
Iterator fromLast() { return impl.fromLast(); }
@@ -116,6 +117,7 @@ public:
ConstIterator begin() const { return impl.begin(); }
ConstIterator end() const { return impl.end(); }
+ ConstIterator fromLast() const { return impl.fromLast(); }
T& operator[] (uint index) { return ((QValueListNode<T> *)impl.nodeAt(index))->value; }
const T& operator[] (uint index) const { return ((const QValueListNode<T> *)impl.nodeAt(index))->value; }
diff --git a/WebCore/kwq/KWQValueListImpl.h b/WebCore/kwq/KWQValueListImpl.h
index 9e7964d..f909627 100644
--- a/WebCore/kwq/KWQValueListImpl.h
+++ b/WebCore/kwq/KWQValueListImpl.h
@@ -73,6 +73,7 @@ public:
void removeEqualNodes(KWQValueListNodeImpl *node, bool (*equalFunc)(const KWQValueListNodeImpl *, const KWQValueListNodeImpl *));
uint containsEqualNodes(KWQValueListNodeImpl *node, bool (*equalFunc)(const KWQValueListNodeImpl *, const KWQValueListNodeImpl *)) const;
+ KWQValueListIteratorImpl insert(const KWQValueListIteratorImpl &iterator, KWQValueListNodeImpl* node);
KWQValueListIteratorImpl removeIterator(KWQValueListIteratorImpl &iterator);
KWQValueListIteratorImpl fromLast();
@@ -87,7 +88,8 @@ public:
KWQValueListIteratorImpl begin() const;
KWQValueListIteratorImpl end() const;
-
+ KWQValueListIteratorImpl fromLast() const;
+
KWQValueListNodeImpl *nodeAt(uint index);
KWQValueListNodeImpl *nodeAt(uint index) const;
diff --git a/WebCore/kwq/KWQValueListImpl.mm b/WebCore/kwq/KWQValueListImpl.mm
index 8490737..4724025 100644
--- a/WebCore/kwq/KWQValueListImpl.mm
+++ b/WebCore/kwq/KWQValueListImpl.mm
@@ -186,9 +186,12 @@ KWQValueListImpl::~KWQValueListImpl()
void KWQValueListImpl::clear()
{
- d->deleteList(d->head);
- d->head = NULL;
- d->count = 0;
+ if (d->head) {
+ copyOnWrite();
+ d->deleteList(d->head);
+ d->head = NULL;
+ d->count = 0;
+ }
}
uint KWQValueListImpl::count() const
@@ -285,6 +288,30 @@ uint KWQValueListImpl::containsEqualNodes(KWQValueListNodeImpl *node, bool (*equ
return contains;
}
+KWQValueListIteratorImpl KWQValueListImpl::insert(const KWQValueListIteratorImpl &iterator, KWQValueListNodeImpl *node)
+{
+ copyOnWrite();
+
+ KWQValueListNodeImpl *next = iterator.nodeImpl;
+
+ if (next == NULL)
+ return appendNode(node);
+
+ if (next == d->head)
+ return prependNode(node);
+
+ KWQValueListNodeImpl *prev = next->prev;
+
+ node->next = next;
+ node->prev = prev;
+ next->prev = node;
+ prev->next = node;
+
+ d->count++;
+
+ return node;
+}
+
KWQValueListIteratorImpl KWQValueListImpl::removeIterator(KWQValueListIteratorImpl &iterator)
{
copyOnWrite();
@@ -313,6 +340,7 @@ KWQValueListIteratorImpl KWQValueListImpl::removeIterator(KWQValueListIteratorIm
KWQValueListIteratorImpl KWQValueListImpl::fromLast()
{
+ copyOnWrite();
return KWQValueListIteratorImpl(lastNode());
}
@@ -373,6 +401,10 @@ KWQValueListIteratorImpl KWQValueListImpl::end() const
return KWQValueListIteratorImpl(NULL);
}
+KWQValueListIteratorImpl KWQValueListImpl::fromLast() const
+{
+ return KWQValueListIteratorImpl(lastNode());
+}
KWQValueListNodeImpl *KWQValueListImpl::nodeAt(uint index)
{
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list