Bug 939970 - Only convert XPath result to type requested. r=sicking.

--HG--
extra : rebase_source : 9cec2445b10b477244de9b7eebba573c39860442
This commit is contained in:
Peter Van der Beken 2013-11-26 13:48:44 +01:00
parent ce61bc6fe4
commit efb96cc475

View File

@ -258,6 +258,8 @@ nsresult
nsXPathResult::SetExprResult(txAExprResult* aExprResult, uint16_t aResultType,
nsINode* aContextNode)
{
MOZ_ASSERT(aExprResult);
if ((isSnapshot(aResultType) || isIterator(aResultType) ||
isNode(aResultType)) &&
aExprResult->getResultType() != txAExprResult::NODESET) {
@ -279,11 +281,29 @@ nsXPathResult::SetExprResult(txAExprResult* aExprResult, uint16_t aResultType,
// XXX This will keep the recycler alive, should we clear it?
mResult = aExprResult;
mBooleanResult = mResult->booleanValue();
mNumberResult = mResult->numberValue();
mResult->stringValue(mStringResult);
switch (mResultType) {
case BOOLEAN_TYPE:
{
mBooleanResult = mResult->booleanValue();
break;
}
case NUMBER_TYPE:
{
mNumberResult = mResult->numberValue();
break;
}
case STRING_TYPE:
{
mResult->stringValue(mStringResult);
break;
}
default:
{
MOZ_ASSERT(isNode() || isIterator() || isSnapshot());
}
}
if (aExprResult && aExprResult->getResultType() == txAExprResult::NODESET) {
if (aExprResult->getResultType() == txAExprResult::NODESET) {
txNodeSet *nodeSet = static_cast<txNodeSet*>(aExprResult);
nsCOMPtr<nsIDOMNode> node;
int32_t i, count = nodeSet->size();