зеркало из https://github.com/mozilla/pjs.git
Throw xforms-compute-exception on XPath parse errors. Bug 299280, r=aaronr+doronr, a=mkaply, NPOTB
This commit is contained in:
Родитель
b5db761ddf
Коммит
da9445627b
|
@ -410,50 +410,56 @@ nsXFormsUtils::EvaluateXPath(const nsAString &aExpression,
|
||||||
eval->CreateExpression(aExpression,
|
eval->CreateExpression(aExpression,
|
||||||
aResolverNode,
|
aResolverNode,
|
||||||
getter_AddRefs(expression));
|
getter_AddRefs(expression));
|
||||||
|
|
||||||
|
nsIDOMXPathResult *result = nsnull;
|
||||||
|
PRBool throwException = PR_FALSE;
|
||||||
if (!expression) {
|
if (!expression) {
|
||||||
const nsPromiseFlatString& flat = PromiseFlatString(aExpression);
|
const nsPromiseFlatString& flat = PromiseFlatString(aExpression);
|
||||||
const PRUnichar *strings[] = { flat.get() };
|
const PRUnichar *strings[] = { flat.get() };
|
||||||
nsXFormsUtils::ReportError(NS_LITERAL_STRING("exprParseError"),
|
nsXFormsUtils::ReportError(NS_LITERAL_STRING("exprParseError"),
|
||||||
strings, 1, aContextNode, nsnull);
|
strings, 1, aContextNode, nsnull);
|
||||||
return nsnull;
|
throwException = PR_TRUE;
|
||||||
}
|
} else {
|
||||||
|
nsCOMPtr<nsISupports> supResult;
|
||||||
|
nsresult rv = expression->EvaluateWithContext(aContextNode,
|
||||||
|
aContextPosition,
|
||||||
|
aContextSize,
|
||||||
|
aResultType,
|
||||||
|
nsnull,
|
||||||
|
getter_AddRefs(supResult));
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> supResult;
|
if (NS_SUCCEEDED(rv) && supResult) {
|
||||||
nsresult rv = expression->EvaluateWithContext(aContextNode,
|
/// @todo beaufour: This is somewhat "hackish". Hopefully, this will
|
||||||
aContextPosition,
|
/// improve when we integrate properly with Transformiix (XXX)
|
||||||
aContextSize,
|
/// @see http://bugzilla.mozilla.org/show_bug.cgi?id=265212
|
||||||
aResultType,
|
if (aSet) {
|
||||||
nsnull,
|
nsXFormsXPathParser parser;
|
||||||
getter_AddRefs(supResult));
|
nsXFormsXPathAnalyzer analyzer(eval, aResolverNode);
|
||||||
|
nsAutoPtr<nsXFormsXPathNode> xNode(parser.Parse(aExpression));
|
||||||
|
rv = analyzer.Analyze(aContextNode,
|
||||||
|
xNode,
|
||||||
|
expression,
|
||||||
|
&aExpression,
|
||||||
|
aSet,
|
||||||
|
aContextPosition,
|
||||||
|
aContextSize);
|
||||||
|
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||||
|
|
||||||
nsIDOMXPathResult *result = nsnull;
|
if (aIndexesUsed)
|
||||||
if (NS_SUCCEEDED(rv) && supResult) {
|
*aIndexesUsed = analyzer.IndexesUsed();
|
||||||
/// @todo beaufour: This is somewhat "hackish". Hopefully, this will
|
}
|
||||||
/// improve when we integrate properly with Transformiix (XXX)
|
CallQueryInterface(supResult, &result); // addrefs
|
||||||
/// @see http://bugzilla.mozilla.org/show_bug.cgi?id=265212
|
} else if (rv == NS_ERROR_XFORMS_CALCUATION_EXCEPTION) {
|
||||||
if (aSet) {
|
const nsPromiseFlatString& flat = PromiseFlatString(aExpression);
|
||||||
nsXFormsXPathParser parser;
|
const PRUnichar *strings[] = { flat.get() };
|
||||||
nsXFormsXPathAnalyzer analyzer(eval, aResolverNode);
|
nsXFormsUtils::ReportError(NS_LITERAL_STRING("exprEvaluateError"),
|
||||||
nsAutoPtr<nsXFormsXPathNode> xNode(parser.Parse(aExpression));
|
strings, 1, aContextNode, nsnull);
|
||||||
rv = analyzer.Analyze(aContextNode,
|
throwException = PR_TRUE;
|
||||||
xNode,
|
|
||||||
expression,
|
|
||||||
&aExpression,
|
|
||||||
aSet,
|
|
||||||
aContextPosition,
|
|
||||||
aContextSize);
|
|
||||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
|
||||||
|
|
||||||
if (aIndexesUsed)
|
|
||||||
*aIndexesUsed = analyzer.IndexesUsed();
|
|
||||||
}
|
}
|
||||||
CallQueryInterface(supResult, &result); // addrefs
|
|
||||||
}
|
}
|
||||||
else if (rv == NS_ERROR_XFORMS_CALCUATION_EXCEPTION) {
|
|
||||||
const nsPromiseFlatString& flat = PromiseFlatString(aExpression);
|
// Throw xforms-compute-exception
|
||||||
const PRUnichar *strings[] = { flat.get() };
|
if (throwException) {
|
||||||
nsXFormsUtils::ReportError(NS_LITERAL_STRING("exprEvaluateError"),
|
|
||||||
strings, 1, aContextNode, nsnull);
|
|
||||||
nsCOMPtr<nsIDOMElement> resolverElement = do_QueryInterface(aResolverNode);
|
nsCOMPtr<nsIDOMElement> resolverElement = do_QueryInterface(aResolverNode);
|
||||||
nsCOMPtr<nsIModelElementPrivate> modelPriv = nsXFormsUtils::GetModel(resolverElement);
|
nsCOMPtr<nsIModelElementPrivate> modelPriv = nsXFormsUtils::GetModel(resolverElement);
|
||||||
nsCOMPtr<nsIDOMNode> model = do_QueryInterface(modelPriv);
|
nsCOMPtr<nsIDOMNode> model = do_QueryInterface(modelPriv);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче