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

List:       kfm-devel
Subject:    Re: kdelibs/khtml/xml
From:       Germain Garand <germain () ebooksfrance ! org>
Date:       2004-06-14 2:50:31
Message-ID: 200406140350.31257.germain () ebooksfrance ! org
[Download RAW message or body]

Le Dimanche 13 Juin 2004 09:22, Zack Rusin a écrit :
> On Saturday 12 June 2004 22:25, Germain Garand wrote:
> > CVS commit by ggarand:
> >
> > HTML tags lookup: refining 1.276/1.280
>
> Thanks for looking into it, but I'm afraid it's not going to work. Check
> the testcase I'm attaching and this page:
>http://developer.apple.com/internet/webcontent/XMLHttpRequestExample/example.html
> for example of pages which completely confuse the getid lookup (in
> the latter we even have two different id's for the same tag).

Yes, you are right... it works for the XMLHttpRequest example but not for the 
xml testcase. 
It looks indeed like we can't avoid the HTML lookup for null or XHTML NS...
I attach a patch reverting to doing it that way, but avoids a double 
strcasecmp, and fixes the 6 namespaces.html regressions.
Does it look OK to you?

Germain


["dom_docimpl.cpp.diff" (text/x-diff)]

Index: xml/dom_docimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/xml/dom_docimpl.cpp,v
retrieving revision 1.282
diff -u -3 -p -B -r1.282 dom_docimpl.cpp
--- xml/dom_docimpl.cpp	13 Jun 2004 17:08:26 -0000	1.282
+++ xml/dom_docimpl.cpp	14 Jun 2004 02:39:23 -0000
@@ -1660,7 +1660,7 @@ typedef const char* (*NameLookupFunction
 typedef int (*IdLookupFunction)(const char *tagStr, int len);
 
 NodeImpl::Id DocumentImpl::getId( NodeImpl::IdType _type, DOMStringImpl* _nsURI, \
                DOMStringImpl *_prefix,
-                                  DOMStringImpl *_name, bool readonly, bool \
lookupHTML, int *pExceptioncode) +                                  DOMStringImpl \
*_name, bool readonly, bool /*lookupHTML*/, int *pExceptioncode)  {
     /*kdDebug() << "DocumentImpl::getId( type: " << _type << ", uri: " << \
                DOMString(_nsURI).string()
               << ", prefix: " << DOMString(_prefix).string() << ", name: " << \
DOMString(_name).string() @@ -1692,50 +1692,49 @@ NodeImpl::Id DocumentImpl::getId( \
NodeIm  return 0;
     }
 
-    NodeImpl::Id id = 0;
+    NodeImpl::Id id, nsid = 0;
     QConstString n(_name->s, _name->l);
     bool cs = true; // case sensitive
-    if (lookupHTML && _type != NodeImpl::NamespaceId) {
+    if (_type != NodeImpl::NamespaceId) {
+        if (_nsURI) 
+            nsid = getId( NodeImpl::NamespaceId, 0, 0, _nsURI, false, false, 0 ) << \
16; +
         // Each document maintains a mapping of tag name -> id for every tag name \
encountered  // in the document.
-        cs = (htmlMode() == XHtml);
-        // First see if it's a HTML element name
-        if ((!_nsURI && isHTMLDocument()) || !strcasecmp(_nsURI, XHTML_NAMESPACE)) {
-            // we're in HTML namespace if we know the tag.
+        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;
-            // ok, the fast path didn't work out, we need the full check
         }
     }
-    // now lets find out the namespace
-    if (_type != NodeImpl::NamespaceId && _nsURI)
-        id = getId( NodeImpl::NamespaceId, 0, 0, _nsURI, false, false, 0 ) << 16;
 
     // Look in the names array for the name
     // compatibility mode has to lookup upper case
     QString name = cs ? n.string() : n.string().upper();
-    NodeImpl::Id tmp;
+
     if (!_nsURI) {
-        tmp = (NodeImpl::Id) map->ids.find( name );
-        if (!tmp)
-            tmp = (NodeImpl::Id) map->ids.find( "aliases: " + name );
+        id = (NodeImpl::Id) map->ids.find( name );
+        if (!id && _type != NodeImpl::NamespaceId)
+            id = (NodeImpl::Id) map->ids.find( "aliases: " + name );
     } else {
-        tmp = (NodeImpl::Id) map->ids.find( name );
-        if (!readonly && tmp && _prefix && _prefix->l) {
+        id = (NodeImpl::Id) map->ids.find( name );
+        if (!readonly && id && _prefix && _prefix->l) {
             // we were called in registration mode... check if the alias exists
             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*)tmp );
+                map->ids.insert( qn, (void*)id );
             }
         }
     }
 
-    if(tmp) return id + tmp;
+    if (id) return nsid + id;
 
     // unknown
     if (readonly) return 0;
@@ -1765,7 +1764,7 @@ NodeImpl::Id DocumentImpl::getId( NodeIm
         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 id + cid;
+    return nsid + cid;
  }
 
 NodeImpl::Id DocumentImpl::getId( NodeImpl::IdType _type, DOMStringImpl *_nodeName, \
bool readonly, bool lookupHTML, int *pExceptioncode)



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

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