зеркало из https://github.com/mozilla/gecko-dev.git
Added some changes from Marina (see changes.txt)
This commit is contained in:
Родитель
1cfa374ce4
Коммит
96cc7b4153
|
@ -20,15 +20,18 @@
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Keith Visco, kvisco@ziplink.net
|
* Keith Visco, kvisco@ziplink.net
|
||||||
* -- original author.
|
* -- original author.
|
||||||
|
*
|
||||||
|
* Marina Mechtcheriakova, mmarina@mindspring.com
|
||||||
|
* -- changed some behavoir to be more compliant with spec
|
||||||
*
|
*
|
||||||
* $Id: NodeSetFunctionCall.cpp,v 1.1 2000/04/06 07:45:34 kvisco%ziplink.net Exp $
|
* $Id: NodeSetFunctionCall.cpp,v 1.2 2000/04/20 10:12:05 kvisco%ziplink.net Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NodeSetFunctionCall
|
* NodeSetFunctionCall
|
||||||
* A representation of the XPath NodeSet funtions
|
* A representation of the XPath NodeSet funtions
|
||||||
* @author <A HREF="mailto:kvisco@ziplink.net">Keith Visco</a>
|
* @author <A HREF="mailto:kvisco@ziplink.net">Keith Visco</a>
|
||||||
* @version $Revision: 1.1 $ $Date: 2000/04/06 07:45:34 $
|
* @version $Revision: 1.2 $ $Date: 2000/04/20 10:12:05 $
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include "FunctionLib.h"
|
#include "FunctionLib.h"
|
||||||
|
@ -129,7 +132,14 @@ ExprResult* NodeSetFunctionCall::evaluate(Node* context, ContextState* cs) {
|
||||||
}
|
}
|
||||||
delete exprResult;
|
delete exprResult;
|
||||||
}
|
}
|
||||||
if ( !node ) node = context;
|
//if ( !node ) node = context; ///Marina
|
||||||
|
else node = context;
|
||||||
|
|
||||||
|
//-- if no node was found just return an empty string (Marina)
|
||||||
|
if ( !node ) {
|
||||||
|
result = new StringResult("");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch ( type ) {
|
switch ( type ) {
|
||||||
case LOCAL_NAME :
|
case LOCAL_NAME :
|
||||||
|
|
|
@ -20,10 +20,16 @@
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Keith Visco, kvisco@ziplink.net
|
* Keith Visco, kvisco@ziplink.net
|
||||||
* -- original author.
|
* -- original author.
|
||||||
|
*
|
||||||
* Bob Miller, kbob@oblix.com
|
* Bob Miller, kbob@oblix.com
|
||||||
* -- plugged core leak.
|
* -- plugged core leak.
|
||||||
*
|
*
|
||||||
* $Id: PathExpr.cpp,v 1.1 2000/04/06 07:45:36 kvisco%ziplink.net Exp $
|
* Marina Mechtcheriakova, mmarina@mindspring.com
|
||||||
|
* -- fixed bug in PathExpr::matches
|
||||||
|
* - foo//bar would not match properly if there was more than
|
||||||
|
* one node in the NodeSet (nodes) on the final iteration
|
||||||
|
*
|
||||||
|
* $Id: PathExpr.cpp,v 1.2 2000/04/20 10:12:06 kvisco%ziplink.net Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Expr.h"
|
#include "Expr.h"
|
||||||
|
@ -209,18 +215,19 @@ MBool PathExpr::matches(Node* node, Node* context, ContextState* cs) {
|
||||||
if ( (!node) || (expressions.getLength() == 0))
|
if ( (!node) || (expressions.getLength() == 0))
|
||||||
return MB_FALSE;
|
return MB_FALSE;
|
||||||
|
|
||||||
NodeSet nodes;
|
NodeSet nodes(3);
|
||||||
|
NodeSet tmpNodes(3);
|
||||||
|
|
||||||
nodes.add(node);
|
nodes.add(node);
|
||||||
|
|
||||||
|
|
||||||
ListIterator* iter = expressions.iterator();
|
ListIterator* iter = expressions.iterator();
|
||||||
iter->reverse();
|
iter->reverse();
|
||||||
|
|
||||||
NodeSet tmpNodes;
|
|
||||||
MBool result = MB_FALSE;
|
|
||||||
while ( iter->hasNext() ) {
|
while ( iter->hasNext() ) {
|
||||||
|
|
||||||
PathExprItem* pxi = (PathExprItem*)iter->next();
|
PathExprItem* pxi = (PathExprItem*)iter->next();
|
||||||
|
|
||||||
for (int i = 0; i < nodes.size(); i++) {
|
for (int i = 0; i < nodes.size(); i++) {
|
||||||
|
|
||||||
Node* tnode = nodes.get(i);
|
Node* tnode = nodes.get(i);
|
||||||
|
@ -247,18 +254,35 @@ MBool PathExpr::matches(Node* node, Node* context, ContextState* cs) {
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if ( !iter->hasNext() ) {
|
if ( !iter->hasNext() ) {
|
||||||
result = pxi->pExpr->matches(tnode, context, cs);
|
|
||||||
|
/*
|
||||||
|
// PREVIOUS // result = pxi->pExpr->matches(tnode, context, cs);
|
||||||
|
// result was being overwritten if there was more than one
|
||||||
|
// node in nodes during the final iteration (Marina)
|
||||||
|
|
||||||
|
result = result || pxi->pExpr->matches(tnode, context, cs)
|
||||||
|
*/
|
||||||
|
|
||||||
|
//-- Just return true if we match here
|
||||||
|
if (pxi->pExpr->matches(tnode, context, cs)) {
|
||||||
|
delete iter;
|
||||||
|
return MB_TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//-- error in expression
|
//-- error in expression, will we ever see this?
|
||||||
tmpNodes.clear();
|
|
||||||
nodes.clear();
|
|
||||||
delete iter;
|
delete iter;
|
||||||
return MB_FALSE;
|
return MB_FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} //-- for
|
} //-- for
|
||||||
|
|
||||||
|
if (tmpNodes.size() == 0) {
|
||||||
|
delete iter;
|
||||||
|
return MB_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
nodes.clear();
|
nodes.clear();
|
||||||
tmpNodes.copyInto(nodes);
|
tmpNodes.copyInto(nodes);
|
||||||
tmpNodes.clear();
|
tmpNodes.clear();
|
||||||
|
@ -267,11 +291,15 @@ MBool PathExpr::matches(Node* node, Node* context, ContextState* cs) {
|
||||||
delete iter;
|
delete iter;
|
||||||
|
|
||||||
if ( this->isAbsolute()) {
|
if ( this->isAbsolute()) {
|
||||||
Node* doc = node->getOwnerDocument();
|
Node* doc = 0;
|
||||||
|
if (node->getNodeType() == Node::DOCUMENT_NODE)
|
||||||
|
doc = node;
|
||||||
|
else
|
||||||
|
doc = node->getOwnerDocument();
|
||||||
return (MBool) nodes.contains(doc);
|
return (MBool) nodes.contains(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (MBool) (result || (nodes.size() > 0));
|
return (MBool) (nodes.size() > 0);
|
||||||
|
|
||||||
} //-- matches
|
} //-- matches
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче