mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Remove txAtom.h and remove uses of special tx-macros for atoms.
b=157142 r=Pike sr=peterv
This commit is contained in:
parent
bfe08ec07f
commit
7a9a568e7f
@ -1,79 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Jonas Sicking.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* Jonas Sicking. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jonas Sicking <sicking@bigfoot.com>
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Atom implementation for standalone and wrapper for module
|
||||
*
|
||||
* For module,
|
||||
* txAtom is typedef'd to nsIAtom,
|
||||
* for standalone there is a separate implementation. The
|
||||
* code is all inlined in this header file.
|
||||
*
|
||||
* There is one major difference between the standalone and
|
||||
* the module implementation, module atoms are refcounted,
|
||||
* standalone atoms are not. Therefor code that is standalone
|
||||
* only may not use TX_RELEASE..ATOM, code that works in both
|
||||
* module and standalone has to pair these. Or you leak.
|
||||
*
|
||||
* To use this code standalone,
|
||||
* TX_IMPL_ATOM_STATICS;
|
||||
* has to appear in your source file.
|
||||
* XSLTProcessor.cpp does this.
|
||||
*/
|
||||
|
||||
#ifndef TRANSFRMX_ATOM_H
|
||||
#define TRANSFRMX_ATOM_H
|
||||
|
||||
#include "nsIAtom.h"
|
||||
|
||||
#define TX_GET_ATOM(str) \
|
||||
NS_NewAtom(str)
|
||||
|
||||
#define TX_ADDREF_ATOM(atom) NS_ADDREF(atom)
|
||||
|
||||
#define TX_IF_ADDREF_ATOM(atom) NS_IF_ADDREF(atom)
|
||||
|
||||
#define TX_RELEASE_ATOM(atom) NS_RELEASE(atom)
|
||||
|
||||
#define TX_IF_RELEASE_ATOM(atom) NS_IF_RELEASE(atom)
|
||||
|
||||
#define TX_GET_ATOM_STRING(atom, string) \
|
||||
NS_SUCCEEDED((atom)->ToString(string))
|
||||
|
||||
#endif // TRANSFRMX_ATOM_H
|
@ -100,7 +100,7 @@ MBool txHTMLAtoms::init()
|
||||
#undef TX_ATOM
|
||||
|
||||
#define TX_ATOM(_name, _value) \
|
||||
TX_IF_RELEASE_ATOM(_name)
|
||||
NS_IF_RELEASE(_name)
|
||||
|
||||
void txXMLAtoms::shutdown()
|
||||
{
|
||||
|
@ -39,7 +39,7 @@
|
||||
#ifndef TRANSFRMX_ATOMS_H
|
||||
#define TRANSFRMX_ATOMS_H
|
||||
|
||||
#include "txAtom.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "baseutils.h"
|
||||
|
||||
/*
|
||||
|
@ -85,7 +85,7 @@ nsresult txExpandedNameMap::add(const txExpandedName& aKey, TxObject* aValue)
|
||||
|
||||
mItems[mItemCount].mNamespaceID = aKey.mNamespaceID;
|
||||
mItems[mItemCount].mLocalName = aKey.mLocalName;
|
||||
TX_IF_ADDREF_ATOM(mItems[mItemCount].mLocalName);
|
||||
NS_IF_ADDREF(mItems[mItemCount].mLocalName);
|
||||
mItems[mItemCount].mValue = aValue;
|
||||
++mItemCount;
|
||||
|
||||
@ -130,7 +130,7 @@ nsresult txExpandedNameMap::set(const txExpandedName& aKey, TxObject* aValue)
|
||||
|
||||
mItems[mItemCount].mNamespaceID = aKey.mNamespaceID;
|
||||
mItems[mItemCount].mLocalName = aKey.mLocalName;
|
||||
TX_IF_ADDREF_ATOM(mItems[mItemCount].mLocalName);
|
||||
NS_IF_ADDREF(mItems[mItemCount].mLocalName);
|
||||
mItems[mItemCount].mValue = aValue;
|
||||
++mItemCount;
|
||||
|
||||
@ -167,7 +167,7 @@ TxObject* txExpandedNameMap::remove(const txExpandedName& aKey)
|
||||
for (i = 0; i < mItemCount; ++i) {
|
||||
if (mItems[i].mLocalName == aKey.mLocalName &&
|
||||
mItems[i].mNamespaceID == aKey.mNamespaceID) {
|
||||
TX_IF_RELEASE_ATOM(mItems[i].mLocalName);
|
||||
NS_IF_RELEASE(mItems[i].mLocalName);
|
||||
if (mOwnsValues) {
|
||||
delete mItems[i].mValue;
|
||||
}
|
||||
@ -190,7 +190,7 @@ void txExpandedNameMap::clear()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < mItemCount; ++i) {
|
||||
TX_IF_RELEASE_ATOM(mItems[i].mLocalName);
|
||||
NS_IF_RELEASE(mItems[i].mLocalName);
|
||||
if (mOwnsValues) {
|
||||
delete mItems[i].mValue;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "XMLUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "txAtoms.h"
|
||||
#include "txStringUtils.h"
|
||||
|
||||
nsresult txExpandedName::init(const nsAString& aQName,
|
||||
Node* aResolver,
|
||||
@ -210,13 +211,10 @@ MBool XMLUtils::getXMLSpacePreserve(Node* aNode)
|
||||
if (parent->getNodeType() == Node::ELEMENT_NODE) {
|
||||
Element* elem = (Element*)parent;
|
||||
if (elem->getAttr(txXMLAtoms::space, kNameSpaceID_XML, value)) {
|
||||
nsIAtom* val = TX_GET_ATOM(value);
|
||||
if (val == txXMLAtoms::preserve) {
|
||||
TX_IF_RELEASE_ATOM(val);
|
||||
if (TX_StringEqualsAtom(value, txXMLAtoms::preserve)) {
|
||||
return MB_TRUE;
|
||||
}
|
||||
if (val == txXMLAtoms::_default) {
|
||||
TX_IF_RELEASE_ATOM(val);
|
||||
if (TX_StringEqualsAtom(value, txXMLAtoms::_default)) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "baseutils.h"
|
||||
#include "dom.h"
|
||||
#include "nsDependentSubstring.h"
|
||||
#include "txAtom.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "txError.h"
|
||||
|
||||
class txExpandedName {
|
||||
|
@ -95,6 +95,6 @@ MBool Attr::getLocalName(nsIAtom** aLocalName)
|
||||
}
|
||||
*aLocalName = mLocalName;
|
||||
NS_ENSURE_TRUE(*aLocalName, MB_FALSE);
|
||||
TX_ADDREF_ATOM(*aLocalName);
|
||||
NS_ADDREF(*aLocalName);
|
||||
return MB_TRUE;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include "nsIContent.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "pldhash.h"
|
||||
#include "txAtom.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "TxObject.h"
|
||||
|
||||
#define kTxNsNodeIndexOffset 0x00000000;
|
||||
|
@ -37,26 +37,25 @@ Attr::Attr(const nsAString& name, Document* owner):
|
||||
{
|
||||
int idx = nodeName.FindChar(':');
|
||||
if (idx == kNotFound) {
|
||||
mLocalName = TX_GET_ATOM(nodeName);
|
||||
mLocalName = do_GetAtom(nodeName);
|
||||
if (mLocalName == txXMLAtoms::xmlns)
|
||||
mNamespaceID = kNameSpaceID_XMLNS;
|
||||
else
|
||||
mNamespaceID = kNameSpaceID_None;
|
||||
}
|
||||
else {
|
||||
mLocalName = TX_GET_ATOM(Substring(nodeName, idx + 1,
|
||||
nodeName.Length() - (idx + 1)));
|
||||
mLocalName = do_GetAtom(Substring(nodeName, idx + 1,
|
||||
nodeName.Length() - (idx + 1)));
|
||||
// namespace handling has to be handled late, the attribute must
|
||||
// be added to the tree to resolve the prefix, unless it's
|
||||
// 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)
|
||||
mNamespaceID = kNameSpaceID_XMLNS;
|
||||
else if (prefixAtom == txXMLAtoms::xml)
|
||||
mNamespaceID = kNameSpaceID_XML;
|
||||
else
|
||||
mNamespaceID = kNameSpaceID_Unknown;
|
||||
TX_IF_RELEASE_ATOM(prefixAtom);
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +69,7 @@ Attr::Attr(const nsAString& aNamespaceURI,
|
||||
else
|
||||
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()
|
||||
{
|
||||
TX_IF_RELEASE_ATOM(mLocalName);
|
||||
}
|
||||
|
||||
void Attr::setNodeValue(const nsAString& aValue)
|
||||
@ -109,7 +107,7 @@ MBool Attr::getLocalName(nsIAtom** aLocalName)
|
||||
if (!aLocalName)
|
||||
return MB_FALSE;
|
||||
*aLocalName = mLocalName;
|
||||
TX_ADDREF_ATOM(*aLocalName);
|
||||
NS_ADDREF(*aLocalName);
|
||||
return MB_TRUE;
|
||||
}
|
||||
|
||||
@ -126,7 +124,7 @@ PRInt32 Attr::getNamespaceID()
|
||||
mNamespaceID = kNameSpaceID_None;
|
||||
PRInt32 idx = nodeName.FindChar(':');
|
||||
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);
|
||||
}
|
||||
return mNamespaceID;
|
||||
|
@ -42,11 +42,11 @@ Element::Element(const nsAString& tagName, Document* owner) :
|
||||
|
||||
int idx = tagName.FindChar(':');
|
||||
if (idx == kNotFound) {
|
||||
mLocalName = TX_GET_ATOM(tagName);
|
||||
mLocalName = do_GetAtom(tagName);
|
||||
}
|
||||
else {
|
||||
mLocalName = TX_GET_ATOM(Substring(tagName, idx + 1,
|
||||
tagName.Length() - (idx + 1)));
|
||||
mLocalName = do_GetAtom(Substring(tagName, idx + 1,
|
||||
tagName.Length() - (idx + 1)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +69,6 @@ Element::Element(const nsAString& aNamespaceURI,
|
||||
Element::~Element()
|
||||
{
|
||||
mAttributes.clear();
|
||||
TX_IF_RELEASE_ATOM(mLocalName);
|
||||
}
|
||||
|
||||
Node* Element::appendChild(Node* newChild)
|
||||
@ -104,7 +103,7 @@ MBool Element::getLocalName(nsIAtom** aLocalName)
|
||||
if (!aLocalName)
|
||||
return MB_FALSE;
|
||||
*aLocalName = mLocalName;
|
||||
TX_ADDREF_ATOM(*aLocalName);
|
||||
NS_ADDREF(*aLocalName);
|
||||
return MB_TRUE;
|
||||
}
|
||||
|
||||
@ -182,14 +181,12 @@ void Element::setAttributeNS(const nsAString& aNamespaceURI,
|
||||
AttrMap::ListItem* item = mAttributes.firstItem;
|
||||
while (item) {
|
||||
foundNode = (Attr*)item->node;
|
||||
nsIAtom* attrName;
|
||||
if (foundNode->getLocalName(&attrName) &&
|
||||
nsCOMPtr<nsIAtom> attrName;
|
||||
if (foundNode->getLocalName(getter_AddRefs(attrName)) &&
|
||||
namespaceID == foundNode->getNamespaceID() &&
|
||||
localName == attrName) {
|
||||
TX_IF_RELEASE_ATOM(attrName);
|
||||
break;
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(attrName);
|
||||
foundNode = 0;
|
||||
item = item->next;
|
||||
}
|
||||
@ -226,15 +223,13 @@ MBool Element::getAttr(nsIAtom* aLocalName, PRInt32 aNSID,
|
||||
AttrMap::ListItem* item = mAttributes.firstItem;
|
||||
while (item) {
|
||||
Attr* attrNode = (Attr*)item->node;
|
||||
nsIAtom* localName;
|
||||
if (attrNode->getLocalName(&localName) &&
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
if (attrNode->getLocalName(getter_AddRefs(localName)) &&
|
||||
aNSID == attrNode->getNamespaceID() &&
|
||||
aLocalName == localName) {
|
||||
attrNode->getNodeValue(aValue);
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
return MB_TRUE;
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
item = item->next;
|
||||
}
|
||||
return MB_FALSE;
|
||||
@ -249,14 +244,12 @@ MBool Element::hasAttr(nsIAtom* aLocalName, PRInt32 aNSID)
|
||||
AttrMap::ListItem* item = mAttributes.firstItem;
|
||||
while (item) {
|
||||
Attr* attrNode = (Attr*)item->node;
|
||||
nsIAtom* localName;
|
||||
if (attrNode->getLocalName(&localName) &&
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
if (attrNode->getLocalName(getter_AddRefs(localName)) &&
|
||||
aNSID == attrNode->getNamespaceID() &&
|
||||
aLocalName == localName) {
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
return MB_TRUE;
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
item = item->next;
|
||||
}
|
||||
return MB_FALSE;
|
||||
|
@ -309,7 +309,7 @@ PRInt32 NodeDefinition::lookupNamespaceID(nsIAtom* aPrefix)
|
||||
if (aPrefix && (aPrefix != txXMLAtoms::_empty)) {
|
||||
// We have a prefix, search for xmlns:prefix attributes.
|
||||
nsAutoString prefixString;
|
||||
TX_GET_ATOM_STRING(aPrefix, prefixString);
|
||||
aPrefix->ToString(prefixString);
|
||||
name.Append(prefixString);
|
||||
}
|
||||
else {
|
||||
|
@ -30,7 +30,7 @@
|
||||
//
|
||||
|
||||
#include "dom.h"
|
||||
#include "txAtom.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
//
|
||||
//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,
|
||||
theTarget, theData, owner)
|
||||
{
|
||||
mLocalName = TX_GET_ATOM(nodeName);
|
||||
mLocalName = do_GetAtom(nodeName);
|
||||
}
|
||||
|
||||
//
|
||||
@ -49,7 +49,6 @@ ProcessingInstruction::ProcessingInstruction(const nsAString& theTarget,
|
||||
//
|
||||
ProcessingInstruction::~ProcessingInstruction()
|
||||
{
|
||||
TX_IF_RELEASE_ATOM(mLocalName);
|
||||
}
|
||||
|
||||
//
|
||||
@ -62,6 +61,6 @@ MBool ProcessingInstruction::getLocalName(nsIAtom** aLocalName)
|
||||
if (!aLocalName)
|
||||
return MB_FALSE;
|
||||
*aLocalName = mLocalName;
|
||||
TX_ADDREF_ATOM(*aLocalName);
|
||||
NS_ADDREF(*aLocalName);
|
||||
return MB_TRUE;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@
|
||||
#endif
|
||||
|
||||
#include "List.h"
|
||||
#include "txAtom.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "baseutils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
@ -431,7 +431,7 @@ class Element : public NodeDefinition
|
||||
Document* aOwner);
|
||||
|
||||
AttrMap mAttributes;
|
||||
nsIAtom* mLocalName;
|
||||
nsCOMPtr<nsIAtom> mLocalName;
|
||||
PRInt32 mNamespaceID;
|
||||
};
|
||||
|
||||
@ -470,7 +470,7 @@ class Attr : public NodeDefinition
|
||||
|
||||
Element* ownerElement;
|
||||
|
||||
nsIAtom* mLocalName;
|
||||
nsCOMPtr<nsIAtom> mLocalName;
|
||||
PRInt32 mNamespaceID;
|
||||
};
|
||||
|
||||
@ -495,7 +495,7 @@ class ProcessingInstruction : public NodeDefinition
|
||||
ProcessingInstruction(const nsAString& theTarget, const nsAString& theData,
|
||||
Document* owner);
|
||||
|
||||
nsIAtom* mLocalName;
|
||||
nsCOMPtr<nsIAtom> mLocalName;
|
||||
};
|
||||
|
||||
class txNamespaceManager
|
||||
|
@ -154,6 +154,6 @@ nsresult BooleanFunctionCall::getNameAtom(nsIAtom** aAtom)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
TX_ADDREF_ATOM(*aAtom);
|
||||
NS_ADDREF(*aAtom);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include "dom.h"
|
||||
#include "List.h"
|
||||
#include "nsString.h"
|
||||
#include "txAtom.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "TxObject.h"
|
||||
|
||||
/*
|
||||
@ -232,8 +232,8 @@ public:
|
||||
TX_DECL_NODE_TEST;
|
||||
|
||||
private:
|
||||
nsIAtom* mPrefix;
|
||||
nsIAtom* mLocalName;
|
||||
nsCOMPtr<nsIAtom> mPrefix;
|
||||
nsCOMPtr<nsIAtom> mLocalName;
|
||||
PRInt32 mNamespace;
|
||||
Node::NodeType mNodeType;
|
||||
};
|
||||
@ -267,7 +267,7 @@ public:
|
||||
|
||||
private:
|
||||
NodeType mNodeType;
|
||||
nsIAtom* mNodeName;
|
||||
nsCOMPtr<nsIAtom> mNodeName;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -560,8 +560,8 @@ public:
|
||||
TX_DECL_EXPR;
|
||||
|
||||
private:
|
||||
nsIAtom* mPrefix;
|
||||
nsIAtom* mLocalName;
|
||||
nsCOMPtr<nsIAtom> mPrefix;
|
||||
nsCOMPtr<nsIAtom> mLocalName;
|
||||
PRInt32 mNamespace;
|
||||
};
|
||||
|
||||
|
@ -326,17 +326,16 @@ Expr* ExprParser::createFilterExpr(ExprLexer& lexer, txIParseContext* aContext)
|
||||
break;
|
||||
case Token::VAR_REFERENCE :
|
||||
{
|
||||
nsIAtom *prefix, *lName;
|
||||
nsCOMPtr<nsIAtom> prefix, lName;
|
||||
PRInt32 nspace;
|
||||
nsresult rv = resolveQName(tok->value, prefix, aContext,
|
||||
lName, nspace);
|
||||
nsresult rv = resolveQName(tok->value, *getter_AddRefs(prefix),
|
||||
aContext, *getter_AddRefs(lName),
|
||||
nspace);
|
||||
if (NS_FAILED(rv)) {
|
||||
// XXX error report namespace resolve failed
|
||||
return 0;
|
||||
}
|
||||
expr = new VariableRefExpr(prefix, lName, nspace);
|
||||
TX_IF_RELEASE_ATOM(prefix);
|
||||
TX_IF_RELEASE_ATOM(lName);
|
||||
}
|
||||
break;
|
||||
case Token::L_PAREN:
|
||||
@ -490,16 +489,15 @@ Expr* ExprParser::createFunctionCall(ExprLexer& lexer,
|
||||
fnCall = new NumberFunctionCall(NumberFunctionCall::FLOOR);
|
||||
}
|
||||
else {
|
||||
nsIAtom *prefix, *lName;
|
||||
nsCOMPtr<nsIAtom> prefix, lName;
|
||||
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)) {
|
||||
// XXX error report namespace resolve failed
|
||||
return 0;
|
||||
}
|
||||
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
|
||||
// NS_ERROR_NOT_IMPLEMENTED for unparsed-entity-uri(). As should the
|
||||
@ -640,10 +638,12 @@ LocationStep* ExprParser::createLocationStep(ExprLexer& lexer,
|
||||
case Token::CNAME :
|
||||
{
|
||||
// resolve QName
|
||||
nsIAtom *prefix, *lName;
|
||||
nsCOMPtr<nsIAtom> prefix, lName;
|
||||
PRInt32 nspace;
|
||||
nsresult rv = resolveQName(tok->value, prefix, aContext,
|
||||
lName, nspace);
|
||||
nsresult rv = resolveQName(tok->value,
|
||||
*getter_AddRefs(prefix),
|
||||
aContext,
|
||||
*getter_AddRefs(lName), nspace);
|
||||
if (NS_FAILED(rv)) {
|
||||
// XXX error report namespace resolve failed
|
||||
return 0;
|
||||
@ -658,8 +658,6 @@ LocationStep* ExprParser::createLocationStep(ExprLexer& lexer,
|
||||
Node::ELEMENT_NODE);
|
||||
break;
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(prefix);
|
||||
TX_IF_RELEASE_ATOM(lName);
|
||||
}
|
||||
if (!nodeTest) {
|
||||
//XXX ErrorReport: out of memory
|
||||
@ -1019,22 +1017,21 @@ nsresult ExprParser::resolveQName(const nsAString& aQName,
|
||||
aNamespace = kNameSpaceID_None;
|
||||
PRInt32 idx = aQName.FindChar(':');
|
||||
if (idx > 0) {
|
||||
aPrefix = TX_GET_ATOM(Substring(aQName, 0, (PRUint32)idx));
|
||||
aPrefix = NS_NewAtom(Substring(aQName, 0, (PRUint32)idx));
|
||||
if (!aPrefix) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
aLocalName = TX_GET_ATOM(Substring(aQName, (PRUint32)idx + 1,
|
||||
aQName.Length() - (idx + 1)));
|
||||
aLocalName = NS_NewAtom(Substring(aQName, (PRUint32)idx + 1,
|
||||
aQName.Length() - (idx + 1)));
|
||||
if (!aLocalName) {
|
||||
TX_RELEASE_ATOM(aPrefix);
|
||||
aPrefix = 0;
|
||||
NS_RELEASE(aPrefix);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return aContext->resolveNamespacePrefix(aPrefix, aNamespace);
|
||||
}
|
||||
// the lexer dealt with idx == 0
|
||||
aPrefix = 0;
|
||||
aLocalName = TX_GET_ATOM(aQName);
|
||||
aLocalName = NS_NewAtom(aQName);
|
||||
if (!aLocalName) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
#define MITREXSL_EXPRPARSER_H
|
||||
|
||||
#include "baseutils.h"
|
||||
#include "txAtom.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "txError.h"
|
||||
|
||||
class AttributeValueTemplate;
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include "Expr.h"
|
||||
#include "ExprResult.h"
|
||||
#include "txAtom.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "txIXPathContext.h"
|
||||
|
||||
/**
|
||||
@ -176,15 +176,13 @@ MBool FunctionCall::requireParams(int paramCountMin, txIEvalContext* aContext)
|
||||
**/
|
||||
void FunctionCall::toString(nsAString& aDest)
|
||||
{
|
||||
nsIAtom* functionNameAtom = 0;
|
||||
nsCOMPtr<nsIAtom> functionNameAtom;
|
||||
nsAutoString functionName;
|
||||
if (!NS_SUCCEEDED(getNameAtom(&functionNameAtom)) ||
|
||||
!TX_GET_ATOM_STRING(functionNameAtom, functionName)) {
|
||||
if (NS_FAILED(getNameAtom(getter_AddRefs(functionNameAtom))) ||
|
||||
NS_FAILED(functionNameAtom->ToString(functionName))) {
|
||||
NS_ASSERTION(0, "Can't get function name.");
|
||||
TX_IF_RELEASE_ATOM(functionNameAtom);
|
||||
return;
|
||||
}
|
||||
TX_RELEASE_ATOM(functionNameAtom);
|
||||
|
||||
aDest.Append(functionName);
|
||||
aDest.Append(PRUnichar('('));
|
||||
|
@ -161,12 +161,11 @@ ExprResult* NodeSetFunctionCall::evaluate(txIEvalContext* aContext) {
|
||||
case LOCAL_NAME:
|
||||
{
|
||||
nsAutoString localName;
|
||||
nsIAtom* localNameAtom;
|
||||
node->getLocalName(&localNameAtom);
|
||||
nsCOMPtr<nsIAtom> localNameAtom;
|
||||
node->getLocalName(getter_AddRefs(localNameAtom));
|
||||
if (localNameAtom) {
|
||||
// Node has a localName
|
||||
TX_GET_ATOM_STRING(localNameAtom, localName);
|
||||
TX_RELEASE_ATOM(localNameAtom);
|
||||
localNameAtom->ToString(localName);
|
||||
}
|
||||
|
||||
return new StringResult(localName);
|
||||
@ -264,6 +263,6 @@ nsresult NodeSetFunctionCall::getNameAtom(nsIAtom** aAtom)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
TX_ADDREF_ATOM(*aAtom);
|
||||
NS_ADDREF(*aAtom);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -172,6 +172,6 @@ nsresult NumberFunctionCall::getNameAtom(nsIAtom** aAtom)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
TX_ADDREF_ATOM(*aAtom);
|
||||
NS_ADDREF(*aAtom);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -310,6 +310,6 @@ nsresult StringFunctionCall::getNameAtom(nsIAtom** aAtom)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
TX_ADDREF_ATOM(*aAtom);
|
||||
NS_ADDREF(*aAtom);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -42,8 +42,6 @@ VariableRefExpr::VariableRefExpr(nsIAtom* aPrefix, nsIAtom* aLocalName,
|
||||
NS_ASSERTION(mLocalName, "VariableRefExpr without local name?");
|
||||
if (mPrefix == txXMLAtoms::_empty)
|
||||
mPrefix = 0;
|
||||
TX_IF_ADDREF_ATOM(mPrefix);
|
||||
TX_IF_ADDREF_ATOM(mLocalName);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -51,8 +49,6 @@ VariableRefExpr::VariableRefExpr(nsIAtom* aPrefix, nsIAtom* aLocalName,
|
||||
*/
|
||||
VariableRefExpr::~VariableRefExpr()
|
||||
{
|
||||
TX_IF_RELEASE_ATOM(mPrefix);
|
||||
TX_IF_RELEASE_ATOM(mLocalName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,11 +82,11 @@ void VariableRefExpr::toString(nsAString& aDest)
|
||||
aDest.Append(PRUnichar('$'));
|
||||
if (mPrefix) {
|
||||
nsAutoString prefix;
|
||||
TX_GET_ATOM_STRING(mPrefix, prefix);
|
||||
mPrefix->ToString(prefix);
|
||||
aDest.Append(prefix);
|
||||
aDest.Append(PRUnichar(':'));
|
||||
}
|
||||
nsAutoString lname;
|
||||
TX_GET_ATOM_STRING(mLocalName, lname);
|
||||
mLocalName->ToString(lname);
|
||||
aDest.Append(lname);
|
||||
} //-- toString
|
||||
|
@ -40,7 +40,7 @@
|
||||
#define __TX_I_XPATH_CONTEXT
|
||||
|
||||
#include "baseutils.h"
|
||||
#include "txAtom.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "txError.h"
|
||||
|
||||
class ExprResult;
|
||||
|
@ -35,14 +35,10 @@ txNameTest::txNameTest(nsIAtom* aPrefix, nsIAtom* aLocalName, PRInt32 aNSID,
|
||||
if (aPrefix == txXMLAtoms::_empty)
|
||||
mPrefix = 0;
|
||||
NS_ASSERTION(aLocalName, "txNameTest without a local name?");
|
||||
TX_IF_ADDREF_ATOM(mPrefix);
|
||||
TX_IF_ADDREF_ATOM(mLocalName);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
// Compare local-names
|
||||
nsIAtom* localName;
|
||||
aNode->getLocalName(&localName);
|
||||
MBool result = localName == mLocalName;
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
|
||||
return result;
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
aNode->getLocalName(getter_AddRefs(localName));
|
||||
return localName == mLocalName;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -24,25 +24,24 @@
|
||||
*/
|
||||
|
||||
#include "Expr.h"
|
||||
#include "txAtom.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "txIXPathContext.h"
|
||||
|
||||
/*
|
||||
* Creates a new txNodeTypeTest of the given type
|
||||
*/
|
||||
txNodeTypeTest::txNodeTypeTest(NodeType aNodeType)
|
||||
: mNodeType(aNodeType), mNodeName(0)
|
||||
: mNodeType(aNodeType)
|
||||
{
|
||||
}
|
||||
|
||||
txNodeTypeTest::~txNodeTypeTest()
|
||||
{
|
||||
TX_IF_RELEASE_ATOM(mNodeName);
|
||||
}
|
||||
|
||||
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);
|
||||
case PI_TYPE:
|
||||
if (type == Node::PROCESSING_INSTRUCTION_NODE) {
|
||||
nsIAtom* localName = 0;
|
||||
MBool result;
|
||||
result = !mNodeName ||
|
||||
(aNode->getLocalName(&localName) &&
|
||||
localName == mNodeName);
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
return result;
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
return !mNodeName ||
|
||||
(aNode->getLocalName(getter_AddRefs(localName)) &&
|
||||
localName == mNodeName);
|
||||
}
|
||||
return MB_FALSE;
|
||||
case NODE_TYPE:
|
||||
@ -107,7 +103,7 @@ void txNodeTypeTest::toString(nsAString& aDest)
|
||||
aDest.Append(NS_LITERAL_STRING("processing-instruction("));
|
||||
if (mNodeName) {
|
||||
nsAutoString str;
|
||||
TX_GET_ATOM_STRING(mNodeName, str);
|
||||
mNodeName->ToString(str);
|
||||
aDest.Append(PRUnichar('\''));
|
||||
aDest.Append(str);
|
||||
aDest.Append(PRUnichar('\''));
|
||||
|
@ -154,12 +154,11 @@ void ProcessorState::addAttributeSet(Element* aAttributeSet,
|
||||
PRInt32 nsID = node->getNamespaceID();
|
||||
if (nsID != kNameSpaceID_XSLT)
|
||||
continue;
|
||||
nsIAtom* nodeName;
|
||||
if (!node->getLocalName(&nodeName) || !nodeName)
|
||||
nsCOMPtr<nsIAtom> nodeName;
|
||||
if (!node->getLocalName(getter_AddRefs(nodeName)) || !nodeName)
|
||||
continue;
|
||||
if (nodeName == txXSLTAtoms::attribute)
|
||||
attSet->append(node);
|
||||
TX_RELEASE_ATOM(nodeName);
|
||||
}
|
||||
node = node->getNextSibling();
|
||||
}
|
||||
@ -485,7 +484,7 @@ Node* ProcessorState::findTemplate(Node* aNode,
|
||||
#ifdef PR_LOGGING
|
||||
nsAutoString mode, nodeName;
|
||||
if (aMode.mLocalName) {
|
||||
TX_GET_ATOM_STRING(aMode.mLocalName, mode);
|
||||
aMode.mLocalName->ToString(mode);
|
||||
}
|
||||
aNode->getNodeName(nodeName);
|
||||
if (matchTemplate) {
|
||||
|
@ -333,8 +333,8 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
}
|
||||
|
||||
Expr* expr = 0;
|
||||
nsIAtom* localName;
|
||||
aAction->getLocalName(&localName);
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
aAction->getLocalName(getter_AddRefs(localName));
|
||||
// xsl:apply-imports
|
||||
if (localName == txXSLTAtoms::applyImports) {
|
||||
ProcessorState::TemplateRule* curr;
|
||||
@ -345,7 +345,6 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
if (!curr) {
|
||||
aPs->receiveError(NS_LITERAL_STRING("apply-imports not allowed here"),
|
||||
NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -365,13 +364,11 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
expr = gNodeExpr;
|
||||
|
||||
if (!expr) {
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
ExprResult* exprResult = expr->evaluate(aPs->getEvalContext());
|
||||
if (!exprResult) {
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -379,7 +376,6 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
NodeSet* nodeSet = (NodeSet*)exprResult;
|
||||
if (nodeSet->isEmpty()) {
|
||||
delete nodeSet;
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -389,12 +385,11 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
while (child) {
|
||||
if (child->getNodeType() == Node::ELEMENT_NODE &&
|
||||
child->getNamespaceID() == kNameSpaceID_XSLT) {
|
||||
nsIAtom* childLocalName;
|
||||
child->getLocalName(&childLocalName);
|
||||
nsCOMPtr<nsIAtom> childLocalName;
|
||||
child->getLocalName(getter_AddRefs(childLocalName));
|
||||
if (childLocalName == txXSLTAtoms::sort) {
|
||||
sorter.addSortElement((Element*)child);
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(childLocalName);
|
||||
}
|
||||
child = child->getNextSibling();
|
||||
}
|
||||
@ -412,7 +407,6 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
rv = mode.init(modeStr, actionElement, MB_FALSE);
|
||||
if (NS_FAILED(rv)) {
|
||||
aPs->receiveError(NS_LITERAL_STRING("malformed mode-name in xsl:apply-templates"));
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -444,7 +438,6 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
if (!actionElement->getAttr(txXSLTAtoms::name,
|
||||
kNameSpaceID_None, nameAttr)) {
|
||||
aPs->receiveError(NS_LITERAL_STRING("missing required name attribute for xsl:attribute"), NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -457,18 +450,13 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
aPs->receiveError(NS_LITERAL_STRING("error processing xsl:attribute, ") +
|
||||
name + NS_LITERAL_STRING(" is not a valid QName."),
|
||||
NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
nsIAtom* nameAtom = TX_GET_ATOM(name);
|
||||
if (nameAtom == txXMLAtoms::xmlns) {
|
||||
TX_RELEASE_ATOM(nameAtom);
|
||||
if (TX_StringEqualsAtom(name, txXMLAtoms::xmlns)) {
|
||||
aPs->receiveError(NS_LITERAL_STRING("error processing xsl:attribute, name is xmlns."), NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(nameAtom);
|
||||
|
||||
// Determine namespace URI from the namespace attribute or
|
||||
// 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?
|
||||
if (resultNsID == kNameSpaceID_Unknown) {
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -546,13 +533,12 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
}
|
||||
|
||||
Element* xslTemplate = (Element*)condition;
|
||||
nsIAtom* conditionLocalName;
|
||||
condition->getLocalName(&conditionLocalName);
|
||||
nsCOMPtr<nsIAtom> conditionLocalName;
|
||||
condition->getLocalName(getter_AddRefs(conditionLocalName));
|
||||
if (conditionLocalName == txXSLTAtoms::when) {
|
||||
expr = aPs->getExpr(xslTemplate,
|
||||
ProcessorState::TestAttr);
|
||||
if (!expr) {
|
||||
TX_RELEASE_ATOM(conditionLocalName);
|
||||
condition = condition->getNextSibling();
|
||||
continue;
|
||||
}
|
||||
@ -569,7 +555,6 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
processChildren(xslTemplate, aPs);
|
||||
caseFound = MB_TRUE;
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(conditionLocalName);
|
||||
condition = condition->getNextSibling();
|
||||
} // end for-each child of xsl:choose
|
||||
}
|
||||
@ -597,7 +582,6 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
else if (localName == txXSLTAtoms::copyOf) {
|
||||
expr = aPs->getExpr(actionElement, ProcessorState::SelectAttr);
|
||||
if (!expr) {
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -611,7 +595,6 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
if (!actionElement->getAttr(txXSLTAtoms::name,
|
||||
kNameSpaceID_None, nameAttr)) {
|
||||
aPs->receiveError(NS_LITERAL_STRING("missing required name attribute for xsl:element"), NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -626,7 +609,6 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
NS_ERROR_FAILURE);
|
||||
// XXX We should processChildren without creating attributes or
|
||||
// namespace nodes.
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -654,7 +636,6 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
NS_ERROR_FAILURE);
|
||||
// XXX We should processChildren without creating attributes or
|
||||
// namespace nodes.
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -669,13 +650,11 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
else if (localName == txXSLTAtoms::forEach) {
|
||||
expr = aPs->getExpr(actionElement, ProcessorState::SelectAttr);
|
||||
if (!expr) {
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
ExprResult* exprResult = expr->evaluate(aPs->getEvalContext());
|
||||
if (!exprResult) {
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -683,7 +662,6 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
NodeSet* nodeSet = (NodeSet*)exprResult;
|
||||
if (nodeSet->isEmpty()) {
|
||||
delete nodeSet;
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
txNodeSetContext evalContext(nodeSet, aPs);
|
||||
@ -696,16 +674,14 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
while (child) {
|
||||
unsigned short nodeType = child->getNodeType();
|
||||
if (nodeType == Node::ELEMENT_NODE) {
|
||||
nsIAtom* childLocalName;
|
||||
child->getLocalName(&childLocalName);
|
||||
nsCOMPtr<nsIAtom> childLocalName;
|
||||
child->getLocalName(getter_AddRefs(childLocalName));
|
||||
if (child->getNamespaceID() != kNameSpaceID_XSLT ||
|
||||
childLocalName != txXSLTAtoms::sort) {
|
||||
// xsl:sort must occur first
|
||||
TX_IF_RELEASE_ATOM(childLocalName);
|
||||
break;
|
||||
}
|
||||
sorter.addSortElement((Element*)child);
|
||||
TX_RELEASE_ATOM(childLocalName);
|
||||
}
|
||||
else if ((nodeType == Node::TEXT_NODE ||
|
||||
nodeType == Node::CDATA_SECTION_NODE) &&
|
||||
@ -741,13 +717,11 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
else if (localName == txXSLTAtoms::_if) {
|
||||
expr = aPs->getExpr(actionElement, ProcessorState::TestAttr);
|
||||
if (!expr) {
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
ExprResult* exprResult = expr->evaluate(aPs->getEvalContext());
|
||||
if (!exprResult) {
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -782,7 +756,6 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
if (!actionElement->getAttr(txXSLTAtoms::name,
|
||||
kNameSpaceID_None, nameAttr)) {
|
||||
aPs->receiveError(NS_LITERAL_STRING("missing required name attribute for xsl:processing-instruction"), NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -834,7 +807,6 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
else if (localName == txXSLTAtoms::valueOf) {
|
||||
expr = aPs->getExpr(actionElement, ProcessorState::SelectAttr);
|
||||
if (!expr) {
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -843,7 +815,6 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
if (!exprResult) {
|
||||
aPs->receiveError(NS_LITERAL_STRING("null ExprResult"),
|
||||
NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
exprResult->stringValue(value);
|
||||
@ -875,12 +846,10 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
if (NS_FAILED(rv)) {
|
||||
aPs->receiveError(NS_LITERAL_STRING("bad name for xsl:variable"),
|
||||
NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
ExprResult* exprResult = processVariable(actionElement, aPs);
|
||||
if (!exprResult) {
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -892,7 +861,6 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||
NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1125,10 +1093,9 @@ txXSLTProcessor::processParameters(Element* aAction,
|
||||
while (tmpNode) {
|
||||
if (tmpNode->getNodeType() == Node::ELEMENT_NODE &&
|
||||
tmpNode->getNamespaceID() == kNameSpaceID_XSLT) {
|
||||
nsIAtom* localName;
|
||||
tmpNode->getLocalName(&localName);
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
tmpNode->getLocalName(getter_AddRefs(localName));
|
||||
if (localName != txXSLTAtoms::withParam) {
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
tmpNode = tmpNode->getNextSibling();
|
||||
continue;
|
||||
}
|
||||
@ -1156,7 +1123,6 @@ txXSLTProcessor::processParameters(Element* aAction,
|
||||
NS_ERROR_FAILURE);
|
||||
return rv;
|
||||
}
|
||||
TX_RELEASE_ATOM(localName);
|
||||
}
|
||||
tmpNode = tmpNode->getNextSibling();
|
||||
}
|
||||
@ -1189,9 +1155,9 @@ txXSLTProcessor::processStylesheet(Document* aStylesheet,
|
||||
|
||||
Element* elem = aStylesheet->getDocumentElement();
|
||||
|
||||
nsIAtom* localName;
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
PRInt32 namespaceID = elem->getNamespaceID();
|
||||
elem->getLocalName(&localName);
|
||||
elem->getLocalName(getter_AddRefs(localName));
|
||||
|
||||
if (((localName == txXSLTAtoms::stylesheet) ||
|
||||
(localName == txXSLTAtoms::transform)) &&
|
||||
@ -1201,13 +1167,11 @@ txXSLTProcessor::processStylesheet(Document* aStylesheet,
|
||||
else {
|
||||
NS_ASSERTION(aImportFrame->current(), "no current importframe");
|
||||
if (!aImportFrame->current()) {
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
return;
|
||||
}
|
||||
aPs->addLREStylesheet(aStylesheet,
|
||||
(ProcessorState::ImportFrame*)aImportFrame->current());
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1228,14 +1192,12 @@ txXSLTProcessor::processTemplate(Node* aTemplate,
|
||||
while (tmpNode) {
|
||||
int nodeType = tmpNode->getNodeType();
|
||||
if (nodeType == Node::ELEMENT_NODE) {
|
||||
nsIAtom* localName;
|
||||
tmpNode->getLocalName(&localName);
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
tmpNode->getLocalName(getter_AddRefs(localName));
|
||||
if (tmpNode->getNamespaceID() != kNameSpaceID_XSLT ||
|
||||
localName != txXSLTAtoms::param) {
|
||||
TX_RELEASE_ATOM(localName);
|
||||
break;
|
||||
}
|
||||
TX_RELEASE_ATOM(localName);
|
||||
|
||||
Element* action = (Element*)tmpNode;
|
||||
txExpandedName paramName;
|
||||
@ -1319,8 +1281,8 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
|
||||
Node* node = aStylesheet->getFirstChild();
|
||||
while (node && !importsDone) {
|
||||
if (node->getNodeType() == Node::ELEMENT_NODE) {
|
||||
nsIAtom* localName;
|
||||
node->getLocalName(&localName);
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
node->getLocalName(getter_AddRefs(localName));
|
||||
if (node->getNamespaceID() == kNameSpaceID_XSLT &&
|
||||
localName == txXSLTAtoms::import) {
|
||||
Element* element = (Element*)node;
|
||||
@ -1352,7 +1314,6 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
|
||||
else {
|
||||
importsDone = MB_TRUE;
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
}
|
||||
if (!importsDone)
|
||||
node = node->getNextSibling();
|
||||
@ -1365,8 +1326,8 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
|
||||
continue;
|
||||
}
|
||||
|
||||
nsIAtom* localName;
|
||||
node->getLocalName(&localName);
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
node->getLocalName(getter_AddRefs(localName));
|
||||
Element* element = (Element*)node;
|
||||
// xsl:attribute-set
|
||||
if (localName == txXSLTAtoms::attributeSet) {
|
||||
@ -1585,7 +1546,6 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
|
||||
currentFrame);
|
||||
}
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
node = node->getNextSibling();
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,6 @@ ExprResult* CurrentFunctionCall::evaluate(txIEvalContext* aContext)
|
||||
nsresult CurrentFunctionCall::getNameAtom(nsIAtom** aAtom)
|
||||
{
|
||||
*aAtom = txXSLTAtoms::current;
|
||||
TX_ADDREF_ATOM(*aAtom);
|
||||
NS_ADDREF(*aAtom);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -131,6 +131,6 @@ ExprResult* DocumentFunctionCall::evaluate(txIEvalContext* aContext)
|
||||
nsresult DocumentFunctionCall::getNameAtom(nsIAtom** aAtom)
|
||||
{
|
||||
*aAtom = txXSLTAtoms::document;
|
||||
TX_ADDREF_ATOM(*aAtom);
|
||||
NS_ADDREF(*aAtom);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -136,6 +136,6 @@ ExprResult* ElementAvailableFunctionCall::evaluate(txIEvalContext* aContext)
|
||||
nsresult ElementAvailableFunctionCall::getNameAtom(nsIAtom** aAtom)
|
||||
{
|
||||
*aAtom = txXSLTAtoms::elementAvailable;
|
||||
TX_ADDREF_ATOM(*aAtom);
|
||||
NS_ADDREF(*aAtom);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -135,6 +135,6 @@ ExprResult* FunctionAvailableFunctionCall::evaluate(txIEvalContext* aContext)
|
||||
nsresult FunctionAvailableFunctionCall::getNameAtom(nsIAtom** aAtom)
|
||||
{
|
||||
*aAtom = txXSLTAtoms::functionAvailable;
|
||||
TX_ADDREF_ATOM(*aAtom);
|
||||
NS_ADDREF(*aAtom);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -96,6 +96,6 @@ ExprResult* GenerateIdFunctionCall::evaluate(txIEvalContext* aContext)
|
||||
nsresult GenerateIdFunctionCall::getNameAtom(nsIAtom** aAtom)
|
||||
{
|
||||
*aAtom = txXSLTAtoms::generateId;
|
||||
TX_ADDREF_ATOM(*aAtom);
|
||||
NS_ADDREF(*aAtom);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -67,6 +67,6 @@ ExprResult* SystemPropertyFunctionCall::evaluate(txIEvalContext* aContext)
|
||||
nsresult SystemPropertyFunctionCall::getNameAtom(nsIAtom** aAtom)
|
||||
{
|
||||
*aAtom = txXSLTAtoms::systemProperty;
|
||||
TX_ADDREF_ATOM(*aAtom);
|
||||
NS_ADDREF(*aAtom);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
||||
nsresult txFormatNumberFunctionCall::getNameAtom(nsIAtom** aAtom)
|
||||
{
|
||||
*aAtom = txXSLTAtoms::formatNumber;
|
||||
TX_ADDREF_ATOM(*aAtom);
|
||||
NS_ADDREF(*aAtom);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ ExprResult* txKeyFunctionCall::evaluate(txIEvalContext* aContext)
|
||||
nsresult txKeyFunctionCall::getNameAtom(nsIAtom** aAtom)
|
||||
{
|
||||
*aAtom = txXSLTAtoms::key;
|
||||
TX_ADDREF_ATOM(*aAtom);
|
||||
NS_ADDREF(*aAtom);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ void txHTMLOutput::attribute(const nsAString& aName,
|
||||
localPart.Equals(aValue, txCaseInsensitiveStringComparator())) {
|
||||
txListIterator iter(&mAttributes);
|
||||
txAttribute* setAtt = 0;
|
||||
nsIAtom* localName = TX_GET_ATOM(localPart);
|
||||
nsCOMPtr<nsIAtom> localName = do_GetAtom(localPart);
|
||||
txExpandedName att(aNsID, localName);
|
||||
while ((setAtt = (txAttribute*)iter.next())) {
|
||||
if (setAtt->mName == att) {
|
||||
@ -229,7 +229,6 @@ void txHTMLOutput::attribute(const nsAString& aName,
|
||||
setAtt->mShorthand = MB_TRUE;
|
||||
mAttributes.add(setAtt);
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
}
|
||||
}
|
||||
if (!shortHand)
|
||||
@ -304,18 +303,17 @@ void txHTMLOutput::startElement(const nsAString& aName,
|
||||
{
|
||||
txXMLOutput::startElement(aName, aNsID);
|
||||
|
||||
nsIAtom* localAtom;
|
||||
nsCOMPtr<nsIAtom> localAtom;
|
||||
if (aNsID == kNameSpaceID_None) {
|
||||
nsAutoString localName;
|
||||
TX_ToLowerCase(aName, localName);
|
||||
localAtom = TX_GET_ATOM(localName);
|
||||
localAtom = do_GetAtom(localName);
|
||||
}
|
||||
else {
|
||||
localAtom = TX_GET_ATOM(aName);
|
||||
localAtom = do_GetAtom(aName);
|
||||
}
|
||||
NS_ASSERTION(localAtom, "Can't get atom");
|
||||
txExpandedName* currentElement = new txExpandedName(aNsID, localAtom);
|
||||
TX_IF_RELEASE_ATOM(localAtom);
|
||||
NS_ASSERTION(currentElement, "Can't create currentElement");
|
||||
if (currentElement)
|
||||
mCurrentElements.push(currentElement);
|
||||
|
@ -262,15 +262,14 @@ nsresult txPatternParser::createKeyPattern(ExprLexer& aLexer,
|
||||
|
||||
if (!XMLUtils::isValidQName(key))
|
||||
return NS_ERROR_XPATH_PARSE_FAILED;
|
||||
nsIAtom *prefix = 0, *localName = 0;
|
||||
nsCOMPtr<nsIAtom> prefix, localName;
|
||||
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))
|
||||
return rv;
|
||||
|
||||
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;
|
||||
}
|
||||
@ -302,9 +301,10 @@ nsresult txPatternParser::createStepPattern(ExprLexer& aLexer,
|
||||
txNodeTest* nodeTest = 0;
|
||||
if (tok->type == Token::CNAME) {
|
||||
// resolve QName
|
||||
nsIAtom *prefix, *lName;
|
||||
nsCOMPtr<nsIAtom> prefix, lName;
|
||||
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)) {
|
||||
// XXX error report namespace resolve failed
|
||||
return rv;
|
||||
@ -317,8 +317,6 @@ nsresult txPatternParser::createStepPattern(ExprLexer& aLexer,
|
||||
nodeTest = new txNameTest(prefix, lName, nspace,
|
||||
Node::ELEMENT_NODE);
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(prefix);
|
||||
TX_IF_RELEASE_ATOM(lName);
|
||||
if (!nodeTest) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -246,9 +246,8 @@ void txXMLOutput::startElement(const nsAString& aName,
|
||||
mCDATASections.push((void*)mInCDATASection);
|
||||
mInCDATASection = MB_FALSE;
|
||||
|
||||
nsIAtom* localName = TX_GET_ATOM(aName);
|
||||
nsCOMPtr<nsIAtom> localName = do_GetAtom(aName);
|
||||
txExpandedName currentElement(aNsID, localName);
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
txListIterator iter(&(mOutputFormat.mCDATASectionElements));
|
||||
while (iter.hasNext()) {
|
||||
if (currentElement == *(txExpandedName*)iter.next()) {
|
||||
|
@ -150,12 +150,11 @@ nsresult txXSLTNumber::getValueList(Element* aNumberElement,
|
||||
switch (currNode->getNodeType()) {
|
||||
case Node::ELEMENT_NODE:
|
||||
{
|
||||
nsIAtom* localName = 0;
|
||||
currNode->getLocalName(&localName);
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
currNode->getLocalName(getter_AddRefs(localName));
|
||||
nodeTest = new txNameTest(0, localName,
|
||||
currNode->getNamespaceID(),
|
||||
Node::ELEMENT_NODE);
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
break;
|
||||
}
|
||||
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
|
||||
|
||||
nsAutoString levelStr;
|
||||
nsIAtom* level = 0;
|
||||
nsCOMPtr<nsIAtom> level;
|
||||
if (aNumberElement->getAttr(txXSLTAtoms::level, kNameSpaceID_None, levelStr)) {
|
||||
level = TX_GET_ATOM(levelStr);
|
||||
level = do_GetAtom(levelStr);
|
||||
}
|
||||
|
||||
// level = "single"
|
||||
@ -325,7 +324,6 @@ nsresult txXSLTNumber::getValueList(Element* aNumberElement,
|
||||
if (ownsCountPattern) {
|
||||
delete countPattern;
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(level);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -456,11 +456,11 @@ void txKeyPattern::toString(nsAString& aDest)
|
||||
aDest.Append(NS_LITERAL_STRING("key('"));
|
||||
nsAutoString tmp;
|
||||
if (mPrefix) {
|
||||
TX_GET_ATOM_STRING(mPrefix, tmp);
|
||||
mPrefix->ToString(tmp);
|
||||
aDest.Append(tmp);
|
||||
aDest.Append(PRUnichar(':'));
|
||||
}
|
||||
TX_GET_ATOM_STRING(mName.mLocalName, tmp);
|
||||
mName.mLocalName->ToString(tmp);
|
||||
aDest.Append(tmp);
|
||||
aDest.Append(NS_LITERAL_STRING(", "));
|
||||
aDest.Append(mValue);
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
#include "baseutils.h"
|
||||
#include "List.h"
|
||||
#include "txAtom.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
class Element;
|
||||
class Expr;
|
||||
|
Loading…
Reference in New Issue
Block a user