Bug 659539 Part 3: Use nsINode::NodeName where possible. Remove the now unused mQualifiedNameCorrectedCase. r=bz,peterv

This commit is contained in:
Jonas Sicking 2011-06-14 00:56:49 -07:00
Родитель ed0ee3f3bd
Коммит 2045ee25aa
6 изменённых файлов: 20 добавлений и 39 удалений

Просмотреть файл

@ -120,15 +120,6 @@ public:
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
*/
@ -381,10 +372,6 @@ protected:
// 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;

Просмотреть файл

@ -205,7 +205,7 @@ nsDOMAttribute::SetOwnerDocument(nsIDocument* aDocument)
NS_IMETHODIMP
nsDOMAttribute::GetName(nsAString& aName)
{
aName = mNodeInfo->QualifiedName();
aName = NodeName();
return NS_OK;
}

Просмотреть файл

@ -2410,7 +2410,7 @@ nsGenericElement::HasChildNodes(PRBool* aReturn)
NS_IMETHODIMP
nsGenericElement::GetTagName(nsAString& aTagName)
{
aTagName = mNodeInfo->QualifiedNameCorrectedCase();
aTagName = NodeName();
return NS_OK;
}

Просмотреть файл

@ -132,18 +132,17 @@ nsNodeInfo::nsNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID,
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:

Просмотреть файл

@ -467,16 +467,11 @@ txXPathNodeUtils::getNodeName(const txXPathNode& aNode, nsAString& aName)
}
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;
}
@ -486,11 +481,6 @@ txXPathNodeUtils::getNodeName(const txXPathNode& aNode, nsAString& aName)
}
aNode.Content()->GetAttrNameAt(aNode.mIndex)->GetQualifiedName(aName);
// Check for html
if (aNode.Content()->IsHTML()) {
ToUpperCase(aName);
}
}
/* static */

Просмотреть файл

@ -866,6 +866,11 @@ customMethodCalls = {
'nsIDOMElement_': {
'thisType': 'nsGenericElement'
},
'nsIDOMElement_GetTagName': {
'thisType': 'nsINode',
'code': 'nsString result = self->NodeName();',
'canFail': False
},
'nsIDOMDocument_CreateElement': {
'thisType': 'nsDocument',
'code': ' nsCOMPtr<nsIContent> result;\n'