bug 98704, kill ContextState|ProcessorState|DOMHelper::getParentNode, r=sicking, peterv; sr=jst

This commit is contained in:
axel%pike.org 2005-11-02 07:36:57 +00:00
Родитель 3648055cf6
Коммит fc51a7858c
3 изменённых файлов: 16 добавлений и 22 удалений

Просмотреть файл

@ -78,14 +78,6 @@ public:
**/
virtual Stack* getNodeSetStack() = 0;
/**
* handles finding the parent of a node, since in DOM some
* nodes such as Attribute Nodes do not have parents
* @param node the Node to search for the parent of
* @return the parent of the given node, or null
**/
virtual Node* getParentNode(Node* node) = 0;
virtual MBool isStripSpaceAllowed(Node* node) = 0;
/**

Просмотреть файл

@ -68,14 +68,14 @@ ExprResult* LocationStep::evaluate(Node* context, ContextState* cs) {
Node* node = context;
switch (axisIdentifier) {
case ANCESTOR_AXIS :
node = cs->getParentNode(context);
node = context->getXPathParent();
//-- do not break here
case ANCESTOR_OR_SELF_AXIS :
while (node) {
if (nodeExpr->matches(node, context, cs)) {
nodes->add(node);
}
node = cs->getParentNode(node);
node = node->getXPathParent();
}
break;
case ATTRIBUTE_AXIS :
@ -99,11 +99,11 @@ ExprResult* LocationStep::evaluate(Node* context, ContextState* cs) {
case FOLLOWING_AXIS :
{
if ( node->getNodeType() == Node::ATTRIBUTE_NODE) {
node = cs->getParentNode(node);
node = node->getXPathParent();
fromDescendants(node, cs, nodes);
}
while (node && !node->getNextSibling()) {
node = cs->getParentNode(node);
node = node->getXPathParent();
}
while (node) {
node = node->getNextSibling();
@ -136,14 +136,14 @@ ExprResult* LocationStep::evaluate(Node* context, ContextState* cs) {
break;
case PARENT_AXIS :
{
Node* parent = cs->getParentNode(context);
Node* parent = context->getXPathParent();
if ( nodeExpr->matches(parent, context, cs) )
nodes->add(parent);
break;
}
case PRECEDING_AXIS :
while (node && !node->getPreviousSibling()) {
node = cs->getParentNode(node);
node = node->getXPathParent();
}
while (node) {
node = node->getPreviousSibling();
@ -241,13 +241,15 @@ void LocationStep::fromDescendantsRev(Node* context, ContextState* cs, NodeSet*
**/
MBool LocationStep::matches(Node* node, Node* context, ContextState* cs) {
if ( !nodeExpr ) return MB_FALSE;
if (!nodeExpr || !node)
return MB_FALSE;
if ( !nodeExpr->matches(node, context, cs) ) return MB_FALSE;
if (!nodeExpr->matches(node, context, cs))
return MB_FALSE;
MBool result = MB_TRUE;
if ( !isEmpty() ) {
NodeSet* nodes = (NodeSet*)evaluate(cs->getParentNode(node),cs);
if (!isEmpty()) {
NodeSet* nodes = (NodeSet*)evaluate(node->getXPathParent(),cs);
result = nodes->contains(node);
delete nodes;
}

Просмотреть файл

@ -218,7 +218,7 @@ MBool PathExpr::matches(Node* node, Node* context, ContextState* cs)
case ANCESTOR_OP:
{
Node* ancestor = node;
while ((ancestor = cs->getParentNode(ancestor))) {
while ((ancestor = ancestor->getXPathParent())) {
if (pxi->expr->matches(node, ancestor, cs))
return MB_TRUE;
}
@ -226,7 +226,7 @@ MBool PathExpr::matches(Node* node, Node* context, ContextState* cs)
}
case PARENT_OP:
{
Node* parent = cs->getParentNode(node);
Node* parent = node->getXPathParent();
if (parent) {
//-- make sure node is Document node
if (parent->getNodeType() == Node::DOCUMENT_NODE)
@ -262,7 +262,7 @@ MBool PathExpr::matches(Node* node, Node* context, ContextState* cs)
case ANCESTOR_OP:
{
Node* parent = tnode;
while ((parent = cs->getParentNode(parent))) {
while ((parent = parent->getXPathParent())) {
if (pxi->expr->matches(tnode, parent, cs))
tmpNodes.add(parent);
}
@ -270,7 +270,7 @@ MBool PathExpr::matches(Node* node, Node* context, ContextState* cs)
}
case PARENT_OP:
{
Node* parent = cs->getParentNode(tnode);
Node* parent = tnode->getXPathParent();
if (parent) {
//-- make sure we have a document node if necessary
if (!iter->hasPrevious())