Bug 659539 Part 3: Use nsINode::NodeName where possible. Remove the now unused mQualifiedNameCorrectedCase. r=bz,peterv
authorJonas Sicking <jonas@sicking.cc>
Tue, 14 Jun 2011 00:56:49 -0700
changeset 71038 3daac40be649607cbb75188c07a7f0cc444c9a1f
parent 71037 e297fa2153871b34f54b837886119cc884865f19
child 71039 9ea784903fdffeae0939bfa46c01ca9ce1907ca1
push id4
push usergsharp@mozilla.com
push dateTue, 14 Jun 2011 13:08:19 +0000
treeherderfx-team@8f822ccd9a32 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, peterv
bugs659539
milestone7.0a1
Bug 659539 Part 3: Use nsINode::NodeName where possible. Remove the now unused mQualifiedNameCorrectedCase. r=bz,peterv
content/base/public/nsINodeInfo.h
content/base/src/nsDOMAttribute.cpp
content/base/src/nsGenericElement.cpp
content/base/src/nsNodeInfo.cpp
content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp
js/src/xpconnect/src/dom_quickstubs.qsconf
--- a/content/base/public/nsINodeInfo.h
+++ b/content/base/public/nsINodeInfo.h
@@ -116,25 +116,16 @@ public:
    * For the HTML element "<body>" this will return "body" and for the XML
    * element "<html:body>" this will return "html:body".
    */
   const nsString& QualifiedName() const {
     return mQualifiedName;
   }
 
   /*
-   * As above, but return the qualified name in corrected case as
-   * needed.  For example, for HTML elements in HTML documents, this
-   * will return an ASCII-uppercased version of the qualified name.
-   */
-  const nsString& QualifiedNameCorrectedCase() const {
-    return mQualifiedNameCorrectedCase;
-  }
-
-  /*
    * Returns the node's nodeName as defined in DOM Core
    */
   const nsString& NodeName() const {
     return mNodeName;
   }
 
   /*
    * Returns the node's localName as defined in DOM Core
@@ -376,20 +367,16 @@ protected:
   /*
    * Members for various functions of mName+mPrefix that we can be
    * asked to compute.
    */
 
   // Qualified name
   nsString mQualifiedName;
 
-  // Qualified name in "corrected case"; this will depend on our
-  // document and on mNamespaceID.
-  nsString mQualifiedNameCorrectedCase;
-
   // nodeName for the node.
   nsString mNodeName;
 
   // localName for the node. This is either equal to mInner.mName, or a
   // void string, depending on mInner.mNodeType.
   nsString mLocalName;
 };
 
--- a/content/base/src/nsDOMAttribute.cpp
+++ b/content/base/src/nsDOMAttribute.cpp
@@ -200,17 +200,17 @@ nsDOMAttribute::SetOwnerDocument(nsIDocu
   mNodeInfo.swap(newNodeInfo);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMAttribute::GetName(nsAString& aName)
 {
-  aName = mNodeInfo->QualifiedName();
+  aName = NodeName();
   return NS_OK;
 }
 
 already_AddRefed<nsIAtom>
 nsDOMAttribute::GetNameAtom(nsIContent* aContent)
 {
   nsIAtom* result = nsnull;
   if (!mNsAware &&
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -2405,17 +2405,17 @@ nsGenericElement::HasChildNodes(PRBool* 
   *aReturn = mAttrsAndChildren.ChildCount() > 0;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGenericElement::GetTagName(nsAString& aTagName)
 {
-  aTagName = mNodeInfo->QualifiedNameCorrectedCase();
+  aTagName = NodeName();
   return NS_OK;
 }
 
 nsresult
 nsGenericElement::GetAttribute(const nsAString& aName,
                                nsAString& aReturn)
 {
   const nsAttrName* name = InternalGetExistingAttrNameFromQName(aName);
--- a/content/base/src/nsNodeInfo.cpp
+++ b/content/base/src/nsNodeInfo.cpp
@@ -127,28 +127,27 @@ nsNodeInfo::nsNodeInfo(nsIAtom *aName, n
   if (aPrefix) {
     mQualifiedName = nsDependentAtomString(mInner.mPrefix) +
                      NS_LITERAL_STRING(":") +
                      nsDependentAtomString(mInner.mName);
   } else {
     mInner.mName->ToString(mQualifiedName);
   }
 
-  // Qualified name in corrected case
-  if (aNamespaceID == kNameSpaceID_XHTML && GetDocument() &&
-      GetDocument()->IsHTML()) {
-    nsContentUtils::ASCIIToUpper(mQualifiedName, mQualifiedNameCorrectedCase);
-  } else {
-    mQualifiedNameCorrectedCase = mQualifiedName;
-  }
-
   switch (aNodeType) {
     case nsIDOMNode::ELEMENT_NODE:
     case nsIDOMNode::ATTRIBUTE_NODE:
-      mNodeName = mQualifiedNameCorrectedCase;
+      // Correct the case for HTML
+      if (aNodeType == nsIDOMNode::ELEMENT_NODE &&
+          aNamespaceID == kNameSpaceID_XHTML && GetDocument() &&
+          GetDocument()->IsHTML()) {
+        nsContentUtils::ASCIIToUpper(mQualifiedName, mNodeName);
+      } else {
+        mNodeName = mQualifiedName;
+      }
       mInner.mName->ToString(mLocalName);
       break;
     case nsIDOMNode::TEXT_NODE:
     case nsIDOMNode::CDATA_SECTION_NODE:
     case nsIDOMNode::COMMENT_NODE:
     case nsIDOMNode::DOCUMENT_NODE:
     case nsIDOMNode::DOCUMENT_FRAGMENT_NODE:
       mInner.mName->ToString(mNodeName);
--- a/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp
+++ b/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp
@@ -462,40 +462,30 @@ txXPathNodeUtils::getNodeName(const txXP
 {
     if (aNode.isDocument()) {
         aName.Truncate();
 
         return;
     }
 
     if (aNode.isContent()) {
-        if (aNode.mNode->IsElement()) {
-            aName = aNode.Content()->NodeInfo()->QualifiedNameCorrectedCase();
-            return;
-        }
-
-        if (aNode.mNode->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) {
-            // PIs don't have a nodeinfo but do have a name
-            nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode.mNode);
-            node->GetNodeName(aName);
-
+        // Elements and PIs have a name
+        if (aNode.mNode->IsElement() ||
+            aNode.mNode->NodeType() ==
+            nsIDOMNode::PROCESSING_INSTRUCTION_NODE) {
+            aName = aNode.Content()->NodeName();
             return;
         }
 
         aName.Truncate();
 
         return;
     }
 
     aNode.Content()->GetAttrNameAt(aNode.mIndex)->GetQualifiedName(aName);
-
-    // Check for html
-    if (aNode.Content()->IsHTML()) {
-        ToUpperCase(aName);
-    }
 }
 
 /* static */
 PRInt32
 txXPathNodeUtils::getNamespaceID(const txXPathNode& aNode)
 {
     if (aNode.isDocument()) {
         return kNameSpaceID_None;
--- a/js/src/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/src/xpconnect/src/dom_quickstubs.qsconf
@@ -861,16 +861,21 @@ customMethodCalls = {
         'thisType': 'nsDocument',
         'code': '    nsRefPtr<nsContentList> result ='
                 'self->GetElementsByTagNameNS(arg0, arg1);',
         'canFail': False
         },
     'nsIDOMElement_': {
         'thisType': 'nsGenericElement'
         },
+    'nsIDOMElement_GetTagName': {
+        'thisType': 'nsINode',
+        'code': 'nsString result = self->NodeName();',
+        'canFail': False
+        },
     'nsIDOMDocument_CreateElement': {
         'thisType': 'nsDocument',
         'code': '    nsCOMPtr<nsIContent> result;\n'
                 '    rv = self->CreateElement(arg0, getter_AddRefs(result));'
     },
     'nsIDOMDocument_CreateElementNS': {
         'thisType': 'nsDocument',
         'code': '    nsCOMPtr<nsIContent> result;\n'