[webkit-changes] cvs commit: WebCore/khtml/html html_miscimpl.cpp
html_miscimpl.h
Eric
eseidel at opensource.apple.com
Thu Dec 29 19:33:55 PST 2005
eseidel 05/12/29 19:33:55
Modified: . ChangeLog
khtml/html html_miscimpl.cpp html_miscimpl.h
Log:
Bug #: 6230
Submitted by: eseidel
Reviewed by: mjs
Remove QDict from khtml/html
http://bugzilla.opendarwin.org/show_bug.cgi?id=6230
Uses HashMap instead.
* khtml/html/html_miscimpl.cpp:
(DOM::HTMLCollectionImpl::CollectionInfo::CollectionInfo):
(DOM::HTMLCollectionImpl::CollectionInfo::reset):
(DOM::HTMLCollectionImpl::namedItem):
(DOM::HTMLCollectionImpl::updateNameCache):
(DOM::HTMLCollectionImpl::namedItems):
(DOM::HTMLCollectionImpl::nextNamedItem):
(DOM::HTMLFormCollectionImpl::nextNamedItemInternal):
(DOM::HTMLFormCollectionImpl::updateNameCache):
* khtml/html/html_miscimpl.h:
Revision Changes Path
1.58 +19 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- ChangeLog 30 Dec 2005 03:27:15 -0000 1.57
+++ ChangeLog 30 Dec 2005 03:33:54 -0000 1.58
@@ -2,6 +2,25 @@
Reviewed by mjs.
+ Remove QDict from khtml/html
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=6230
+ Uses HashMap instead.
+
+ * khtml/html/html_miscimpl.cpp:
+ (DOM::HTMLCollectionImpl::CollectionInfo::CollectionInfo):
+ (DOM::HTMLCollectionImpl::CollectionInfo::reset):
+ (DOM::HTMLCollectionImpl::namedItem):
+ (DOM::HTMLCollectionImpl::updateNameCache):
+ (DOM::HTMLCollectionImpl::namedItems):
+ (DOM::HTMLCollectionImpl::nextNamedItem):
+ (DOM::HTMLFormCollectionImpl::nextNamedItemInternal):
+ (DOM::HTMLFormCollectionImpl::updateNameCache):
+ * khtml/html/html_miscimpl.h:
+
+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
1.41 +34 -36 WebCore/khtml/html/html_miscimpl.cpp
Index: html_miscimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_miscimpl.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- html_miscimpl.cpp 1 Dec 2005 10:32:19 -0000 1.40
+++ html_miscimpl.cpp 30 Dec 2005 03:33:54 -0000 1.41
@@ -94,8 +94,6 @@
HTMLCollectionImpl::CollectionInfo::CollectionInfo() :
version(0)
{
- idCache.setAutoDelete(true);
- nameCache.setAutoDelete(true);
reset();
}
@@ -106,7 +104,9 @@
length = 0;
haslength = false;
elementsArrayPosition = 0;
+ deleteAllValues(idCache);
idCache.clear();
+ deleteAllValues(nameCache);
nameCache.clear();
hasNameCache = false;
}
@@ -338,9 +338,8 @@
NodeImpl *n;
for (n = traverseNextItem(m_base.get()); n; n = traverseNextItem(n)) {
- if (checkForNameMatch(n, idsDone, name, caseSensitive)) {
+ if (checkForNameMatch(n, idsDone, name, caseSensitive))
break;
- }
}
info->current = n;
@@ -349,9 +348,8 @@
idsDone = true;
for (n = traverseNextItem(m_base.get()); n; n = traverseNextItem(n)) {
- if (checkForNameMatch(n, idsDone, name, caseSensitive)) {
+ if (checkForNameMatch(n, idsDone, name, caseSensitive))
break;
- }
}
info->current = n;
@@ -431,14 +429,14 @@
if (!n->isHTMLElement())
continue;
HTMLElementImpl* e = static_cast<HTMLElementImpl*>(n);
- QString idAttrVal = e->getAttribute(idAttr).qstring();
- QString nameAttrVal = e->getAttribute(nameAttr).qstring();
+ const AtomicString& idAttrVal = e->getAttribute(idAttr);
+ const AtomicString& nameAttrVal = e->getAttribute(nameAttr);
if (!idAttrVal.isEmpty()) {
// add to id cache
- QPtrVector<NodeImpl> *idVector = info->idCache.find(idAttrVal);
+ QPtrVector<NodeImpl> *idVector = info->idCache.get(idAttrVal.impl());
if (!idVector) {
idVector = new QPtrVector<NodeImpl>;
- info->idCache.insert(idAttrVal, idVector);
+ info->idCache.add(idAttrVal.impl(), idVector);
}
appendToVector(idVector, n);
}
@@ -448,10 +446,10 @@
e->hasLocalName(appletTag) || e->hasLocalName(objectTag) ||
e->hasLocalName(embedTag)))) {
// add to name cache
- QPtrVector<NodeImpl> *nameVector = info->nameCache.find(nameAttrVal);
+ QPtrVector<NodeImpl> *nameVector = info->nameCache.get(nameAttrVal.impl());
if (!nameVector) {
nameVector = new QPtrVector<NodeImpl>;
- info->nameCache.insert(nameAttrVal, nameVector);
+ info->nameCache.add(nameAttrVal.impl(), nameVector);
}
appendToVector(nameVector, n);
}
@@ -460,7 +458,7 @@
info->hasNameCache = true;
}
-QValueList< RefPtr<NodeImpl> > HTMLCollectionImpl::namedItems(const DOMString &name) const
+QValueList< RefPtr<NodeImpl> > HTMLCollectionImpl::namedItems(const AtomicString &name) const
{
QValueList< RefPtr<NodeImpl> > result;
@@ -470,8 +468,8 @@
resetCollectionInfo();
updateNameCache();
- QPtrVector<NodeImpl> *idResults = info->idCache.find(name.qstring());
- QPtrVector<NodeImpl> *nameResults = info->nameCache.find(name.qstring());
+ QPtrVector<NodeImpl> *idResults = info->idCache.get(name.impl());
+ QPtrVector<NodeImpl> *nameResults = info->nameCache.get(name.impl());
for (unsigned i = 0; idResults && i < idResults->count(); ++i) {
result.append(RefPtr<NodeImpl>(idResults->at(i)));
@@ -485,7 +483,7 @@
}
-NodeImpl *HTMLCollectionImpl::nextNamedItem( const DOMString &name ) const
+NodeImpl *HTMLCollectionImpl::nextNamedItem(const DOMString &name) const
{
resetCollectionInfo();
@@ -638,12 +636,12 @@
return item(info->position + 1);
}
-NodeImpl * HTMLFormCollectionImpl::nextNamedItemInternal( const DOMString &name ) const
+NodeImpl * HTMLFormCollectionImpl::nextNamedItemInternal(const DOMString &name) const
{
NodeImpl *retval = getNamedFormItem( idsDone ? nameAttr : idAttr, name, ++info->position, true );
- if ( retval )
+ if (retval)
return retval;
- if ( idsDone ) // we're done
+ if (idsDone) // we're done
return 0;
// After doing id, do name
idsDone = true;
@@ -696,7 +694,7 @@
if (info->hasNameCache)
return;
- QDict<char> foundInputElements;
+ HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> > foundInputElements;
if (!m_base->hasTagName(formTag)) {
info->hasNameCache = true;
@@ -709,50 +707,50 @@
for (unsigned i = 0; i < f->formElements.count(); ++i) {
HTMLGenericFormElementImpl* e = f->formElements[i];
if (e->isEnumeratable()) {
- QString idAttrVal = e->getAttribute(idAttr).qstring();
- QString nameAttrVal = e->getAttribute(nameAttr).qstring();
+ const AtomicString& idAttrVal = e->getAttribute(idAttr);
+ const AtomicString& nameAttrVal = e->getAttribute(nameAttr);
if (!idAttrVal.isEmpty()) {
// add to id cache
- QPtrVector<NodeImpl> *idVector = info->idCache.find(idAttrVal);
+ QPtrVector<NodeImpl> *idVector = info->idCache.get(idAttrVal.impl());
if (!idVector) {
idVector = new QPtrVector<NodeImpl>;
- info->idCache.insert(idAttrVal, idVector);
+ info->idCache.add(idAttrVal.impl(), idVector);
}
appendToVector(idVector, static_cast<NodeImpl *>(e));
- foundInputElements.insert(idAttrVal, (char *)true);
+ foundInputElements.insert(idAttrVal.impl());
}
if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal) {
// add to name cache
- QPtrVector<NodeImpl> *nameVector = info->nameCache.find(nameAttrVal);
+ QPtrVector<NodeImpl> *nameVector = info->nameCache.get(nameAttrVal.impl());
if (!nameVector) {
nameVector = new QPtrVector<NodeImpl>;
- info->nameCache.insert(nameAttrVal, nameVector);
+ info->nameCache.add(nameAttrVal.impl(), nameVector);
}
appendToVector(nameVector, static_cast<NodeImpl *>(e));
- foundInputElements.insert(nameAttrVal, (char *)true);
+ foundInputElements.insert(nameAttrVal.impl());
}
}
}
for (unsigned i = 0; i < f->imgElements.count(); ++i) {
HTMLImageElementImpl* e = f->imgElements[i];
- QString idAttrVal = e->getAttribute(idAttr).qstring();
- QString nameAttrVal = e->getAttribute(nameAttr).qstring();
- if (!idAttrVal.isEmpty() && !foundInputElements.find(idAttrVal)) {
+ const AtomicString& idAttrVal = e->getAttribute(idAttr);
+ const AtomicString& nameAttrVal = e->getAttribute(nameAttr);
+ if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.impl())) {
// add to id cache
- QPtrVector<NodeImpl> *idVector = info->idCache.find(idAttrVal);
+ QPtrVector<NodeImpl> *idVector = info->idCache.get(idAttrVal.impl());
if (!idVector) {
idVector = new QPtrVector<NodeImpl>;
- info->idCache.insert(idAttrVal, idVector);
+ info->idCache.add(idAttrVal.impl(), idVector);
}
appendToVector(idVector, static_cast<NodeImpl *>(e));
}
- if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && !foundInputElements.find(nameAttrVal)) {
+ if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && !foundInputElements.contains(nameAttrVal.impl())) {
// add to name cache
- QPtrVector<NodeImpl> *nameVector = info->nameCache.find(nameAttrVal);
+ QPtrVector<NodeImpl> *nameVector = info->nameCache.get(nameAttrVal.impl());
if (!nameVector) {
nameVector = new QPtrVector<NodeImpl>;
- info->nameCache.insert(nameAttrVal, nameVector);
+ info->nameCache.add(nameAttrVal.impl(), nameVector);
}
appendToVector(nameVector, static_cast<NodeImpl *>(e));
}
1.25 +5 -5 WebCore/khtml/html/html_miscimpl.h
Index: html_miscimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_miscimpl.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- html_miscimpl.h 1 Dec 2005 10:32:19 -0000 1.24
+++ html_miscimpl.h 30 Dec 2005 03:33:54 -0000 1.25
@@ -25,8 +25,8 @@
#include "html_elementimpl.h"
#include "misc/shared.h"
-#include <qdict.h>
#include <qptrvector.h>
+#include <kxmlcore/HashMap.h>
namespace DOM {
@@ -99,7 +99,7 @@
// In case of multiple items named the same way
virtual NodeImpl *nextNamedItem(const DOMString &name) const;
- QValueList< RefPtr<NodeImpl> > namedItems(const DOMString &name) const;
+ QValueList< RefPtr<NodeImpl> > namedItems(const AtomicString &name) const;
NodeImpl *base() { return m_base.get(); }
@@ -110,10 +110,10 @@
NodeImpl *current;
unsigned int position;
unsigned int length;
- bool haslength;
int elementsArrayPosition;
- QDict<QPtrVector<NodeImpl> > idCache;
- QDict<QPtrVector<NodeImpl> > nameCache;
+ HashMap<DOMStringImpl*, QPtrVector<NodeImpl>*, PointerHash<DOMStringImpl*> > idCache;
+ HashMap<DOMStringImpl*, QPtrVector<NodeImpl>*, PointerHash<DOMStringImpl*> > nameCache;
+ bool haslength;
bool hasNameCache;
};
More information about the webkit-changes
mailing list