Fix for bug 151002 (abstract the content by a treewalker). Patch by me, with parts by Pike and sicking. r=sicking, sr=jst.
git-svn-id: svn://10.0.0.236/trunk@149516 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "txAtoms.h"
|
||||
#include "txIXPathContext.h"
|
||||
#include "txStringUtils.h"
|
||||
#include "txXPathTreeWalker.h"
|
||||
|
||||
/**
|
||||
* Creates a default BooleanFunctionCall, which always evaluates to False
|
||||
@@ -71,27 +72,27 @@ BooleanFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
|
||||
if (!requireParams(1, 1, aContext))
|
||||
return NS_ERROR_XPATH_BAD_ARGUMENT_COUNT;
|
||||
|
||||
txXPathTreeWalker walker(aContext->getContextNode());
|
||||
|
||||
nsAutoString lang;
|
||||
Node* node = aContext->getContextNode();
|
||||
while (node) {
|
||||
if (node->getNodeType() == Node::ELEMENT_NODE) {
|
||||
Element* elem = (Element*)node;
|
||||
if (elem->getAttr(txXMLAtoms::lang,
|
||||
kNameSpaceID_XML, lang))
|
||||
break;
|
||||
}
|
||||
node = node->getParentNode();
|
||||
PRBool found;
|
||||
do {
|
||||
found = walker.getAttr(txXMLAtoms::lang, kNameSpaceID_XML,
|
||||
lang);
|
||||
} while (!found && walker.moveToParent());
|
||||
|
||||
if (!found) {
|
||||
aContext->recycler()->getBoolResult(PR_FALSE, aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MBool result = MB_FALSE;
|
||||
if (node) {
|
||||
nsAutoString arg;
|
||||
evaluateToString((Expr*)iter.next(), aContext, arg);
|
||||
result = arg.Equals(Substring(lang, 0, arg.Length()),
|
||||
txCaseInsensitiveStringComparator()) &&
|
||||
(lang.Length() == arg.Length() ||
|
||||
lang.CharAt(arg.Length()) == '-');
|
||||
}
|
||||
nsAutoString arg;
|
||||
evaluateToString((Expr*)iter.next(), aContext, arg);
|
||||
PRBool result = arg.Equals(Substring(lang, 0, arg.Length()),
|
||||
txCaseInsensitiveStringComparator()) &&
|
||||
(lang.Length() == arg.Length() ||
|
||||
lang.CharAt(arg.Length()) == '-');
|
||||
|
||||
aContext->recycler()->getBoolResult(result, aResult);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user