Rolling out fix for <rdar://problem/4097849> because the following layout...
authoradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Apr 2005 01:04:59 +0000 (01:04 +0000)
committeradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Apr 2005 01:04:59 +0000 (01:04 +0000)
        fast/css/namespaces/001
        fast/css/namespaces/002
        fast/css/namespaces/004
        fast/css/namespaces/005
        fast/css/namespaces/006
        fast/overflow/003

        * khtml/html/html_documentimpl.cpp:
        * khtml/html/html_documentimpl.h:
        * khtml/html/html_elementimpl.cpp:
        (HTMLElementImpl::namespaceURI):
        * khtml/xml/dom_docimpl.cpp:
        (DocumentImpl::importNode):
        (DocumentImpl::createElementNS):
        (DocumentImpl::createHTMLElement):
        (DocumentImpl::attrId):
        (DocumentImpl::tagId):
        * khtml/xml/dom_docimpl.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9075 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/khtml/html/html_documentimpl.cpp
WebCore/khtml/html/html_documentimpl.h
WebCore/khtml/html/html_elementimpl.cpp
WebCore/khtml/xml/dom_docimpl.cpp
WebCore/khtml/xml/dom_docimpl.h

index 4fa803cbfded825806693ee6375ee5a90a116f10..9d1cd4e7e0c58ecd76015c0623a3f9fddb339459 100644 (file)
@@ -1,3 +1,27 @@
+2005-04-27 Adele Peterson  <adele@apple.com>
+
+        Rolling out fix for <rdar://problem/4097849> because the following layout tests were failing:
+
+        fast/css/namespaces/001
+        fast/css/namespaces/002
+        fast/css/namespaces/004
+        fast/css/namespaces/005
+        fast/css/namespaces/006
+        fast/overflow/003
+        
+
+        * khtml/html/html_documentimpl.cpp:
+        * khtml/html/html_documentimpl.h:
+        * khtml/html/html_elementimpl.cpp:
+        (HTMLElementImpl::namespaceURI):
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::importNode):
+        (DocumentImpl::createElementNS):
+        (DocumentImpl::createHTMLElement):
+        (DocumentImpl::attrId):
+        (DocumentImpl::tagId):
+        * khtml/xml/dom_docimpl.h:
+
 2005-04-27  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Darin.
index d23b2f8cc0c81640fe21a776836dd040a7c15b98..e184dd5c8ac489d6c20e026856dab3db9544b6ca 100644 (file)
@@ -533,16 +533,4 @@ void HTMLDocumentImpl::determineParseMode( const QString &str )
  
 }
 
-DOMStringImpl *HTMLDocumentImpl::HTMLElementNamespace() const
-{
-    // For HTML documents, we treat HTML elements as having no namespace.
-    return 0;
-}
-
-bool HTMLDocumentImpl::isHTMLNamespace(DOMStringImpl *n) const
-{
-    // For HTML documents, either "no namespace" or the HTML namespace qualifies.
-    return !n || DocumentImpl::isHTMLNamespace(n);
-}
-
 #include "html_documentimpl.moc"
index 22c1f226ff877c53f77be4cd237b404ee9109dcb..06d9c8261f47fa2039203259a11587db7485c885 100644 (file)
@@ -67,9 +67,6 @@ public:
 
     HTMLCollectionImpl::CollectionInfo *collectionInfo(int type) { return m_collection_info+type; }
 
-    virtual DOMStringImpl *HTMLElementNamespace() const;
-    virtual bool isHTMLNamespace(DOMStringImpl *) const;
-
 protected:
     HTMLElementImpl *bodyElement;
     HTMLElementImpl *htmlElement;
index 9fba4bb311cb29ca1e5215ed2f3a4626f9d8a53b..5d26ded9e1fc59f5c7baf23b97cbee469852603e 100644 (file)
@@ -965,9 +965,15 @@ bool HTMLElementImpl::setOuterText( const DOMString &text )
     return true;
 }
 
+
 DOMString HTMLElementImpl::namespaceURI() const
 {
-    return getDocument()->HTMLElementNamespace();
+    // For HTML documents, we treat HTML elements as having no namespace. But for XML documents
+    // the elements have the namespace defined in the XHTML spec
+    if (getDocument()->isHTMLDocument())
+        return DOMString();
+    else
+        return XHTML_NAMESPACE;
 }
 
 void HTMLElementImpl::addHTMLAlignment(HTMLAttributeImpl* attr)
index fc2223ce79ba83a665503270f91f8b185d0ff82c..ac7349ebe8df5ed56e8994491ba54bebcb8e4171 100644 (file)
@@ -531,99 +531,83 @@ CSSStyleDeclarationImpl *DocumentImpl::createCSSStyleDeclaration()
 
 NodeImpl *DocumentImpl::importNode(NodeImpl *importedNode, bool deep, int &exceptioncode)
 {
-    exceptioncode = 0;
-
-    switch (importedNode->nodeType()) {
-        case Node::TEXT_NODE:
-            return createTextNode(importedNode->nodeValue());
-        case Node::CDATA_SECTION_NODE:
-            return createCDATASection(importedNode->nodeValue());
-        case Node::ENTITY_REFERENCE_NODE:
-            return createEntityReference(importedNode->nodeName());
-        case Node::PROCESSING_INSTRUCTION_NODE:
-            return createProcessingInstruction(importedNode->nodeName(), importedNode->nodeValue());
-        case Node::COMMENT_NODE:
-            return createComment(importedNode->nodeValue());
-        case Node::ELEMENT_NODE: {
-            ElementImpl *e = createElementNS(importedNode->getDocument()->namespaceURI(importedNode->id()), importedNode->nodeName(), exceptioncode);
-            if (exceptioncode)
-                return 0;
-
-            e->ref();
-            if (static_cast<ElementImpl *>(importedNode)->attributes(true) && static_cast<ElementImpl *>(importedNode)->attributes(true)->length()) {
-                NamedAttrMapImpl *attrs = static_cast<ElementImpl *>(importedNode)->attributes();
-                unsigned length = attrs->length();
-                for (unsigned i = 0; i < length; i++) {
-                    AttrImpl *attr = attrs->item(i);
-                    DOMString qualifiedName = attr->nodeName();
-                    DOMString value = attr->nodeValue();
-
-                    int colonpos = qualifiedName.find(':');
-                    DOMString localName = qualifiedName;
-                    if (colonpos >= 0) {
-                        localName.remove(0, colonpos + 1);
-                        // ### extract and set new prefix
-                    }
-
-                    NodeImpl::Id nodeId = attrId(importedNode->getDocument()->namespaceURI(attr->attrImpl()->id()), localName.implementation(), false /* allocate */);
-                    e->setAttribute(nodeId, value.implementation(), exceptioncode);
-                    if (exceptioncode != 0) {
-                        e->deref();
-                        return 0;
-                    }
-                }
-            }
-
-            if (deep) {
-                for (NodeImpl *n = importedNode->firstChild(); n; n = n->nextSibling()) {
-                    NodeImpl *newNode = importNode(n, true, exceptioncode);
-                    if (exceptioncode != 0) {
-                        e->deref();
-                        return 0;
-                    }
-                    newNode->ref();
-                    e->appendChild(newNode, exceptioncode);
-                    if (exceptioncode != 0) {
-                        newNode->deref();
-                        e->deref();
-                        return 0;
-                    }
-                }
-            }
-
-            // Trick to get the result back to the floating state, with 0 refs but not destroyed.
-            e->setParent(this);
-            e->deref();
-            e->setParent(0);
-
-            return e;
-        }
-    }
-    exceptioncode = DOMException::NOT_SUPPORTED_ERR;
-    return 0;
-}
+       NodeImpl *result = 0;
+
+       if(importedNode->nodeType() == Node::ELEMENT_NODE)
+       {
+               ElementImpl *tempElementImpl = createElementNS(getDocument()->namespaceURI(id()), importedNode->nodeName(), exceptioncode);
+                if (exceptioncode)
+                    return 0;
+               result = tempElementImpl;
+
+               if(static_cast<ElementImpl *>(importedNode)->attributes(true) && static_cast<ElementImpl *>(importedNode)->attributes(true)->length())
+               {
+                       NamedNodeMapImpl *attr = static_cast<ElementImpl *>(importedNode)->attributes();
+
+                       for(unsigned int i = 0; i < attr->length(); i++)
+                       {
+                               DOMString qualifiedName = attr->item(i)->nodeName();
+                               DOMString value = attr->item(i)->nodeValue();
+
+                               int colonpos = qualifiedName.find(':');
+                               DOMString localName = qualifiedName;
+                               if(colonpos >= 0)
+                               {
+                                       localName.remove(0, colonpos + 1);
+                                       // ### extract and set new prefix
+                               }
+
+                               NodeImpl::Id nodeId = getDocument()->attrId(getDocument()->namespaceURI(id()), localName.implementation(), false /* allocate */);
+                               tempElementImpl->setAttribute(nodeId, value.implementation(), exceptioncode);
+
+                               if(exceptioncode != 0)
+                                       break;
+                       }
+               }
+       }
+       else if(importedNode->nodeType() == Node::TEXT_NODE)
+       {
+               result = createTextNode(importedNode->nodeValue());
+               deep = false;
+       }
+       else if(importedNode->nodeType() == Node::CDATA_SECTION_NODE)
+       {
+               result = createCDATASection(importedNode->nodeValue());
+               deep = false;
+       }
+       else if(importedNode->nodeType() == Node::ENTITY_REFERENCE_NODE)
+               result = createEntityReference(importedNode->nodeName());
+       else if(importedNode->nodeType() == Node::PROCESSING_INSTRUCTION_NODE)
+       {
+               result = createProcessingInstruction(importedNode->nodeName(), importedNode->nodeValue());
+               deep = false;
+       }
+       else if(importedNode->nodeType() == Node::COMMENT_NODE)
+       {
+               result = createComment(importedNode->nodeValue());
+               deep = false;
+       }
+       else
+               exceptioncode = DOMException::NOT_SUPPORTED_ERR;
 
-DOMStringImpl *DocumentImpl::HTMLElementNamespace() const
-{
-    // For XML documents, HTML elements have the namespace defined in the XHTML specification.
-    static DOMString result = XHTML_NAMESPACE;
-    return result.implementation();
-}
+       if(deep)
+       {
+               for(Node n = importedNode->firstChild(); !n.isNull(); n = n.nextSibling())
+                       result->appendChild(importNode(n.handle(), true, exceptioncode), exceptioncode);
+       }
 
-bool DocumentImpl::isHTMLNamespace(DOMStringImpl *n) const
-{
-    return strcasecmp(DOMString(n), XHTML_NAMESPACE) == 0;
+       return result;
 }
 
 ElementImpl *DocumentImpl::createElementNS( const DOMString &_namespaceURI, const DOMString &_qualifiedName, int &exceptioncode)
 {
     ElementImpl *e = 0;
+    QString qName = _qualifiedName.string();
+    int colonPos = qName.find(':',0);
 
-    if (isHTMLNamespace(_namespaceURI.implementation())) {
+    if (_namespaceURI == XHTML_NAMESPACE) {
         // User requested an element in the XHTML namespace - this means we create a HTML element
         // (elements not in this namespace are treated as normal XML elements)
-        QString qName = _qualifiedName.string();
-        int colonPos = qName.find(':',0);
         e = createHTMLElement(qName.mid(colonPos+1), exceptioncode);
         if (exceptioncode)
             return 0;
@@ -757,7 +741,7 @@ ElementImpl *DocumentImpl::createHTMLElement( const DOMString &name, int &except
         exceptioncode = DOMException::INVALID_CHARACTER_ERR;
         return 0;
     }
-    return createHTMLElement(tagId(HTMLElementNamespace(), name.implementation(), false));
+    return createHTMLElement(tagId(0, name.implementation(), false));
 }
 
 ElementImpl *DocumentImpl::createHTMLElement(unsigned short tagID)
@@ -2074,9 +2058,9 @@ NodeImpl::Id DocumentImpl::attrId(DOMStringImpl* _namespaceURI, DOMStringImpl *_
 
     // First see if it's a HTML attribute name
     QConstString n(_name->s, _name->l);
-    if (isHTMLNamespace(_namespaceURI)) {
+    if (!_namespaceURI || !strcasecmp(_namespaceURI, XHTML_NAMESPACE)) {
         // we're in HTML namespace if we know the tag.
-        // XHTML is lower case - case sensitive, easy to implement
+        // xhtml is lower case - case sensitive, easy to implement
         if ( htmlMode() == XHtml && (id = getAttrID(n.string().ascii(), _name->l)) )
             return id;
         // compatibility: upper case - case insensitive
@@ -2154,7 +2138,7 @@ NodeImpl::Id DocumentImpl::tagId(DOMStringImpl* _namespaceURI, DOMStringImpl *_n
 
     // First see if it's a HTML element name
     QConstString n(_name->s, _name->l);
-    if (isHTMLNamespace(_namespaceURI)) {
+    if (!_namespaceURI || !strcasecmp(_namespaceURI, XHTML_NAMESPACE)) {
         // we're in HTML namespace if we know the tag.
         // xhtml is lower case - case sensitive, easy to implement
         if ( htmlMode() == XHtml && (id = getTagID(n.string().ascii(), _name->l)) )
index e33e03a2e57b1771efc991fe839bbfde45f0d39c..da8860b3e8d26e85ffc175a75b6f6f3bd49ee36c 100644 (file)
@@ -217,9 +217,6 @@ public:
     ElementImpl *createHTMLElement(const DOMString &tagName, int &exceptioncode);
     ElementImpl *createHTMLElement(unsigned short tagID);
 
-    virtual DOMStringImpl *HTMLElementNamespace() const;
-    virtual bool isHTMLNamespace(DOMStringImpl *) const;
-
     khtml::CSSStyleSelector *styleSelector() { return m_styleSelector; }
 
     ElementImpl *DocumentImpl::getElementByAccessKey( const DOMString &key );