[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

hyatt hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:23:44 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 18cf9ea84b769902dab27fb0b4747f5196bc1ca1
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jan 26 22:33:19 2004 +0000

    	Add CSS3 @namespace support.  The whole way namespaces, element, and attribute names are being handled
    	right now is temporary.  This code gives us a baseline of functionality (for regression testing) that we
    	can use when we implement namespaces "the right way."
    
            Reviewed by darin
    
            * WebCore.pbproj/project.pbxproj:
            * khtml/css/css_base.cpp:
            (CSSSelector::specificity):
            (CSSSelector::selectorText):
            * khtml/css/css_base.h:
            (DOM::CSSNamespace::m_parent):
            (DOM::CSSNamespace::~CSSNamespace):
            (DOM::CSSNamespace::uri):
            (DOM::CSSNamespace::prefix):
            (DOM::CSSNamespace::namespaceForPrefix):
            (DOM::CSSSelector::CSSSelector):
            * khtml/css/css_stylesheetimpl.cpp:
            (CSSStyleSheetImpl::CSSStyleSheetImpl):
            (CSSStyleSheetImpl::addNamespace):
            (CSSStyleSheetImpl::determineNamespace):
            * khtml/css/css_stylesheetimpl.h:
            (DOM::CSSStyleSheetImpl::~CSSStyleSheetImpl):
            * khtml/css/cssparser.cpp:
            (CSSParser::CSSParser):
            (CSSParser::parseSheet):
            * khtml/css/cssparser.h:
            * khtml/css/cssstyleselector.cpp:
            (khtml::CSSStyleSelector::styleForElement):
            (khtml::CSSStyleSelector::pseudoStyleForElement):
            (khtml::CSSStyleSelector::checkSelector):
            (khtml::CSSStyleSelector::checkOneSelector):
            (khtml::CSSStyleSelector::buildLists):
            * khtml/css/html4.css:
            * khtml/css/parser.cpp:
            * khtml/css/parser.y:
            * khtml/xml/dom_docimpl.cpp:
            (DocumentImpl::DocumentImpl):
            (DocumentImpl::~DocumentImpl):
            (DocumentImpl::attrId):
            (DocumentImpl::attrName):
            (DocumentImpl::tagId):
            (DocumentImpl::tagName):
            (DocumentImpl::namespaceURI):
            * khtml/xml/dom_elementimpl.cpp:
            (NamedAttrMapImpl::getAttributeItem):
            * khtml/xml/dom_nodeimpl.cpp:
            (NodeImpl::checkSetPrefix):
            * khtml/xml/dom_nodeimpl.h:
            (DOM::namespacePart):
            (DOM::localNamePart):
            (DOM::makeId):
            * khtml/xml/dom_xmlimpl.cpp:
            (ProcessingInstructionImpl::checkStyleSheet):
            * khtml/xml/xml_namespace_table.cpp: Added.
            (DOM::XmlNamespaceTable::getNamespaceID):
            (DOM::XmlNamespaceTable::getNamespaceURI):
            * khtml/xml/xml_namespace_table.h: Added.
            (DOM::XmlNamespaceEntry::m_uri):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5978 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index d52826b..8b2f26d 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,65 @@
+2004-01-26  David Hyatt  <hyatt at apple.com>
+
+	Add CSS3 @namespace support.  The whole way namespaces, element, and attribute names are being handled
+	right now is temporary.  This code gives us a baseline of functionality (for regression testing) that we
+	can use when we implement namespaces "the right way."
+	
+        Reviewed by darin
+
+        * WebCore.pbproj/project.pbxproj:
+        * khtml/css/css_base.cpp:
+        (CSSSelector::specificity):
+        (CSSSelector::selectorText):
+        * khtml/css/css_base.h:
+        (DOM::CSSNamespace::m_parent):
+        (DOM::CSSNamespace::~CSSNamespace):
+        (DOM::CSSNamespace::uri):
+        (DOM::CSSNamespace::prefix):
+        (DOM::CSSNamespace::namespaceForPrefix):
+        (DOM::CSSSelector::CSSSelector):
+        * khtml/css/css_stylesheetimpl.cpp:
+        (CSSStyleSheetImpl::CSSStyleSheetImpl):
+        (CSSStyleSheetImpl::addNamespace):
+        (CSSStyleSheetImpl::determineNamespace):
+        * khtml/css/css_stylesheetimpl.h:
+        (DOM::CSSStyleSheetImpl::~CSSStyleSheetImpl):
+        * khtml/css/cssparser.cpp:
+        (CSSParser::CSSParser):
+        (CSSParser::parseSheet):
+        * khtml/css/cssparser.h:
+        * khtml/css/cssstyleselector.cpp:
+        (khtml::CSSStyleSelector::styleForElement):
+        (khtml::CSSStyleSelector::pseudoStyleForElement):
+        (khtml::CSSStyleSelector::checkSelector):
+        (khtml::CSSStyleSelector::checkOneSelector):
+        (khtml::CSSStyleSelector::buildLists):
+        * khtml/css/html4.css:
+        * khtml/css/parser.cpp:
+        * khtml/css/parser.y:
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::DocumentImpl):
+        (DocumentImpl::~DocumentImpl):
+        (DocumentImpl::attrId):
+        (DocumentImpl::attrName):
+        (DocumentImpl::tagId):
+        (DocumentImpl::tagName):
+        (DocumentImpl::namespaceURI):
+        * khtml/xml/dom_elementimpl.cpp:
+        (NamedAttrMapImpl::getAttributeItem):
+        * khtml/xml/dom_nodeimpl.cpp:
+        (NodeImpl::checkSetPrefix):
+        * khtml/xml/dom_nodeimpl.h:
+        (DOM::namespacePart):
+        (DOM::localNamePart):
+        (DOM::makeId):
+        * khtml/xml/dom_xmlimpl.cpp:
+        (ProcessingInstructionImpl::checkStyleSheet):
+        * khtml/xml/xml_namespace_table.cpp: Added.
+        (DOM::XmlNamespaceTable::getNamespaceID):
+        (DOM::XmlNamespaceTable::getNamespaceURI):
+        * khtml/xml/xml_namespace_table.h: Added.
+        (DOM::XmlNamespaceEntry::m_uri):
+
 2004-01-26  Darin Adler  <darin at apple.com>
 
         Reviewed by Dave.
diff --git a/WebCore/WebCore.pbproj/project.pbxproj b/WebCore/WebCore.pbproj/project.pbxproj
index b369e60..fc8dc74 100644
--- a/WebCore/WebCore.pbproj/project.pbxproj
+++ b/WebCore/WebCore.pbproj/project.pbxproj
@@ -521,6 +521,7 @@
 				BEB1DD2805C197F800DD1F43,
 				BEB1DD3205C1980700DD1F43,
 				BEB1DD3E05C1982000DD1F43,
+				BC7FDE3405C1D9AB0070A902,
 			);
 			isa = PBXHeadersBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -794,6 +795,7 @@
 				BEB1DD2705C197F800DD1F43,
 				BEB1DD3105C1980700DD1F43,
 				BEB1DD3D05C1982000DD1F43,
+				BC7FDE3305C1D9AB0070A902,
 			);
 			isa = PBXSourcesBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -2101,6 +2103,34 @@
 			settings = {
 			};
 		};
+		BC7FDE3105C1D9AB0070A902 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.cpp.cpp;
+			path = xml_namespace_table.cpp;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BC7FDE3205C1D9AB0070A902 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.c.h;
+			path = xml_namespace_table.h;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BC7FDE3305C1D9AB0070A902 = {
+			fileRef = BC7FDE3105C1D9AB0070A902;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BC7FDE3405C1D9AB0070A902 = {
+			fileRef = BC7FDE3205C1D9AB0070A902;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		BC80A6930468B78100DBCC9C = {
 			fileEncoding = 30;
 			isa = PBXFileReference;
@@ -5903,6 +5933,8 @@
 				F523D30602DE4476018635CA,
 				F523D30702DE4476018635CA,
 				F523D30802DE4476018635CA,
+				BC7FDE3105C1D9AB0070A902,
+				BC7FDE3205C1D9AB0070A902,
 				F523D30902DE4476018635CA,
 				F523D30A02DE4476018635CA,
 			);
diff --git a/WebCore/khtml/css/css_base.cpp b/WebCore/khtml/css/css_base.cpp
index ef4527f..24abaff 100644
--- a/WebCore/khtml/css/css_base.cpp
+++ b/WebCore/khtml/css/css_base.cpp
@@ -135,7 +135,7 @@ unsigned int CSSSelector::specificity()
     if ( nonCSSHint )
         return 0;
 
-    int s = ((tag == -1) ? 0 : 1);
+    int s = ((localNamePart(tag) == anyLocalName) ? 0 : 1);
     switch(match)
     {
     case Id:
@@ -256,26 +256,29 @@ bool CSSSelector::operator == ( const CSSSelector &other )
 
 DOMString CSSSelector::selectorText() const
 {
+    // FIXME: Support namespaces when dumping the selector text.  This requires preserving
+    // the original namespace prefix used. Ugh. -dwh
     DOMString str;
     const CSSSelector* cs = this;
-    if ( cs->tag == -1 && cs->attr == ATTR_ID && cs->match == CSSSelector::Exact )
+    Q_UINT16 tag = localNamePart(cs->tag);
+    if ( tag == anyLocalName && cs->attr == ATTR_ID && cs->match == CSSSelector::Exact )
     {
         str = "#";
         str += cs->value;
     }
-    else if ( cs->tag == -1 && cs->attr == ATTR_CLASS && cs->match == CSSSelector::List )
+    else if ( tag == anyLocalName && cs->attr == ATTR_CLASS && cs->match == CSSSelector::List )
     {
         str = ".";
         str += cs->value;
     }
-    else if ( cs->tag == -1 && cs->match == CSSSelector::Pseudo )
+    else if ( tag == anyLocalName && cs->match == CSSSelector::Pseudo )
     {
         str = ":";
         str += cs->value;
     }
     else
     {
-        if ( cs->tag == -1 )
+        if ( tag == anyLocalName )
             str = "*";
         else
             str = getTagName( cs->tag );
diff --git a/WebCore/khtml/css/css_base.h b/WebCore/khtml/css/css_base.h
index a50fcb5..60bfde9 100644
--- a/WebCore/khtml/css/css_base.h
+++ b/WebCore/khtml/css/css_base.h
@@ -27,6 +27,7 @@
 
 #include "dom/dom_string.h"
 #include "dom/dom_misc.h"
+#include "xml/dom_nodeimpl.h"
 #include "misc/shared.h"
 #include <qdatetime.h>
 #include <qptrlist.h>
@@ -46,13 +47,35 @@ namespace DOM {
 
     class DocumentImpl;
 
+    struct CSSNamespace {
+        DOMString m_prefix;
+        DOMString m_uri;
+        CSSNamespace* m_parent;
+
+        CSSNamespace(const DOMString& p, const DOMString& u, CSSNamespace* parent) 
+            :m_prefix(p), m_uri(u), m_parent(parent) {}
+        ~CSSNamespace() { delete m_parent; }
+        
+        const DOMString& uri() { return m_uri; }
+        const DOMString& prefix() { return m_prefix; }
+        
+        CSSNamespace* namespaceForPrefix(const DOMString& prefix) {
+            if (prefix == m_prefix)
+                return this;
+            if (m_parent)
+                return m_parent->namespaceForPrefix(prefix);
+            return 0;
+        }
+    };
+    
 // this class represents a selector for a StyleRule
     class CSSSelector
     {
     public:
 	CSSSelector()
-	    : tagHistory(0), simpleSelector(0), attr(0), tag(-1), relation( Descendant ),
-	      match( None ), nonCSSHint( false ), pseudoId( 0 ), _pseudoType(PseudoNotParsed)
+	    : tagHistory(0), simpleSelector(0), attr(0), tag(anyQName),
+              relation( Descendant ), match( None ), nonCSSHint( false ), 
+              pseudoId( 0 ), _pseudoType(PseudoNotParsed)
         {}
 
 	~CSSSelector() {
@@ -134,10 +157,10 @@ namespace DOM {
 	mutable DOM::DOMString value;
 	CSSSelector *tagHistory;
         CSSSelector* simpleSelector; // Used for :not.
-	int          attr;
-	int          tag;
+	Q_UINT32     attr;
+	Q_UINT32     tag;
 
-	Relation relation     : 2;
+        Relation relation     : 2;
 	Match 	 match         : 4;
 	bool	nonCSSHint : 1;
 	unsigned int pseudoId : 3;
diff --git a/WebCore/khtml/css/css_stylesheetimpl.cpp b/WebCore/khtml/css/css_stylesheetimpl.cpp
index 8e1cde7..799a300 100644
--- a/WebCore/khtml/css/css_stylesheetimpl.cpp
+++ b/WebCore/khtml/css/css_stylesheetimpl.cpp
@@ -37,6 +37,8 @@
 #include "html/html_documentimpl.h"
 #include "misc/loader.h"
 
+#include "xml_namespace_table.h"
+
 #include <kdebug.h>
 
 using namespace DOM;
@@ -104,6 +106,7 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(CSSStyleSheetImpl *parentSheet, DOMString h
     m_lstChildren = new QPtrList<StyleBaseImpl>;
     m_doc = 0;
     m_implicit = false;
+    m_namespaces = 0;
 }
 
 CSSStyleSheetImpl::CSSStyleSheetImpl(DOM::NodeImpl *parentNode, DOMString href, bool _implicit)
@@ -111,7 +114,8 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(DOM::NodeImpl *parentNode, DOMString href,
 {
     m_lstChildren = new QPtrList<StyleBaseImpl>;
     m_doc = parentNode->getDocument();
-    m_implicit = _implicit;
+    m_implicit = _implicit; 
+    m_namespaces = 0;
 }
 
 CSSStyleSheetImpl::CSSStyleSheetImpl(CSSRuleImpl *ownerRule, DOMString href)
@@ -120,6 +124,7 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(CSSRuleImpl *ownerRule, DOMString href)
     m_lstChildren = new QPtrList<StyleBaseImpl>;
     m_doc = 0;
     m_implicit = false;
+    m_namespaces = 0;
 }
 
 CSSStyleSheetImpl::CSSStyleSheetImpl(DOM::NodeImpl *parentNode, CSSStyleSheetImpl *orig)
@@ -134,6 +139,7 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(DOM::NodeImpl *parentNode, CSSStyleSheetImp
     }
     m_doc = parentNode->getDocument();
     m_implicit = false;
+    m_namespaces = 0;
 }
 
 CSSStyleSheetImpl::CSSStyleSheetImpl(CSSRuleImpl *ownerRule, CSSStyleSheetImpl *orig)
@@ -149,6 +155,7 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(CSSRuleImpl *ownerRule, CSSStyleSheetImpl *
     }
     m_doc  = 0;
     m_implicit = false;
+    m_namespaces = 0;
 }
 
 CSSRuleImpl *CSSStyleSheetImpl::ownerRule() const
@@ -195,14 +202,36 @@ void CSSStyleSheetImpl::deleteRule( unsigned long index, int &exceptioncode )
     b->deref();
 }
 
-void CSSStyleSheetImpl::addNamespace(const DOM::DOMString& prefix, const DOM::DOMString& uri)
+void CSSStyleSheetImpl::addNamespace(CSSParser* p, const DOM::DOMString& prefix, const DOM::DOMString& uri)
 {
-    printf("Adding namespace.\n");
+    if (uri.isEmpty())
+        return;
+
+    m_namespaces = new CSSNamespace(prefix, uri, m_namespaces);
+    
+    if (prefix.isEmpty())
+        // Set the default namespace on the parser so that selectors that omit namespace info will
+        // be able to pick it up easily.
+        p->defaultNamespace = XmlNamespaceTable::getNamespaceID(uri, false);
 }
 
-void CSSStyleSheetImpl::determineNamespace(CSSSelector* selector, const DOM::DOMString& prefix)
+void CSSStyleSheetImpl::determineNamespace(Q_UINT32& id, const DOM::DOMString& prefix)
 {
-    printf("Determining namespace.\n");
+    // If the stylesheet has no namespaces we can just return.  There won't be any need to ever check
+    // namespace values in selectors.
+    if (!m_namespaces)
+        return;
+    
+    if (prefix.isEmpty())
+        id = makeId(noNamespace, localNamePart(id)); // No namespace. If an element/attribute has a namespace, we won't match it.
+    else if (prefix == "*")
+        id = makeId(anyNamespace, localNamePart(id)); // We'll match any namespace.
+    else {
+        CSSNamespace* ns = m_namespaces->namespaceForPrefix(prefix);
+        if (ns)
+            // Look up the id for this namespace URI.
+            id = makeId(XmlNamespaceTable::getNamespaceID(ns->uri(), false), localNamePart(id));
+    }
 }
 
 bool CSSStyleSheetImpl::parseString(const DOMString &string, bool strict)
diff --git a/WebCore/khtml/css/css_stylesheetimpl.h b/WebCore/khtml/css/css_stylesheetimpl.h
index 5ae0a14..152552c 100644
--- a/WebCore/khtml/css/css_stylesheetimpl.h
+++ b/WebCore/khtml/css/css_stylesheetimpl.h
@@ -37,6 +37,7 @@ namespace khtml {
 
 namespace DOM {
 
+class CSSParser;
 class StyleSheet;
 class CSSStyleSheet;
 class MediaListImpl;
@@ -87,7 +88,9 @@ public:
     // clone from a cached version of the sheet
     CSSStyleSheetImpl(DOM::NodeImpl *parentNode, CSSStyleSheetImpl *orig);
     CSSStyleSheetImpl(CSSRuleImpl *ownerRule, CSSStyleSheetImpl *orig);
-
+    
+    ~CSSStyleSheetImpl() { delete m_namespaces; }
+    
     virtual bool isCSSStyleSheet() const { return true; }
 
     virtual DOM::DOMString type() const { return "text/css"; }
@@ -97,8 +100,8 @@ public:
     unsigned long insertRule ( const DOM::DOMString &rule, unsigned long index, int &exceptioncode );
     void deleteRule ( unsigned long index, int &exceptioncode );
 
-    void addNamespace(const DOM::DOMString& prefix, const DOM::DOMString& uri);
-    void determineNamespace(CSSSelector* selector, const DOM::DOMString& prefix);
+    void addNamespace(CSSParser* p, const DOM::DOMString& prefix, const DOM::DOMString& uri);
+    void determineNamespace(Q_UINT32& id, const DOM::DOMString& prefix);
     
     virtual bool parseString( const DOMString &string, bool strict = true );
 
@@ -112,6 +115,7 @@ public:
 protected:
     DocumentImpl *m_doc;
     bool m_implicit;
+    CSSNamespace* m_namespaces;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/WebCore/khtml/css/cssparser.cpp b/WebCore/khtml/css/cssparser.cpp
index 1efd54e..5c8d37a 100644
--- a/WebCore/khtml/css/cssparser.cpp
+++ b/WebCore/khtml/css/cssparser.cpp
@@ -101,6 +101,9 @@ CSSParser::CSSParser( bool strictParsing )
     important = false;
     nonCSSHint = false;
     inParseShortHand = false;
+    
+    defaultNamespace = anyNamespace;
+    
     yy_start = 1;
 
 #if YYDEBUG > 0
@@ -128,7 +131,8 @@ CSSParser::~CSSParser()
 void CSSParser::parseSheet( CSSStyleSheetImpl *sheet, const DOMString &string )
 {
     styleElement = sheet;
-
+    defaultNamespace = anyNamespace; // Reset the default namespace.
+    
     int length = string.length() + 3;
     data = (unsigned short *)malloc( length *sizeof( unsigned short ) );
     memcpy( data, string.unicode(), string.length()*sizeof( unsigned short) );
diff --git a/WebCore/khtml/css/cssparser.h b/WebCore/khtml/css/cssparser.h
index d3aaa04..fc4c987 100644
--- a/WebCore/khtml/css/cssparser.h
+++ b/WebCore/khtml/css/cssparser.h
@@ -143,6 +143,8 @@ namespace DOM {
 	int maxParsedProperties;
 	bool inParseShortHand;
 
+        Q_UINT16 defaultNamespace;
+        
 	static CSSParser *currentParser;
 
 	// tokenizer methods and data
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index 213bb6f..8203a36 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -350,14 +350,13 @@ RenderStyle* CSSStyleSelector::styleForElement(ElementImpl* e, RenderStyle* defa
     unsigned int numPropsToApply = 0;
     
     // try to sort out most style rules as early as possible.
-    // ### implement CSS3 namespace support
-    int cssTagId = (e->id() & NodeImpl::IdLocalMask);
+    Q_UINT16 cssTagId = localNamePart(e->id());
     int smatch = 0;
     int schecked = 0;
 
     for ( unsigned int i = 0; i < selectors_size; i++ ) {
-	int tag = selectors[i]->tag;
-	if ( cssTagId == tag || tag == -1 ) {
+	Q_UINT16 tag = localNamePart(selectors[i]->tag);
+	if ( cssTagId == tag || tag == anyLocalName ) {
 	    ++schecked;
 
 	    checkSelector( i, e );
@@ -447,13 +446,12 @@ RenderStyle* CSSStyleSelector::pseudoStyleForElement(RenderStyle::PseudoId pseud
     unsigned int numPseudoProps = 0;
     
     // try to sort out most style rules as early as possible.
-    // ### implement CSS3 namespace support
-    int cssTagId = (e->id() & NodeImpl::IdLocalMask);
+    Q_UINT16 cssTagId = localNamePart(e->id());
     int schecked = 0;
     
     for ( unsigned int i = 0; i < selectors_size; i++ ) {
-        int tag = selectors[i]->tag;
-        if ( cssTagId == tag || tag == -1 ) {
+        Q_UINT16 tag = localNamePart(selectors[i]->tag);
+        if ( cssTagId == tag || tag == anyLocalName ) {
             ++schecked;
             
             checkSelector( i, e, pseudoStyle );
@@ -747,7 +745,7 @@ void CSSStyleSelector::checkSelector(int selIndex, DOM::ElementImpl *e, RenderSt
     // We track whether or not the rule contains only :hover and :active in a simple selector. If
     // so, we can't allow that to apply to every element on the page.  We assume the author intended
     // to apply the rules only to links.
-    bool onlyHoverActive = (sel->tag == -1 &&
+    bool onlyHoverActive = (sel->tag == anyQName &&
                             (sel->match == CSSSelector::Pseudo &&
                               (sel->pseudoType() == CSSSelector::PseudoHover ||
                                sel->pseudoType() == CSSSelector::PseudoActive)));
@@ -856,7 +854,20 @@ bool CSSStyleSelector::checkOneSelector(DOM::CSSSelector *sel, DOM::ElementImpl
     if(!e)
         return false;
 
-    if((e->id() & NodeImpl::IdLocalMask) != uint(sel->tag) && sel->tag != -1) return false;
+    if (sel->tag != anyQName) {
+        int eltID = e->id();
+        Q_UINT16 localName = localNamePart(eltID);
+        Q_UINT16 ns = namespacePart(eltID);
+        Q_UINT16 selLocalName = localNamePart(sel->tag);
+        Q_UINT16 selNS = namespacePart(sel->tag);
+        
+        if (selNS == xhtmlNamespace && localName < ID_LAST_TAG)
+            selNS = anyNamespace; // Always match HTML elements even when in HTML docs.
+        
+        if ((selLocalName != anyLocalName && localName != selLocalName) ||
+            (selNS != anyNamespace && ns != selNS))
+            return false;
+    }
 
     if(sel->attr)
     {
@@ -1205,37 +1216,6 @@ void CSSStyleSelector::buildLists()
         }
     }
     delete [] offsets;
-
-
-#if 0
-    // and now the same for the selector map
-    for ( unsigned int sel = 0; sel < selectors_size; ++sel ) {
-        kdDebug( 6080 ) << "trying for sel: " << sel << endl;
-        int len = 0;
-        int offset = 0;
-        bool matches = false;
-        for ( unsigned int i = 0; i < selectors_size; i++ ) {
-            int tag = selectors[i]->tag;
-            if ( sel != tag && tag != -1 )
-                selectorCache[i].state = Invalid;
-            else
-                selectorCache[i].state = Unknown;
-
-            if ( matches != ( selectorCache[i].state == Unknown ) ) {
-                if ( matches ) {
-                    kdDebug( 6080 ) << "new: offs: " << offset << " len: " << len << endl;
-                    matches = false;
-                }
-                else {
-                    matches = true;
-//                    offset = p-selectors;
-                    len = 0;
-                }
-            }
-            ++len;
-        }
-    }
-#endif
 }
 
 
diff --git a/WebCore/khtml/css/html4.css b/WebCore/khtml/css/html4.css
index 6da8ae1..d6ce8ea 100644
--- a/WebCore/khtml/css/html4.css
+++ b/WebCore/khtml/css/html4.css
@@ -7,6 +7,8 @@
  * what you are doing.
  */
 
+ at namespace "http://www.w3.org/1999/xhtml";
+
 html {
 	display: block;
 } 
@@ -424,7 +426,7 @@ acronym {
 	font-style: italic;
 }
 
-:focus          { outline: auto 3px #1f5ccf }
+*|:focus          { outline: auto 3px #1f5ccf }
 a:link          { color: #0000EE; text-decoration: underline; }
 a:link:active          { color: red }
 a:visited              { color: #551A8B; text-decoration: underline; }
diff --git a/WebCore/khtml/css/parser.cpp b/WebCore/khtml/css/parser.cpp
index b37ac5f..e25a333 100644
--- a/WebCore/khtml/css/parser.cpp
+++ b/WebCore/khtml/css/parser.cpp
@@ -92,6 +92,8 @@
 #include <misc/htmlhashes.h>
 #include "cssparser.h"
 
+#include "xml_namespace_table.h"
+    
 #include <assert.h>
 #include <kdebug.h>
 // #define CSS_DEBUG
@@ -135,7 +137,7 @@ static inline int getValueID(const char *tagStr, int len)
 #define YYMAXDEPTH 0
 #define YYPARSE_PARAM parser
 
-#line 84 "parser.y"
+#line 86 "parser.y"
 typedef union {
     CSSRuleImpl *rule;
     CSSSelector *selector;
@@ -155,7 +157,7 @@ typedef union {
     Value value;
     ValueList *valueList;
 } YYSTYPE;
-#line 104 "parser.y"
+#line 106 "parser.y"
 
 
 static inline int cssyyerror(const char *x ) {
@@ -193,15 +195,15 @@ static const char yytranslate[] = {     0,
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      2,     2,     2,     2,    61,     2,     2,     2,     2,     2,
-    59,    13,    53,    52,    55,    15,    60,     2,     2,     2,
-     2,     2,     2,     2,     2,     2,     2,    14,    51,     2,
-    58,    54,     2,    62,     2,     2,     2,     2,     2,     2,
+    59,    55,    52,    51,    54,    14,    60,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,    13,    50,     2,
+    58,    53,     2,    62,     2,     2,     2,     2,     2,     2,
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-    16,     2,    57,     2,     2,     2,     2,     2,     2,     2,
+    15,     2,    57,     2,     2,     2,     2,     2,     2,     2,
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,    49,    56,    50,     2,     2,     2,     2,     2,
+     2,     2,    48,    56,    49,     2,     2,     2,     2,     2,
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
@@ -215,10 +217,10 @@ static const char yytranslate[] = {     0,
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
-     7,     8,     9,    10,    11,    12,    17,    18,    19,    20,
-    21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
-    31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
-    41,    42,    43,    44,    45,    46,    47,    48
+     7,     8,     9,    10,    11,    12,    16,    17,    18,    19,
+    20,    21,    22,    23,    24,    25,    26,    27,    28,    29,
+    30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
+    40,    41,    42,    43,    44,    45,    46,    47
 };
 
 #if YYDEBUG != 0
@@ -244,59 +246,59 @@ static const short yyprhs[] = {     0,
 
 static const short yyrhs[] = {    69,
     68,    70,    71,    72,     0,    64,    67,     0,    65,    67,
-     0,    66,    67,     0,    23,    49,    67,    87,    67,    50,
-     0,    24,    49,    67,   101,    50,     0,    25,    49,    67,
-   106,    50,     0,     0,    67,     3,     0,     0,    68,     4,
-     0,    68,     3,     0,     0,    21,    67,    10,    67,    51,
-     0,    21,     1,   114,     0,    21,     1,    51,     0,     0,
+     0,    66,    67,     0,    22,    48,    67,    87,    67,    49,
+     0,    23,    48,    67,   101,    49,     0,    24,    48,    67,
+   106,    49,     0,     0,    67,     3,     0,     0,    68,     4,
+     0,    68,     3,     0,     0,    20,    67,    10,    67,    50,
+     0,    20,     1,   114,     0,    20,     1,    50,     0,     0,
     70,    74,    68,     0,     0,    71,    75,    68,     0,     0,
     72,    73,    68,     0,    87,     0,    80,     0,    83,     0,
-    84,     0,   113,     0,   112,     0,    17,    67,    77,    67,
-    78,    51,     0,    17,     1,   114,     0,    17,     1,    51,
-     0,    22,    67,    76,    77,    67,    51,     0,    22,     1,
-   114,     0,    22,     1,    51,     0,     0,    11,     3,     0,
-    10,     0,    46,     0,     0,    79,     0,     0,    82,     0,
-    79,    52,    67,    82,     0,    79,     1,     0,    19,    67,
-    79,    49,    67,    81,    50,     0,     0,    81,    87,    67,
-     0,    11,    67,     0,    18,     1,   114,     0,    18,     1,
-    51,     0,    20,     1,   114,     0,    20,     1,    51,     0,
-    53,    67,     0,    54,    67,     0,     0,    55,     0,    53,
-     0,    88,    49,    67,   101,    50,     0,    89,     0,    88,
-    52,    67,    89,     0,    88,     1,     0,    91,     0,    89,
-    85,    91,     0,    89,     1,     0,     0,    13,     0,    11,
+    84,     0,   113,     0,   112,     0,    16,    67,    77,    67,
+    78,    50,     0,    16,     1,   114,     0,    16,     1,    50,
+     0,    21,    67,    76,    77,    67,    50,     0,    21,     1,
+   114,     0,    21,     1,    50,     0,     0,    11,     3,     0,
+    10,     0,    45,     0,     0,    79,     0,     0,    82,     0,
+    79,    51,    67,    82,     0,    79,     1,     0,    18,    67,
+    79,    48,    67,    81,    49,     0,     0,    81,    87,    67,
+     0,    11,    67,     0,    17,     1,   114,     0,    17,     1,
+    50,     0,    19,     1,   114,     0,    19,     1,    50,     0,
+    52,    67,     0,    53,    67,     0,     0,    54,     0,    52,
+     0,    88,    48,    67,   101,    49,     0,    89,     0,    88,
+    51,    67,    89,     0,    88,     1,     0,    91,     0,    89,
+    85,    91,     0,    89,     1,     0,     0,    55,     0,    11,
      0,    92,    67,     0,    92,    93,    67,     0,    93,    67,
      0,    90,    56,    92,    67,     0,    90,    56,    92,    93,
-    67,     0,    90,    56,    93,    67,     0,    11,     0,    13,
+    67,     0,    90,    56,    93,    67,     0,    11,     0,    55,
      0,    94,     0,    93,    94,     0,    93,     1,     0,    12,
-     0,    95,     0,    97,     0,   100,     0,    15,    11,     0,
-    11,    67,     0,    16,    67,    96,    57,     0,    16,    67,
-    96,    98,    67,    99,    67,    57,     0,    16,    67,    90,
-    56,    96,    57,     0,    16,    67,    90,    56,    96,    98,
+     0,    95,     0,    97,     0,   100,     0,    14,    11,     0,
+    11,    67,     0,    15,    67,    96,    57,     0,    15,    67,
+    96,    98,    67,    99,    67,    57,     0,    15,    67,    90,
+    56,    96,    57,     0,    15,    67,    90,    56,    96,    98,
     67,    99,    67,    57,     0,    58,     0,     5,     0,     6,
      0,     7,     0,     8,     0,     9,     0,    11,     0,    10,
-     0,    14,    11,     0,    14,    14,    11,     0,    14,    47,
+     0,    13,    11,     0,    13,    13,    11,     0,    13,    46,
     67,    91,    67,    59,     0,   103,     0,   102,   103,     0,
-   102,     0,     1,   115,     1,     0,     1,     0,   103,    51,
-    67,     0,   103,   115,    51,    67,     0,     1,    51,    67,
-     0,     1,   115,     1,    51,    67,     0,   102,   103,    51,
-    67,     0,   102,     1,    51,    67,     0,   102,     1,   115,
-     1,    51,    67,     0,   104,    14,    67,   106,   105,     0,
-   104,     1,     0,   104,    14,    67,     1,   106,   105,     0,
-   105,     0,   104,    14,    67,     0,    11,    67,     0,    26,
+   102,     0,     1,   115,     1,     0,     1,     0,   103,    50,
+    67,     0,   103,   115,    50,    67,     0,     1,    50,    67,
+     0,     1,   115,     1,    50,    67,     0,   102,   103,    50,
+    67,     0,   102,     1,    50,    67,     0,   102,     1,   115,
+     1,    50,    67,     0,   104,    13,    67,   106,   105,     0,
+   104,     1,     0,   104,    13,    67,     1,   106,   105,     0,
+   105,     0,   104,    13,    67,     0,    11,    67,     0,    25,
     67,     0,     0,   108,     0,   106,   107,   108,     0,   106,
-     1,     0,    60,    67,     0,    52,    67,     0,     0,   109,
+     1,     0,    60,    67,     0,    51,    67,     0,     0,   109,
      0,    86,   109,     0,    10,    67,     0,    11,    67,     0,
-    43,    67,     0,    86,    43,    67,     0,    46,    67,     0,
-    48,    67,     0,   111,     0,    61,    67,     0,   110,     0,
-    45,    67,     0,    44,    67,     0,    30,    67,     0,    31,
-    67,     0,    32,    67,     0,    33,    67,     0,    34,    67,
-     0,    35,    67,     0,    36,    67,     0,    37,    67,     0,
-    38,    67,     0,    39,    67,     0,    40,    67,     0,    41,
-    67,     0,    42,    67,     0,    28,    67,     0,    27,    67,
-     0,    29,    67,     0,    47,    67,   106,    59,    67,     0,
-    47,    67,     1,     0,    12,    67,     0,    62,     1,   114,
-     0,    62,     1,    51,     0,     1,   114,     0,    49,     1,
-   115,     1,    50,     0,    49,     1,    50,     0,   114,     0,
+    42,    67,     0,    86,    42,    67,     0,    45,    67,     0,
+    47,    67,     0,   111,     0,    61,    67,     0,   110,     0,
+    44,    67,     0,    43,    67,     0,    29,    67,     0,    30,
+    67,     0,    31,    67,     0,    32,    67,     0,    33,    67,
+     0,    34,    67,     0,    35,    67,     0,    36,    67,     0,
+    37,    67,     0,    38,    67,     0,    39,    67,     0,    40,
+    67,     0,    41,    67,     0,    27,    67,     0,    26,    67,
+     0,    28,    67,     0,    46,    67,   106,    59,    67,     0,
+    46,    67,     1,     0,    12,    67,     0,    62,     1,   114,
+     0,    62,     1,    50,     0,     1,   114,     0,    48,     1,
+   115,     1,    49,     0,    48,     1,    49,     0,   114,     0,
    115,     1,   114,     0
 };
 
@@ -304,23 +306,23 @@ static const short yyrhs[] = {    69,
 
 #if YYDEBUG != 0
 static const short yyrline[] = { 0,
-   236,   238,   239,   240,   243,   250,   256,   281,   283,   286,
-   288,   289,   292,   294,   299,   300,   303,   305,   315,   317,
-   320,   322,   332,   334,   335,   336,   337,   338,   341,   354,
-   357,   362,   371,   372,   375,   377,   380,   382,   385,   389,
-   393,   397,   401,   406,   412,   426,   428,   437,   459,   463,
-   468,   472,   477,   479,   480,   483,   485,   488,   508,   522,
-   536,   542,   546,   569,   575,   577,   578,   581,   586,   591,
-   596,   603,   612,   623,   644,   649,   654,   664,   670,   677,
-   678,   679,   682,   691,   715,   721,   727,   735,   746,   750,
-   753,   756,   759,   762,   767,   769,   772,   778,   784,   792,
-   796,   801,   804,   810,   818,   822,   825,   831,   837,   842,
-   848,   856,   879,   883,   891,   896,   903,   910,   912,   915,
-   920,   933,   939,   943,   946,   951,   953,   954,   955,   962,
-   963,   964,   965,   966,   967,   969,   974,   976,   977,   978,
-   979,   980,   981,   982,   983,   984,   985,   986,   987,   988,
-   989,   990,   991,   992,   996,  1004,  1019,  1026,  1033,  1041,
-  1067,  1069,  1072,  1074
+   237,   239,   240,   241,   244,   251,   257,   282,   284,   287,
+   289,   290,   293,   295,   300,   301,   304,   306,   316,   318,
+   321,   323,   333,   335,   336,   337,   338,   339,   342,   355,
+   358,   363,   372,   373,   376,   378,   381,   383,   386,   390,
+   394,   398,   402,   407,   413,   427,   429,   438,   460,   464,
+   469,   473,   478,   480,   481,   484,   486,   489,   509,   523,
+   537,   543,   547,   570,   576,   578,   579,   582,   587,   592,
+   597,   604,   613,   624,   641,   646,   651,   661,   667,   674,
+   675,   676,   679,   688,   708,   714,   720,   728,   739,   743,
+   746,   749,   752,   755,   760,   762,   765,   771,   777,   785,
+   789,   794,   797,   803,   811,   815,   818,   824,   830,   835,
+   841,   849,   872,   876,   884,   889,   896,   903,   905,   908,
+   913,   926,   932,   936,   939,   944,   946,   947,   948,   955,
+   956,   957,   958,   959,   960,   962,   967,   969,   970,   971,
+   972,   973,   974,   975,   976,   977,   978,   979,   980,   981,
+   982,   983,   984,   985,   989,   997,  1012,  1019,  1026,  1034,
+  1060,  1062,  1065,  1067
 };
 #endif
 
@@ -329,12 +331,12 @@ static const short yyrline[] = { 0,
 
 static const char * const yytname[] = {   "$","error","$undefined.","S","SGML_CD",
 "INCLUDES","DASHMATCH","BEGINSWITH","ENDSWITH","CONTAINS","STRING","IDENT","HASH",
-"'*'","':'","'.'","'['","IMPORT_SYM","PAGE_SYM","MEDIA_SYM","FONT_FACE_SYM",
-"CHARSET_SYM","NAMESPACE_SYM","KHTML_RULE_SYM","KHTML_DECLS_SYM","KHTML_VALUE_SYM",
-"IMPORTANT_SYM","QEMS","EMS","EXS","PXS","CMS","MMS","INS","PTS","PCS","DEGS",
-"RADS","GRADS","MSECS","SECS","HERZ","KHERZ","DIMEN","PERCENTAGE","NUMBER","URI",
-"FUNCTION","UNICODERANGE","'{'","'}'","';'","','","'+'","'>'","'-'","'|'","']'",
-"'='","')'","'/'","'#'","'@'","stylesheet","khtml_rule","khtml_decls","khtml_value",
+"':'","'.'","'['","IMPORT_SYM","PAGE_SYM","MEDIA_SYM","FONT_FACE_SYM","CHARSET_SYM",
+"NAMESPACE_SYM","KHTML_RULE_SYM","KHTML_DECLS_SYM","KHTML_VALUE_SYM","IMPORTANT_SYM",
+"QEMS","EMS","EXS","PXS","CMS","MMS","INS","PTS","PCS","DEGS","RADS","GRADS",
+"MSECS","SECS","HERZ","KHERZ","DIMEN","PERCENTAGE","NUMBER","URI","FUNCTION",
+"UNICODERANGE","'{'","'}'","';'","','","'+'","'>'","'-'","'*'","'|'","']'","'='",
+"')'","'/'","'#'","'@'","stylesheet","khtml_rule","khtml_decls","khtml_value",
 "maybe_space","maybe_sgml","maybe_charset","import_list","namespace_list","rule_list",
 "rule","import","namespace","maybe_ns_prefix","string_or_uri","maybe_media_list",
 "media_list","media","ruleset_list","medium","page","font_face","combinator",
@@ -390,7 +392,7 @@ static const short yydefact[] = {    13,
      0,     0,     0,     0,     8,     8,     8,    10,     0,     0,
      8,     8,     8,     2,     3,     4,    17,     0,    16,    15,
      9,     8,    65,     0,     0,    12,    11,    19,     0,     0,
-    74,    79,    75,     0,     0,     8,     8,     0,     0,     0,
+    74,    79,     0,     0,     8,    75,     8,     0,     0,     0,
     62,     8,     0,    76,    80,    81,    82,   104,     8,     8,
      0,     0,   100,     0,   115,     8,     8,     8,     8,     8,
      8,     8,     8,     8,     8,     8,     8,     8,     8,     8,
@@ -429,195 +431,187 @@ static const short yydefgoto[] = {   308,
     94,    95
 };
 
-static const short yypact[] = {   201,
-    23,   -40,   -29,   -24,-32768,-32768,-32768,-32768,    70,    28,
--32768,-32768,-32768,    40,    40,    40,    49,    46,-32768,-32768,
--32768,-32768,   392,   113,   542,-32768,-32768,    91,   126,   120,
-    64,-32768,    82,     3,   133,-32768,-32768,    50,   226,    94,
--32768,   253,   200,-32768,-32768,-32768,-32768,    96,-32768,-32768,
-   104,   222,   121,    14,-32768,-32768,-32768,-32768,-32768,-32768,
+static const short yypact[] = {   372,
+    22,   -39,   -22,   -15,-32768,-32768,-32768,-32768,     3,    21,
+-32768,-32768,-32768,    37,    37,    37,   185,    43,-32768,-32768,
+-32768,-32768,   288,   173,   532,-32768,-32768,   104,   143,   110,
+    58,-32768,   108,   112,-32768,    70,-32768,    46,   227,    77,
+-32768,   274,   200,-32768,-32768,-32768,-32768,    89,-32768,-32768,
+   101,    99,   121,    16,-32768,-32768,-32768,-32768,-32768,-32768,
 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
--32768,-32768,-32768,   583,   390,-32768,-32768,-32768,-32768,   218,
-   170,-32768,-32768,-32768,   194,-32768,-32768,   198,-32768,-32768,
-    26,     4,-32768,-32768,-32768,-32768,-32768,-32768,   345,   398,
-    40,   200,-32768,    40,-32768,-32768,   204,    40,    40,-32768,
-   140,   159,-32768,   109,-32768,-32768,    40,    40,    40,    40,
-    40,    40,    40,    40,    40,    40,    40,    40,    40,    40,
-    40,    40,    40,    40,    40,    40,    40,    40,    40,   496,
-    40,    40,-32768,-32768,-32768,-32768,-32768,-32768,   623,   149,
-   131,   183,   117,-32768,    49,   250,-32768,   392,    64,-32768,
-   175,    85,-32768,   113,   392,    40,    40,-32768,-32768,-32768,
-   253,   200,    40,    40,   155,-32768,   234,-32768,    40,   196,
--32768,   337,-32768,   443,    40,    40,    40,-32768,-32768,-32768,
--32768,-32768,-32768,   206,    29,   196,   249,-32768,   269,   276,
--32768,-32768,-32768,-32768,-32768,-32768,-32768,    49,-32768,-32768,
--32768,    40,   240,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
--32768,   233,   593,    40,   200,    40,-32768,    40,   209,    40,
-    40,   623,   284,-32768,    98,-32768,-32768,   286,   136,-32768,
-   212,   185,   225,   237,    49,    24,-32768,   160,   102,-32768,
-    40,    40,-32768,   284,-32768,    40,-32768,   236,    45,-32768,
--32768,-32768,-32768,-32768,    99,-32768,-32768,-32768,-32768,-32768,
--32768,-32768,-32768,-32768,-32768,    40,-32768,    40,-32768,-32768,
--32768,   123,-32768,   102,    27,   185,-32768,    40,-32768,-32768,
--32768,   339,    31,-32768,-32768,-32768,    40,   291,   293,-32768
+-32768,-32768,-32768,   606,   388,-32768,-32768,-32768,-32768,   223,
+   149,-32768,-32768,-32768,   161,-32768,-32768,   171,-32768,-32768,
+    35,    47,-32768,-32768,-32768,-32768,-32768,-32768,   346,   395,
+    37,   200,-32768,    37,-32768,-32768,   199,    37,    37,-32768,
+   127,   155,-32768,    38,-32768,-32768,    37,    37,    37,    37,
+    37,    37,    37,    37,    37,    37,    37,    37,    37,    37,
+    37,    37,    37,    37,    37,    37,    37,    37,    37,   487,
+    37,    37,-32768,-32768,-32768,-32768,-32768,-32768,   570,   156,
+   102,   262,   117,-32768,   185,   147,-32768,   288,    58,-32768,
+   153,   136,-32768,   173,   288,    37,    37,-32768,-32768,-32768,
+   274,   200,    37,    37,   177,-32768,   209,-32768,    37,   170,
+-32768,   336,-32768,   435,    37,    37,    37,-32768,-32768,-32768,
+-32768,-32768,-32768,   181,    17,   170,   218,-32768,   244,   248,
+-32768,-32768,-32768,-32768,-32768,-32768,-32768,   185,-32768,-32768,
+-32768,    37,   239,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
+-32768,   205,   539,    37,   200,    37,-32768,    37,   187,    37,
+    37,   570,   284,-32768,     4,-32768,-32768,   254,   141,-32768,
+   210,   135,   219,   226,   185,    24,-32768,   159,    98,-32768,
+    37,    37,-32768,   284,-32768,    37,-32768,   211,    42,-32768,
+-32768,-32768,-32768,-32768,    51,-32768,-32768,-32768,-32768,-32768,
+-32768,-32768,-32768,-32768,-32768,    37,-32768,    37,-32768,-32768,
+-32768,   113,-32768,    98,    27,   135,-32768,    37,-32768,-32768,
+-32768,   338,    34,-32768,-32768,-32768,    37,   264,   270,-32768
 };
 
 static const short yypgoto[] = {-32768,
 -32768,-32768,-32768,    -1,   -84,-32768,-32768,-32768,-32768,-32768,
--32768,-32768,-32768,    48,-32768,    51,-32768,-32768,     5,-32768,
--32768,-32768,-32768,  -162,-32768,   127,   205,   -87,   195,   -23,
-   -27,-32768,    84,-32768,    83,    15,-32768,   134,-32768,   290,
--32768,  -220,  -147,-32768,   184,   262,-32768,-32768,-32768,-32768,
+-32768,-32768,-32768,    28,-32768,    41,-32768,-32768,     1,-32768,
+-32768,-32768,-32768,  -162,-32768,   130,   207,   -87,   196,   -23,
+   -27,-32768,   118,-32768,    82,    48,-32768,   180,-32768,   303,
+-32768,  -229,  -147,-32768,   197,   307,-32768,-32768,-32768,-32768,
     -7,   -35
 };
 
 
-#define	YYLAST		684
+#define	YYLAST		650
 
 
 static const short yytable[] = {    10,
    215,    20,   194,    14,    15,    16,    21,   165,    11,    23,
-    24,    25,   117,    97,   125,   115,    98,   124,   112,    12,
-    30,   178,   265,     9,    13,    -8,    21,   126,    21,    21,
-    21,    21,    -8,    21,   101,   102,   169,    22,   170,   248,
-   111,   114,    21,   287,   243,   290,    29,   118,   119,    99,
-   103,    26,    27,   173,   127,   128,   129,   130,   131,   132,
+    24,    25,   117,   265,   267,   115,   125,   124,   112,    21,
+    30,   178,     9,    21,    -8,    12,    21,   248,   126,    21,
+    22,    -8,    13,   101,   287,   102,    21,    21,   190,    21,
+   111,   114,   290,    29,   243,   169,   103,   118,   119,    21,
+    18,   290,    19,   -39,   127,   128,   129,   130,   131,   132,
    133,   134,   135,   136,   137,   138,   139,   140,   141,   142,
    143,   144,   145,   146,   147,   148,   149,   150,   151,   218,
-   221,   152,   280,   300,   115,   187,   182,   306,   161,   224,
-   225,   226,   227,   228,   264,   -40,   291,   168,   104,   290,
-    21,   105,   174,   175,    21,   176,   177,    90,   267,   190,
-   183,   283,   284,    48,   184,    21,    -1,   206,    18,   -67,
-    19,   189,    21,    49,   192,    21,   255,    31,    32,    33,
-    34,    35,    36,    21,   207,   208,   209,   -66,    50,   305,
-   201,   229,   230,   100,    18,   201,   116,   293,   -39,   110,
-   291,   195,   200,   120,   115,   196,   197,   235,   220,   191,
-   205,  -119,  -119,  -119,   224,   225,   226,   227,   228,    18,
-    96,   123,   -65,   297,    18,    93,   202,   220,   210,   234,
-   236,   202,   220,   204,   238,    -8,   240,    21,    18,   241,
-   186,   162,    -8,    -8,   166,   267,   247,    18,   250,   199,
-   113,   245,    -8,    18,   185,   237,   252,   115,   167,   188,
-    -8,    32,    -8,    34,    35,    36,   281,   230,   160,   256,
-    -8,     1,   121,     2,     3,     4,   106,    -8,    -8,   259,
-   223,   220,    49,   261,   239,   262,   -55,   -55,   -55,   -55,
-   -55,   -55,   266,   274,    18,   277,   279,    50,    -8,   251,
-   257,    -8,    -8,    -8,    18,    -8,   246,    18,    -8,   263,
-    18,   286,   273,    -8,    32,   288,    34,    35,    36,   253,
-   292,  -102,  -119,    18,   -59,   276,   254,   -59,   107,   108,
-   294,   -55,   260,   295,   155,    18,   289,   278,   271,   296,
-   309,   298,   310,  -125,  -125,  -125,   272,   303,    18,   219,
-   301,   233,   275,   307,   181,   171,   258,   232,   299,    50,
+   221,   152,   280,   300,   115,   187,   182,   191,   161,   170,
+   306,   -40,   291,   104,   264,   173,   105,   168,   293,   121,
+    21,   291,   174,   175,    21,   176,   177,   283,   284,    49,
+   183,   201,    21,   -67,   184,    21,    -1,   206,    97,    90,
+    98,   189,   100,    50,   192,   -66,   255,    31,    32,    33,
+    34,    35,   110,   207,   208,   209,    18,    21,   116,   305,
+   224,   225,   226,   227,   228,   267,   202,  -102,  -119,   120,
+   201,   195,   200,    99,   115,   196,   197,   235,   220,    96,
+   205,   166,   297,   224,   225,   226,   227,   228,    18,   162,
+   123,    36,   -65,    48,    18,    21,   186,   220,   210,   234,
+   236,   167,   220,    49,   238,   202,   240,    26,    27,   241,
+    18,    93,   229,   230,    18,   219,   247,    50,   250,   185,
+   113,   245,    -8,    18,   188,   199,   252,   115,   223,   239,
+    -8,    32,    33,    34,    35,   281,   230,    18,   251,   256,
+  -119,  -119,  -119,   160,    18,    -8,   237,   106,    18,   259,
+   246,   220,    -8,   261,    18,   262,   263,   -55,   -55,   -55,
+   -55,   -55,   266,   274,   253,   277,   279,    -8,   254,   257,
+    -8,    -8,    -8,   260,    -8,    -8,   271,    18,    -8,   273,
+   289,   286,   204,   309,    -8,   288,    18,    -8,   276,   310,
+   292,    -8,    -8,    18,   -59,   278,   272,   -59,   107,   108,
+   294,   -55,   -55,   295,   155,    32,    33,    34,    35,   296,
+    21,   298,   275,  -125,  -125,  -125,   301,   303,    31,    32,
+    33,    34,    35,   307,   233,   181,    -8,   171,    50,  -125,
   -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,
   -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,
-  -125,  -125,  -119,  -119,  -119,   157,  -125,   242,  -125,    21,
-   282,   122,   198,   158,  -125,   154,    56,    57,    58,    31,
-    32,    33,    34,    35,    36,    31,    32,    33,    34,    35,
-    36,     0,     0,    59,    60,    61,    62,    63,    64,    65,
-    66,    67,    68,    69,    70,    71,    72,    73,    74,    75,
-    76,    77,    78,    79,    80,  -116,  -116,  -116,   304,    81,
-   155,    82,     0,     0,    21,     0,     0,    83,     0,  -125,
-  -125,  -125,    31,    32,    33,    34,    35,    36,   179,    32,
-   180,    34,    35,    36,     0,     0,  -125,  -125,  -125,  -125,
+  -125,  -119,  -119,  -119,   157,  -125,   242,  -125,    21,   282,
+   258,   299,    36,   158,  -125,    56,    57,    58,    31,    32,
+    33,    34,    35,   232,   122,   198,    31,    32,    33,    34,
+    35,    59,    60,    61,    62,    63,    64,    65,    66,    67,
+    68,    69,    70,    71,    72,    73,    74,    75,    76,    77,
+    78,    79,    80,  -116,  -116,  -116,   304,    81,   155,    82,
+   154,     1,    36,     2,     3,     4,    83,  -125,  -125,  -125,
+    36,     0,     0,     0,     0,   179,    32,    33,    34,    35,
+     0,     0,     0,  -125,  -125,  -125,  -125,  -125,  -125,  -125,
   -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,
-  -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,     0,   156,
-     0,   157,  -125,   155,  -125,     0,     0,     0,     0,   158,
-  -125,     0,  -125,  -125,  -125,     0,     0,     0,     0,     0,
-     0,     0,     0,     0,     0,     0,     0,     0,     0,  -125,
+  -125,  -125,  -125,  -125,  -125,   155,   156,     0,   157,  -125,
+     0,  -125,     0,     0,  -125,  -125,  -125,   158,  -125,   180,
+     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
   -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,
   -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,  -125,
-  -125,     0,     0,     0,   157,  -125,   193,  -125,    21,     0,
-     0,   244,   158,  -125,     0,    56,    57,    58,     0,     0,
+  -125,  -125,     0,     0,     0,   157,  -125,   193,  -125,    21,
+     0,     0,     0,   244,   158,  -125,    56,    57,    58,     0,
      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
      0,     0,    59,    60,    61,    62,    63,    64,    65,    66,
     67,    68,    69,    70,    71,    72,    73,    74,    75,    76,
-    77,    78,    79,    80,    21,     0,     0,     0,    81,     0,
-    82,    56,    57,    58,     0,     0,    83,     0,     0,     0,
-     0,     0,     0,     0,     0,     0,     0,     0,    59,    60,
-    61,    62,    63,    64,    65,    66,    67,    68,    69,    70,
-    71,    72,    73,    74,    75,    76,    77,    78,    79,    80,
-     0,     0,     0,   106,    81,     0,    82,     0,     0,     0,
-     0,     0,    83,   -55,   -55,   -55,   -55,   -55,   -55,    59,
-    60,    61,    62,    63,    64,    65,    66,    67,    68,    69,
-    70,    71,    72,    73,    74,   153,    76,    77,     0,     0,
-     0,     0,    56,    57,    58,     0,     0,     0,     0,     0,
-     0,   -60,     0,     0,   -60,   107,   108,     0,   -55,    59,
-    60,    61,    62,    63,    64,    65,    66,    67,    68,    69,
-    70,    71,    72,    73,    74,    75,    76,    77,    78,    79,
-    80,     0,     0,     0,     0,    81,     0,    82,     0,     0,
-     0,     0,     0,    83
+    77,    78,    79,    80,    21,     0,     0,     0,    81,   106,
+    82,    56,    57,    58,     0,     0,     0,    83,     0,   -55,
+   -55,   -55,   -55,   -55,     0,     0,     0,    59,    60,    61,
+    62,    63,    64,    65,    66,    67,    68,    69,    70,    71,
+    72,    73,    74,    75,    76,    77,    78,    79,    80,    56,
+    57,    58,     0,    81,     0,    82,   -60,     0,     0,   -60,
+   107,   108,    83,   -55,   -55,    59,    60,    61,    62,    63,
+    64,    65,    66,    67,    68,    69,    70,    71,    72,    73,
+    74,    75,    76,    77,    78,    79,    80,     0,     0,     0,
+     0,    81,     0,    82,     0,     0,     0,     0,     0,     0,
+    83,    59,    60,    61,    62,    63,    64,    65,    66,    67,
+    68,    69,    70,    71,    72,    73,    74,   153,    76,    77
 };
 
 static const short yycheck[] = {     1,
-   163,     9,   150,     5,     6,     7,     3,    92,    49,    11,
-    12,    13,    48,    11,     1,    43,    14,    53,    42,    49,
-    22,   109,   243,     1,    49,     3,     3,    14,     3,     3,
-     3,     3,    10,     3,    36,    37,    11,    10,    13,    11,
-    42,    43,     3,   264,   192,     1,     1,    49,    50,    47,
-     1,     3,     4,    50,    56,    57,    58,    59,    60,    61,
+   163,     9,   150,     5,     6,     7,     3,    92,    48,    11,
+    12,    13,    48,   243,    11,    43,     1,    53,    42,     3,
+    22,   109,     1,     3,     3,    48,     3,    11,    13,     3,
+    10,    10,    48,    35,   264,    37,     3,     3,     1,     3,
+    42,    43,     1,     1,   192,    11,     1,    49,    50,     3,
+    48,     1,    50,    50,    56,    57,    58,    59,    60,    61,
     62,    63,    64,    65,    66,    67,    68,    69,    70,    71,
     72,    73,    74,    75,    76,    77,    78,    79,    80,   164,
-   168,    83,    59,    57,   112,   121,   110,    57,    90,     5,
-     6,     7,     8,     9,   242,    51,    52,    99,    49,     1,
-     3,    52,   104,   105,     3,   107,   108,    17,    11,     1,
-   112,    10,    11,     1,   116,     3,     0,     1,    49,    56,
-    51,   123,     3,    11,   126,     3,   211,    11,    12,    13,
-    14,    15,    16,     3,    18,    19,    20,    56,    26,   302,
-    10,    57,    58,    11,    49,    10,    51,    49,    51,    56,
-    52,   153,   160,    50,   182,   157,   158,   181,   166,    51,
-   162,    49,    50,    51,     5,     6,     7,     8,     9,    49,
-    51,    51,    56,    51,    49,    50,    46,   185,    62,   181,
-   182,    46,   190,     1,   186,     3,   188,     3,    49,   191,
-    51,    22,    10,    11,     1,    11,   204,    49,   206,    51,
-     1,   203,     3,    49,     1,    51,   208,   235,    11,    51,
-    11,    12,    13,    14,    15,    16,    57,    58,     1,   221,
-     3,    21,     1,    23,    24,    25,     1,    10,    46,   231,
-    56,   239,    11,   235,     1,   237,    11,    12,    13,    14,
-    15,    16,   244,   251,    49,   253,   254,    26,    49,     1,
-    11,    52,    53,    54,    49,    56,    51,    49,    59,    51,
-    49,   263,    51,    46,    12,   267,    14,    15,    16,     1,
-   272,    50,    51,    49,    49,    51,     1,    52,    53,    54,
-   282,    56,    50,   285,     1,    49,    51,    51,     3,   291,
-     0,   293,     0,    10,    11,    12,   249,   299,    49,    50,
-   296,   175,   252,   305,   110,   101,   223,   174,   294,    26,
+   168,    83,    59,    57,   112,   121,   110,    50,    90,    55,
+    57,    50,    51,    48,   242,    49,    51,    99,    48,     1,
+     3,    51,   104,   105,     3,   107,   108,    10,    11,    11,
+   112,    10,     3,    56,   116,     3,     0,     1,    11,    16,
+    13,   123,    11,    25,   126,    56,   211,    11,    12,    13,
+    14,    15,    56,    17,    18,    19,    48,     3,    50,   302,
+     5,     6,     7,     8,     9,    11,    45,    49,    50,    49,
+    10,   153,   160,    46,   182,   157,   158,   181,   166,    50,
+   162,     1,    50,     5,     6,     7,     8,     9,    48,    21,
+    50,    55,    56,     1,    48,     3,    50,   185,    62,   181,
+   182,    11,   190,    11,   186,    45,   188,     3,     4,   191,
+    48,    49,    57,    58,    48,    49,   204,    25,   206,     1,
+     1,   203,     3,    48,    50,    50,   208,   235,    56,     1,
+    11,    12,    13,    14,    15,    57,    58,    48,     1,   221,
+    48,    49,    50,     1,    48,     3,    50,     1,    48,   231,
+    50,   239,    10,   235,    48,   237,    50,    11,    12,    13,
+    14,    15,   244,   251,     1,   253,   254,    48,     1,    11,
+    51,    52,    53,    49,    55,    56,     3,    48,    59,    50,
+    50,   263,     1,     0,     3,   267,    48,    45,    50,     0,
+   272,    10,    11,    48,    48,    50,   249,    51,    52,    53,
+   282,    55,    56,   285,     1,    12,    13,    14,    15,   291,
+     3,   293,   252,    10,    11,    12,   296,   299,    11,    12,
+    13,    14,    15,   305,   175,   110,    45,   101,    25,    26,
     27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
     37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
-    47,    48,    49,    50,    51,    52,    53,     1,    55,     3,
-   258,    52,   159,    60,    61,    84,    10,    11,    12,    11,
-    12,    13,    14,    15,    16,    11,    12,    13,    14,    15,
-    16,    -1,    -1,    27,    28,    29,    30,    31,    32,    33,
-    34,    35,    36,    37,    38,    39,    40,    41,    42,    43,
-    44,    45,    46,    47,    48,    49,    50,    51,    50,    53,
-     1,    55,    -1,    -1,     3,    -1,    -1,    61,    -1,    10,
-    11,    12,    11,    12,    13,    14,    15,    16,    11,    12,
-    13,    14,    15,    16,    -1,    -1,    27,    28,    29,    30,
-    31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
-    41,    42,    43,    44,    45,    46,    47,    48,    -1,    50,
-    -1,    52,    53,     1,    55,    -1,    -1,    -1,    -1,    60,
-    61,    -1,    10,    11,    12,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    27,
-    28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
-    38,    39,    40,    41,    42,    43,    44,    45,    46,    47,
-    48,    -1,    -1,    -1,    52,    53,     1,    55,     3,    -1,
-    -1,    59,    60,    61,    -1,    10,    11,    12,    -1,    -1,
-    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    27,    28,    29,    30,    31,    32,    33,    34,
+    47,    48,    49,    50,    51,    52,     1,    54,     3,   258,
+   223,   294,    55,    60,    61,    10,    11,    12,    11,    12,
+    13,    14,    15,   174,    52,   159,    11,    12,    13,    14,
+    15,    26,    27,    28,    29,    30,    31,    32,    33,    34,
     35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
-    45,    46,    47,    48,     3,    -1,    -1,    -1,    53,    -1,
-    55,    10,    11,    12,    -1,    -1,    61,    -1,    -1,    -1,
-    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    27,    28,
+    45,    46,    47,    48,    49,    50,    49,    52,     1,    54,
+    84,    20,    55,    22,    23,    24,    61,    10,    11,    12,
+    55,    -1,    -1,    -1,    -1,    11,    12,    13,    14,    15,
+    -1,    -1,    -1,    26,    27,    28,    29,    30,    31,    32,
+    33,    34,    35,    36,    37,    38,    39,    40,    41,    42,
+    43,    44,    45,    46,    47,     1,    49,    -1,    51,    52,
+    -1,    54,    -1,    -1,    10,    11,    12,    60,    61,    55,
+    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+    26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
+    36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
+    46,    47,    -1,    -1,    -1,    51,    52,     1,    54,     3,
+    -1,    -1,    -1,    59,    60,    61,    10,    11,    12,    -1,
+    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+    -1,    -1,    26,    27,    28,    29,    30,    31,    32,    33,
+    34,    35,    36,    37,    38,    39,    40,    41,    42,    43,
+    44,    45,    46,    47,     3,    -1,    -1,    -1,    52,     1,
+    54,    10,    11,    12,    -1,    -1,    -1,    61,    -1,    11,
+    12,    13,    14,    15,    -1,    -1,    -1,    26,    27,    28,
     29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
-    39,    40,    41,    42,    43,    44,    45,    46,    47,    48,
-    -1,    -1,    -1,     1,    53,    -1,    55,    -1,    -1,    -1,
-    -1,    -1,    61,    11,    12,    13,    14,    15,    16,    27,
-    28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
-    38,    39,    40,    41,    42,    43,    44,    45,    -1,    -1,
-    -1,    -1,    10,    11,    12,    -1,    -1,    -1,    -1,    -1,
-    -1,    49,    -1,    -1,    52,    53,    54,    -1,    56,    27,
-    28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
-    38,    39,    40,    41,    42,    43,    44,    45,    46,    47,
-    48,    -1,    -1,    -1,    -1,    53,    -1,    55,    -1,    -1,
-    -1,    -1,    -1,    61
+    39,    40,    41,    42,    43,    44,    45,    46,    47,    10,
+    11,    12,    -1,    52,    -1,    54,    48,    -1,    -1,    51,
+    52,    53,    61,    55,    56,    26,    27,    28,    29,    30,
+    31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
+    41,    42,    43,    44,    45,    46,    47,    -1,    -1,    -1,
+    -1,    52,    -1,    54,    -1,    -1,    -1,    -1,    -1,    -1,
+    61,    26,    27,    28,    29,    30,    31,    32,    33,    34,
+    35,    36,    37,    38,    39,    40,    41,    42,    43,    44
 };
 #define YYPURE 1
 
@@ -1165,20 +1159,20 @@ yyreduce:
   switch (yyn) {
 
 case 5:
-#line 244 "parser.y"
+#line 245 "parser.y"
 {
         CSSParser *p = static_cast<CSSParser *>(parser);
         p->rule = yyvsp[-2].rule;
     ;
     break;}
 case 6:
-#line 251 "parser.y"
+#line 252 "parser.y"
 {
 	/* can be empty */
     ;
     break;}
 case 7:
-#line 257 "parser.y"
+#line 258 "parser.y"
 {
 	CSSParser *p = static_cast<CSSParser *>(parser);
 	if ( yyvsp[-1].valueList ) {
@@ -1203,7 +1197,7 @@ case 7:
     ;
     break;}
 case 14:
-#line 294 "parser.y"
+#line 295 "parser.y"
 {
 #ifdef CSS_DEBUG
      kdDebug( 6080 ) << "charset rule: " << qString(yyvsp[-2].string) << endl;
@@ -1211,7 +1205,7 @@ case 14:
  ;
     break;}
 case 18:
-#line 305 "parser.y"
+#line 306 "parser.y"
 {
      CSSParser *p = static_cast<CSSParser *>(parser);
      if ( yyvsp[-1].rule && p->styleElement && p->styleElement->isCSSStyleSheet() ) {
@@ -1222,7 +1216,7 @@ case 18:
  ;
     break;}
 case 22:
-#line 322 "parser.y"
+#line 323 "parser.y"
 {
      CSSParser *p = static_cast<CSSParser *>(parser);
      if ( yyvsp[-1].rule && p->styleElement && p->styleElement->isCSSStyleSheet() ) {
@@ -1233,7 +1227,7 @@ case 22:
  ;
     break;}
 case 29:
-#line 342 "parser.y"
+#line 343 "parser.y"
 {
 #ifdef CSS_DEBUG
 	kdDebug( 6080 ) << "@import: " << qString(yyvsp[-3].string) << endl;
@@ -1248,57 +1242,57 @@ case 29:
     ;
     break;}
 case 30:
-#line 354 "parser.y"
+#line 355 "parser.y"
 {
         yyval.rule = 0;
     ;
     break;}
 case 31:
-#line 357 "parser.y"
+#line 358 "parser.y"
 {
         yyval.rule = 0;
     ;
     break;}
 case 32:
-#line 363 "parser.y"
+#line 364 "parser.y"
 {
 #ifdef CSS_DEBUG
     kdDebug( 6080 ) << "@namespace: " << qString(yyvsp[-2].string) << endl;
 #endif
     CSSParser *p = static_cast<CSSParser *>(parser);
     if (p->styleElement && p->styleElement->isCSSStyleSheet())
-        static_cast<CSSStyleSheetImpl*>(p->styleElement)->addNamespace(domString(yyvsp[-3].string), domString(yyvsp[-2].string));
+        static_cast<CSSStyleSheetImpl*>(p->styleElement)->addNamespace(p, domString(yyvsp[-3].string), domString(yyvsp[-2].string));
 ;
     break;}
 case 35:
-#line 376 "parser.y"
+#line 377 "parser.y"
 { yyval.string.string = 0; ;
     break;}
 case 36:
-#line 377 "parser.y"
+#line 378 "parser.y"
 { yyval.string = yyvsp[-1].string; ;
     break;}
 case 39:
-#line 386 "parser.y"
+#line 387 "parser.y"
 {
         yyval.mediaList = new MediaListImpl();
      ;
     break;}
 case 41:
-#line 394 "parser.y"
+#line 395 "parser.y"
 {
 	yyval.mediaList = 0;
     ;
     break;}
 case 42:
-#line 397 "parser.y"
+#line 398 "parser.y"
 {
 	yyval.mediaList = new MediaListImpl();
 	yyval.mediaList->appendMedium( domString(yyvsp[0].string).lower() );
     ;
     break;}
 case 43:
-#line 401 "parser.y"
+#line 402 "parser.y"
 {
 	yyval.mediaList = yyvsp[-3].mediaList;
         if (yyval.mediaList)
@@ -1306,14 +1300,14 @@ case 43:
     ;
     break;}
 case 44:
-#line 406 "parser.y"
+#line 407 "parser.y"
 {
         delete yyvsp[-1].mediaList;
         yyval.mediaList = 0;
     ;
     break;}
 case 45:
-#line 413 "parser.y"
+#line 414 "parser.y"
 {
 	CSSParser *p = static_cast<CSSParser *>(parser);
 	if ( yyvsp[-4].mediaList && yyvsp[-1].ruleList &&
@@ -1327,11 +1321,11 @@ case 45:
     ;
     break;}
 case 46:
-#line 427 "parser.y"
+#line 428 "parser.y"
 { yyval.ruleList = 0; ;
     break;}
 case 47:
-#line 428 "parser.y"
+#line 429 "parser.y"
 {
       yyval.ruleList = yyvsp[-2].ruleList;
       if ( yyvsp[-1].rule ) {
@@ -1341,57 +1335,57 @@ case 47:
   ;
     break;}
 case 48:
-#line 438 "parser.y"
+#line 439 "parser.y"
 {
       yyval.string = yyvsp[-1].string;
   ;
     break;}
 case 49:
-#line 460 "parser.y"
+#line 461 "parser.y"
 {
       yyval.rule = 0;
     ;
     break;}
 case 50:
-#line 463 "parser.y"
+#line 464 "parser.y"
 {
       yyval.rule = 0;
     ;
     break;}
 case 51:
-#line 469 "parser.y"
+#line 470 "parser.y"
 {
       yyval.rule = 0;
     ;
     break;}
 case 52:
-#line 472 "parser.y"
+#line 473 "parser.y"
 {
       yyval.rule = 0;
     ;
     break;}
 case 53:
-#line 478 "parser.y"
+#line 479 "parser.y"
 { yyval.relation = CSSSelector::Sibling; ;
     break;}
 case 54:
-#line 479 "parser.y"
+#line 480 "parser.y"
 { yyval.relation = CSSSelector::Child; ;
     break;}
 case 55:
-#line 480 "parser.y"
+#line 481 "parser.y"
 { yyval.relation = CSSSelector::Descendant; ;
     break;}
 case 56:
-#line 484 "parser.y"
+#line 485 "parser.y"
 { yyval.val = -1; ;
     break;}
 case 57:
-#line 485 "parser.y"
+#line 486 "parser.y"
 { yyval.val = 1; ;
     break;}
 case 58:
-#line 489 "parser.y"
+#line 490 "parser.y"
 {
 #ifdef CSS_DEBUG
 	kdDebug( 6080 ) << "got ruleset" << endl << "  selector:" << endl;
@@ -1411,7 +1405,7 @@ case 58:
     ;
     break;}
 case 59:
-#line 509 "parser.y"
+#line 510 "parser.y"
 {
 	if ( yyvsp[0].selector ) {
 	    yyval.selectorList = new QPtrList<CSSSelector>;
@@ -1427,7 +1421,7 @@ case 59:
     ;
     break;}
 case 60:
-#line 522 "parser.y"
+#line 523 "parser.y"
 {
 	if ( yyvsp[-3].selectorList && yyvsp[0].selector ) {
 	    yyval.selectorList = yyvsp[-3].selectorList;
@@ -1444,20 +1438,20 @@ case 60:
     ;
     break;}
 case 61:
-#line 536 "parser.y"
+#line 537 "parser.y"
 {
         delete yyvsp[-1].selectorList;
         yyval.selectorList = 0;
     ;
     break;}
 case 62:
-#line 543 "parser.y"
+#line 544 "parser.y"
 {
 	yyval.selector = yyvsp[0].selector;
     ;
     break;}
 case 63:
-#line 546 "parser.y"
+#line 547 "parser.y"
 {
     	yyval.selector = yyvsp[0].selector;
         if (!yyvsp[-2].selector) {
@@ -1483,33 +1477,33 @@ case 63:
     ;
     break;}
 case 64:
-#line 569 "parser.y"
+#line 570 "parser.y"
 {
         delete yyvsp[-1].selector;
         yyval.selector = 0;
     ;
     break;}
 case 65:
-#line 576 "parser.y"
+#line 577 "parser.y"
 { yyval.string.string = 0; yyval.string.length = 0; ;
     break;}
 case 66:
-#line 577 "parser.y"
-{ yyval.string = yyvsp[0].string; ;
+#line 578 "parser.y"
+{ static unsigned short star = '*'; yyval.string.string = &star; yyval.string.length = 1; ;
     break;}
 case 67:
-#line 578 "parser.y"
+#line 579 "parser.y"
 { yyval.string = yyvsp[0].string; ;
     break;}
 case 68:
-#line 582 "parser.y"
+#line 583 "parser.y"
 {
 	yyval.selector = new CSSSelector();
 	yyval.selector->tag = yyvsp[-1].element;
     ;
     break;}
 case 69:
-#line 586 "parser.y"
+#line 587 "parser.y"
 {
 	yyval.selector = yyvsp[-1].selector;
 	if ( yyval.selector )
@@ -1517,49 +1511,49 @@ case 69:
     ;
     break;}
 case 70:
-#line 591 "parser.y"
+#line 592 "parser.y"
 {
 	yyval.selector = yyvsp[-1].selector;
-	if ( yyval.selector )
-            yyval.selector->tag = 0xffffffff;
+        if (yyval.selector)
+            yyval.selector->tag = makeId(static_cast<CSSParser*>(parser)->defaultNamespace, anyLocalName);;
     ;
     break;}
 case 71:
-#line 596 "parser.y"
+#line 597 "parser.y"
 {
         yyval.selector = new CSSSelector();
         yyval.selector->tag = yyvsp[-1].element;
         CSSParser *p = static_cast<CSSParser *>(parser);
         if (p->styleElement && p->styleElement->isCSSStyleSheet())
-            static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace(yyval.selector, domString(yyvsp[-3].string));
+            static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace(yyval.selector->tag, domString(yyvsp[-3].string));
     ;
     break;}
 case 72:
-#line 603 "parser.y"
+#line 604 "parser.y"
 {
         yyval.selector = yyvsp[-1].selector;
         if (yyval.selector) {
             yyval.selector->tag = yyvsp[-2].element;
             CSSParser *p = static_cast<CSSParser *>(parser);
             if (p->styleElement && p->styleElement->isCSSStyleSheet())
-                static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace(yyval.selector, domString(yyvsp[-4].string));
+                static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace(yyval.selector->tag, domString(yyvsp[-4].string));
         }
     ;
     break;}
 case 73:
-#line 612 "parser.y"
+#line 613 "parser.y"
 {
         yyval.selector = yyvsp[-1].selector;
         if (yyval.selector) {
-            yyval.selector->tag = 0xffffffff;
+            yyval.selector->tag = makeId(anyNamespace, anyLocalName);
             CSSParser *p = static_cast<CSSParser *>(parser);
             if (p->styleElement && p->styleElement->isCSSStyleSheet())
-                static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace(yyval.selector, domString(yyvsp[-3].string));
+                static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace(yyval.selector->tag, domString(yyvsp[-3].string));
         }
     ;
     break;}
 case 74:
-#line 624 "parser.y"
+#line 625 "parser.y"
 {
 	CSSParser *p = static_cast<CSSParser *>(parser);
 	DOM::DocumentImpl *doc = p->document();
@@ -1568,13 +1562,9 @@ case 74:
 	    if (doc->isHTMLDocument())
 		tag = tag.lower();
 	    const DOMString dtag(tag);
-#if APPLE_CHANGES
-            yyval.element = doc->tagId(0, dtag.implementation(), false);
-#else
-	    yyval.element = doc->elementNames()->getId(dtag.implementation(), false);
-#endif
+            yyval.element = makeId(p->defaultNamespace, doc->tagId(0, dtag.implementation(), false));
 	} else {
-	    yyval.element = khtml::getTagID(tag.lower().ascii(), tag.length());
+	    yyval.element = makeId(p->defaultNamespace, khtml::getTagID(tag.lower().ascii(), tag.length()));
 	    // this case should never happen - only when loading
 	    // the default stylesheet - which must not contain unknown tags
 // 	    assert($$ != 0);
@@ -1582,20 +1572,20 @@ case 74:
     ;
     break;}
 case 75:
-#line 644 "parser.y"
+#line 641 "parser.y"
 {
-	yyval.element = -1;
+	yyval.element = makeId(static_cast<CSSParser*>(parser)->defaultNamespace, anyLocalName);
     ;
     break;}
 case 76:
-#line 650 "parser.y"
+#line 647 "parser.y"
 {
 	yyval.selector = yyvsp[0].selector;
 	yyval.selector->nonCSSHint = static_cast<CSSParser *>(parser)->nonCSSHint;
     ;
     break;}
 case 77:
-#line 654 "parser.y"
+#line 651 "parser.y"
 {
 	yyval.selector = yyvsp[-1].selector;
         if (yyval.selector) {
@@ -1608,14 +1598,14 @@ case 77:
     ;
     break;}
 case 78:
-#line 664 "parser.y"
+#line 661 "parser.y"
 {
         delete yyvsp[-1].selector;
         yyval.selector = 0;
     ;
     break;}
 case 79:
-#line 671 "parser.y"
+#line 668 "parser.y"
 {
 	yyval.selector = new CSSSelector();
 	yyval.selector->match = CSSSelector::Id;
@@ -1624,7 +1614,7 @@ case 79:
     ;
     break;}
 case 83:
-#line 683 "parser.y"
+#line 680 "parser.y"
 {
 	yyval.selector = new CSSSelector();
 	yyval.selector->match = CSSSelector::List;
@@ -1633,7 +1623,7 @@ case 83:
     ;
     break;}
 case 84:
-#line 692 "parser.y"
+#line 689 "parser.y"
 {
 	CSSParser *p = static_cast<CSSParser *>(parser);
 	DOM::DocumentImpl *doc = p->document();
@@ -1643,21 +1633,17 @@ case 84:
 	    if (doc->isHTMLDocument())
 		attr = attr.lower();
 	    const DOMString dattr(attr);
-#if APPLE_CHANGES
             yyval.attribute = doc->attrId(0, dattr.implementation(), false);
-#else
-	    yyval.attribute = doc->attrNames()->getId(dattr.implementation(), false);
-#endif
 	} else {
 	    yyval.attribute = khtml::getAttrID(attr.lower().ascii(), attr.length());
 	    // this case should never happen - only when loading
 	    // the default stylesheet - which must not contain unknown attributes
 	    assert(yyval.attribute != 0);
-	    }
+        }
     ;
     break;}
 case 85:
-#line 716 "parser.y"
+#line 709 "parser.y"
 {
 	yyval.selector = new CSSSelector();
 	yyval.selector->attr = yyvsp[-1].attribute;
@@ -1665,7 +1651,7 @@ case 85:
     ;
     break;}
 case 86:
-#line 721 "parser.y"
+#line 714 "parser.y"
 {
 	yyval.selector = new CSSSelector();
 	yyval.selector->attr = yyvsp[-5].attribute;
@@ -1674,18 +1660,18 @@ case 86:
     ;
     break;}
 case 87:
-#line 727 "parser.y"
+#line 720 "parser.y"
 {
         yyval.selector = new CSSSelector();
         yyval.selector->attr = yyvsp[-1].attribute;
         yyval.selector->match = CSSSelector::Set;
         CSSParser *p = static_cast<CSSParser *>(parser);
         if (p->styleElement && p->styleElement->isCSSStyleSheet())
-            static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace(yyval.selector, domString(yyvsp[-3].string));
+            static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace(yyval.selector->attr, domString(yyvsp[-3].string));
     ;
     break;}
 case 88:
-#line 735 "parser.y"
+#line 728 "parser.y"
 {
         yyval.selector = new CSSSelector();
         yyval.selector->attr = yyvsp[-5].attribute;
@@ -1693,47 +1679,47 @@ case 88:
         yyval.selector->value = domString(yyvsp[-2].string);
         CSSParser *p = static_cast<CSSParser *>(parser);
         if (p->styleElement && p->styleElement->isCSSStyleSheet())
-            static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace(yyval.selector, domString(yyvsp[-7].string));
+            static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace(yyval.selector->attr, domString(yyvsp[-7].string));
     ;
     break;}
 case 89:
-#line 747 "parser.y"
+#line 740 "parser.y"
 {
 	yyval.val = CSSSelector::Exact;
     ;
     break;}
 case 90:
-#line 750 "parser.y"
+#line 743 "parser.y"
 {
 	yyval.val = CSSSelector::List;
     ;
     break;}
 case 91:
-#line 753 "parser.y"
+#line 746 "parser.y"
 {
 	yyval.val = CSSSelector::Hyphen;
     ;
     break;}
 case 92:
-#line 756 "parser.y"
+#line 749 "parser.y"
 {
 	yyval.val = CSSSelector::Begin;
     ;
     break;}
 case 93:
-#line 759 "parser.y"
+#line 752 "parser.y"
 {
 	yyval.val = CSSSelector::End;
     ;
     break;}
 case 94:
-#line 762 "parser.y"
+#line 755 "parser.y"
 {
 	yyval.val = CSSSelector::Contain;
     ;
     break;}
 case 97:
-#line 773 "parser.y"
+#line 766 "parser.y"
 {
         yyval.selector = new CSSSelector();
         yyval.selector->match = CSSSelector::Pseudo;
@@ -1741,7 +1727,7 @@ case 97:
     ;
     break;}
 case 98:
-#line 779 "parser.y"
+#line 772 "parser.y"
 {
         yyval.selector = new CSSSelector();
         yyval.selector->match = CSSSelector::Pseudo;
@@ -1749,7 +1735,7 @@ case 98:
     ;
     break;}
 case 99:
-#line 784 "parser.y"
+#line 777 "parser.y"
 {
         yyval.selector = new CSSSelector();
         yyval.selector->match = CSSSelector::Pseudo;
@@ -1758,13 +1744,13 @@ case 99:
     ;
     break;}
 case 100:
-#line 793 "parser.y"
+#line 786 "parser.y"
 {
 	yyval.ok = yyvsp[0].ok;
     ;
     break;}
 case 101:
-#line 796 "parser.y"
+#line 789 "parser.y"
 {
 	yyval.ok = yyvsp[-1].ok;
 	if ( yyvsp[0].ok )
@@ -1772,13 +1758,13 @@ case 101:
     ;
     break;}
 case 102:
-#line 801 "parser.y"
+#line 794 "parser.y"
 {
 	yyval.ok = yyvsp[0].ok;
     ;
     break;}
 case 103:
-#line 804 "parser.y"
+#line 797 "parser.y"
 {
 	yyval.ok = false;
 #ifdef CSS_DEBUG
@@ -1787,7 +1773,7 @@ case 103:
     ;
     break;}
 case 104:
-#line 810 "parser.y"
+#line 803 "parser.y"
 {
 	yyval.ok = false;
 #ifdef CSS_DEBUG
@@ -1796,19 +1782,19 @@ case 104:
     ;
     break;}
 case 105:
-#line 819 "parser.y"
+#line 812 "parser.y"
 {
 	yyval.ok = yyvsp[-2].ok;
     ;
     break;}
 case 106:
-#line 822 "parser.y"
+#line 815 "parser.y"
 {
         yyval.ok = false;
     ;
     break;}
 case 107:
-#line 825 "parser.y"
+#line 818 "parser.y"
 {
 	yyval.ok = false;
 #ifdef CSS_DEBUG
@@ -1817,7 +1803,7 @@ case 107:
     ;
     break;}
 case 108:
-#line 831 "parser.y"
+#line 824 "parser.y"
 {
 	yyval.ok = false;
 #ifdef CSS_DEBUG
@@ -1826,7 +1812,7 @@ case 108:
     ;
     break;}
 case 109:
-#line 837 "parser.y"
+#line 830 "parser.y"
 {
 	yyval.ok = yyvsp[-3].ok;
 	if ( yyvsp[-2].ok )
@@ -1834,7 +1820,7 @@ case 109:
     ;
     break;}
 case 110:
-#line 842 "parser.y"
+#line 835 "parser.y"
 {
 	yyval.ok = yyvsp[-3].ok;
 #ifdef CSS_DEBUG
@@ -1843,7 +1829,7 @@ case 110:
     ;
     break;}
 case 111:
-#line 848 "parser.y"
+#line 841 "parser.y"
 {
 	yyval.ok = yyvsp[-5].ok;
 #ifdef CSS_DEBUG
@@ -1852,7 +1838,7 @@ case 111:
     ;
     break;}
 case 112:
-#line 857 "parser.y"
+#line 850 "parser.y"
 {
 	yyval.ok = false;
 	CSSParser *p = static_cast<CSSParser *>(parser);
@@ -1877,13 +1863,13 @@ case 112:
     ;
     break;}
 case 113:
-#line 880 "parser.y"
+#line 873 "parser.y"
 {
         yyval.ok = false;
     ;
     break;}
 case 114:
-#line 884 "parser.y"
+#line 877 "parser.y"
 {
         /* The default movable type template has letter-spacing: .none;  Handle this by looking for
         error tokens at the start of an expr, recover the expr and then treat as an error, cleaning
@@ -1893,43 +1879,43 @@ case 114:
     ;
     break;}
 case 115:
-#line 892 "parser.y"
+#line 885 "parser.y"
 {
         /* Handle this case: div { text-align: center; !important } Just reduce away the stray !important. */
         yyval.ok = false;
     ;
     break;}
 case 116:
-#line 897 "parser.y"
+#line 890 "parser.y"
 {
         /* div { font-family: } Just reduce away this property with no value. */
         yyval.ok = false;
     ;
     break;}
 case 117:
-#line 904 "parser.y"
+#line 897 "parser.y"
 {
 	QString str = qString(yyvsp[-1].string);
 	yyval.prop_id = getPropertyID( str.lower().latin1(), str.length() );
     ;
     break;}
 case 118:
-#line 911 "parser.y"
+#line 904 "parser.y"
 { yyval.b = true; ;
     break;}
 case 119:
-#line 912 "parser.y"
+#line 905 "parser.y"
 { yyval.b = false; ;
     break;}
 case 120:
-#line 916 "parser.y"
+#line 909 "parser.y"
 {
 	yyval.valueList = new ValueList;
 	yyval.valueList->addValue( yyvsp[0].value );
     ;
     break;}
 case 121:
-#line 920 "parser.y"
+#line 913 "parser.y"
 {
         yyval.valueList = yyvsp[-2].valueList;
 	if ( yyval.valueList ) {
@@ -1945,44 +1931,44 @@ case 121:
     ;
     break;}
 case 122:
-#line 933 "parser.y"
+#line 926 "parser.y"
 {
         delete yyvsp[-1].valueList;
         yyval.valueList = 0;
     ;
     break;}
 case 123:
-#line 940 "parser.y"
+#line 933 "parser.y"
 {
 	yyval.tok = '/';
     ;
     break;}
 case 124:
-#line 943 "parser.y"
+#line 936 "parser.y"
 {
 	yyval.tok = ',';
     ;
     break;}
 case 125:
-#line 946 "parser.y"
+#line 939 "parser.y"
 {
         yyval.tok = 0;
   ;
     break;}
 case 126:
-#line 952 "parser.y"
+#line 945 "parser.y"
 { yyval.value = yyvsp[0].value; ;
     break;}
 case 127:
-#line 953 "parser.y"
+#line 946 "parser.y"
 { yyval.value = yyvsp[0].value; yyval.value.fValue *= yyvsp[-1].val; ;
     break;}
 case 128:
-#line 954 "parser.y"
+#line 947 "parser.y"
 { yyval.value.id = 0; yyval.value.string = yyvsp[-1].string; yyval.value.unit = CSSPrimitiveValue::CSS_STRING; ;
     break;}
 case 129:
-#line 955 "parser.y"
+#line 948 "parser.y"
 {
       QString str = qString( yyvsp[-1].string );
       yyval.value.id = getValueID( str.lower().latin1(), str.length() );
@@ -1991,109 +1977,109 @@ case 129:
   ;
     break;}
 case 130:
-#line 962 "parser.y"
+#line 955 "parser.y"
 { yyval.value.id = 0; yyval.value.string = yyvsp[-1].string; yyval.value.unit = CSSPrimitiveValue::CSS_DIMENSION ;
     break;}
 case 131:
-#line 963 "parser.y"
+#line 956 "parser.y"
 { yyval.value.id = 0; yyval.value.string = yyvsp[-1].string; yyval.value.unit = CSSPrimitiveValue::CSS_DIMENSION ;
     break;}
 case 132:
-#line 964 "parser.y"
+#line 957 "parser.y"
 { yyval.value.id = 0; yyval.value.string = yyvsp[-1].string; yyval.value.unit = CSSPrimitiveValue::CSS_URI; ;
     break;}
 case 133:
-#line 965 "parser.y"
+#line 958 "parser.y"
 { yyval.value.id = 0; yyval.value.iValue = 0; yyval.value.unit = CSSPrimitiveValue::CSS_UNKNOWN;/* ### */ ;
     break;}
 case 134:
-#line 966 "parser.y"
+#line 959 "parser.y"
 { yyval.value.id = 0; yyval.value.string = yyvsp[0].string; yyval.value.unit = CSSPrimitiveValue::CSS_RGBCOLOR; ;
     break;}
 case 135:
-#line 967 "parser.y"
+#line 960 "parser.y"
 { yyval.value.id = 0; yyval.value.string = ParseString(); yyval.value.unit = CSSPrimitiveValue::CSS_RGBCOLOR; ;
     break;}
 case 136:
-#line 969 "parser.y"
+#line 962 "parser.y"
 {
       yyval.value = yyvsp[0].value;
   ;
     break;}
 case 137:
-#line 975 "parser.y"
+#line 968 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_NUMBER; ;
     break;}
 case 138:
-#line 976 "parser.y"
+#line 969 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_PERCENTAGE; ;
     break;}
 case 139:
-#line 977 "parser.y"
+#line 970 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_PX; ;
     break;}
 case 140:
-#line 978 "parser.y"
+#line 971 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_CM; ;
     break;}
 case 141:
-#line 979 "parser.y"
+#line 972 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_MM; ;
     break;}
 case 142:
-#line 980 "parser.y"
+#line 973 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_IN; ;
     break;}
 case 143:
-#line 981 "parser.y"
+#line 974 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_PT; ;
     break;}
 case 144:
-#line 982 "parser.y"
+#line 975 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_PC; ;
     break;}
 case 145:
-#line 983 "parser.y"
+#line 976 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_DEG; ;
     break;}
 case 146:
-#line 984 "parser.y"
+#line 977 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_RAD; ;
     break;}
 case 147:
-#line 985 "parser.y"
+#line 978 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_GRAD; ;
     break;}
 case 148:
-#line 986 "parser.y"
+#line 979 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_MS; ;
     break;}
 case 149:
-#line 987 "parser.y"
+#line 980 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_S; ;
     break;}
 case 150:
-#line 988 "parser.y"
+#line 981 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_HZ; ;
     break;}
 case 151:
-#line 989 "parser.y"
+#line 982 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_KHZ; ;
     break;}
 case 152:
-#line 990 "parser.y"
+#line 983 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_EMS; ;
     break;}
 case 153:
-#line 991 "parser.y"
+#line 984 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = Value::Q_EMS; ;
     break;}
 case 154:
-#line 992 "parser.y"
+#line 985 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_EXS; ;
     break;}
 case 155:
-#line 997 "parser.y"
+#line 990 "parser.y"
 {
       Function *f = new Function;
       f->name = yyvsp[-4].string;
@@ -2104,7 +2090,7 @@ case 155:
   ;
     break;}
 case 156:
-#line 1005 "parser.y"
+#line 998 "parser.y"
 {
       Function *f = new Function;
       f->name = yyvsp[-2].string;
@@ -2115,11 +2101,11 @@ case 156:
   ;
     break;}
 case 157:
-#line 1020 "parser.y"
+#line 1013 "parser.y"
 { yyval.string = yyvsp[-1].string; ;
     break;}
 case 158:
-#line 1027 "parser.y"
+#line 1020 "parser.y"
 {
 	yyval.rule = 0;
 #ifdef CSS_DEBUG
@@ -2128,7 +2114,7 @@ case 158:
     ;
     break;}
 case 159:
-#line 1033 "parser.y"
+#line 1026 "parser.y"
 {
 	yyval.rule = 0;
 #ifdef CSS_DEBUG
@@ -2137,7 +2123,7 @@ case 159:
     ;
     break;}
 case 160:
-#line 1042 "parser.y"
+#line 1035 "parser.y"
 {
 	yyval.rule = 0;
 #ifdef CSS_DEBUG
@@ -2367,6 +2353,6 @@ yyerrhandle:
     }
   return 1;
 }
-#line 1077 "parser.y"
+#line 1070 "parser.y"
 
 
diff --git a/WebCore/khtml/css/parser.y b/WebCore/khtml/css/parser.y
index f37453b..a4dc817 100644
--- a/WebCore/khtml/css/parser.y
+++ b/WebCore/khtml/css/parser.y
@@ -35,6 +35,8 @@
 #include <misc/htmlhashes.h>
 #include "cssparser.h"
 
+#include "xml_namespace_table.h"
+    
 #include <assert.h>
 #include <kdebug.h>
 // #define CSS_DEBUG
@@ -134,7 +136,6 @@ static int cssyylex( YYSTYPE *yylval ) {
 %token <string> IDENT
 
 %token <string> HASH
-%token <string> '*'
 %token ':'
 %token '.'
 %token '['
@@ -366,7 +367,7 @@ NAMESPACE_SYM maybe_space maybe_ns_prefix string_or_uri maybe_space ';' {
 #endif
     CSSParser *p = static_cast<CSSParser *>(parser);
     if (p->styleElement && p->styleElement->isCSSStyleSheet())
-        static_cast<CSSStyleSheetImpl*>(p->styleElement)->addNamespace(domString($3), domString($4));
+        static_cast<CSSStyleSheetImpl*>(p->styleElement)->addNamespace(p, domString($3), domString($4));
 }
 | NAMESPACE_SYM error invalid_block
 | NAMESPACE_SYM error ';'
@@ -574,7 +575,7 @@ selector:
 
 namespace_selector:
     /* empty */ { $$.string = 0; $$.length = 0; }
-    | '*' { $$ = $1; }
+    | '*' { static unsigned short star = '*'; $$.string = &star; $$.length = 1; }
     | IDENT { $$ = $1; }
 ;
 
@@ -590,15 +591,15 @@ simple_selector:
     }
     | specifier_list maybe_space {
 	$$ = $1;
-	if ( $$ )
-            $$->tag = 0xffffffff;
+        if ($$)
+            $$->tag = makeId(static_cast<CSSParser*>(parser)->defaultNamespace, anyLocalName);;
     }
     | namespace_selector '|' element_name maybe_space {
         $$ = new CSSSelector();
         $$->tag = $3;
         CSSParser *p = static_cast<CSSParser *>(parser);
         if (p->styleElement && p->styleElement->isCSSStyleSheet())
-            static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$, domString($1));
+            static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$->tag, domString($1));
     }
     | namespace_selector '|' element_name specifier_list maybe_space {
         $$ = $4;
@@ -606,16 +607,16 @@ simple_selector:
             $$->tag = $3;
             CSSParser *p = static_cast<CSSParser *>(parser);
             if (p->styleElement && p->styleElement->isCSSStyleSheet())
-                static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$, domString($1));
+                static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$->tag, domString($1));
         }
     }
     | namespace_selector '|' specifier_list maybe_space {
         $$ = $3;
         if ($$) {
-            $$->tag = 0xffffffff;
+            $$->tag = makeId(anyNamespace, anyLocalName);
             CSSParser *p = static_cast<CSSParser *>(parser);
             if (p->styleElement && p->styleElement->isCSSStyleSheet())
-                static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$, domString($1));
+                static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$->tag, domString($1));
         }
     }
   ;
@@ -629,20 +630,16 @@ element_name:
 	    if (doc->isHTMLDocument())
 		tag = tag.lower();
 	    const DOMString dtag(tag);
-#if APPLE_CHANGES
-            $$ = doc->tagId(0, dtag.implementation(), false);
-#else
-	    $$ = doc->elementNames()->getId(dtag.implementation(), false);
-#endif
+            $$ = makeId(p->defaultNamespace, doc->tagId(0, dtag.implementation(), false));
 	} else {
-	    $$ = khtml::getTagID(tag.lower().ascii(), tag.length());
+	    $$ = makeId(p->defaultNamespace, khtml::getTagID(tag.lower().ascii(), tag.length()));
 	    // this case should never happen - only when loading
 	    // the default stylesheet - which must not contain unknown tags
 // 	    assert($$ != 0);
 	}
     }
     | '*' {
-	$$ = -1;
+	$$ = makeId(static_cast<CSSParser*>(parser)->defaultNamespace, anyLocalName);
     }
   ;
 
@@ -698,17 +695,13 @@ attrib_id:
 	    if (doc->isHTMLDocument())
 		attr = attr.lower();
 	    const DOMString dattr(attr);
-#if APPLE_CHANGES
             $$ = doc->attrId(0, dattr.implementation(), false);
-#else
-	    $$ = doc->attrNames()->getId(dattr.implementation(), false);
-#endif
 	} else {
 	    $$ = khtml::getAttrID(attr.lower().ascii(), attr.length());
 	    // this case should never happen - only when loading
 	    // the default stylesheet - which must not contain unknown attributes
 	    assert($$ != 0);
-	    }
+        }
     }
     ;
 
@@ -730,7 +723,7 @@ attrib:
         $$->match = CSSSelector::Set;
         CSSParser *p = static_cast<CSSParser *>(parser);
         if (p->styleElement && p->styleElement->isCSSStyleSheet())
-            static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$, domString($3));
+            static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$->attr, domString($3));
     }
     | '[' maybe_space namespace_selector '|' attrib_id match maybe_space ident_or_string maybe_space ']' {
         $$ = new CSSSelector();
@@ -739,7 +732,7 @@ attrib:
         $$->value = domString($8);
         CSSParser *p = static_cast<CSSParser *>(parser);
         if (p->styleElement && p->styleElement->isCSSStyleSheet())
-            static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$, domString($3));
+            static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$->attr, domString($3));
     }
   ;
 
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 35aa46d..fbefe75 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -31,6 +31,8 @@
 #include "xml/dom2_eventsimpl.h"
 #include "xml/xml_tokenizer.h"
 
+#include "xml_namespace_table.h"
+
 #include "css/csshelper.h"
 #include "css/cssstyleselector.h"
 #include "css/css_stylesheetimpl.h"
@@ -292,12 +294,6 @@ DocumentImpl::DocumentImpl(DOMImplementationImpl *_implementation, KHTMLView *v)
     m_attrNames = 0;
     m_attrNameAlloc = 0;
     m_attrNameCount = 0;
-    m_namespaceURIAlloc = 4;
-    m_namespaceURICount = 1;
-    QString xhtml(XHTML_NAMESPACE);
-    m_namespaceURIs = new DOMStringImpl* [m_namespaceURIAlloc];
-    m_namespaceURIs[0] = new DOMStringImpl(xhtml.unicode(), xhtml.length());
-    m_namespaceURIs[0]->ref();
     m_focusNode = 0;
     m_hoverNode = 0;
     m_defaultView = new AbstractViewImpl(this);
@@ -357,9 +353,6 @@ DocumentImpl::~DocumentImpl()
             m_attrNames[id]->deref();
         delete [] m_attrNames;
     }
-    for (unsigned short id = 0; id < m_namespaceURICount; ++id)
-        m_namespaceURIs[id]->deref();
-    delete [] m_namespaceURIs;
     m_defaultView->deref();
     m_styleSheets->deref();
 
@@ -1839,33 +1832,14 @@ NodeImpl::Id DocumentImpl::attrId(DOMStringImpl* _namespaceURI, DOMStringImpl *_
     }
 
     // now lets find out the namespace
+    Q_UINT16 ns = noNamespace;
     if (_namespaceURI) {
         DOMString nsU(_namespaceURI);
-        bool found = false;
-        // ### yeah, this is lame. use a dictionary / map instead
-        for (unsigned short ns = 0; ns < m_namespaceURICount; ++ns)
-            if (nsU == DOMString(m_namespaceURIs[ns])) {
-                id |= ns << 16;
-                found = true;
-                break;
-            }
-
-        if (!found && !readonly) {
-            // something new, add it
-            if (m_namespaceURICount >= m_namespaceURIAlloc) {
-                m_namespaceURIAlloc += 32;
-                DOMStringImpl **newURIs = new DOMStringImpl* [m_namespaceURIAlloc];
-                for (unsigned short i = 0; i < m_namespaceURICount; i++)
-                    newURIs[i] = m_namespaceURIs[i];
-                delete [] m_namespaceURIs;
-                m_namespaceURIs = newURIs;
-            }
-            m_namespaceURIs[m_namespaceURICount++] = _namespaceURI;
-            _namespaceURI->ref();
-            id |= m_namespaceURICount << 16;
-        }
+        int nsID = XmlNamespaceTable::getNamespaceID(nsU, readonly);
+        if (nsID != -1)
+            ns = (Q_UINT16)nsID;
     }
-
+    
     // Look in the m_attrNames array for the name
     // ### yeah, this is lame. use a dictionary / map instead
     DOMString nme(n.string());
@@ -1873,7 +1847,7 @@ NodeImpl::Id DocumentImpl::attrId(DOMStringImpl* _namespaceURI, DOMStringImpl *_
     if (htmlMode() != XHtml) nme = nme.upper();
     for (id = 0; id < m_attrNameCount; id++)
         if (DOMString(m_attrNames[id]) == nme)
-            return ATTR_LAST_ATTR+id;
+            return makeId(ns, ATTR_LAST_ATTR+id);
 
     // unknown
     if (readonly) return 0;
@@ -1896,14 +1870,14 @@ NodeImpl::Id DocumentImpl::attrId(DOMStringImpl* _namespaceURI, DOMStringImpl *_
     m_attrNames[id] = nme.implementation();
     m_attrNames[id]->ref();
 
-    return ATTR_LAST_ATTR+id;
+    return makeId(ns, ATTR_LAST_ATTR+id);
 }
 
 DOMString DocumentImpl::attrName(NodeImpl::Id _id) const
 {
     DOMString result;
-    if (_id >= ATTR_LAST_ATTR)
-        result = m_attrNames[_id-ATTR_LAST_ATTR];
+    if (localNamePart(_id) >= ATTR_LAST_ATTR)
+        result = m_attrNames[localNamePart(_id)-ATTR_LAST_ATTR];
     else
         result = getAttrName(_id);
 
@@ -1938,31 +1912,12 @@ NodeImpl::Id DocumentImpl::tagId(DOMStringImpl* _namespaceURI, DOMStringImpl *_n
     }
 
     // now lets find out the namespace
+    Q_UINT16 ns = noNamespace;
     if (_namespaceURI) {
         DOMString nsU(_namespaceURI);
-        bool found = false;
-        // ### yeah, this is lame. use a dictionary / map instead
-        for (unsigned short ns = 0; ns < m_namespaceURICount; ++ns)
-            if (nsU == DOMString(m_namespaceURIs[ns])) {
-                id |= ns << 16;
-                found = true;
-                break;
-            }
-
-        if (!found && !readonly) {
-            // something new, add it
-            if (m_namespaceURICount >= m_namespaceURIAlloc) {
-                m_namespaceURIAlloc += 32;
-                DOMStringImpl **newURIs = new DOMStringImpl* [m_namespaceURIAlloc];
-                for (unsigned short i = 0; i < m_namespaceURICount; i++)
-                    newURIs[i] = m_namespaceURIs[i];
-                delete [] m_namespaceURIs;
-                m_namespaceURIs = newURIs;
-            }
-            m_namespaceURIs[m_namespaceURICount++] = _namespaceURI;
-            _namespaceURI->ref();
-            id |= m_namespaceURICount << 16;
-        }
+        int nsID = XmlNamespaceTable::getNamespaceID(nsU, readonly);
+        if (nsID != -1)
+            ns = (Q_UINT16)nsID;
     }
 
     // Look in the m_elementNames array for the name
@@ -1972,7 +1927,7 @@ NodeImpl::Id DocumentImpl::tagId(DOMStringImpl* _namespaceURI, DOMStringImpl *_n
     if (htmlMode() != XHtml) nme = nme.upper();
     for (id = 0; id < m_elementNameCount; id++)
         if (DOMString(m_elementNames[id]) == nme)
-            return ID_LAST_TAG+id;
+            return makeId(ns, ID_LAST_TAG+id);
 
     // unknown
     if (readonly) return 0;
@@ -1995,13 +1950,13 @@ NodeImpl::Id DocumentImpl::tagId(DOMStringImpl* _namespaceURI, DOMStringImpl *_n
     m_elementNames[id] = nme.implementation();
     m_elementNames[id]->ref();
 
-    return ID_LAST_TAG+id;
+    return makeId(ns, ID_LAST_TAG+id);
 }
 
 DOMString DocumentImpl::tagName(NodeImpl::Id _id) const
 {
-    if (_id >= ID_LAST_TAG)
-        return m_elementNames[_id-ID_LAST_TAG];
+    if (localNamePart(_id) >= ID_LAST_TAG)
+        return m_elementNames[localNamePart(_id)-ID_LAST_TAG];
     else {
         // ### put them in a cache
         if (getDocument()->htmlMode() == DocumentImpl::XHtml)
@@ -2015,13 +1970,13 @@ DOMString DocumentImpl::tagName(NodeImpl::Id _id) const
 DOMStringImpl* DocumentImpl::namespaceURI(NodeImpl::Id _id) const
 {
     if (_id < ID_LAST_TAG)
-        return htmlMode() == XHtml ? m_namespaceURIs[0] : 0;
+        return htmlMode() == XHtml ? XmlNamespaceTable::getNamespaceURI(xhtmlNamespace).implementation() : 0;
 
     unsigned short ns = _id >> 16;
 
     if (!ns) return 0;
 
-    return m_namespaceURIs[ns-1];
+    return XmlNamespaceTable::getNamespaceURI(ns).implementation();
 }
 
 StyleSheetListImpl* DocumentImpl::styleSheets()
diff --git a/WebCore/khtml/xml/dom_elementimpl.cpp b/WebCore/khtml/xml/dom_elementimpl.cpp
index 22b3a9a..5e1fb8b 100644
--- a/WebCore/khtml/xml/dom_elementimpl.cpp
+++ b/WebCore/khtml/xml/dom_elementimpl.cpp
@@ -850,10 +850,15 @@ unsigned long NamedAttrMapImpl::length(  ) const
 
 AttributeImpl* NamedAttrMapImpl::getAttributeItem(NodeImpl::Id id) const
 {
-    for (unsigned long i = 0; i < len; ++i)
-        if (attrs[i]->id() == id)
+    bool matchAnyNamespace = (namespacePart(id) == anyNamespace);
+    for (unsigned long i = 0; i < len; ++i) {
+        if (matchAnyNamespace) {
+            if (localNamePart(attrs[i]->id()) == localNamePart(id))
+                return attrs[i];
+        }
+        else if (attrs[i]->id() == id)
             return attrs[i];
-
+    }
     return 0;
 }
 
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index 7972eed..371cca4 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -50,9 +50,6 @@
 using namespace DOM;
 using namespace khtml;
 
-const Q_UINT32 NodeImpl::IdNSMask    = 0xffff0000;
-const Q_UINT32 NodeImpl::IdLocalMask = 0x0000ffff;
-
 NodeImpl::NodeImpl(DocumentPtr *doc)
     : document(doc),
       m_previous(0),
@@ -997,7 +994,7 @@ void NodeImpl::checkSetPrefix(const DOMString &_prefix, int &exceptioncode)
     // - if this node is an attribute and the specified prefix is "xmlns" and
     //   the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/",
     // - or if this node is an attribute and the qualifiedName of this node is "xmlns" [Namespaces].
-    if (Element::khtmlMalformedPrefix(_prefix) || (!(id() & IdNSMask) && id() > ID_LAST_TAG) ||
+    if (Element::khtmlMalformedPrefix(_prefix) || (namespacePart(id()) == noNamespace && id() > ID_LAST_TAG) ||
         (_prefix == "xml" && DOMString(getDocument()->namespaceURI(id())) != "http://www.w3.org/XML/1998/namespace")) {
         exceptioncode = DOMException::NAMESPACE_ERR;
         return;
@@ -1862,14 +1859,14 @@ NodeListImpl* NodeBaseImpl::getElementsByTagNameNS ( DOMStringImpl* namespaceURI
 {
     if (!localName) return 0;
 
-    NodeImpl::Id idMask = NodeImpl::IdNSMask | NodeImpl::IdLocalMask;
+    NodeImpl::Id idMask = namespaceMask | localNameMask;
     if (localName->l && localName->s[0] == '*')
-        idMask &= ~NodeImpl::IdLocalMask;
+        idMask &= ~localNameMask;
     if (namespaceURI && namespaceURI->l && namespaceURI->s[0] == '*')
-        idMask &= ~NodeImpl::IdNSMask;
+        idMask &= ~namespaceMask;
 
     Id id = 0; // 0 means "all items"
-    if ( (idMask & NodeImpl::IdLocalMask) || namespaceURI ) // not getElementsByTagName("*")
+    if ( (idMask & localNameMask) || namespaceURI ) // not getElementsByTagName("*")
     {
         id = getDocument()->tagId( namespaceURI, localName, true);
         if ( !id ) // not found -> we want to return an empty list, not "all items"
diff --git a/WebCore/khtml/xml/dom_nodeimpl.h b/WebCore/khtml/xml/dom_nodeimpl.h
index 06b1740..eaa57ee 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.h
+++ b/WebCore/khtml/xml/dom_nodeimpl.h
@@ -31,9 +31,6 @@
 #include "misc/helper.h"
 #include "misc/shared.h"
 
-// The namespace used for XHTML elements
-#define XHTML_NAMESPACE "http://www.w3.org/1999/xhtml"
-
 class QPainter;
 template <class type> class QPtrList;
 class KHTMLView;
@@ -59,6 +56,23 @@ class Range;
 class RegisteredEventListener;
 class EventImpl;
 
+// The namespace used for XHTML elements
+#define XHTML_NAMESPACE "http://www.w3.org/1999/xhtml"
+
+const Q_UINT16 noNamespace = 0;
+const Q_UINT16 anyNamespace = 1;
+const Q_UINT16 xhtmlNamespace = 2;
+const Q_UINT16 anyLocalName = 0;
+
+const Q_UINT32 namespaceMask = 0xFFFF0000U;
+const Q_UINT32 localNameMask = 0x0000FFFFU;
+
+inline Q_UINT16 namespacePart(Q_UINT32 i) { return i >> 16; }
+inline Q_UINT16 localNamePart(Q_UINT32 i) { return i; }
+inline Q_UINT32 makeId(Q_UINT16 n, Q_UINT16 l) { return (n << 16) | l; }
+
+const Q_UINT32 anyQName = makeId(anyNamespace, anyLocalName);
+
 class DocumentPtr : public khtml::Shared<DocumentPtr>
 {
 public:
@@ -148,8 +162,6 @@ public:
     virtual NodeImpl *addChild(NodeImpl *newChild);
 
     typedef Q_UINT32 Id;
-    static const Q_UINT32 IdNSMask;
-    static const Q_UINT32 IdLocalMask;
     // id() is used to easily and exactly identify a node. It
     // is optimized for quick comparison and low memory consumption.
     // its value depends on the owner document of the node and is
diff --git a/WebCore/khtml/xml/dom_xmlimpl.cpp b/WebCore/khtml/xml/dom_xmlimpl.cpp
index 44e8a9e..a2b253e 100644
--- a/WebCore/khtml/xml/dom_xmlimpl.cpp
+++ b/WebCore/khtml/xml/dom_xmlimpl.cpp
@@ -401,7 +401,7 @@ void ProcessingInstructionImpl::checkStyleSheet()
         QXmlAttributes attrs = attrReader.readAttrs(attrsOk);
         if (!attrsOk)
             return;
-        if (attrs.value("type") != "text/css")
+        if (attrs.value("type") != "text/css" && !attrs.value("type").isEmpty())
             return;
 
         DOMString href = attrs.value("href");
diff --git a/WebCore/khtml/xml/xml_namespace_table.cpp b/WebCore/khtml/xml/xml_namespace_table.cpp
new file mode 100644
index 0000000..ee2ccc6
--- /dev/null
+++ b/WebCore/khtml/xml/xml_namespace_table.cpp
@@ -0,0 +1,79 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 2004 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "xml_namespace_table.h"
+#include "dom_nodeimpl.h"
+
+namespace DOM
+{
+
+QDict<XmlNamespaceEntry>* XmlNamespaceTable::gNamespaceTable = 0;
+
+int XmlNamespaceTable::getNamespaceID(const DOMString& uri, bool readonly)
+{
+    if (uri == XHTML_NAMESPACE)
+        return xhtmlNamespace;
+    
+    if (uri.isEmpty())
+        return noNamespace;
+    
+    QString uriStr = uri.string();
+
+    if (!gNamespaceTable) {
+        gNamespaceTable = new QDict<XmlNamespaceEntry>;
+        gNamespaceTable->insert(XHTML_NAMESPACE, new XmlNamespaceEntry(xhtmlNamespace, XHTML_NAMESPACE));
+    }
+    
+    XmlNamespaceEntry* ns = gNamespaceTable->find(uriStr);
+    if (ns) return ns->m_id;
+    
+    if (!readonly) {
+        static int id = xhtmlNamespace+1;
+        ns = new XmlNamespaceEntry(id++, uri);
+        gNamespaceTable->insert(uriStr, ns);
+        return ns->m_id;
+    }
+    
+    return -1;
+}
+
+DOMString XmlNamespaceTable::getNamespaceURI(int id)
+{
+    if (id == noNamespace || id == anyNamespace || !gNamespaceTable)
+        return "";
+
+    if (!gNamespaceTable) {
+        gNamespaceTable = new QDict<XmlNamespaceEntry>;
+        gNamespaceTable->insert(XHTML_NAMESPACE, new XmlNamespaceEntry(xhtmlNamespace, XHTML_NAMESPACE));
+    }
+    
+    // Have to iterate over the dictionary entries looking for a match.
+    // (This should be ok, since this is not the common direction.)
+    QDictIterator<XmlNamespaceEntry> it(*gNamespaceTable);
+    for (unsigned i = 0; i < it.count(); i++, ++it) {
+        if (it.current()->m_id == id)
+            return it.current()->m_uri;
+    }
+    
+    return "";
+}
+
+}
diff --git a/WebCore/khtml/html/dtd.h b/WebCore/khtml/xml/xml_namespace_table.h
similarity index 65%
copy from WebCore/khtml/html/dtd.h
copy to WebCore/khtml/xml/xml_namespace_table.h
index 7e5a6c0..100effa 100644
--- a/WebCore/khtml/html/dtd.h
+++ b/WebCore/khtml/xml/xml_namespace_table.h
@@ -1,7 +1,7 @@
-/*
+/**
  * This file is part of the DOM implementation for KDE.
  *
- * (C) 1999 Lars Knoll (knoll at kde.org)
+ * Copyright (C) 2004 Apple Computer, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -17,25 +17,30 @@
  * along with this library; see the file COPYING.LIB.  If not, write to
  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
- *
  */
-#ifndef _DOM_dtd_h_
-#define _DOM_dtd_h_
 
+#include <qdict.h>
 #include "dom/dom_string.h"
 
 namespace DOM
-{
-
-void addForbidden(int tagId, ushort *forbiddenTags);
-void removeForbidden(int tagId, ushort *forbiddenTags);
+{    
+struct XmlNamespaceEntry;
 
-enum tagStatus { OPTIONAL, REQUIRED, FORBIDDEN };
-
-bool checkChild(ushort tagID, ushort childID);
+class XmlNamespaceTable
+{
+public:
+    static int getNamespaceID(const DOMString& uri, bool readonly = true);
+    static DOMString getNamespaceURI(int id);
+    
+    static QDict<XmlNamespaceEntry>* gNamespaceTable;
+};
 
-extern const unsigned short tagPriority[];
-extern const tagStatus endTag[];
+struct XmlNamespaceEntry
+{
+    XmlNamespaceEntry(int id, const DOMString& uri) :m_id(id), m_uri(uri) {}
+    
+    int m_id;
+    DOMString m_uri;
+};
 
-} //namespace DOM
-#endif
+}

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list