diff --git a/mozilla/extensions/transformiix/source/xml/util/DOMHelper.cpp b/mozilla/extensions/transformiix/source/xml/util/DOMHelper.cpp index 322c53cc7f5..15288f2fbb3 100644 --- a/mozilla/extensions/transformiix/source/xml/util/DOMHelper.cpp +++ b/mozilla/extensions/transformiix/source/xml/util/DOMHelper.cpp @@ -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(); diff --git a/mozilla/extensions/transformiix/source/xml/util/DOMHelper.h b/mozilla/extensions/transformiix/source/xml/util/DOMHelper.h index 77c3ff14492..2ddd52d79bc 100644 --- a/mozilla/extensions/transformiix/source/xml/util/DOMHelper.h +++ b/mozilla/extensions/transformiix/source/xml/util/DOMHelper.h @@ -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: /** diff --git a/mozilla/extensions/transformiix/source/xpath/AttributeExpr.cpp b/mozilla/extensions/transformiix/source/xpath/AttributeExpr.cpp index 671300d7bfd..5f84747a4a6 100644 --- a/mozilla/extensions/transformiix/source/xpath/AttributeExpr.cpp +++ b/mozilla/extensions/transformiix/source/xpath/AttributeExpr.cpp @@ -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); diff --git a/mozilla/extensions/transformiix/source/xpath/Expr.h b/mozilla/extensions/transformiix/source/xpath/Expr.h index 9ed1232f926..757d60f0916 100644 --- a/mozilla/extensions/transformiix/source/xpath/Expr.h +++ b/mozilla/extensions/transformiix/source/xpath/Expr.h @@ -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; /** diff --git a/mozilla/extensions/transformiix/source/xpath/LocationStep.cpp b/mozilla/extensions/transformiix/source/xpath/LocationStep.cpp index ca3e4df4913..db0e2e34152 100644 --- a/mozilla/extensions/transformiix/source/xpath/LocationStep.cpp +++ b/mozilla/extensions/transformiix/source/xpath/LocationStep.cpp @@ -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; } diff --git a/mozilla/extensions/transformiix/source/xpath/PathExpr.cpp b/mozilla/extensions/transformiix/source/xpath/PathExpr.cpp index 56358b6246a..7748a16e02d 100644 --- a/mozilla/extensions/transformiix/source/xpath/PathExpr.cpp +++ b/mozilla/extensions/transformiix/source/xpath/PathExpr.cpp @@ -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()) diff --git a/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp b/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp index ae378503fc2..af021573e98 100644 --- a/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp +++ b/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp @@ -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 diff --git a/mozilla/extensions/transformiix/source/xslt/ProcessorState.h b/mozilla/extensions/transformiix/source/xslt/ProcessorState.h index f8bb81cc0de..640163c89e8 100644 --- a/mozilla/extensions/transformiix/source/xslt/ProcessorState.h +++ b/mozilla/extensions/transformiix/source/xslt/ProcessorState.h @@ -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 diff --git a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp index 88843f6be55..e8d8e0e4782 100644 --- a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp +++ b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp @@ -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