[webkit-changes] cvs commit: WebCore/khtml/xml dom_atomicstring.h
dom_docimpl.cpp dom_stringimpl.cpp dom_stringimpl.h
Eric
eseidel at opensource.apple.com
Thu Dec 29 19:27:22 PST 2005
eseidel 05/12/29 19:27:22
Modified: . ChangeLog
khtml khtml_part.cpp
khtml/css css_base.cpp css_ruleimpl.cpp css_valueimpl.cpp
cssparser.cpp cssstyleselector.cpp
khtml/dom dom_string.cpp dom_string.h
khtml/html html_formimpl.cpp
khtml/misc decoder.cpp
khtml/xml dom_atomicstring.h dom_docimpl.cpp
dom_stringimpl.cpp dom_stringimpl.h
Log:
Bug #: 6228
Submitted by: eseidel
Reviewed by: mjs
DOMString/DOMStringImpl/AtomicString need enhancements before replacing QString
http://bugzilla.opendarwin.org/show_bug.cgi?id=6228
Added find(), contains(), startsWith() and endsWith() to DOMString
Uses the above functions throughout the code.
Small performance boost.
* khtml/css/css_base.cpp:
(CSSSelector::print):
* khtml/css/css_ruleimpl.cpp:
(DOM::CSSImportRuleImpl::init):
* khtml/css/css_valueimpl.cpp:
(DOM::CSSStyleDeclarationImpl::setProperty):
* khtml/css/cssparser.cpp:
(CSSParser::parseValue):
(CSSParser::parseDeclaration):
(CSSParser::parseContent):
* khtml/css/cssstyleselector.cpp:
(khtml::CSSStyleSelector::CSSStyleSelector):
(khtml::CSSStyleSelector::setEncodedURL):
(khtml::parseUASheet):
(khtml::cleanpath):
(khtml::CSSStyleSelector::checkSelector):
(khtml::CSSStyleSelector::checkOneSelector):
(khtml::CSSRuleSet::addRulesFromSheet):
(khtml::CSSStyleSelector::applyProperty):
* khtml/dom/dom_string.cpp:
* khtml/dom/dom_string.h:
(DOM::DOMString::contains):
(DOM::DOMString::find):
(DOM::DOMString::startsWith):
(DOM::DOMString::endsWith):
* khtml/html/html_formimpl.cpp:
(DOM::HTMLFormElementImpl::parseEnctype):
* khtml/khtml_part.cpp:
(KHTMLPart::requestFrame):
(KHTMLPart::submitForm):
* khtml/misc/decoder.cpp:
(Decoder::decode):
* khtml/xml/dom_atomicstring.h:
(DOM::AtomicString::length):
(DOM::AtomicString::operator []):
(DOM::AtomicString::contains):
(DOM::AtomicString::find):
(DOM::AtomicString::startsWith):
(DOM::AtomicString::endsWith):
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::processHttpEquiv):
* khtml/xml/dom_stringimpl.cpp:
(DOM::equal):
(DOM::equalCaseInsensitive):
(DOM::DOMStringImpl::find):
(DOM::DOMStringImpl::endsWith):
* khtml/xml/dom_stringimpl.h:
(DOM::DOMStringImpl::startsWith):
Revision Changes Path
1.57 +59 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- ChangeLog 30 Dec 2005 03:23:51 -0000 1.56
+++ ChangeLog 30 Dec 2005 03:27:15 -0000 1.57
@@ -1,3 +1,62 @@
+2005-12-29 Eric Seidel <eseidel at apple.com>
+
+ Reviewed by mjs.
+
+ DOMString/DOMStringImpl/AtomicString need enhancements before replacing QString
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=6228
+ Added find(), contains(), startsWith() and endsWith() to DOMString
+ Uses the above functions throughout the code.
+ Small performance boost.
+
+ * khtml/css/css_base.cpp:
+ (CSSSelector::print):
+ * khtml/css/css_ruleimpl.cpp:
+ (DOM::CSSImportRuleImpl::init):
+ * khtml/css/css_valueimpl.cpp:
+ (DOM::CSSStyleDeclarationImpl::setProperty):
+ * khtml/css/cssparser.cpp:
+ (CSSParser::parseValue):
+ (CSSParser::parseDeclaration):
+ (CSSParser::parseContent):
+ * khtml/css/cssstyleselector.cpp:
+ (khtml::CSSStyleSelector::CSSStyleSelector):
+ (khtml::CSSStyleSelector::setEncodedURL):
+ (khtml::parseUASheet):
+ (khtml::cleanpath):
+ (khtml::CSSStyleSelector::checkSelector):
+ (khtml::CSSStyleSelector::checkOneSelector):
+ (khtml::CSSRuleSet::addRulesFromSheet):
+ (khtml::CSSStyleSelector::applyProperty):
+ * khtml/dom/dom_string.cpp:
+ * khtml/dom/dom_string.h:
+ (DOM::DOMString::contains):
+ (DOM::DOMString::find):
+ (DOM::DOMString::startsWith):
+ (DOM::DOMString::endsWith):
+ * khtml/html/html_formimpl.cpp:
+ (DOM::HTMLFormElementImpl::parseEnctype):
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::requestFrame):
+ (KHTMLPart::submitForm):
+ * khtml/misc/decoder.cpp:
+ (Decoder::decode):
+ * khtml/xml/dom_atomicstring.h:
+ (DOM::AtomicString::length):
+ (DOM::AtomicString::operator []):
+ (DOM::AtomicString::contains):
+ (DOM::AtomicString::find):
+ (DOM::AtomicString::startsWith):
+ (DOM::AtomicString::endsWith):
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::processHttpEquiv):
+ * khtml/xml/dom_stringimpl.cpp:
+ (DOM::equal):
+ (DOM::equalCaseInsensitive):
+ (DOM::DOMStringImpl::find):
+ (DOM::DOMStringImpl::endsWith):
+ * khtml/xml/dom_stringimpl.h:
+ (DOM::DOMStringImpl::startsWith):
+
2005-12-29 Rob Buis <rwlbuis at xs4all.nl>
Reviewed by eseidel.
1.374 +4 -13 WebCore/khtml/khtml_part.cpp
Index: khtml_part.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/khtml_part.cpp,v
retrieving revision 1.373
retrieving revision 1.374
diff -u -r1.373 -r1.374
--- khtml_part.cpp 23 Dec 2005 18:44:04 -0000 1.373
+++ khtml_part.cpp 30 Dec 2005 03:27:15 -0000 1.374
@@ -1711,12 +1711,9 @@
bool KHTMLPart::requestFrame( khtml::RenderPart *frame, const QString &url, const QString &frameName,
const QStringList ¶mNames, const QStringList ¶mValues, bool isIFrame )
{
-// kdDebug( 6050 ) << "childRequest( ..., " << url << ", " << frameName << " )" << endl;
FrameIt it = d->m_frames.find( frameName );
- if ( it == d->m_frames.end() )
- {
+ if (it == d->m_frames.end()) {
khtml::ChildFrame child;
-// kdDebug( 6050 ) << "inserting new frame into frame map " << frameName << endl;
child.m_name = frameName;
it = d->m_frames.append( child );
}
@@ -1727,8 +1724,7 @@
(*it).m_paramNames = paramValues;
// Support for <frame src="javascript:string">
- if ( url.find( QString::fromLatin1( "javascript:" ), 0, false ) == 0 )
- {
+ if (url.startsWith("javascript:", false)) {
if (!processObjectRequest(&(*it), "about:blank", "text/html" ))
return false;
@@ -1923,16 +1919,12 @@
kdDebug(6000) << this << ": KHTMLPart::submitForm target=" << _target << " url=" << url << endl;
KURL u = completeURL( url );
- if ( !u.isValid() )
- {
+ if (!u.isValid())
// ### ERROR HANDLING!
return;
- }
-
QString urlstring = u.url();
-
- if ( urlstring.find( QString::fromLatin1( "javascript:" ), 0, false ) == 0 ) {
+ if (urlstring.startsWith("javascript:", false)) {
urlstring = KURL::decode_string(urlstring);
d->m_executingJavaScriptFormAction = true;
executeScript( urlstring.right( urlstring.length() - 11) );
@@ -1940,7 +1932,6 @@
return;
}
-
KParts::URLArgs args;
if (!d->m_referrer.isEmpty())
1.26 +1 -5 WebCore/khtml/css/css_base.cpp
Index: css_base.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/css_base.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- css_base.cpp 23 Dec 2005 18:44:05 -0000 1.25
+++ css_base.cpp 30 Dec 2005 03:27:16 -0000 1.26
@@ -95,12 +95,8 @@
void CSSSelector::print(void)
{
- kdDebug( 6080 ) << "[Selector: tag = " << tag.localName().qstring() << ", attr = \"" << attr.localName().qstring() << "\", match = \"" << match
- << "\" value = \"" << value.qstring().latin1() << "\" relation = " << (int)relation
- << "]" << endl;
- if ( tagHistory )
+ if (tagHistory)
tagHistory->print();
- kdDebug( 6080 ) << " specificity = " << specificity() << endl;
}
unsigned int CSSSelector::specificity()
1.29 +0 -7 WebCore/khtml/css/css_ruleimpl.cpp
Index: css_ruleimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/css_ruleimpl.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- css_ruleimpl.cpp 15 Dec 2005 21:39:56 -0000 1.28
+++ css_ruleimpl.cpp 30 Dec 2005 03:27:16 -0000 1.29
@@ -146,13 +146,6 @@
// use parent styleheet's URL as the base URL
absHref = KURL(parentSheet->href().qstring(),m_strHref.qstring()).url();
}
-/*
- else {
- // use documents's URL as the base URL
- DocumentImpl *doc = static_cast<CSSStyleSheetImpl*>(root)->doc();
- absHref = KURL(doc->URL(),m_strHref.qstring()).url();
- }
-*/
// Check for a cycle in our import chain. If we encounter a stylesheet
// in our parent chain with the same URL, then just bail.
1.86 +1 -1 WebCore/khtml/css/css_valueimpl.cpp
Index: css_valueimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/css_valueimpl.cpp,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -r1.85 -r1.86
--- css_valueimpl.cpp 15 Dec 2005 21:39:56 -0000 1.85
+++ css_valueimpl.cpp 30 Dec 2005 03:27:16 -0000 1.86
@@ -155,7 +155,7 @@
int propID = propertyID(propertyName);
if (!propID) // set exception?
return;
- bool important = priority.qstring().find("important", 0, false) != -1;
+ bool important = priority.find("important", 0, false) != -1;
setProperty(propID, value, important, exception);
}
1.118 +0 -12 WebCore/khtml/css/cssparser.cpp
Index: cssparser.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/cssparser.cpp,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -r1.117 -r1.118
--- cssparser.cpp 15 Dec 2005 21:39:57 -0000 1.117
+++ cssparser.cpp 30 Dec 2005 03:27:17 -0000 1.118
@@ -204,11 +204,6 @@
bool CSSParser::parseValue( CSSMutableStyleDeclarationImpl *declaration, int _id, const DOMString &string,
bool _important)
{
-#ifdef CSS_DEBUG
- kdDebug( 6080 ) << "CSSParser::parseValue: id=" << _id << " important=" << _important
- << " value='" << string.qstring() << "'" << endl;
-#endif
-
styleElement = declaration->stylesheet();
setupParser ("@-khtml-value{", string, "} ");
@@ -281,10 +276,6 @@
bool CSSParser::parseDeclaration( CSSMutableStyleDeclarationImpl *declaration, const DOMString &string )
{
-#ifdef CSS_DEBUG
- kdDebug( 6080 ) << "CSSParser::parseDeclaration:value='" << string.qstring() << "'" << endl;
-#endif
-
styleElement = declaration->stylesheet();
setupParser ( "@-khtml-decls{", string, "} ");
@@ -1507,9 +1498,6 @@
DOMString value = parseURL(domString(val->string));
parsedValue = new CSSImageValueImpl(
DOMString(KURL( styleElement->baseURL().qstring(), value.qstring()).url() ), styleElement );
-#ifdef CSS_DEBUG
- kdDebug( 6080 ) << "content, url=" << value.qstring() << " base=" << styleElement->baseURL().qstring() << endl;
-#endif
} else if ( val->unit == Value::Function ) {
// attr( X )
ValueList *args = val->function->args;
1.233 +48 -124 WebCore/khtml/css/cssstyleselector.cpp
Index: cssstyleselector.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/cssstyleselector.cpp,v
retrieving revision 1.232
retrieving revision 1.233
diff -u -r1.232 -r1.233
--- cssstyleselector.cpp 23 Dec 2005 18:44:06 -0000 1.232
+++ cssstyleselector.cpp 30 Dec 2005 03:27:17 -0000 1.233
@@ -248,9 +248,6 @@
m_ruleList = 0;
m_collectRulesOnly = false;
-
- //kdDebug( 6080 ) << "number of style sheets in document " << authorStyleSheets.count() << endl;
- //kdDebug( 6080 ) << "CSSStyleSelector: author style has " << authorStyle->count() << " elements"<< endl;
}
CSSStyleSelector::CSSStyleSelector( CSSStyleSheetImpl *sheet )
@@ -288,8 +285,6 @@
}
u.setPath( QString::null );
encodedurl.host = u.url();
-
- //kdDebug() << "CSSStyleSelector::CSSStyleSelector encoded url " << encodedurl.path << endl;
}
CSSStyleSelector::~CSSStyleSelector()
@@ -310,11 +305,8 @@
if (readbytes >= 0)
file[readbytes] = '\0';
- QString style = QString::fromLatin1(file.data());
- DOMString str(style);
-
CSSStyleSheetImpl* sheet = new CSSStyleSheetImpl((CSSStyleSheetImpl*)0);
- sheet->parseString(str);
+ sheet->parseString(DOMString(file.data()));
return sheet;
}
@@ -559,7 +551,7 @@
int refPos = -2;
while ( (pos = path.find( "//", pos )) != -1) {
if (refPos == -2)
- refPos = path.find("#", 0);
+ refPos = path.find("#");
if (refPos > 0 && pos >= refPos)
break;
@@ -570,7 +562,6 @@
}
while ( (pos = path.find( "/./" )) != -1)
path.remove( pos, 2 );
- //kdDebug() << "checkPseudoState " << path << endl;
}
static void checkPseudoState( ElementImpl *e, bool checkVisited = true )
@@ -1111,13 +1102,14 @@
bool havePseudo = pseudoStyle != RenderStyle::NOPSEUDO;
// first selector has to match
- if (!checkOneSelector(sel, e)) return false;
+ if (!checkOneSelector(sel, e))
+ return false;
// check the subselectors
CSSSelector::Relation relation = sel->relation;
- while((sel = sel->tagHistory))
- {
- if (!n->isElementNode()) return false;
+ while((sel = sel->tagHistory)) {
+ if (!n->isElementNode())
+ return false;
if (relation != CSSSelector::SubSelector) {
subject = false;
if (havePseudo && dynamicPseudo != pseudoStyle)
@@ -1127,26 +1119,23 @@
switch(relation)
{
case CSSSelector::Descendant:
- {
// FIXME: This match needs to know how to backtrack and be non-deterministic.
- bool found = false;
- while(!found)
- {
+ do {
n = n->parentNode();
- if(!n || !n->isElementNode()) return false;
- ElementImpl *elem = static_cast<ElementImpl *>(n);
- if (checkOneSelector(sel, elem)) found = true;
- }
+ if (!n || !n->isElementNode())
+ return false;
+ } while (!checkOneSelector(sel, static_cast<ElementImpl *>(n)));
break;
- }
case CSSSelector::Child:
{
n = n->parentNode();
if (!strictParsing)
- while (n && n->implicitNode()) n = n->parentNode();
- if(!n || !n->isElementNode()) return false;
- ElementImpl *elem = static_cast<ElementImpl *>(n);
- if (!checkOneSelector(sel, elem)) return false;
+ while (n && n->implicitNode())
+ n = n->parentNode();
+ if (!n || !n->isElementNode())
+ return false;
+ if (!checkOneSelector(sel, static_cast<ElementImpl *>(n)))
+ return false;
break;
}
case CSSSelector::DirectAdjacent:
@@ -1154,26 +1143,22 @@
n = n->previousSibling();
while (n && !n->isElementNode())
n = n->previousSibling();
- if (!n) return false;
- ElementImpl *elem = static_cast<ElementImpl*>(n);
- if (!checkOneSelector(sel, elem))
+ if (!n)
+ return false;
+ if (!checkOneSelector(sel, static_cast<ElementImpl*>(n)))
return false;
break;
}
case CSSSelector::IndirectAdjacent:
- {
// FIXME: This match needs to know how to backtrack and be non-deterministic.
- ElementImpl *elem = 0;
do {
n = n->previousSibling();
while (n && !n->isElementNode())
n = n->previousSibling();
if (!n)
return false;
- elem = static_cast<ElementImpl*>(n);
- } while (!checkOneSelector(sel, elem));
+ } while (!checkOneSelector(sel, static_cast<ElementImpl*>(n)));
break;
- }
case CSSSelector::SubSelector:
{
if (onlyHoverActive)
@@ -1181,13 +1166,12 @@
(sel->pseudoType() == CSSSelector::PseudoHover ||
sel->pseudoType() == CSSSelector::PseudoActive));
- //kdDebug() << "CSSOrderedRule::checkSelector" << endl;
ElementImpl *elem = static_cast<ElementImpl *>(n);
// a selector is invalid if something follows :first-xxx
if (elem == element && dynamicPseudo != RenderStyle::NOPSEUDO)
return false;
- if (!checkOneSelector(sel, elem)) return false;
- //kdDebug() << "CSSOrderedRule::checkSelector: passed" << endl;
+ if (!checkOneSelector(sel, elem))
+ return false;
break;
}
}
@@ -1245,94 +1229,57 @@
style->setAffectedByAttributeSelectors(); // Special-case the "type" attribute so input form controls can share style.
const AtomicString& value = e->getAttribute(sel->attr);
- if (value.isNull()) return false; // attribute is not set
+ if (value.isNull())
+ return false; // attribute is not set
switch(sel->match) {
case CSSSelector::Exact:
- if ((isXMLDoc && sel->value != value) ||
- (!isXMLDoc && !equalsIgnoreCase(sel->value, value)))
+ if ((isXMLDoc && sel->value != value) || (!isXMLDoc && !equalsIgnoreCase(sel->value, value)))
return false;
break;
case CSSSelector::List:
{
- int spacePos = value.find(' ', 0);
- if (spacePos == -1) {
- // There is no list, just a single item. We can avoid
- // allocing QStrings and just treat this as an exact
- // match check.
- if ((isXMLDoc && sel->value != value) ||
- (!isXMLDoc && !equalsIgnoreCase(sel->value, value)))
- return false;
- break;
- }
-
// The selector's value can't contain a space, or it's totally bogus.
- spacePos = sel->value.find(' ');
- if (spacePos != -1)
+ if (sel->value.contains(' '))
return false;
- QString str = value.qstring();
- QString selStr = sel->value.qstring();
int startSearchAt = 0;
while (true) {
- int foundPos = str.find(selStr, startSearchAt, isXMLDoc);
- if (foundPos == -1) return false;
- if (foundPos == 0 || str[foundPos-1] == ' ') {
- uint endStr = foundPos + selStr.length();
- if (endStr == str.length() || str[endStr] == ' ')
+ int foundPos = value.find(sel->value, startSearchAt, isXMLDoc);
+ if (foundPos == -1)
+ return false;
+ if (foundPos == 0 || value[foundPos-1] == ' ') {
+ uint endStr = foundPos + sel->value.length();
+ if (endStr == value.length() || value[endStr] == ' ')
break; // We found a match.
}
// No match. Keep looking.
startSearchAt = foundPos + 1;
}
-
break;
}
case CSSSelector::Contain:
- {
- //kdDebug( 6080 ) << "checking for contains match" << endl;
- QString str = value.qstring();
- QString selStr = sel->value.qstring();
- int pos = str.find(selStr, 0, isXMLDoc);
- if(pos == -1) return false;
+ if (!value.contains(sel->value, isXMLDoc))
+ return false;
break;
- }
case CSSSelector::Begin:
- {
- //kdDebug( 6080 ) << "checking for beginswith match" << endl;
- QString str = value.qstring();
- QString selStr = sel->value.qstring();
- int pos = str.find(selStr, 0, isXMLDoc);
- if(pos != 0) return false;
+ if (!value.startsWith(sel->value, isXMLDoc))
+ return false;
break;
- }
case CSSSelector::End:
- {
- //kdDebug( 6080 ) << "checking for endswith match" << endl;
- QString str = value.qstring();
- QString selStr = sel->value.qstring();
- if (isXMLDoc && !str.endsWith(selStr)) return false;
- if (!isXMLDoc) {
- int pos = str.length() - selStr.length();
- if (pos < 0 || pos != str.find(selStr, pos, false) )
- return false;
- }
+ if (!value.endsWith(sel->value, isXMLDoc))
+ return false;
break;
- }
case CSSSelector::Hyphen:
- {
- //kdDebug( 6080 ) << "checking for hyphen match" << endl;
- QString str = value.qstring();
- QString selStr = sel->value.qstring();
- if(str.length() < selStr.length()) return false;
- // Check if str begins with selStr:
- if(str.find(selStr, 0, isXMLDoc) != 0) return false;
- // It does. Check for exact match or following '-':
- if(str.length() != selStr.length()
- && str[selStr.length()] != '-') return false;
+ if (value.length() < sel->value.length())
+ return false;
+ if (!value.startsWith(sel->value, isXMLDoc))
+ return false;
+ // It they start the same, check for exact match or following '-':
+ if (value.length() != sel->value.length() && value[sel->value.length()] != '-')
+ return false;
break;
- }
case CSSSelector::PseudoClass:
case CSSSelector::PseudoElement:
default:
@@ -1343,7 +1290,6 @@
{
// Pseudo elements. We need to check first child here. No dynamic pseudo
// elements for the moment
-// kdDebug() << "CSSOrderedRule::pseudo " << value << endl;
switch (sel->pseudoType()) {
// Pseudo classes:
case CSSSelector::PseudoEmpty:
@@ -1636,7 +1582,8 @@
void CSSRuleSet::addRulesFromSheet(CSSStyleSheetImpl *sheet, const DOMString &medium)
{
- if (!sheet || !sheet->isCSSStyleSheet()) return;
+ if (!sheet || !sheet->isCSSStyleSheet())
+ return;
// No media implies "all", but if a media list exists it must
// contain our current medium
@@ -1654,10 +1601,6 @@
}
else if(item->isImportRule()) {
CSSImportRuleImpl *import = static_cast<CSSImportRuleImpl *>(item);
-
- //kdDebug( 6080 ) << "@import: Media: "
- // << import->media()->mediaText().qstring() << endl;
-
if (!import->media() || import->media()->contains(medium))
addRulesFromSheet(import->styleSheet(), medium);
}
@@ -1665,15 +1608,9 @@
CSSMediaRuleImpl *r = static_cast<CSSMediaRuleImpl*>(item);
CSSRuleListImpl *rules = r->cssRules();
- //DOMString mediaText = media->mediaText();
- //kdDebug( 6080 ) << "@media: Media: "
- // << r->media()->mediaText().qstring() << endl;
-
if ((!r->media() || r->media()->contains(medium)) && rules) {
// Traverse child elements of the @media rule.
for (unsigned j = 0; j < rules->length(); j++) {
- //kdDebug( 6080 ) << "*** Rule #" << j << endl;
-
CSSRuleImpl *childItem = rules->item(j);
if (childItem->isStyleRule()) {
// It is a StyleRule, so append it to our list
@@ -1682,20 +1619,9 @@
addRule(rule, s);
}
- else
- {
- //kdDebug( 6080 ) << "Ignoring child rule of "
- // "ImportRule: rule is not a StyleRule!" << endl;
- }
} // for rules
} // if rules
- else
- {
- //kdDebug( 6080 ) << "CSSMediaRule not rendered: "
- // << "rule empty or wrong medium!" << endl;
- }
}
- // ### include other rules
}
}
@@ -1835,8 +1761,6 @@
void CSSStyleSelector::applyProperty( int id, CSSValueImpl *value )
{
- //kdDebug( 6080 ) << "applying property " << prop->m_id << endl;
-
CSSPrimitiveValueImpl *primitiveValue = 0;
if(value->isPrimitiveValue()) primitiveValue = static_cast<CSSPrimitiveValueImpl *>(value);
1.25 +0 -13 WebCore/khtml/dom/dom_string.cpp
Index: dom_string.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/dom/dom_string.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- dom_string.cpp 16 Dec 2005 22:26:12 -0000 1.24
+++ dom_string.cpp 30 Dec 2005 03:27:19 -0000 1.25
@@ -105,19 +105,6 @@
return *(m_impl->s+i);
}
-int DOMString::find(const QChar c, int start) const
-{
- unsigned int l = start;
- if (!m_impl || l >= m_impl->l )
- return -1;
- while(l < m_impl->l) {
- if (*(m_impl->s+l) == c)
- return l;
- l++;
- }
- return -1;
-}
-
uint DOMString::length() const
{
if (!m_impl)
1.19 +17 -9 WebCore/khtml/dom/dom_string.h
Index: dom_string.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/dom/dom_string.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- dom_string.h 25 Dec 2005 05:11:05 -0000 1.18
+++ dom_string.h 30 Dec 2005 03:27:19 -0000 1.19
@@ -71,8 +71,23 @@
* character returned will be 0.
*/
const QChar &operator [](unsigned int i) const;
+
+ // NOTE: contains returns bool, eventually we'll add count() which returns an int.
+ bool contains(QChar c) const { return (find(c) != -1); }
+ bool contains(const char *str, bool caseSensitive = true) const { return (find(str, 0, caseSensitive) != -1); }
+
+ int find(const QChar c, int start = 0) const
+ { if (m_impl) return m_impl->find(c, start); return -1; }
+ int find(const char *str, int start = 0, bool caseSensitive = true) const
+ { if (m_impl) return m_impl->find(str, start, caseSensitive); return -1; }
+ int find(const DOMString& str, int start = 0, bool caseSensitive = true) const
+ { if (m_impl) return m_impl->find(str.impl(), start, caseSensitive); return -1; }
+
+ bool startsWith(const DOMString &s, bool caseSensitive = true) const
+ { if (m_impl) return m_impl->startsWith(s.impl(), caseSensitive); return false; }
+ bool endsWith(const DOMString &s, bool caseSensitive = true) const
+ { if (m_impl) return m_impl->endsWith(s.impl(), caseSensitive); return false; }
- int find(const QChar c, int start = 0) const;
DOMString &replace(QChar a, QChar b) { if (m_impl) m_impl = m_impl->replace(a, b); return *this; }
uint length() const;
@@ -87,12 +102,9 @@
DOMString split(unsigned int pos);
/**
- * Returns a lowercase version of the string
+ * Returns a lowercase/uppercase version of the string
*/
DOMString lower() const;
- /**
- * Returns an uppercase version of the string
- */
DOMString upper() const;
QChar *unicode() const;
@@ -108,10 +120,6 @@
bool isNull() const { return (m_impl == 0); }
bool isEmpty() const;
- /**
- * @internal get a handle to the imlementation of the DOMString
- * Use at own risk!!!
- */
DOMStringImpl *impl() const { return m_impl.get(); }
#ifdef __OBJC__
1.217 +4 -8 WebCore/khtml/html/html_formimpl.cpp
Index: html_formimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_formimpl.cpp,v
retrieving revision 1.216
retrieving revision 1.217
diff -u -r1.216 -r1.217
--- html_formimpl.cpp 23 Dec 2005 18:44:15 -0000 1.216
+++ html_formimpl.cpp 30 Dec 2005 03:27:19 -0000 1.217
@@ -407,20 +407,16 @@
return true;
}
-void HTMLFormElementImpl::parseEnctype( const DOMString& type )
+void HTMLFormElementImpl::parseEnctype(const DOMString& type)
{
- if(type.qstring().find("multipart", 0, false) != -1 || type.qstring().find("form-data", 0, false) != -1)
- {
+ if(type.contains("multipart", false) || type.contains("form-data", false)) {
m_enctype = "multipart/form-data";
m_multipart = true;
m_post = true;
- } else if (type.qstring().find("text", 0, false) != -1 || type.qstring().find("plain", 0, false) != -1)
- {
+ } else if (type.contains("text", false) || type.contains("plain", false)) {
m_enctype = "text/plain";
m_multipart = false;
- }
- else
- {
+ } else {
m_enctype = "application/x-www-form-urlencoded";
m_multipart = false;
}
1.50 +0 -4 WebCore/khtml/misc/decoder.cpp
Index: decoder.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/misc/decoder.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- decoder.cpp 20 Dec 2005 08:49:48 -0000 1.49
+++ decoder.cpp 30 Dec 2005 03:27:20 -0000 1.50
@@ -511,16 +511,12 @@
withinTitle = !end;
if (!end && tag == metaTag) {
- // found a meta tag...
- //ptr += 5;
const char * end = ptr;
while(*end != '>' && *end != '\0') end++;
if ( *end == '\0' ) break;
QCString str( ptr, (end-ptr)+1);
str = str.lower();
int pos = 0;
- //if( (pos = str.find("http-equiv", pos)) == -1) break;
- //if( (pos = str.find("content-type", pos)) == -1) break;
while( pos < ( int ) str.length() ) {
if( (pos = str.find("charset", pos, false)) == -1) break;
pos += 7;
1.10 +12 -1 WebCore/khtml/xml/dom_atomicstring.h
Index: dom_atomicstring.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_atomicstring.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- dom_atomicstring.h 31 Aug 2005 04:38:41 -0000 1.9
+++ dom_atomicstring.h 30 Dec 2005 03:27:20 -0000 1.10
@@ -45,9 +45,20 @@
DOMStringImpl* impl() const { return m_string.impl(); }
const QChar *unicode() const { return m_string.unicode(); }
- int length() const { return m_string.length(); }
+ uint length() const { return m_string.length(); }
+ const QChar &operator [](unsigned int i) const { return m_string[i]; }
+
+ bool contains(const QChar c) const { return m_string.contains(c); }
+ bool contains(const AtomicString &s, bool caseSentitive = true) const { return (find(s, 0, caseSentitive) != -1); }
+
int find(const QChar c, int start = 0) const { return m_string.find(c, start); }
+ int find(const AtomicString &s, int start = 0, bool caseSentitive = true) const
+ { return m_string.find(s.domString(), start, caseSentitive); }
+
+ bool startsWith(const AtomicString &s, bool caseSensitive = true) const { return (find(s, 0, caseSensitive) == 0); }
+ bool endsWith(const AtomicString &s, bool caseSensitive = true) const
+ { return m_string.endsWith(s.domString(), caseSensitive); }
int toInt() const { return m_string.toInt(); }
bool percentage(int &_percentage) const { return m_string.percentage(_percentage); }
1.294 +6 -6 WebCore/khtml/xml/dom_docimpl.cpp
Index: dom_docimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.cpp,v
retrieving revision 1.293
retrieving revision 1.294
diff -u -r1.293 -r1.294
--- dom_docimpl.cpp 23 Dec 2005 18:44:28 -0000 1.293
+++ dom_docimpl.cpp 30 Dec 2005 03:27:20 -0000 1.294
@@ -1862,11 +1862,13 @@
pos++;
while(pos < (int)str.length() && str[pos].isSpace()) pos++;
str = str.mid(pos);
- if(str.find("url", 0, false ) == 0) str = str.mid(3);
+ if (str.find("url", 0, false ) == 0)
+ str = str.mid(3);
str = str.stripWhiteSpace();
- if ( str.length() && str[0] == '=' ) str = str.mid( 1 ).stripWhiteSpace();
- str = parseURL( DOMString(str) ).qstring();
- if ( ok && part )
+ if (str.length() && str[0] == '=')
+ str = str.mid(1).stripWhiteSpace();
+ str = parseURL(DOMString(str)).qstring();
+ if (ok && part)
// We want a new history item if the refresh timeout > 1 second
part->scheduleRedirection(delay, completeURL( str ), delay <= 1);
}
@@ -1883,9 +1885,7 @@
QString str = content.qstring().lower().stripWhiteSpace();
KURL url = part->url();
if ((str == "no-cache") && url.protocol().startsWith("http"))
- {
KIO::http_update_cache(url, true, 0);
- }
}
else if( (strcasecmp(equiv, "set-cookie") == 0))
{
1.36 +158 -0 WebCore/khtml/xml/dom_stringimpl.cpp
Index: dom_stringimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_stringimpl.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- dom_stringimpl.cpp 23 Dec 2005 18:44:29 -0000 1.35
+++ dom_stringimpl.cpp 30 Dec 2005 03:27:21 -0000 1.36
@@ -30,6 +30,7 @@
#include <string.h>
#include "dom_atomicstring.h"
+#include <kxmlcore/Assertions.h>
using namespace khtml;
@@ -448,6 +449,163 @@
return QConstString(s, i).string().toInt(ok);
}
+static bool equal(const QChar *a, const char *b, int l)
+{
+ ASSERT(l >= 0);
+ while (l--) {
+ if (*a != *b)
+ return false;
+ a++; b++;
+ }
+ return true;
+}
+
+static bool equalCaseInsensitive(const QChar *a, const char *b, int l)
+{
+ ASSERT(l >= 0);
+ while (l--) {
+ if (tolower(a->unicode()) != tolower(*b))
+ return false;
+ a++; b++;
+ }
+ return true;
+}
+
+static bool equalCaseInsensitive(const QChar *a, const QChar *b, int l)
+{
+ ASSERT(l >= 0);
+ while (l--) {
+ if (tolower(a->unicode()) != tolower(b->unicode()))
+ return false;
+ a++; b++;
+ }
+ return true;
+}
+
+// This function should be as fast as possible, every little bit helps.
+// Our usage patterns are typically small strings. In time trials
+// this simplistic algorithm is much faster than Boyer-Moore or hash
+// based algorithms.
+// NOTE: Those time trials were done when this function was part of QString
+// It was copied here and changed slightly since.
+int DOMStringImpl::find(const char *chs, int index, bool caseSensitive) const
+{
+ if (!chs || index < 0)
+ return -1;
+
+ int chsLength = strlen(chs);
+ int n = l - index;
+ if (n < 0)
+ return -1;
+ n -= chsLength - 1;
+ if (n <= 0)
+ return -1;
+
+ const char *chsPlusOne = chs + 1;
+ int chsLengthMinusOne = chsLength - 1;
+
+ const QChar *ptr = s + index - 1;
+ if (caseSensitive) {
+ QChar c = *chs;
+ do {
+ if (*++ptr == c && equal(ptr + 1, chsPlusOne, chsLengthMinusOne))
+ return l - chsLength - n + 1;
+ } while (--n);
+ } else {
+ int lc = tolower((unsigned char)*chs);
+ do {
+ if (tolower((++ptr)->unicode()) == lc && equalCaseInsensitive(ptr + 1, chsPlusOne, chsLengthMinusOne))
+ return l - chsLength - n + 1;
+ } while (--n);
+ }
+
+ return -1;
+}
+
+int DOMStringImpl::find(const QChar c, int start) const
+{
+ unsigned int index = start;
+ if (index >= l )
+ return -1;
+ while(index < l) {
+ if (s[index] == c)
+ return index;
+ index++;
+ }
+ return -1;
+}
+
+// This was copied from QString and made to work here w/ small modifications.
+// FIXME comments were from the QString version.
+int DOMStringImpl::find(const DOMStringImpl *str, int index, bool caseSensitive) const
+{
+ // FIXME, use the first character algorithm
+ /*
+ We use some weird hashing for efficiency's sake. Instead of
+ comparing strings, we compare the sum of str with that of
+ a part of this QString. Only if that matches, we call memcmp
+ or ucstrnicmp.
+
+ The hash value of a string is the sum of the cells of its
+ QChars.
+ */
+ ASSERT(str);
+ if (index < 0)
+ index += l;
+ int lstr = str->l;
+ int lthis = l - index;
+ if ((uint)lthis > l)
+ return -1;
+ int delta = lthis - lstr;
+ if (delta < 0)
+ return -1;
+
+ const QChar *uthis = s + index;
+ const QChar *ustr = str->s;
+ uint hthis = 0;
+ uint hstr = 0;
+ if (caseSensitive) {
+ for (int i = 0; i < lstr; i++) {
+ hthis += uthis[i].unicode();
+ hstr += ustr[i].unicode();
+ }
+ int i = 0;
+ while (1) {
+ if (hthis == hstr && memcmp(uthis + i, ustr, lstr * sizeof(QChar)) == 0)
+ return index + i;
+ if (i == delta)
+ return -1;
+ hthis += uthis[i + lstr].unicode();
+ hthis -= uthis[i].unicode();
+ i++;
+ }
+ } else {
+ for (int i = 0; i < lstr; i++ ) {
+ hthis += tolower(uthis[i].unicode());
+ hstr += tolower(ustr[i].unicode());
+ }
+ int i = 0;
+ while (1) {
+ if (hthis == hstr && equalCaseInsensitive(uthis + i, ustr, lstr))
+ return index + i;
+ if (i == delta)
+ return -1;
+ hthis += tolower(uthis[i + lstr].unicode());
+ hthis -= tolower(uthis[i].unicode());
+ i++;
+ }
+ }
+}
+
+bool DOMStringImpl::endsWith(const DOMStringImpl *s, bool caseSensitive) const
+{
+ ASSERT(s);
+ int start = l - s->l;
+ if (start >= 0)
+ return (find(s, start, caseSensitive) == start);
+ return -1;
+}
+
DOMStringImpl *DOMStringImpl::replace(QChar oldC, QChar newC)
{
if (oldC == newC)
1.20 +7 -0 WebCore/khtml/xml/dom_stringimpl.h
Index: dom_stringimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_stringimpl.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- dom_stringimpl.h 23 Dec 2005 03:57:25 -0000 1.19
+++ dom_stringimpl.h 30 Dec 2005 03:27:21 -0000 1.20
@@ -82,6 +82,13 @@
DOMStringImpl *upper() const;
DOMStringImpl *capitalize() const;
+ int find(const char *chs, int index = 0, bool caseSensitive = true) const;
+ int find(QChar c, int index = 0) const;
+ int find(const DOMStringImpl *str, int index, bool caseSensitive = true) const;
+
+ bool startsWith(const DOMStringImpl *s, bool caseSensitive = true) const { return (find(s, 0, caseSensitive) == 0); }
+ bool endsWith(const DOMStringImpl *s, bool caseSensitive = true) const;
+
// This modifies the string in place if there is only one ref, makes a new string otherwise.
DOMStringImpl *replace(QChar, QChar);
More information about the webkit-changes
mailing list