зеркало из https://github.com/mozilla/pjs.git
Fix for bug 279878 (Unknown extension function shouldn't stop processing unless called). r=sicking, sr=jst.
This commit is contained in:
Родитель
2002206eb8
Коммит
357fee1763
|
@ -263,11 +263,6 @@ PRBool nsXFormsXPathEvaluator::XFormsParseContextImpl::caseInsensitiveNameTests(
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsXFormsXPathEvaluator::XFormsParseContextImpl::fcp()
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsXFormsXPathEvaluator::XFormsParseContextImpl::SetErrorOffset(PRUint32 aOffset)
|
||||
{
|
||||
|
|
|
@ -1,102 +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 Mozilla XForms support.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Aaron Reed <aaronr@us.ibm.com>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#ifndef nsXFormsXPathEvaluator_h__
|
||||
#define nsXFormsXPathEvaluator_h__
|
||||
|
||||
#include "nsIXFormsXPathEvaluator.h"
|
||||
#include "txIXPathContext.h"
|
||||
#include "nsIXPathEvaluatorInternal.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "txResultRecycler.h"
|
||||
|
||||
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMXPathExpression;
|
||||
|
||||
/**
|
||||
* A class for evaluating an XPath expression string
|
||||
*/
|
||||
class nsXFormsXPathEvaluator : public nsIXFormsXPathEvaluator
|
||||
{
|
||||
public:
|
||||
nsXFormsXPathEvaluator();
|
||||
virtual ~nsXFormsXPathEvaluator();
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIXFormsXPathEvaluator interface
|
||||
NS_DECL_NSIXFORMXPATHEVALUATOR
|
||||
|
||||
private:
|
||||
// txIParseContext implementation
|
||||
class XFormsParseContextImpl : public txIParseContext
|
||||
{
|
||||
public:
|
||||
XFormsParseContextImpl(nsIDOMNode* aResolverNode)
|
||||
: mResolverNode(aResolverNode), mLastError(NS_OK)
|
||||
{
|
||||
}
|
||||
|
||||
~XFormsParseContextImpl()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult getError()
|
||||
{
|
||||
return mLastError;
|
||||
}
|
||||
|
||||
nsresult resolveNamespacePrefix(nsIAtom* aPrefix, PRInt32& aID);
|
||||
nsresult resolveFunctionCall(nsIAtom* aName, PRInt32 aID,
|
||||
FunctionCall*& aFunction);
|
||||
PRBool caseInsensitiveNameTests();
|
||||
PRBool fcp();
|
||||
void SetErrorOffset(PRUint32 aOffset);
|
||||
|
||||
private:
|
||||
nsIDOMNode* mResolverNode;
|
||||
nsresult mLastError;
|
||||
};
|
||||
|
||||
nsRefPtr<txResultRecycler> mRecycler;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -204,11 +204,6 @@ PRBool nsXPathEvaluator::ParseContextImpl::caseInsensitiveNameTests()
|
|||
return !mIsCaseSensitive;
|
||||
}
|
||||
|
||||
PRBool nsXPathEvaluator::ParseContextImpl::fcp()
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsXPathEvaluator::ParseContextImpl::SetErrorOffset(PRUint32 aOffset)
|
||||
{
|
||||
|
|
|
@ -92,7 +92,6 @@ private:
|
|||
nsresult resolveFunctionCall(nsIAtom* aName, PRInt32 aID,
|
||||
FunctionCall*& aFunction);
|
||||
PRBool caseInsensitiveNameTests();
|
||||
PRBool fcp();
|
||||
void SetErrorOffset(PRUint32 aOffset);
|
||||
|
||||
private:
|
||||
|
|
|
@ -575,12 +575,7 @@ txExprParser::createFunctionCall(txExprLexer& lexer, txIParseContext* aContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (rv == NS_ERROR_XPATH_UNKNOWN_FUNCTION && aContext->fcp()) {
|
||||
// Don't throw parse error, just error on evaluation
|
||||
fnCall = new txErrorFunctionCall(lName, namespaceID);
|
||||
NS_ENSURE_TRUE(fnCall, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
else if (NS_FAILED(rv)) {
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Creation of FunctionCall failed");
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -198,29 +198,3 @@ FunctionCall::toString(nsAString& aDest)
|
|||
aDest.Append(PRUnichar(')'));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Implementation of txErrorFunctionCall
|
||||
*
|
||||
* Used for fcp and unknown extension functions.
|
||||
*/
|
||||
|
||||
nsresult
|
||||
txErrorFunctionCall::evaluate(txIEvalContext* aContext,
|
||||
txAExprResult** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
return NS_ERROR_XPATH_BAD_EXTENSION_FUNCTION;
|
||||
}
|
||||
|
||||
#ifdef TX_TO_STRING
|
||||
nsresult
|
||||
txErrorFunctionCall::getNameAtom(nsIAtom** aAtom)
|
||||
{
|
||||
*aAtom = mLName;
|
||||
NS_IF_ADDREF(*aAtom);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -90,28 +90,6 @@ private:
|
|||
BooleanFunctions mType;
|
||||
}; //-- BooleanFunctionCall
|
||||
|
||||
/**
|
||||
* Error Function to be used for unknown extension functions and
|
||||
* forwards-compatible-processing (not implemented, bug XXX)
|
||||
*
|
||||
* txErrorFunctionCall returns NS_ERROR_XPATH_UNKNOWN_FUNCTION
|
||||
* (see FunctionCall.cpp)
|
||||
*/
|
||||
class txErrorFunctionCall : public FunctionCall
|
||||
{
|
||||
public:
|
||||
txErrorFunctionCall(nsIAtom* aLName, const PRInt32 aID)
|
||||
: mLName(aLName),
|
||||
mID(aID)
|
||||
{}
|
||||
|
||||
TX_DECL_FUNCTION;
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIAtom> mLName;
|
||||
PRInt32 mID;
|
||||
};
|
||||
|
||||
/*
|
||||
* A representation of the XPath NodeSet funtions
|
||||
*/
|
||||
|
|
|
@ -80,11 +80,6 @@ public:
|
|||
*/
|
||||
virtual PRBool caseInsensitiveNameTests() = 0;
|
||||
|
||||
/**
|
||||
* Should the expression be parsed in forwards compatible parsing mode
|
||||
*/
|
||||
virtual PRBool fcp() = 0;
|
||||
|
||||
/*
|
||||
* Callback to be used by the Parser if errors are detected.
|
||||
*/
|
||||
|
|
|
@ -855,72 +855,115 @@ txStylesheetCompilerState::resolveNamespacePrefix(nsIAtom* aPrefix,
|
|||
return (aID != kNameSpaceID_Unknown) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error Function to be used for unknown extension functions.
|
||||
*
|
||||
*/
|
||||
class txErrorFunctionCall : public FunctionCall
|
||||
{
|
||||
public:
|
||||
txErrorFunctionCall(nsIAtom* aName, const PRInt32 aID)
|
||||
: mName(aName),
|
||||
mID(aID)
|
||||
{
|
||||
}
|
||||
|
||||
TX_DECL_FUNCTION;
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIAtom> mName;
|
||||
PRInt32 mID;
|
||||
};
|
||||
|
||||
nsresult
|
||||
txErrorFunctionCall::evaluate(txIEvalContext* aContext,
|
||||
txAExprResult** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
return NS_ERROR_XPATH_BAD_EXTENSION_FUNCTION;
|
||||
}
|
||||
|
||||
#ifdef TX_TO_STRING
|
||||
nsresult
|
||||
txErrorFunctionCall::getNameAtom(nsIAtom** aAtom)
|
||||
{
|
||||
NS_IF_ADDREF(*aAtom = mName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
txStylesheetCompilerState::resolveFunctionCall(nsIAtom* aName, PRInt32 aID,
|
||||
FunctionCall*& aFunction)
|
||||
{
|
||||
aFunction = nsnull;
|
||||
aFunction = nsnull;
|
||||
|
||||
if (aID != kNameSpaceID_None) {
|
||||
return NS_ERROR_XPATH_UNKNOWN_FUNCTION;
|
||||
}
|
||||
if (aName == txXSLTAtoms::document) {
|
||||
aFunction = new DocumentFunctionCall(mElementContext->mBaseURI);
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
if (aID == kNameSpaceID_None) {
|
||||
if (aName == txXSLTAtoms::document) {
|
||||
aFunction = new DocumentFunctionCall(mElementContext->mBaseURI);
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (aName == txXSLTAtoms::key) {
|
||||
aFunction = new txKeyFunctionCall(mElementContext->mMappings);
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (aName == txXSLTAtoms::formatNumber) {
|
||||
aFunction = new txFormatNumberFunctionCall(mStylesheet,
|
||||
mElementContext->mMappings);
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (aName == txXSLTAtoms::current) {
|
||||
aFunction = new CurrentFunctionCall();
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (aName == txXSLTAtoms::unparsedEntityUri) {
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
if (aName == txXSLTAtoms::generateId) {
|
||||
aFunction = new GenerateIdFunctionCall();
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (aName == txXSLTAtoms::systemProperty) {
|
||||
aFunction = new SystemPropertyFunctionCall(mElementContext->mMappings);
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (aName == txXSLTAtoms::elementAvailable) {
|
||||
aFunction =
|
||||
new ElementAvailableFunctionCall(mElementContext->mMappings);
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (aName == txXSLTAtoms::functionAvailable) {
|
||||
aFunction =
|
||||
new FunctionAvailableFunctionCall(mElementContext->mMappings);
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (!fcp()) {
|
||||
return NS_ERROR_XPATH_UNKNOWN_FUNCTION;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (aName == txXSLTAtoms::key) {
|
||||
aFunction = new txKeyFunctionCall(mElementContext->mMappings);
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
aFunction = new txErrorFunctionCall(aName, aID);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (aName == txXSLTAtoms::formatNumber) {
|
||||
aFunction = new txFormatNumberFunctionCall(mStylesheet,
|
||||
mElementContext->mMappings);
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (aName == txXSLTAtoms::current) {
|
||||
aFunction = new CurrentFunctionCall();
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (aName == txXSLTAtoms::unparsedEntityUri) {
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
if (aName == txXSLTAtoms::generateId) {
|
||||
aFunction = new GenerateIdFunctionCall();
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (aName == txXSLTAtoms::systemProperty) {
|
||||
aFunction = new SystemPropertyFunctionCall(mElementContext->mMappings);
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (aName == txXSLTAtoms::elementAvailable) {
|
||||
aFunction =
|
||||
new ElementAvailableFunctionCall(mElementContext->mMappings);
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (aName == txXSLTAtoms::functionAvailable) {
|
||||
aFunction =
|
||||
new FunctionAvailableFunctionCall(mElementContext->mMappings);
|
||||
NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_XPATH_UNKNOWN_FUNCTION;
|
||||
return aFunction ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
@ -929,12 +972,6 @@ txStylesheetCompilerState::caseInsensitiveNameTests()
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
txStylesheetCompilerState::fcp()
|
||||
{
|
||||
return mElementContext->mForwardsCompatibleParsing;
|
||||
}
|
||||
|
||||
void
|
||||
txStylesheetCompilerState::SetErrorOffset(PRUint32 aOffset)
|
||||
{
|
||||
|
|
|
@ -142,7 +142,15 @@ public:
|
|||
nsresult resolveFunctionCall(nsIAtom* aName, PRInt32 aID,
|
||||
FunctionCall*& aFunction);
|
||||
PRBool caseInsensitiveNameTests();
|
||||
PRBool fcp();
|
||||
|
||||
/**
|
||||
* Should the stylesheet be parsed in forwards compatible parsing mode.
|
||||
*/
|
||||
PRBool fcp()
|
||||
{
|
||||
return mElementContext->mForwardsCompatibleParsing;
|
||||
}
|
||||
|
||||
void SetErrorOffset(PRUint32 aOffset);
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче