bug 98704, kill ContextState|ProcessorState|DOMHelper::getParentNode, r=sicking, peterv; sr=jst
git-svn-id: svn://10.0.0.236/trunk@102864 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -97,18 +97,6 @@ void DOMHelper::generateId(Node* node, String& dest) {
|
||||
|
||||
} //-- generateId
|
||||
|
||||
/**
|
||||
* Returns the parent of the given node. This method is available
|
||||
* mainly to compensate for the fact that Attr nodes in DOM 1.0
|
||||
* do not have parents. (Why??)
|
||||
* @param node the Node to return the parent of
|
||||
**/
|
||||
Node* DOMHelper::getParentNode(Node* node) {
|
||||
if (!node) return 0;
|
||||
return node->getXPathParent();
|
||||
} //-- getParentNode
|
||||
|
||||
|
||||
//-------------------/
|
||||
//- Private Methods -/
|
||||
//-------------------/
|
||||
@@ -163,7 +151,7 @@ OrderInfo* DOMHelper::getDocumentOrder(Node* node) {
|
||||
orderInfo->order[0] = 0;
|
||||
}
|
||||
else {
|
||||
Node* parent = getParentNode(node);
|
||||
Node* parent = node->getXPathParent();
|
||||
OrderInfo* parentOrder = getDocumentOrder(parent);
|
||||
orderInfo = new OrderInfo();
|
||||
|
||||
|
||||
@@ -98,14 +98,6 @@ public:
|
||||
**/
|
||||
int getChildNumber(Node* node);
|
||||
|
||||
/**
|
||||
* Returns the parent of the given node. This method is available
|
||||
* mainly to compensate for the fact that Attr nodes in DOM 1.0
|
||||
* do not have parents. (Why??)
|
||||
* @param node the Node to return the parent of
|
||||
**/
|
||||
Node* getParentNode(Node* node);
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
/*-*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
@@ -127,8 +128,10 @@ MBool AttributeExpr::matches(Node* node, Node* context, ContextState* cs) {
|
||||
nodeName.subString(idx+1, localName);
|
||||
if (isNamespaceWild) return localName.isEqual(this->name);
|
||||
String nsForNode;
|
||||
Node* parent = cs->getParentNode(node);
|
||||
if (parent) XMLDOMUtils::getNameSpace(prefixForNode, (Element*)parent, nsForNode);
|
||||
Node* parent = node->getXPathParent();
|
||||
if (parent)
|
||||
XMLDOMUtils::getNameSpace(prefixForNode, (Element*)parent,
|
||||
nsForNode);
|
||||
String nsForTest;
|
||||
if (prefix.length())
|
||||
cs->getNameSpaceURIFromPrefix(prefix, nsForTest);
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -754,18 +754,6 @@ Stack* ProcessorState::getNodeSetStack() {
|
||||
return &nodeSetStack;
|
||||
} //-- getNodeSetStack
|
||||
|
||||
/**
|
||||
* Returns the parent of the given Node. This method is needed
|
||||
* beacuse with the DOM some nodes such as Attr do not have parents
|
||||
* @param node the Node to find the parent of
|
||||
* @return the parent of the given Node, or null if not found
|
||||
**/
|
||||
Node* ProcessorState::getParentNode(Node* node) {
|
||||
|
||||
return domHelper.getParentNode(node);
|
||||
|
||||
} //-- getParentNode
|
||||
|
||||
/**
|
||||
* Returns the value of a given variable binding within the current scope
|
||||
* @param the name to which the desired variable value has been bound
|
||||
|
||||
@@ -289,14 +289,6 @@ public:
|
||||
//- Virtual Methods from ContextState -/
|
||||
//-------------------------------------/
|
||||
|
||||
/**
|
||||
* Returns the parent of the given Node. This method is needed
|
||||
* beacuse with the DOM some nodes such as Attr do not have parents
|
||||
* @param node the Node to find the parent of
|
||||
* @return the parent of the given Node, or null if not found
|
||||
**/
|
||||
virtual Node* getParentNode(Node* node);
|
||||
|
||||
/**
|
||||
* Returns the value of a given variable binding within the current scope
|
||||
* @param the name to which the desired variable value has been bound
|
||||
|
||||
@@ -1569,7 +1569,7 @@ void XSLTProcessor::processAttributeSets
|
||||
//-- an AttributeSet object, which will handle this case better. - Keith V.
|
||||
//-- Fix: handle use-attribute-set recursion - Marina M.
|
||||
if (attSet->size() > 0) {
|
||||
Element* parent = (Element*) ps->getParentNode(attSet->get(0));
|
||||
Element* parent = (Element*) attSet->get(0)->getXPathParent();
|
||||
processAttributeSets(parent->getAttribute(USE_ATTRIBUTE_SETS_ATTR),node, ps);
|
||||
}
|
||||
//-- End Fix
|
||||
|
||||
Reference in New Issue
Block a user