Remove txAtom.h and remove uses of special tx-macros for atoms.

b=157142 r=Pike sr=peterv
This commit is contained in:
sicking%bigfoot.com 2003-01-19 23:17:13 +00:00
Родитель e7cafa42c9
Коммит 9415220bc1
41 изменённых файлов: 134 добавлений и 215 удалений

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

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

@ -100,7 +100,7 @@ MBool txHTMLAtoms::init()
#undef TX_ATOM #undef TX_ATOM
#define TX_ATOM(_name, _value) \ #define TX_ATOM(_name, _value) \
TX_IF_RELEASE_ATOM(_name) NS_IF_RELEASE(_name)
void txXMLAtoms::shutdown() void txXMLAtoms::shutdown()
{ {

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

@ -39,7 +39,7 @@
#ifndef TRANSFRMX_ATOMS_H #ifndef TRANSFRMX_ATOMS_H
#define TRANSFRMX_ATOMS_H #define TRANSFRMX_ATOMS_H
#include "txAtom.h" #include "nsIAtom.h"
#include "baseutils.h" #include "baseutils.h"
/* /*

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

@ -85,7 +85,7 @@ nsresult txExpandedNameMap::add(const txExpandedName& aKey, TxObject* aValue)
mItems[mItemCount].mNamespaceID = aKey.mNamespaceID; mItems[mItemCount].mNamespaceID = aKey.mNamespaceID;
mItems[mItemCount].mLocalName = aKey.mLocalName; mItems[mItemCount].mLocalName = aKey.mLocalName;
TX_IF_ADDREF_ATOM(mItems[mItemCount].mLocalName); NS_IF_ADDREF(mItems[mItemCount].mLocalName);
mItems[mItemCount].mValue = aValue; mItems[mItemCount].mValue = aValue;
++mItemCount; ++mItemCount;
@ -130,7 +130,7 @@ nsresult txExpandedNameMap::set(const txExpandedName& aKey, TxObject* aValue)
mItems[mItemCount].mNamespaceID = aKey.mNamespaceID; mItems[mItemCount].mNamespaceID = aKey.mNamespaceID;
mItems[mItemCount].mLocalName = aKey.mLocalName; mItems[mItemCount].mLocalName = aKey.mLocalName;
TX_IF_ADDREF_ATOM(mItems[mItemCount].mLocalName); NS_IF_ADDREF(mItems[mItemCount].mLocalName);
mItems[mItemCount].mValue = aValue; mItems[mItemCount].mValue = aValue;
++mItemCount; ++mItemCount;
@ -167,7 +167,7 @@ TxObject* txExpandedNameMap::remove(const txExpandedName& aKey)
for (i = 0; i < mItemCount; ++i) { for (i = 0; i < mItemCount; ++i) {
if (mItems[i].mLocalName == aKey.mLocalName && if (mItems[i].mLocalName == aKey.mLocalName &&
mItems[i].mNamespaceID == aKey.mNamespaceID) { mItems[i].mNamespaceID == aKey.mNamespaceID) {
TX_IF_RELEASE_ATOM(mItems[i].mLocalName); NS_IF_RELEASE(mItems[i].mLocalName);
if (mOwnsValues) { if (mOwnsValues) {
delete mItems[i].mValue; delete mItems[i].mValue;
} }
@ -190,7 +190,7 @@ void txExpandedNameMap::clear()
{ {
int i; int i;
for (i = 0; i < mItemCount; ++i) { for (i = 0; i < mItemCount; ++i) {
TX_IF_RELEASE_ATOM(mItems[i].mLocalName); NS_IF_RELEASE(mItems[i].mLocalName);
if (mOwnsValues) { if (mOwnsValues) {
delete mItems[i].mValue; delete mItems[i].mValue;
} }

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

@ -32,6 +32,7 @@
#include "XMLUtils.h" #include "XMLUtils.h"
#include "nsString.h" #include "nsString.h"
#include "txAtoms.h" #include "txAtoms.h"
#include "txStringUtils.h"
nsresult txExpandedName::init(const nsAString& aQName, nsresult txExpandedName::init(const nsAString& aQName,
Node* aResolver, Node* aResolver,
@ -210,13 +211,10 @@ MBool XMLUtils::getXMLSpacePreserve(Node* aNode)
if (parent->getNodeType() == Node::ELEMENT_NODE) { if (parent->getNodeType() == Node::ELEMENT_NODE) {
Element* elem = (Element*)parent; Element* elem = (Element*)parent;
if (elem->getAttr(txXMLAtoms::space, kNameSpaceID_XML, value)) { if (elem->getAttr(txXMLAtoms::space, kNameSpaceID_XML, value)) {
nsIAtom* val = TX_GET_ATOM(value); if (TX_StringEqualsAtom(value, txXMLAtoms::preserve)) {
if (val == txXMLAtoms::preserve) {
TX_IF_RELEASE_ATOM(val);
return MB_TRUE; return MB_TRUE;
} }
if (val == txXMLAtoms::_default) { if (TX_StringEqualsAtom(value, txXMLAtoms::_default)) {
TX_IF_RELEASE_ATOM(val);
return MB_FALSE; return MB_FALSE;
} }
} }

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

@ -33,7 +33,7 @@
#include "baseutils.h" #include "baseutils.h"
#include "dom.h" #include "dom.h"
#include "nsDependentSubstring.h" #include "nsDependentSubstring.h"
#include "txAtom.h" #include "nsIAtom.h"
#include "txError.h" #include "txError.h"
class txExpandedName { class txExpandedName {

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

@ -95,6 +95,6 @@ MBool Attr::getLocalName(nsIAtom** aLocalName)
} }
*aLocalName = mLocalName; *aLocalName = mLocalName;
NS_ENSURE_TRUE(*aLocalName, MB_FALSE); NS_ENSURE_TRUE(*aLocalName, MB_FALSE);
TX_ADDREF_ATOM(*aLocalName); NS_ADDREF(*aLocalName);
return MB_TRUE; return MB_TRUE;
} }

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

@ -47,7 +47,7 @@
#include "nsIContent.h" #include "nsIContent.h"
#include "nsINameSpaceManager.h" #include "nsINameSpaceManager.h"
#include "pldhash.h" #include "pldhash.h"
#include "txAtom.h" #include "nsIAtom.h"
#include "TxObject.h" #include "TxObject.h"
#define kTxNsNodeIndexOffset 0x00000000; #define kTxNsNodeIndexOffset 0x00000000;

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

@ -37,26 +37,25 @@ Attr::Attr(const nsAString& name, Document* owner):
{ {
int idx = nodeName.FindChar(':'); int idx = nodeName.FindChar(':');
if (idx == kNotFound) { if (idx == kNotFound) {
mLocalName = TX_GET_ATOM(nodeName); mLocalName = do_GetAtom(nodeName);
if (mLocalName == txXMLAtoms::xmlns) if (mLocalName == txXMLAtoms::xmlns)
mNamespaceID = kNameSpaceID_XMLNS; mNamespaceID = kNameSpaceID_XMLNS;
else else
mNamespaceID = kNameSpaceID_None; mNamespaceID = kNameSpaceID_None;
} }
else { else {
mLocalName = TX_GET_ATOM(Substring(nodeName, idx + 1, mLocalName = do_GetAtom(Substring(nodeName, idx + 1,
nodeName.Length() - (idx + 1))); nodeName.Length() - (idx + 1)));
// namespace handling has to be handled late, the attribute must // namespace handling has to be handled late, the attribute must
// be added to the tree to resolve the prefix, unless it's // be added to the tree to resolve the prefix, unless it's
// xmlns or xml, try to do that here // xmlns or xml, try to do that here
nsIAtom* prefixAtom = TX_GET_ATOM(Substring(nodeName, 0, idx)); nsCOMPtr<nsIAtom> prefixAtom = do_GetAtom(Substring(nodeName, 0, idx));
if (prefixAtom == txXMLAtoms::xmlns) if (prefixAtom == txXMLAtoms::xmlns)
mNamespaceID = kNameSpaceID_XMLNS; mNamespaceID = kNameSpaceID_XMLNS;
else if (prefixAtom == txXMLAtoms::xml) else if (prefixAtom == txXMLAtoms::xml)
mNamespaceID = kNameSpaceID_XML; mNamespaceID = kNameSpaceID_XML;
else else
mNamespaceID = kNameSpaceID_Unknown; mNamespaceID = kNameSpaceID_Unknown;
TX_IF_RELEASE_ATOM(prefixAtom);
} }
} }
@ -70,7 +69,7 @@ Attr::Attr(const nsAString& aNamespaceURI,
else else
mNamespaceID = txNamespaceManager::getNamespaceID(aNamespaceURI); mNamespaceID = txNamespaceManager::getNamespaceID(aNamespaceURI);
XMLUtils::getLocalPart(nodeName, &mLocalName); XMLUtils::getLocalPart(nodeName, getter_AddRefs(mLocalName));
} }
// //
@ -78,7 +77,6 @@ Attr::Attr(const nsAString& aNamespaceURI,
// //
Attr::~Attr() Attr::~Attr()
{ {
TX_IF_RELEASE_ATOM(mLocalName);
} }
void Attr::setNodeValue(const nsAString& aValue) void Attr::setNodeValue(const nsAString& aValue)
@ -109,7 +107,7 @@ MBool Attr::getLocalName(nsIAtom** aLocalName)
if (!aLocalName) if (!aLocalName)
return MB_FALSE; return MB_FALSE;
*aLocalName = mLocalName; *aLocalName = mLocalName;
TX_ADDREF_ATOM(*aLocalName); NS_ADDREF(*aLocalName);
return MB_TRUE; return MB_TRUE;
} }
@ -126,7 +124,7 @@ PRInt32 Attr::getNamespaceID()
mNamespaceID = kNameSpaceID_None; mNamespaceID = kNameSpaceID_None;
PRInt32 idx = nodeName.FindChar(':'); PRInt32 idx = nodeName.FindChar(':');
if (idx != kNotFound) { if (idx != kNotFound) {
nsCOMPtr<nsIAtom> prefixAtom = TX_GET_ATOM(Substring(nodeName, 0, idx)); nsCOMPtr<nsIAtom> prefixAtom = do_GetAtom(Substring(nodeName, 0, idx));
mNamespaceID = lookupNamespaceID(prefixAtom); mNamespaceID = lookupNamespaceID(prefixAtom);
} }
return mNamespaceID; return mNamespaceID;

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

@ -42,11 +42,11 @@ Element::Element(const nsAString& tagName, Document* owner) :
int idx = tagName.FindChar(':'); int idx = tagName.FindChar(':');
if (idx == kNotFound) { if (idx == kNotFound) {
mLocalName = TX_GET_ATOM(tagName); mLocalName = do_GetAtom(tagName);
} }
else { else {
mLocalName = TX_GET_ATOM(Substring(tagName, idx + 1, mLocalName = do_GetAtom(Substring(tagName, idx + 1,
tagName.Length() - (idx + 1))); tagName.Length() - (idx + 1)));
} }
} }
@ -69,7 +69,6 @@ Element::Element(const nsAString& aNamespaceURI,
Element::~Element() Element::~Element()
{ {
mAttributes.clear(); mAttributes.clear();
TX_IF_RELEASE_ATOM(mLocalName);
} }
Node* Element::appendChild(Node* newChild) Node* Element::appendChild(Node* newChild)
@ -104,7 +103,7 @@ MBool Element::getLocalName(nsIAtom** aLocalName)
if (!aLocalName) if (!aLocalName)
return MB_FALSE; return MB_FALSE;
*aLocalName = mLocalName; *aLocalName = mLocalName;
TX_ADDREF_ATOM(*aLocalName); NS_ADDREF(*aLocalName);
return MB_TRUE; return MB_TRUE;
} }
@ -182,14 +181,12 @@ void Element::setAttributeNS(const nsAString& aNamespaceURI,
AttrMap::ListItem* item = mAttributes.firstItem; AttrMap::ListItem* item = mAttributes.firstItem;
while (item) { while (item) {
foundNode = (Attr*)item->node; foundNode = (Attr*)item->node;
nsIAtom* attrName; nsCOMPtr<nsIAtom> attrName;
if (foundNode->getLocalName(&attrName) && if (foundNode->getLocalName(getter_AddRefs(attrName)) &&
namespaceID == foundNode->getNamespaceID() && namespaceID == foundNode->getNamespaceID() &&
localName == attrName) { localName == attrName) {
TX_IF_RELEASE_ATOM(attrName);
break; break;
} }
TX_IF_RELEASE_ATOM(attrName);
foundNode = 0; foundNode = 0;
item = item->next; item = item->next;
} }
@ -226,15 +223,13 @@ MBool Element::getAttr(nsIAtom* aLocalName, PRInt32 aNSID,
AttrMap::ListItem* item = mAttributes.firstItem; AttrMap::ListItem* item = mAttributes.firstItem;
while (item) { while (item) {
Attr* attrNode = (Attr*)item->node; Attr* attrNode = (Attr*)item->node;
nsIAtom* localName; nsCOMPtr<nsIAtom> localName;
if (attrNode->getLocalName(&localName) && if (attrNode->getLocalName(getter_AddRefs(localName)) &&
aNSID == attrNode->getNamespaceID() && aNSID == attrNode->getNamespaceID() &&
aLocalName == localName) { aLocalName == localName) {
attrNode->getNodeValue(aValue); attrNode->getNodeValue(aValue);
TX_IF_RELEASE_ATOM(localName);
return MB_TRUE; return MB_TRUE;
} }
TX_IF_RELEASE_ATOM(localName);
item = item->next; item = item->next;
} }
return MB_FALSE; return MB_FALSE;
@ -249,14 +244,12 @@ MBool Element::hasAttr(nsIAtom* aLocalName, PRInt32 aNSID)
AttrMap::ListItem* item = mAttributes.firstItem; AttrMap::ListItem* item = mAttributes.firstItem;
while (item) { while (item) {
Attr* attrNode = (Attr*)item->node; Attr* attrNode = (Attr*)item->node;
nsIAtom* localName; nsCOMPtr<nsIAtom> localName;
if (attrNode->getLocalName(&localName) && if (attrNode->getLocalName(getter_AddRefs(localName)) &&
aNSID == attrNode->getNamespaceID() && aNSID == attrNode->getNamespaceID() &&
aLocalName == localName) { aLocalName == localName) {
TX_IF_RELEASE_ATOM(localName);
return MB_TRUE; return MB_TRUE;
} }
TX_IF_RELEASE_ATOM(localName);
item = item->next; item = item->next;
} }
return MB_FALSE; return MB_FALSE;

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

@ -309,7 +309,7 @@ PRInt32 NodeDefinition::lookupNamespaceID(nsIAtom* aPrefix)
if (aPrefix && (aPrefix != txXMLAtoms::_empty)) { if (aPrefix && (aPrefix != txXMLAtoms::_empty)) {
// We have a prefix, search for xmlns:prefix attributes. // We have a prefix, search for xmlns:prefix attributes.
nsAutoString prefixString; nsAutoString prefixString;
TX_GET_ATOM_STRING(aPrefix, prefixString); aPrefix->ToString(prefixString);
name.Append(prefixString); name.Append(prefixString);
} }
else { else {

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

@ -30,7 +30,7 @@
// //
#include "dom.h" #include "dom.h"
#include "txAtom.h" #include "nsIAtom.h"
// //
//Construct a text object with the specified document owner and data //Construct a text object with the specified document owner and data
@ -41,7 +41,7 @@ ProcessingInstruction::ProcessingInstruction(const nsAString& theTarget,
NodeDefinition(Node::PROCESSING_INSTRUCTION_NODE, NodeDefinition(Node::PROCESSING_INSTRUCTION_NODE,
theTarget, theData, owner) theTarget, theData, owner)
{ {
mLocalName = TX_GET_ATOM(nodeName); mLocalName = do_GetAtom(nodeName);
} }
// //
@ -49,7 +49,6 @@ ProcessingInstruction::ProcessingInstruction(const nsAString& theTarget,
// //
ProcessingInstruction::~ProcessingInstruction() ProcessingInstruction::~ProcessingInstruction()
{ {
TX_IF_RELEASE_ATOM(mLocalName);
} }
// //
@ -62,6 +61,6 @@ MBool ProcessingInstruction::getLocalName(nsIAtom** aLocalName)
if (!aLocalName) if (!aLocalName)
return MB_FALSE; return MB_FALSE;
*aLocalName = mLocalName; *aLocalName = mLocalName;
TX_ADDREF_ATOM(*aLocalName); NS_ADDREF(*aLocalName);
return MB_TRUE; return MB_TRUE;
} }

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

@ -39,7 +39,7 @@
#endif #endif
#include "List.h" #include "List.h"
#include "txAtom.h" #include "nsIAtom.h"
#include "baseutils.h" #include "baseutils.h"
#include "nsString.h" #include "nsString.h"
#include "nsVoidArray.h" #include "nsVoidArray.h"
@ -431,7 +431,7 @@ class Element : public NodeDefinition
Document* aOwner); Document* aOwner);
AttrMap mAttributes; AttrMap mAttributes;
nsIAtom* mLocalName; nsCOMPtr<nsIAtom> mLocalName;
PRInt32 mNamespaceID; PRInt32 mNamespaceID;
}; };
@ -470,7 +470,7 @@ class Attr : public NodeDefinition
Element* ownerElement; Element* ownerElement;
nsIAtom* mLocalName; nsCOMPtr<nsIAtom> mLocalName;
PRInt32 mNamespaceID; PRInt32 mNamespaceID;
}; };
@ -495,7 +495,7 @@ class ProcessingInstruction : public NodeDefinition
ProcessingInstruction(const nsAString& theTarget, const nsAString& theData, ProcessingInstruction(const nsAString& theTarget, const nsAString& theData,
Document* owner); Document* owner);
nsIAtom* mLocalName; nsCOMPtr<nsIAtom> mLocalName;
}; };
class txNamespaceManager class txNamespaceManager

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

@ -154,6 +154,6 @@ nsresult BooleanFunctionCall::getNameAtom(nsIAtom** aAtom)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
} }
TX_ADDREF_ATOM(*aAtom); NS_ADDREF(*aAtom);
return NS_OK; return NS_OK;
} }

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

@ -39,7 +39,7 @@
#include "dom.h" #include "dom.h"
#include "List.h" #include "List.h"
#include "nsString.h" #include "nsString.h"
#include "txAtom.h" #include "nsIAtom.h"
#include "TxObject.h" #include "TxObject.h"
/* /*
@ -232,8 +232,8 @@ public:
TX_DECL_NODE_TEST; TX_DECL_NODE_TEST;
private: private:
nsIAtom* mPrefix; nsCOMPtr<nsIAtom> mPrefix;
nsIAtom* mLocalName; nsCOMPtr<nsIAtom> mLocalName;
PRInt32 mNamespace; PRInt32 mNamespace;
Node::NodeType mNodeType; Node::NodeType mNodeType;
}; };
@ -267,7 +267,7 @@ public:
private: private:
NodeType mNodeType; NodeType mNodeType;
nsIAtom* mNodeName; nsCOMPtr<nsIAtom> mNodeName;
}; };
/** /**
@ -560,8 +560,8 @@ public:
TX_DECL_EXPR; TX_DECL_EXPR;
private: private:
nsIAtom* mPrefix; nsCOMPtr<nsIAtom> mPrefix;
nsIAtom* mLocalName; nsCOMPtr<nsIAtom> mLocalName;
PRInt32 mNamespace; PRInt32 mNamespace;
}; };

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

@ -326,17 +326,16 @@ Expr* ExprParser::createFilterExpr(ExprLexer& lexer, txIParseContext* aContext)
break; break;
case Token::VAR_REFERENCE : case Token::VAR_REFERENCE :
{ {
nsIAtom *prefix, *lName; nsCOMPtr<nsIAtom> prefix, lName;
PRInt32 nspace; PRInt32 nspace;
nsresult rv = resolveQName(tok->value, prefix, aContext, nsresult rv = resolveQName(tok->value, *getter_AddRefs(prefix),
lName, nspace); aContext, *getter_AddRefs(lName),
nspace);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
// XXX error report namespace resolve failed // XXX error report namespace resolve failed
return 0; return 0;
} }
expr = new VariableRefExpr(prefix, lName, nspace); expr = new VariableRefExpr(prefix, lName, nspace);
TX_IF_RELEASE_ATOM(prefix);
TX_IF_RELEASE_ATOM(lName);
} }
break; break;
case Token::L_PAREN: case Token::L_PAREN:
@ -490,16 +489,15 @@ Expr* ExprParser::createFunctionCall(ExprLexer& lexer,
fnCall = new NumberFunctionCall(NumberFunctionCall::FLOOR); fnCall = new NumberFunctionCall(NumberFunctionCall::FLOOR);
} }
else { else {
nsIAtom *prefix, *lName; nsCOMPtr<nsIAtom> prefix, lName;
PRInt32 namespaceID; PRInt32 namespaceID;
rv = resolveQName(tok->value, prefix, aContext, lName, namespaceID); rv = resolveQName(tok->value, *getter_AddRefs(prefix), aContext,
*getter_AddRefs(lName), namespaceID);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
// XXX error report namespace resolve failed // XXX error report namespace resolve failed
return 0; return 0;
} }
rv = aContext->resolveFunctionCall(lName, namespaceID, fnCall); rv = aContext->resolveFunctionCall(lName, namespaceID, fnCall);
TX_IF_RELEASE_ATOM(prefix);
TX_IF_RELEASE_ATOM(lName);
// XXX this should be removed once we don't return // XXX this should be removed once we don't return
// NS_ERROR_NOT_IMPLEMENTED for unparsed-entity-uri(). As should the // NS_ERROR_NOT_IMPLEMENTED for unparsed-entity-uri(). As should the
@ -640,10 +638,12 @@ LocationStep* ExprParser::createLocationStep(ExprLexer& lexer,
case Token::CNAME : case Token::CNAME :
{ {
// resolve QName // resolve QName
nsIAtom *prefix, *lName; nsCOMPtr<nsIAtom> prefix, lName;
PRInt32 nspace; PRInt32 nspace;
nsresult rv = resolveQName(tok->value, prefix, aContext, nsresult rv = resolveQName(tok->value,
lName, nspace); *getter_AddRefs(prefix),
aContext,
*getter_AddRefs(lName), nspace);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
// XXX error report namespace resolve failed // XXX error report namespace resolve failed
return 0; return 0;
@ -658,8 +658,6 @@ LocationStep* ExprParser::createLocationStep(ExprLexer& lexer,
Node::ELEMENT_NODE); Node::ELEMENT_NODE);
break; break;
} }
TX_IF_RELEASE_ATOM(prefix);
TX_IF_RELEASE_ATOM(lName);
} }
if (!nodeTest) { if (!nodeTest) {
//XXX ErrorReport: out of memory //XXX ErrorReport: out of memory
@ -1019,22 +1017,21 @@ nsresult ExprParser::resolveQName(const nsAString& aQName,
aNamespace = kNameSpaceID_None; aNamespace = kNameSpaceID_None;
PRInt32 idx = aQName.FindChar(':'); PRInt32 idx = aQName.FindChar(':');
if (idx > 0) { if (idx > 0) {
aPrefix = TX_GET_ATOM(Substring(aQName, 0, (PRUint32)idx)); aPrefix = NS_NewAtom(Substring(aQName, 0, (PRUint32)idx));
if (!aPrefix) { if (!aPrefix) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
aLocalName = TX_GET_ATOM(Substring(aQName, (PRUint32)idx + 1, aLocalName = NS_NewAtom(Substring(aQName, (PRUint32)idx + 1,
aQName.Length() - (idx + 1))); aQName.Length() - (idx + 1)));
if (!aLocalName) { if (!aLocalName) {
TX_RELEASE_ATOM(aPrefix); NS_RELEASE(aPrefix);
aPrefix = 0;
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return aContext->resolveNamespacePrefix(aPrefix, aNamespace); return aContext->resolveNamespacePrefix(aPrefix, aNamespace);
} }
// the lexer dealt with idx == 0 // the lexer dealt with idx == 0
aPrefix = 0; aPrefix = 0;
aLocalName = TX_GET_ATOM(aQName); aLocalName = NS_NewAtom(aQName);
if (!aLocalName) { if (!aLocalName) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }

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

@ -33,7 +33,7 @@
#define MITREXSL_EXPRPARSER_H #define MITREXSL_EXPRPARSER_H
#include "baseutils.h" #include "baseutils.h"
#include "txAtom.h" #include "nsIAtom.h"
#include "txError.h" #include "txError.h"
class AttributeValueTemplate; class AttributeValueTemplate;

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

@ -25,7 +25,7 @@
#include "Expr.h" #include "Expr.h"
#include "ExprResult.h" #include "ExprResult.h"
#include "txAtom.h" #include "nsIAtom.h"
#include "txIXPathContext.h" #include "txIXPathContext.h"
/** /**
@ -176,15 +176,13 @@ MBool FunctionCall::requireParams(int paramCountMin, txIEvalContext* aContext)
**/ **/
void FunctionCall::toString(nsAString& aDest) void FunctionCall::toString(nsAString& aDest)
{ {
nsIAtom* functionNameAtom = 0; nsCOMPtr<nsIAtom> functionNameAtom;
nsAutoString functionName; nsAutoString functionName;
if (!NS_SUCCEEDED(getNameAtom(&functionNameAtom)) || if (NS_FAILED(getNameAtom(getter_AddRefs(functionNameAtom))) ||
!TX_GET_ATOM_STRING(functionNameAtom, functionName)) { NS_FAILED(functionNameAtom->ToString(functionName))) {
NS_ASSERTION(0, "Can't get function name."); NS_ASSERTION(0, "Can't get function name.");
TX_IF_RELEASE_ATOM(functionNameAtom);
return; return;
} }
TX_RELEASE_ATOM(functionNameAtom);
aDest.Append(functionName); aDest.Append(functionName);
aDest.Append(PRUnichar('(')); aDest.Append(PRUnichar('('));

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

@ -161,12 +161,11 @@ ExprResult* NodeSetFunctionCall::evaluate(txIEvalContext* aContext) {
case LOCAL_NAME: case LOCAL_NAME:
{ {
nsAutoString localName; nsAutoString localName;
nsIAtom* localNameAtom; nsCOMPtr<nsIAtom> localNameAtom;
node->getLocalName(&localNameAtom); node->getLocalName(getter_AddRefs(localNameAtom));
if (localNameAtom) { if (localNameAtom) {
// Node has a localName // Node has a localName
TX_GET_ATOM_STRING(localNameAtom, localName); localNameAtom->ToString(localName);
TX_RELEASE_ATOM(localNameAtom);
} }
return new StringResult(localName); return new StringResult(localName);
@ -264,6 +263,6 @@ nsresult NodeSetFunctionCall::getNameAtom(nsIAtom** aAtom)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
} }
TX_ADDREF_ATOM(*aAtom); NS_ADDREF(*aAtom);
return NS_OK; return NS_OK;
} }

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

@ -172,6 +172,6 @@ nsresult NumberFunctionCall::getNameAtom(nsIAtom** aAtom)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
} }
TX_ADDREF_ATOM(*aAtom); NS_ADDREF(*aAtom);
return NS_OK; return NS_OK;
} }

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

@ -310,6 +310,6 @@ nsresult StringFunctionCall::getNameAtom(nsIAtom** aAtom)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
} }
TX_ADDREF_ATOM(*aAtom); NS_ADDREF(*aAtom);
return NS_OK; return NS_OK;
} }

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

@ -42,8 +42,6 @@ VariableRefExpr::VariableRefExpr(nsIAtom* aPrefix, nsIAtom* aLocalName,
NS_ASSERTION(mLocalName, "VariableRefExpr without local name?"); NS_ASSERTION(mLocalName, "VariableRefExpr without local name?");
if (mPrefix == txXMLAtoms::_empty) if (mPrefix == txXMLAtoms::_empty)
mPrefix = 0; mPrefix = 0;
TX_IF_ADDREF_ATOM(mPrefix);
TX_IF_ADDREF_ATOM(mLocalName);
} }
/* /*
@ -51,8 +49,6 @@ VariableRefExpr::VariableRefExpr(nsIAtom* aPrefix, nsIAtom* aLocalName,
*/ */
VariableRefExpr::~VariableRefExpr() VariableRefExpr::~VariableRefExpr()
{ {
TX_IF_RELEASE_ATOM(mPrefix);
TX_IF_RELEASE_ATOM(mLocalName);
} }
/** /**
@ -86,11 +82,11 @@ void VariableRefExpr::toString(nsAString& aDest)
aDest.Append(PRUnichar('$')); aDest.Append(PRUnichar('$'));
if (mPrefix) { if (mPrefix) {
nsAutoString prefix; nsAutoString prefix;
TX_GET_ATOM_STRING(mPrefix, prefix); mPrefix->ToString(prefix);
aDest.Append(prefix); aDest.Append(prefix);
aDest.Append(PRUnichar(':')); aDest.Append(PRUnichar(':'));
} }
nsAutoString lname; nsAutoString lname;
TX_GET_ATOM_STRING(mLocalName, lname); mLocalName->ToString(lname);
aDest.Append(lname); aDest.Append(lname);
} //-- toString } //-- toString

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

@ -40,7 +40,7 @@
#define __TX_I_XPATH_CONTEXT #define __TX_I_XPATH_CONTEXT
#include "baseutils.h" #include "baseutils.h"
#include "txAtom.h" #include "nsIAtom.h"
#include "txError.h" #include "txError.h"
class ExprResult; class ExprResult;

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

@ -35,14 +35,10 @@ txNameTest::txNameTest(nsIAtom* aPrefix, nsIAtom* aLocalName, PRInt32 aNSID,
if (aPrefix == txXMLAtoms::_empty) if (aPrefix == txXMLAtoms::_empty)
mPrefix = 0; mPrefix = 0;
NS_ASSERTION(aLocalName, "txNameTest without a local name?"); NS_ASSERTION(aLocalName, "txNameTest without a local name?");
TX_IF_ADDREF_ATOM(mPrefix);
TX_IF_ADDREF_ATOM(mLocalName);
} }
txNameTest::~txNameTest() txNameTest::~txNameTest()
{ {
TX_IF_RELEASE_ATOM(mPrefix);
TX_IF_RELEASE_ATOM(mLocalName);
} }
/* /*
@ -66,12 +62,9 @@ MBool txNameTest::matches(Node* aNode, txIMatchContext* aContext)
return MB_TRUE; return MB_TRUE;
// Compare local-names // Compare local-names
nsIAtom* localName; nsCOMPtr<nsIAtom> localName;
aNode->getLocalName(&localName); aNode->getLocalName(getter_AddRefs(localName));
MBool result = localName == mLocalName; return localName == mLocalName;
TX_IF_RELEASE_ATOM(localName);
return result;
} }
/* /*

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

@ -24,25 +24,24 @@
*/ */
#include "Expr.h" #include "Expr.h"
#include "txAtom.h" #include "nsIAtom.h"
#include "txIXPathContext.h" #include "txIXPathContext.h"
/* /*
* Creates a new txNodeTypeTest of the given type * Creates a new txNodeTypeTest of the given type
*/ */
txNodeTypeTest::txNodeTypeTest(NodeType aNodeType) txNodeTypeTest::txNodeTypeTest(NodeType aNodeType)
: mNodeType(aNodeType), mNodeName(0) : mNodeType(aNodeType)
{ {
} }
txNodeTypeTest::~txNodeTypeTest() txNodeTypeTest::~txNodeTypeTest()
{ {
TX_IF_RELEASE_ATOM(mNodeName);
} }
void txNodeTypeTest::setNodeName(const nsAString& aName) void txNodeTypeTest::setNodeName(const nsAString& aName)
{ {
mNodeName = TX_GET_ATOM(aName); mNodeName = do_GetAtom(aName);
} }
/* /*
@ -64,13 +63,10 @@ MBool txNodeTypeTest::matches(Node* aNode, txIMatchContext* aContext)
!aContext->isStripSpaceAllowed(aNode); !aContext->isStripSpaceAllowed(aNode);
case PI_TYPE: case PI_TYPE:
if (type == Node::PROCESSING_INSTRUCTION_NODE) { if (type == Node::PROCESSING_INSTRUCTION_NODE) {
nsIAtom* localName = 0; nsCOMPtr<nsIAtom> localName;
MBool result; return !mNodeName ||
result = !mNodeName || (aNode->getLocalName(getter_AddRefs(localName)) &&
(aNode->getLocalName(&localName) && localName == mNodeName);
localName == mNodeName);
TX_IF_RELEASE_ATOM(localName);
return result;
} }
return MB_FALSE; return MB_FALSE;
case NODE_TYPE: case NODE_TYPE:
@ -107,7 +103,7 @@ void txNodeTypeTest::toString(nsAString& aDest)
aDest.Append(NS_LITERAL_STRING("processing-instruction(")); aDest.Append(NS_LITERAL_STRING("processing-instruction("));
if (mNodeName) { if (mNodeName) {
nsAutoString str; nsAutoString str;
TX_GET_ATOM_STRING(mNodeName, str); mNodeName->ToString(str);
aDest.Append(PRUnichar('\'')); aDest.Append(PRUnichar('\''));
aDest.Append(str); aDest.Append(str);
aDest.Append(PRUnichar('\'')); aDest.Append(PRUnichar('\''));

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

@ -154,12 +154,11 @@ void ProcessorState::addAttributeSet(Element* aAttributeSet,
PRInt32 nsID = node->getNamespaceID(); PRInt32 nsID = node->getNamespaceID();
if (nsID != kNameSpaceID_XSLT) if (nsID != kNameSpaceID_XSLT)
continue; continue;
nsIAtom* nodeName; nsCOMPtr<nsIAtom> nodeName;
if (!node->getLocalName(&nodeName) || !nodeName) if (!node->getLocalName(getter_AddRefs(nodeName)) || !nodeName)
continue; continue;
if (nodeName == txXSLTAtoms::attribute) if (nodeName == txXSLTAtoms::attribute)
attSet->append(node); attSet->append(node);
TX_RELEASE_ATOM(nodeName);
} }
node = node->getNextSibling(); node = node->getNextSibling();
} }
@ -485,7 +484,7 @@ Node* ProcessorState::findTemplate(Node* aNode,
#ifdef PR_LOGGING #ifdef PR_LOGGING
nsAutoString mode, nodeName; nsAutoString mode, nodeName;
if (aMode.mLocalName) { if (aMode.mLocalName) {
TX_GET_ATOM_STRING(aMode.mLocalName, mode); aMode.mLocalName->ToString(mode);
} }
aNode->getNodeName(nodeName); aNode->getNodeName(nodeName);
if (matchTemplate) { if (matchTemplate) {

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

@ -333,8 +333,8 @@ txXSLTProcessor::processAction(Node* aAction,
} }
Expr* expr = 0; Expr* expr = 0;
nsIAtom* localName; nsCOMPtr<nsIAtom> localName;
aAction->getLocalName(&localName); aAction->getLocalName(getter_AddRefs(localName));
// xsl:apply-imports // xsl:apply-imports
if (localName == txXSLTAtoms::applyImports) { if (localName == txXSLTAtoms::applyImports) {
ProcessorState::TemplateRule* curr; ProcessorState::TemplateRule* curr;
@ -345,7 +345,6 @@ txXSLTProcessor::processAction(Node* aAction,
if (!curr) { if (!curr) {
aPs->receiveError(NS_LITERAL_STRING("apply-imports not allowed here"), aPs->receiveError(NS_LITERAL_STRING("apply-imports not allowed here"),
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
TX_RELEASE_ATOM(localName);
return; return;
} }
@ -365,13 +364,11 @@ txXSLTProcessor::processAction(Node* aAction,
expr = gNodeExpr; expr = gNodeExpr;
if (!expr) { if (!expr) {
TX_RELEASE_ATOM(localName);
return; return;
} }
ExprResult* exprResult = expr->evaluate(aPs->getEvalContext()); ExprResult* exprResult = expr->evaluate(aPs->getEvalContext());
if (!exprResult) { if (!exprResult) {
TX_RELEASE_ATOM(localName);
return; return;
} }
@ -379,7 +376,6 @@ txXSLTProcessor::processAction(Node* aAction,
NodeSet* nodeSet = (NodeSet*)exprResult; NodeSet* nodeSet = (NodeSet*)exprResult;
if (nodeSet->isEmpty()) { if (nodeSet->isEmpty()) {
delete nodeSet; delete nodeSet;
TX_RELEASE_ATOM(localName);
return; return;
} }
@ -389,12 +385,11 @@ txXSLTProcessor::processAction(Node* aAction,
while (child) { while (child) {
if (child->getNodeType() == Node::ELEMENT_NODE && if (child->getNodeType() == Node::ELEMENT_NODE &&
child->getNamespaceID() == kNameSpaceID_XSLT) { child->getNamespaceID() == kNameSpaceID_XSLT) {
nsIAtom* childLocalName; nsCOMPtr<nsIAtom> childLocalName;
child->getLocalName(&childLocalName); child->getLocalName(getter_AddRefs(childLocalName));
if (childLocalName == txXSLTAtoms::sort) { if (childLocalName == txXSLTAtoms::sort) {
sorter.addSortElement((Element*)child); sorter.addSortElement((Element*)child);
} }
TX_IF_RELEASE_ATOM(childLocalName);
} }
child = child->getNextSibling(); child = child->getNextSibling();
} }
@ -412,7 +407,6 @@ txXSLTProcessor::processAction(Node* aAction,
rv = mode.init(modeStr, actionElement, MB_FALSE); rv = mode.init(modeStr, actionElement, MB_FALSE);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
aPs->receiveError(NS_LITERAL_STRING("malformed mode-name in xsl:apply-templates")); aPs->receiveError(NS_LITERAL_STRING("malformed mode-name in xsl:apply-templates"));
TX_IF_RELEASE_ATOM(localName);
return; return;
} }
} }
@ -444,7 +438,6 @@ txXSLTProcessor::processAction(Node* aAction,
if (!actionElement->getAttr(txXSLTAtoms::name, if (!actionElement->getAttr(txXSLTAtoms::name,
kNameSpaceID_None, nameAttr)) { kNameSpaceID_None, nameAttr)) {
aPs->receiveError(NS_LITERAL_STRING("missing required name attribute for xsl:attribute"), NS_ERROR_FAILURE); aPs->receiveError(NS_LITERAL_STRING("missing required name attribute for xsl:attribute"), NS_ERROR_FAILURE);
TX_RELEASE_ATOM(localName);
return; return;
} }
@ -457,18 +450,13 @@ txXSLTProcessor::processAction(Node* aAction,
aPs->receiveError(NS_LITERAL_STRING("error processing xsl:attribute, ") + aPs->receiveError(NS_LITERAL_STRING("error processing xsl:attribute, ") +
name + NS_LITERAL_STRING(" is not a valid QName."), name + NS_LITERAL_STRING(" is not a valid QName."),
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
TX_RELEASE_ATOM(localName);
return; return;
} }
nsIAtom* nameAtom = TX_GET_ATOM(name); if (TX_StringEqualsAtom(name, txXMLAtoms::xmlns)) {
if (nameAtom == txXMLAtoms::xmlns) {
TX_RELEASE_ATOM(nameAtom);
aPs->receiveError(NS_LITERAL_STRING("error processing xsl:attribute, name is xmlns."), NS_ERROR_FAILURE); aPs->receiveError(NS_LITERAL_STRING("error processing xsl:attribute, name is xmlns."), NS_ERROR_FAILURE);
TX_RELEASE_ATOM(localName);
return; return;
} }
TX_IF_RELEASE_ATOM(nameAtom);
// Determine namespace URI from the namespace attribute or // Determine namespace URI from the namespace attribute or
// from the prefix of the name (using the xslt action element). // from the prefix of the name (using the xslt action element).
@ -495,7 +483,6 @@ txXSLTProcessor::processAction(Node* aAction,
// XXX Should verify that this is correct behaviour. Signal error too? // XXX Should verify that this is correct behaviour. Signal error too?
if (resultNsID == kNameSpaceID_Unknown) { if (resultNsID == kNameSpaceID_Unknown) {
TX_RELEASE_ATOM(localName);
return; return;
} }
@ -546,13 +533,12 @@ txXSLTProcessor::processAction(Node* aAction,
} }
Element* xslTemplate = (Element*)condition; Element* xslTemplate = (Element*)condition;
nsIAtom* conditionLocalName; nsCOMPtr<nsIAtom> conditionLocalName;
condition->getLocalName(&conditionLocalName); condition->getLocalName(getter_AddRefs(conditionLocalName));
if (conditionLocalName == txXSLTAtoms::when) { if (conditionLocalName == txXSLTAtoms::when) {
expr = aPs->getExpr(xslTemplate, expr = aPs->getExpr(xslTemplate,
ProcessorState::TestAttr); ProcessorState::TestAttr);
if (!expr) { if (!expr) {
TX_RELEASE_ATOM(conditionLocalName);
condition = condition->getNextSibling(); condition = condition->getNextSibling();
continue; continue;
} }
@ -569,7 +555,6 @@ txXSLTProcessor::processAction(Node* aAction,
processChildren(xslTemplate, aPs); processChildren(xslTemplate, aPs);
caseFound = MB_TRUE; caseFound = MB_TRUE;
} }
TX_IF_RELEASE_ATOM(conditionLocalName);
condition = condition->getNextSibling(); condition = condition->getNextSibling();
} // end for-each child of xsl:choose } // end for-each child of xsl:choose
} }
@ -597,7 +582,6 @@ txXSLTProcessor::processAction(Node* aAction,
else if (localName == txXSLTAtoms::copyOf) { else if (localName == txXSLTAtoms::copyOf) {
expr = aPs->getExpr(actionElement, ProcessorState::SelectAttr); expr = aPs->getExpr(actionElement, ProcessorState::SelectAttr);
if (!expr) { if (!expr) {
TX_RELEASE_ATOM(localName);
return; return;
} }
@ -611,7 +595,6 @@ txXSLTProcessor::processAction(Node* aAction,
if (!actionElement->getAttr(txXSLTAtoms::name, if (!actionElement->getAttr(txXSLTAtoms::name,
kNameSpaceID_None, nameAttr)) { kNameSpaceID_None, nameAttr)) {
aPs->receiveError(NS_LITERAL_STRING("missing required name attribute for xsl:element"), NS_ERROR_FAILURE); aPs->receiveError(NS_LITERAL_STRING("missing required name attribute for xsl:element"), NS_ERROR_FAILURE);
TX_RELEASE_ATOM(localName);
return; return;
} }
@ -626,7 +609,6 @@ txXSLTProcessor::processAction(Node* aAction,
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
// XXX We should processChildren without creating attributes or // XXX We should processChildren without creating attributes or
// namespace nodes. // namespace nodes.
TX_RELEASE_ATOM(localName);
return; return;
} }
@ -654,7 +636,6 @@ txXSLTProcessor::processAction(Node* aAction,
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
// XXX We should processChildren without creating attributes or // XXX We should processChildren without creating attributes or
// namespace nodes. // namespace nodes.
TX_RELEASE_ATOM(localName);
return; return;
} }
@ -669,13 +650,11 @@ txXSLTProcessor::processAction(Node* aAction,
else if (localName == txXSLTAtoms::forEach) { else if (localName == txXSLTAtoms::forEach) {
expr = aPs->getExpr(actionElement, ProcessorState::SelectAttr); expr = aPs->getExpr(actionElement, ProcessorState::SelectAttr);
if (!expr) { if (!expr) {
TX_RELEASE_ATOM(localName);
return; return;
} }
ExprResult* exprResult = expr->evaluate(aPs->getEvalContext()); ExprResult* exprResult = expr->evaluate(aPs->getEvalContext());
if (!exprResult) { if (!exprResult) {
TX_RELEASE_ATOM(localName);
return; return;
} }
@ -683,7 +662,6 @@ txXSLTProcessor::processAction(Node* aAction,
NodeSet* nodeSet = (NodeSet*)exprResult; NodeSet* nodeSet = (NodeSet*)exprResult;
if (nodeSet->isEmpty()) { if (nodeSet->isEmpty()) {
delete nodeSet; delete nodeSet;
TX_RELEASE_ATOM(localName);
return; return;
} }
txNodeSetContext evalContext(nodeSet, aPs); txNodeSetContext evalContext(nodeSet, aPs);
@ -696,16 +674,14 @@ txXSLTProcessor::processAction(Node* aAction,
while (child) { while (child) {
unsigned short nodeType = child->getNodeType(); unsigned short nodeType = child->getNodeType();
if (nodeType == Node::ELEMENT_NODE) { if (nodeType == Node::ELEMENT_NODE) {
nsIAtom* childLocalName; nsCOMPtr<nsIAtom> childLocalName;
child->getLocalName(&childLocalName); child->getLocalName(getter_AddRefs(childLocalName));
if (child->getNamespaceID() != kNameSpaceID_XSLT || if (child->getNamespaceID() != kNameSpaceID_XSLT ||
childLocalName != txXSLTAtoms::sort) { childLocalName != txXSLTAtoms::sort) {
// xsl:sort must occur first // xsl:sort must occur first
TX_IF_RELEASE_ATOM(childLocalName);
break; break;
} }
sorter.addSortElement((Element*)child); sorter.addSortElement((Element*)child);
TX_RELEASE_ATOM(childLocalName);
} }
else if ((nodeType == Node::TEXT_NODE || else if ((nodeType == Node::TEXT_NODE ||
nodeType == Node::CDATA_SECTION_NODE) && nodeType == Node::CDATA_SECTION_NODE) &&
@ -741,13 +717,11 @@ txXSLTProcessor::processAction(Node* aAction,
else if (localName == txXSLTAtoms::_if) { else if (localName == txXSLTAtoms::_if) {
expr = aPs->getExpr(actionElement, ProcessorState::TestAttr); expr = aPs->getExpr(actionElement, ProcessorState::TestAttr);
if (!expr) { if (!expr) {
TX_RELEASE_ATOM(localName);
return; return;
} }
ExprResult* exprResult = expr->evaluate(aPs->getEvalContext()); ExprResult* exprResult = expr->evaluate(aPs->getEvalContext());
if (!exprResult) { if (!exprResult) {
TX_RELEASE_ATOM(localName);
return; return;
} }
@ -782,7 +756,6 @@ txXSLTProcessor::processAction(Node* aAction,
if (!actionElement->getAttr(txXSLTAtoms::name, if (!actionElement->getAttr(txXSLTAtoms::name,
kNameSpaceID_None, nameAttr)) { kNameSpaceID_None, nameAttr)) {
aPs->receiveError(NS_LITERAL_STRING("missing required name attribute for xsl:processing-instruction"), NS_ERROR_FAILURE); aPs->receiveError(NS_LITERAL_STRING("missing required name attribute for xsl:processing-instruction"), NS_ERROR_FAILURE);
TX_RELEASE_ATOM(localName);
return; return;
} }
@ -834,7 +807,6 @@ txXSLTProcessor::processAction(Node* aAction,
else if (localName == txXSLTAtoms::valueOf) { else if (localName == txXSLTAtoms::valueOf) {
expr = aPs->getExpr(actionElement, ProcessorState::SelectAttr); expr = aPs->getExpr(actionElement, ProcessorState::SelectAttr);
if (!expr) { if (!expr) {
TX_RELEASE_ATOM(localName);
return; return;
} }
@ -843,7 +815,6 @@ txXSLTProcessor::processAction(Node* aAction,
if (!exprResult) { if (!exprResult) {
aPs->receiveError(NS_LITERAL_STRING("null ExprResult"), aPs->receiveError(NS_LITERAL_STRING("null ExprResult"),
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
TX_RELEASE_ATOM(localName);
return; return;
} }
exprResult->stringValue(value); exprResult->stringValue(value);
@ -875,12 +846,10 @@ txXSLTProcessor::processAction(Node* aAction,
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
aPs->receiveError(NS_LITERAL_STRING("bad name for xsl:variable"), aPs->receiveError(NS_LITERAL_STRING("bad name for xsl:variable"),
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
TX_RELEASE_ATOM(localName);
return; return;
} }
ExprResult* exprResult = processVariable(actionElement, aPs); ExprResult* exprResult = processVariable(actionElement, aPs);
if (!exprResult) { if (!exprResult) {
TX_RELEASE_ATOM(localName);
return; return;
} }
@ -892,7 +861,6 @@ txXSLTProcessor::processAction(Node* aAction,
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
} }
} }
TX_IF_RELEASE_ATOM(localName);
} }
void void
@ -1125,10 +1093,9 @@ txXSLTProcessor::processParameters(Element* aAction,
while (tmpNode) { while (tmpNode) {
if (tmpNode->getNodeType() == Node::ELEMENT_NODE && if (tmpNode->getNodeType() == Node::ELEMENT_NODE &&
tmpNode->getNamespaceID() == kNameSpaceID_XSLT) { tmpNode->getNamespaceID() == kNameSpaceID_XSLT) {
nsIAtom* localName; nsCOMPtr<nsIAtom> localName;
tmpNode->getLocalName(&localName); tmpNode->getLocalName(getter_AddRefs(localName));
if (localName != txXSLTAtoms::withParam) { if (localName != txXSLTAtoms::withParam) {
TX_IF_RELEASE_ATOM(localName);
tmpNode = tmpNode->getNextSibling(); tmpNode = tmpNode->getNextSibling();
continue; continue;
} }
@ -1156,7 +1123,6 @@ txXSLTProcessor::processParameters(Element* aAction,
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
return rv; return rv;
} }
TX_RELEASE_ATOM(localName);
} }
tmpNode = tmpNode->getNextSibling(); tmpNode = tmpNode->getNextSibling();
} }
@ -1189,9 +1155,9 @@ txXSLTProcessor::processStylesheet(Document* aStylesheet,
Element* elem = aStylesheet->getDocumentElement(); Element* elem = aStylesheet->getDocumentElement();
nsIAtom* localName; nsCOMPtr<nsIAtom> localName;
PRInt32 namespaceID = elem->getNamespaceID(); PRInt32 namespaceID = elem->getNamespaceID();
elem->getLocalName(&localName); elem->getLocalName(getter_AddRefs(localName));
if (((localName == txXSLTAtoms::stylesheet) || if (((localName == txXSLTAtoms::stylesheet) ||
(localName == txXSLTAtoms::transform)) && (localName == txXSLTAtoms::transform)) &&
@ -1201,13 +1167,11 @@ txXSLTProcessor::processStylesheet(Document* aStylesheet,
else { else {
NS_ASSERTION(aImportFrame->current(), "no current importframe"); NS_ASSERTION(aImportFrame->current(), "no current importframe");
if (!aImportFrame->current()) { if (!aImportFrame->current()) {
TX_IF_RELEASE_ATOM(localName);
return; return;
} }
aPs->addLREStylesheet(aStylesheet, aPs->addLREStylesheet(aStylesheet,
(ProcessorState::ImportFrame*)aImportFrame->current()); (ProcessorState::ImportFrame*)aImportFrame->current());
} }
TX_IF_RELEASE_ATOM(localName);
} }
void void
@ -1228,14 +1192,12 @@ txXSLTProcessor::processTemplate(Node* aTemplate,
while (tmpNode) { while (tmpNode) {
int nodeType = tmpNode->getNodeType(); int nodeType = tmpNode->getNodeType();
if (nodeType == Node::ELEMENT_NODE) { if (nodeType == Node::ELEMENT_NODE) {
nsIAtom* localName; nsCOMPtr<nsIAtom> localName;
tmpNode->getLocalName(&localName); tmpNode->getLocalName(getter_AddRefs(localName));
if (tmpNode->getNamespaceID() != kNameSpaceID_XSLT || if (tmpNode->getNamespaceID() != kNameSpaceID_XSLT ||
localName != txXSLTAtoms::param) { localName != txXSLTAtoms::param) {
TX_RELEASE_ATOM(localName);
break; break;
} }
TX_RELEASE_ATOM(localName);
Element* action = (Element*)tmpNode; Element* action = (Element*)tmpNode;
txExpandedName paramName; txExpandedName paramName;
@ -1319,8 +1281,8 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
Node* node = aStylesheet->getFirstChild(); Node* node = aStylesheet->getFirstChild();
while (node && !importsDone) { while (node && !importsDone) {
if (node->getNodeType() == Node::ELEMENT_NODE) { if (node->getNodeType() == Node::ELEMENT_NODE) {
nsIAtom* localName; nsCOMPtr<nsIAtom> localName;
node->getLocalName(&localName); node->getLocalName(getter_AddRefs(localName));
if (node->getNamespaceID() == kNameSpaceID_XSLT && if (node->getNamespaceID() == kNameSpaceID_XSLT &&
localName == txXSLTAtoms::import) { localName == txXSLTAtoms::import) {
Element* element = (Element*)node; Element* element = (Element*)node;
@ -1352,7 +1314,6 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
else { else {
importsDone = MB_TRUE; importsDone = MB_TRUE;
} }
TX_IF_RELEASE_ATOM(localName);
} }
if (!importsDone) if (!importsDone)
node = node->getNextSibling(); node = node->getNextSibling();
@ -1365,8 +1326,8 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
continue; continue;
} }
nsIAtom* localName; nsCOMPtr<nsIAtom> localName;
node->getLocalName(&localName); node->getLocalName(getter_AddRefs(localName));
Element* element = (Element*)node; Element* element = (Element*)node;
// xsl:attribute-set // xsl:attribute-set
if (localName == txXSLTAtoms::attributeSet) { if (localName == txXSLTAtoms::attributeSet) {
@ -1585,7 +1546,6 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
currentFrame); currentFrame);
} }
} }
TX_IF_RELEASE_ATOM(localName);
node = node->getNextSibling(); node = node->getNextSibling();
} }
} }

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

@ -28,6 +28,6 @@ ExprResult* CurrentFunctionCall::evaluate(txIEvalContext* aContext)
nsresult CurrentFunctionCall::getNameAtom(nsIAtom** aAtom) nsresult CurrentFunctionCall::getNameAtom(nsIAtom** aAtom)
{ {
*aAtom = txXSLTAtoms::current; *aAtom = txXSLTAtoms::current;
TX_ADDREF_ATOM(*aAtom); NS_ADDREF(*aAtom);
return NS_OK; return NS_OK;
} }

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

@ -131,6 +131,6 @@ ExprResult* DocumentFunctionCall::evaluate(txIEvalContext* aContext)
nsresult DocumentFunctionCall::getNameAtom(nsIAtom** aAtom) nsresult DocumentFunctionCall::getNameAtom(nsIAtom** aAtom)
{ {
*aAtom = txXSLTAtoms::document; *aAtom = txXSLTAtoms::document;
TX_ADDREF_ATOM(*aAtom); NS_ADDREF(*aAtom);
return NS_OK; return NS_OK;
} }

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

@ -136,6 +136,6 @@ ExprResult* ElementAvailableFunctionCall::evaluate(txIEvalContext* aContext)
nsresult ElementAvailableFunctionCall::getNameAtom(nsIAtom** aAtom) nsresult ElementAvailableFunctionCall::getNameAtom(nsIAtom** aAtom)
{ {
*aAtom = txXSLTAtoms::elementAvailable; *aAtom = txXSLTAtoms::elementAvailable;
TX_ADDREF_ATOM(*aAtom); NS_ADDREF(*aAtom);
return NS_OK; return NS_OK;
} }

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

@ -135,6 +135,6 @@ ExprResult* FunctionAvailableFunctionCall::evaluate(txIEvalContext* aContext)
nsresult FunctionAvailableFunctionCall::getNameAtom(nsIAtom** aAtom) nsresult FunctionAvailableFunctionCall::getNameAtom(nsIAtom** aAtom)
{ {
*aAtom = txXSLTAtoms::functionAvailable; *aAtom = txXSLTAtoms::functionAvailable;
TX_ADDREF_ATOM(*aAtom); NS_ADDREF(*aAtom);
return NS_OK; return NS_OK;
} }

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

@ -96,6 +96,6 @@ ExprResult* GenerateIdFunctionCall::evaluate(txIEvalContext* aContext)
nsresult GenerateIdFunctionCall::getNameAtom(nsIAtom** aAtom) nsresult GenerateIdFunctionCall::getNameAtom(nsIAtom** aAtom)
{ {
*aAtom = txXSLTAtoms::generateId; *aAtom = txXSLTAtoms::generateId;
TX_ADDREF_ATOM(*aAtom); NS_ADDREF(*aAtom);
return NS_OK; return NS_OK;
} }

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

@ -67,6 +67,6 @@ ExprResult* SystemPropertyFunctionCall::evaluate(txIEvalContext* aContext)
nsresult SystemPropertyFunctionCall::getNameAtom(nsIAtom** aAtom) nsresult SystemPropertyFunctionCall::getNameAtom(nsIAtom** aAtom)
{ {
*aAtom = txXSLTAtoms::systemProperty; *aAtom = txXSLTAtoms::systemProperty;
TX_ADDREF_ATOM(*aAtom); NS_ADDREF(*aAtom);
return NS_OK; return NS_OK;
} }

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

@ -392,7 +392,7 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
nsresult txFormatNumberFunctionCall::getNameAtom(nsIAtom** aAtom) nsresult txFormatNumberFunctionCall::getNameAtom(nsIAtom** aAtom)
{ {
*aAtom = txXSLTAtoms::formatNumber; *aAtom = txXSLTAtoms::formatNumber;
TX_ADDREF_ATOM(*aAtom); NS_ADDREF(*aAtom);
return NS_OK; return NS_OK;
} }

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

@ -109,7 +109,7 @@ ExprResult* txKeyFunctionCall::evaluate(txIEvalContext* aContext)
nsresult txKeyFunctionCall::getNameAtom(nsIAtom** aAtom) nsresult txKeyFunctionCall::getNameAtom(nsIAtom** aAtom)
{ {
*aAtom = txXSLTAtoms::key; *aAtom = txXSLTAtoms::key;
TX_ADDREF_ATOM(*aAtom); NS_ADDREF(*aAtom);
return NS_OK; return NS_OK;
} }

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

@ -216,7 +216,7 @@ void txHTMLOutput::attribute(const nsAString& aName,
localPart.Equals(aValue, txCaseInsensitiveStringComparator())) { localPart.Equals(aValue, txCaseInsensitiveStringComparator())) {
txListIterator iter(&mAttributes); txListIterator iter(&mAttributes);
txAttribute* setAtt = 0; txAttribute* setAtt = 0;
nsIAtom* localName = TX_GET_ATOM(localPart); nsCOMPtr<nsIAtom> localName = do_GetAtom(localPart);
txExpandedName att(aNsID, localName); txExpandedName att(aNsID, localName);
while ((setAtt = (txAttribute*)iter.next())) { while ((setAtt = (txAttribute*)iter.next())) {
if (setAtt->mName == att) { if (setAtt->mName == att) {
@ -229,7 +229,6 @@ void txHTMLOutput::attribute(const nsAString& aName,
setAtt->mShorthand = MB_TRUE; setAtt->mShorthand = MB_TRUE;
mAttributes.add(setAtt); mAttributes.add(setAtt);
} }
TX_IF_RELEASE_ATOM(localName);
} }
} }
if (!shortHand) if (!shortHand)
@ -304,18 +303,17 @@ void txHTMLOutput::startElement(const nsAString& aName,
{ {
txXMLOutput::startElement(aName, aNsID); txXMLOutput::startElement(aName, aNsID);
nsIAtom* localAtom; nsCOMPtr<nsIAtom> localAtom;
if (aNsID == kNameSpaceID_None) { if (aNsID == kNameSpaceID_None) {
nsAutoString localName; nsAutoString localName;
TX_ToLowerCase(aName, localName); TX_ToLowerCase(aName, localName);
localAtom = TX_GET_ATOM(localName); localAtom = do_GetAtom(localName);
} }
else { else {
localAtom = TX_GET_ATOM(aName); localAtom = do_GetAtom(aName);
} }
NS_ASSERTION(localAtom, "Can't get atom"); NS_ASSERTION(localAtom, "Can't get atom");
txExpandedName* currentElement = new txExpandedName(aNsID, localAtom); txExpandedName* currentElement = new txExpandedName(aNsID, localAtom);
TX_IF_RELEASE_ATOM(localAtom);
NS_ASSERTION(currentElement, "Can't create currentElement"); NS_ASSERTION(currentElement, "Can't create currentElement");
if (currentElement) if (currentElement)
mCurrentElements.push(currentElement); mCurrentElements.push(currentElement);

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

@ -262,15 +262,14 @@ nsresult txPatternParser::createKeyPattern(ExprLexer& aLexer,
if (!XMLUtils::isValidQName(key)) if (!XMLUtils::isValidQName(key))
return NS_ERROR_XPATH_PARSE_FAILED; return NS_ERROR_XPATH_PARSE_FAILED;
nsIAtom *prefix = 0, *localName = 0; nsCOMPtr<nsIAtom> prefix, localName;
PRInt32 namespaceID; PRInt32 namespaceID;
nsresult rv = resolveQName(key, prefix, aContext, localName, namespaceID); nsresult rv = resolveQName(key, *getter_AddRefs(prefix), aContext,
*getter_AddRefs(localName), namespaceID);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
aPattern = new txKeyPattern(aPs, prefix, localName, namespaceID, value); aPattern = new txKeyPattern(aPs, prefix, localName, namespaceID, value);
TX_IF_RELEASE_ATOM(prefix);
TX_RELEASE_ATOM(localName);
return aPattern ? NS_OK : NS_ERROR_OUT_OF_MEMORY; return aPattern ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
} }
@ -302,9 +301,10 @@ nsresult txPatternParser::createStepPattern(ExprLexer& aLexer,
txNodeTest* nodeTest = 0; txNodeTest* nodeTest = 0;
if (tok->type == Token::CNAME) { if (tok->type == Token::CNAME) {
// resolve QName // resolve QName
nsIAtom *prefix, *lName; nsCOMPtr<nsIAtom> prefix, lName;
PRInt32 nspace; PRInt32 nspace;
rv = resolveQName(tok->value, prefix, aContext, lName, nspace); rv = resolveQName(tok->value, *getter_AddRefs(prefix), aContext,
*getter_AddRefs(lName), nspace);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
// XXX error report namespace resolve failed // XXX error report namespace resolve failed
return rv; return rv;
@ -317,8 +317,6 @@ nsresult txPatternParser::createStepPattern(ExprLexer& aLexer,
nodeTest = new txNameTest(prefix, lName, nspace, nodeTest = new txNameTest(prefix, lName, nspace,
Node::ELEMENT_NODE); Node::ELEMENT_NODE);
} }
TX_IF_RELEASE_ATOM(prefix);
TX_IF_RELEASE_ATOM(lName);
if (!nodeTest) { if (!nodeTest) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }

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

@ -246,9 +246,8 @@ void txXMLOutput::startElement(const nsAString& aName,
mCDATASections.push((void*)mInCDATASection); mCDATASections.push((void*)mInCDATASection);
mInCDATASection = MB_FALSE; mInCDATASection = MB_FALSE;
nsIAtom* localName = TX_GET_ATOM(aName); nsCOMPtr<nsIAtom> localName = do_GetAtom(aName);
txExpandedName currentElement(aNsID, localName); txExpandedName currentElement(aNsID, localName);
TX_IF_RELEASE_ATOM(localName);
txListIterator iter(&(mOutputFormat.mCDATASectionElements)); txListIterator iter(&(mOutputFormat.mCDATASectionElements));
while (iter.hasNext()) { while (iter.hasNext()) {
if (currentElement == *(txExpandedName*)iter.next()) { if (currentElement == *(txExpandedName*)iter.next()) {

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

@ -150,12 +150,11 @@ nsresult txXSLTNumber::getValueList(Element* aNumberElement,
switch (currNode->getNodeType()) { switch (currNode->getNodeType()) {
case Node::ELEMENT_NODE: case Node::ELEMENT_NODE:
{ {
nsIAtom* localName = 0; nsCOMPtr<nsIAtom> localName;
currNode->getLocalName(&localName); currNode->getLocalName(getter_AddRefs(localName));
nodeTest = new txNameTest(0, localName, nodeTest = new txNameTest(0, localName,
currNode->getNamespaceID(), currNode->getNamespaceID(),
Node::ELEMENT_NODE); Node::ELEMENT_NODE);
TX_IF_RELEASE_ATOM(localName);
break; break;
} }
case Node::TEXT_NODE: case Node::TEXT_NODE:
@ -218,9 +217,9 @@ nsresult txXSLTNumber::getValueList(Element* aNumberElement,
// Generate list of values depending on the value of the level-attribute // Generate list of values depending on the value of the level-attribute
nsAutoString levelStr; nsAutoString levelStr;
nsIAtom* level = 0; nsCOMPtr<nsIAtom> level;
if (aNumberElement->getAttr(txXSLTAtoms::level, kNameSpaceID_None, levelStr)) { if (aNumberElement->getAttr(txXSLTAtoms::level, kNameSpaceID_None, levelStr)) {
level = TX_GET_ATOM(levelStr); level = do_GetAtom(levelStr);
} }
// level = "single" // level = "single"
@ -325,7 +324,6 @@ nsresult txXSLTNumber::getValueList(Element* aNumberElement,
if (ownsCountPattern) { if (ownsCountPattern) {
delete countPattern; delete countPattern;
} }
TX_IF_RELEASE_ATOM(level);
return NS_OK; return NS_OK;
} }

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

@ -456,11 +456,11 @@ void txKeyPattern::toString(nsAString& aDest)
aDest.Append(NS_LITERAL_STRING("key('")); aDest.Append(NS_LITERAL_STRING("key('"));
nsAutoString tmp; nsAutoString tmp;
if (mPrefix) { if (mPrefix) {
TX_GET_ATOM_STRING(mPrefix, tmp); mPrefix->ToString(tmp);
aDest.Append(tmp); aDest.Append(tmp);
aDest.Append(PRUnichar(':')); aDest.Append(PRUnichar(':'));
} }
TX_GET_ATOM_STRING(mName.mLocalName, tmp); mName.mLocalName->ToString(tmp);
aDest.Append(tmp); aDest.Append(tmp);
aDest.Append(NS_LITERAL_STRING(", ")); aDest.Append(NS_LITERAL_STRING(", "));
aDest.Append(mValue); aDest.Append(mValue);

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

@ -42,7 +42,7 @@
#include "baseutils.h" #include "baseutils.h"
#include "List.h" #include "List.h"
#include "txAtom.h" #include "nsIAtom.h"
class Element; class Element;
class Expr; class Expr;