[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE_3_1_BRANCH: kdelibs/khtml/xml
From:       David Faure <faure () kde ! org>
Date:       2003-06-25 23:21:52
[Download RAW message or body]

CVS commit by faure: 

Fix for getElementByTagName[TS], to support "*" in localname and namespaceuri.
Dirk said the patch looked okay to him. The issue of the id==0 check in tagId()
remains though (see kfm-devel).


  M +12 -6     dom_nodeimpl.cpp   1.192.2.7


--- kdelibs/khtml/xml/dom_nodeimpl.cpp  #1.192.2.6:1.192.2.7
@@ -1400,10 +1400,16 @@ NodeListImpl* NodeBaseImpl::getElementsB
     if (localName->l && localName->s[0] == '*')
         idMask &= ~NodeImpl_IdLocalMask;
-    if (!namespaceURI || (namespaceURI->l && namespaceURI->s[0] == '*'))
+    if (namespaceURI && namespaceURI->l && namespaceURI->s[0] == '*')
         idMask &= ~NodeImpl_IdNSMask;
 
-    return new TagNodeListImpl( this,
-                                getDocument()->tagId(namespaceURI, localName, true, 0),
-                                idMask);
+    Id id = 0; // 0 means "all items"
+    if ( (idMask & NodeImpl_IdLocalMask) || namespaceURI ) // not getElementsByTagName("*")
+    {
+        id = getDocument()->tagId( namespaceURI, localName, true /*readonly*/, 0 );
+        if ( !id ) // not found -> we want to return an empty list, not "all items"
+            id = (Id)-1;
+    }
+
+    return new TagNodeListImpl( this, id, idMask );
 }
 
@@ -1725,6 +1731,6 @@ NodeImpl *TagNodeListImpl::item ( unsign
 bool TagNodeListImpl::nodeMatches( NodeImpl *testNode ) const
 {
-    return ( testNode->isElementNode() && m_id &&
-             (testNode->id() & m_idMask) == m_id);
+    return testNode->isElementNode() &&
+           ((testNode->id() & m_idMask) == m_id);
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic