[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/3.5/kdelibs/khtml
From: Maks Orlovich <maksim () kde ! org>
Date: 2006-01-27 3:15:52
Message-ID: 1138331752.694917.10499.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 502712 by orlovich:
Fix ID assignment to make sure that html nodes
and xml nodes with the same localName get the same ID.
This is important so CSS stuff like *|name works (as it
tries to match on id)
Also, fix dumping of XML node ID's into the render trees.
M +7 -2 rendering/render_object.cpp
M +15 -21 xml/dom_docimpl.cpp
M +22 -0 xml/dom_docimpl.h
--- branches/KDE/3.5/kdelibs/khtml/rendering/render_object.cpp #502711:502712
@@ -1149,6 +1149,11 @@
return ts << "at (" << r.x() << "," << r.y() << ") size " << r.width() << "x" << r.height();
}
+//A bit like getTagName, but handles XML, too.
+static QString lookupTagName(NodeImpl* node) {
+ return node->getDocument()->getName(NodeImpl::ElementId, node->id()).string();
+}
+
void RenderObject::dump(QTextStream &ts, const QString &ind) const
{
if ( !layer() )
@@ -1161,13 +1166,13 @@
}
if (element()) {
- QString tagName(getTagName(element()->id()));
+ QString tagName(lookupTagName(element()));
if (!tagName.isEmpty()) {
ts << " {" << tagName << "}";
}
} else if (isPseudoAnonymous() && style() && style()->styleType() != RenderStyle::NOPSEUDO) {
QString pseudo;
- QString tagName(getTagName(node()->id()));
+ QString tagName(lookupTagName(node()));
switch (style()->styleType()) {
case RenderStyle::FIRST_LETTER:
pseudo = ":first-letter"; break;
--- branches/KDE/3.5/kdelibs/khtml/xml/dom_docimpl.cpp #502711:502712
@@ -1794,15 +1794,17 @@
// in the document.
cs = (htmlMode() == XHtml) || (_nsURI && _type != NodeImpl::AttributeId);
- if (!nsid) {
- // First see if it's a HTML element name
- // xhtml is lower case - case sensitive, easy to implement
- if ( cs && (id = lookup(n.string().ascii(), _name->l)) )
- return id;
- // compatibility: upper case - case insensitive
- if ( !cs && (id = lookup(n.string().lower().ascii(), _name->l )) )
- return id;
+ // First see if it's a HTML element name
+ // xhtml is lower case - case sensitive, easy to implement
+ if ( cs && (id = lookup(n.string().ascii(), _name->l)) ) {
+ map->addAlias(_prefix, _name, cs, id);
+ return nsid + id;
}
+ // compatibility: upper case - case insensitive
+ if ( !cs && (id = lookup(n.string().lower().ascii(), _name->l )) ) {
+ map->addAlias(_prefix, _name, cs, id);
+ return nsid + id;
+ }
}
// Look in the names array for the name
@@ -1811,8 +1813,9 @@
if (!_nsURI) {
id = (NodeImpl::Id)(long) map->ids.find( name );
- if (!id && _type != NodeImpl::NamespaceId)
+ if (!id && _type != NodeImpl::NamespaceId) {
id = (NodeImpl::Id)(long) map->ids.find( "aliases: " + name );
+ }
} else {
id = (NodeImpl::Id)(long) map->ids.find( name );
if (!readonly && id && _prefix && _prefix->l) {
@@ -1843,18 +1846,8 @@
map->ids.insert( name, (void*)cid );
// and register an alias if needed for DOM1 methods compatibility
- if(_prefix && _prefix->l) {
- QConstString px( _prefix->s, _prefix->l );
- QString qn("aliases: " + (cs ? px.string() : px.string().upper()) + ":" + name);
- if (!map->ids.find( qn )) {
- map->ids.insert( qn, (void*)cid );
- }
- }
+ map->addAlias(_prefix, _name, cs, cid);
- if (map->ids.size() == map->ids.count() && map->ids.size() != khtml_MaxSeed)
- map->ids.resize( khtml::nextSeed(map->ids.count()) );
- if (map->names.size() == map->names.count() && map->names.size() != khtml_MaxSeed)
- map->names.resize( khtml::nextSeed(map->names.count()) );
return nsid + cid;
}
@@ -1889,8 +1882,9 @@
return DOMString();;
}
_id = _id & NodeImpl_IdLocalMask;
- if (_id >= map->idStart)
+ if (_id >= map->idStart) {
return map->names[_id];
+ }
else if (lookup) {
// ### put them in a cache
if (hasNS)
--- branches/KDE/3.5/kdelibs/khtml/xml/dom_docimpl.h #502711:502712
@@ -31,6 +31,7 @@
#include "xml/dom2_traversalimpl.h"
#include "misc/shared.h"
#include "misc/loader.h"
+#include "misc/seed.h"
#include <qstringlist.h>
#include <qptrlist.h>
@@ -583,6 +584,27 @@
unsigned short count;
QIntDict<DOM::DOMStringImpl> names;
QDict<void> ids;
+
+ void expandIfNeeded() {
+ if (ids.size() <= ids.count() && ids.size() != khtml_MaxSeed)
+ ids.resize( khtml::nextSeed(ids.count()) );
+ if (names.size() <= names.count() && names.size() != khtml_MaxSeed)
+ names.resize( khtml::nextSeed(names.count()) );
+ }
+
+ void addAlias(DOMStringImpl* _prefix, DOMStringImpl* _name, bool cs, NodeImpl::Id id) {
+ if(_prefix && _prefix->l) {
+ QConstString n(_name->s, _name->l);
+ QConstString px( _prefix->s, _prefix->l );
+ QString name = cs ? n.string() : n.string().upper();
+ QString qn("aliases: " + (cs ? px.string() : px.string().upper()) + ":" + name);
+ if (!ids.find( qn )) {
+ ids.insert( qn, (void*)id );
+ }
+ }
+ expandIfNeeded();
+ }
+
};
IdNameMapping *m_attrMap;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic