2010-07-21 15:05:23 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set ts=4 et sw=4 tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Implementation of DOM Traversal's nsIDOMTreeWalker
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsTreeWalker.h"
|
|
|
|
|
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIDOMNodeFilter.h"
|
2012-07-27 07:03:27 -07:00
|
|
|
#include "nsError.h"
|
2011-07-20 12:18:54 -07:00
|
|
|
#include "nsINode.h"
|
2012-07-20 09:42:08 -07:00
|
|
|
#include "nsDOMClassInfoID.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsContentUtils.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Factories, constructors and destructors
|
|
|
|
*/
|
|
|
|
|
|
|
|
nsTreeWalker::nsTreeWalker(nsINode *aRoot,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aWhatToShow,
|
2012-01-25 04:47:50 -08:00
|
|
|
nsIDOMNodeFilter *aFilter) :
|
|
|
|
nsTraversal(aRoot, aWhatToShow, aFilter),
|
2010-07-21 15:05:23 -07:00
|
|
|
mCurrentNode(aRoot)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTreeWalker::~nsTreeWalker()
|
|
|
|
{
|
|
|
|
/* destructor code */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-08-28 16:42:41 -07:00
|
|
|
* nsISupports and cycle collection stuff
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
|
2007-08-28 16:42:41 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_3(nsTreeWalker, mFilter, mCurrentNode, mRoot)
|
|
|
|
|
2010-01-12 05:08:43 -08:00
|
|
|
DOMCI_DATA(TreeWalker, nsTreeWalker)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// QueryInterface implementation for nsTreeWalker
|
2007-08-28 16:42:41 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTreeWalker)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMTreeWalker)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMTreeWalker)
|
2010-03-17 08:09:05 -07:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(TreeWalker)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2007-08-28 16:42:41 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsTreeWalker)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTreeWalker)
|
|
|
|
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* nsIDOMTreeWalker Getters/Setters
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* readonly attribute nsIDOMNode root; */
|
|
|
|
NS_IMETHODIMP nsTreeWalker::GetRoot(nsIDOMNode * *aRoot)
|
|
|
|
{
|
|
|
|
if (mRoot) {
|
|
|
|
return CallQueryInterface(mRoot, aRoot);
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
*aRoot = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute unsigned long whatToShow; */
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHODIMP nsTreeWalker::GetWhatToShow(uint32_t *aWhatToShow)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*aWhatToShow = mWhatToShow;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute nsIDOMNodeFilter filter; */
|
|
|
|
NS_IMETHODIMP nsTreeWalker::GetFilter(nsIDOMNodeFilter * *aFilter)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aFilter);
|
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
NS_IF_ADDREF(*aFilter = mFilter);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute boolean expandEntityReferences; */
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsTreeWalker::GetExpandEntityReferences(bool *aExpandEntityReferences)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-01-25 04:47:50 -08:00
|
|
|
*aExpandEntityReferences = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* attribute nsIDOMNode currentNode; */
|
|
|
|
NS_IMETHODIMP nsTreeWalker::GetCurrentNode(nsIDOMNode * *aCurrentNode)
|
|
|
|
{
|
|
|
|
if (mCurrentNode) {
|
|
|
|
return CallQueryInterface(mCurrentNode, aCurrentNode);
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
*aCurrentNode = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP nsTreeWalker::SetCurrentNode(nsIDOMNode * aCurrentNode)
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(aCurrentNode, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
2012-04-03 00:25:38 -07:00
|
|
|
NS_ENSURE_TRUE(mRoot, NS_ERROR_UNEXPECTED);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-03-22 13:45:11 -07:00
|
|
|
nsCOMPtr<nsINode> node = do_QueryInterface(aCurrentNode);
|
2012-04-03 00:25:38 -07:00
|
|
|
NS_ENSURE_TRUE(node, NS_ERROR_UNEXPECTED);
|
|
|
|
|
|
|
|
nsresult rv = nsContentUtils::CheckSameOrigin(mRoot, node);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-03-22 13:45:11 -07:00
|
|
|
mCurrentNode.swap(node);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* nsIDOMTreeWalker functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* nsIDOMNode parentNode (); */
|
|
|
|
NS_IMETHODIMP nsTreeWalker::ParentNode(nsIDOMNode **_retval)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*_retval = nullptr;
|
2010-07-21 15:05:23 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsINode> node = mCurrentNode;
|
2010-07-21 15:05:23 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
while (node && node != mRoot) {
|
|
|
|
node = node->GetNodeParent();
|
|
|
|
|
|
|
|
if (node) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t filtered;
|
2007-03-22 10:30:00 -07:00
|
|
|
rv = TestNode(node, &filtered);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (filtered == nsIDOMNodeFilter::FILTER_ACCEPT) {
|
|
|
|
mCurrentNode = node;
|
|
|
|
return CallQueryInterface(node, _retval);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* nsIDOMNode firstChild (); */
|
|
|
|
NS_IMETHODIMP nsTreeWalker::FirstChild(nsIDOMNode **_retval)
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
return FirstChildInternal(false, _retval);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* nsIDOMNode lastChild (); */
|
|
|
|
NS_IMETHODIMP nsTreeWalker::LastChild(nsIDOMNode **_retval)
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
return FirstChildInternal(true, _retval);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* nsIDOMNode previousSibling (); */
|
|
|
|
NS_IMETHODIMP nsTreeWalker::PreviousSibling(nsIDOMNode **_retval)
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
return NextSiblingInternal(true, _retval);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* nsIDOMNode nextSibling (); */
|
|
|
|
NS_IMETHODIMP nsTreeWalker::NextSibling(nsIDOMNode **_retval)
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
return NextSiblingInternal(false, _retval);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* nsIDOMNode previousNode (); */
|
|
|
|
NS_IMETHODIMP nsTreeWalker::PreviousNode(nsIDOMNode **_retval)
|
|
|
|
{
|
2010-07-21 15:05:23 -07:00
|
|
|
nsresult rv;
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t filtered;
|
2010-07-21 15:05:23 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
*_retval = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
nsCOMPtr<nsINode> node = mCurrentNode;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
while (node != mRoot) {
|
|
|
|
while (nsINode *previousSibling = node->GetPreviousSibling()) {
|
|
|
|
node = previousSibling;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
rv = TestNode(node, &filtered);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
nsINode *lastChild;
|
|
|
|
while (filtered != nsIDOMNodeFilter::FILTER_REJECT &&
|
|
|
|
(lastChild = node->GetLastChild())) {
|
|
|
|
node = lastChild;
|
|
|
|
rv = TestNode(node, &filtered);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
if (filtered == nsIDOMNodeFilter::FILTER_ACCEPT) {
|
|
|
|
mCurrentNode = node;
|
|
|
|
return CallQueryInterface(node, _retval);
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
if (node == mRoot)
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
node = node->GetNodeParent();
|
|
|
|
if (!node)
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
rv = TestNode(node, &filtered);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (filtered == nsIDOMNodeFilter::FILTER_ACCEPT) {
|
|
|
|
mCurrentNode = node;
|
|
|
|
return CallQueryInterface(node, _retval);
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
/* nsIDOMNode nextNode (); */
|
|
|
|
NS_IMETHODIMP nsTreeWalker::NextNode(nsIDOMNode **_retval)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult rv;
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t filtered = nsIDOMNodeFilter::FILTER_ACCEPT; // pre-init for inner loop
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
*_retval = nullptr;
|
2010-07-21 15:05:23 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsINode> node = mCurrentNode;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
while (1) {
|
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
nsINode *firstChild;
|
|
|
|
while (filtered != nsIDOMNodeFilter::FILTER_REJECT &&
|
|
|
|
(firstChild = node->GetFirstChild())) {
|
|
|
|
node = firstChild;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
rv = TestNode(node, &filtered);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
if (filtered == nsIDOMNodeFilter::FILTER_ACCEPT) {
|
|
|
|
// Node found
|
|
|
|
mCurrentNode = node;
|
|
|
|
return CallQueryInterface(node, _retval);
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
nsINode *sibling = nullptr;
|
2010-07-21 15:05:23 -07:00
|
|
|
nsINode *temp = node;
|
|
|
|
do {
|
|
|
|
if (temp == mRoot)
|
|
|
|
break;
|
|
|
|
|
|
|
|
sibling = temp->GetNextSibling();
|
|
|
|
if (sibling)
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
temp = temp->GetNodeParent();
|
|
|
|
} while (temp);
|
|
|
|
|
|
|
|
if (!sibling)
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
node = sibling;
|
|
|
|
|
|
|
|
// Found a sibling. Either ours or ancestor's
|
|
|
|
rv = TestNode(node, &filtered);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
if (filtered == nsIDOMNodeFilter::FILTER_ACCEPT) {
|
|
|
|
// Node found
|
|
|
|
mCurrentNode = node;
|
|
|
|
return CallQueryInterface(node, _retval);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-07-21 15:05:23 -07:00
|
|
|
* nsTreeWalker helper functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Implements FirstChild and LastChild which only vary in which direction
|
|
|
|
* they search.
|
|
|
|
* @param aReversed Controls whether we search forwards or backwards
|
|
|
|
* @param _retval Returned node. Null if no child is found
|
2007-03-22 10:30:00 -07:00
|
|
|
* @returns Errorcode
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult nsTreeWalker::FirstChildInternal(bool aReversed, nsIDOMNode **_retval)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult rv;
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t filtered;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
*_retval = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
nsCOMPtr<nsINode> node = aReversed ? mCurrentNode->GetLastChild()
|
|
|
|
: mCurrentNode->GetFirstChild();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
while (node) {
|
|
|
|
rv = TestNode(node, &filtered);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
switch (filtered) {
|
|
|
|
case nsIDOMNodeFilter::FILTER_ACCEPT:
|
|
|
|
// Node found
|
|
|
|
mCurrentNode = node;
|
|
|
|
return CallQueryInterface(node, _retval);
|
|
|
|
case nsIDOMNodeFilter::FILTER_SKIP: {
|
|
|
|
nsINode *child = aReversed ? node->GetLastChild()
|
|
|
|
: node->GetFirstChild();
|
|
|
|
if (child) {
|
|
|
|
node = child;
|
|
|
|
continue;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-07-21 15:05:23 -07:00
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-07-21 15:05:23 -07:00
|
|
|
case nsIDOMNodeFilter::FILTER_REJECT:
|
|
|
|
// Keep searching
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
do {
|
|
|
|
nsINode *sibling = aReversed ? node->GetPreviousSibling()
|
|
|
|
: node->GetNextSibling();
|
|
|
|
if (sibling) {
|
|
|
|
node = sibling;
|
|
|
|
break;
|
|
|
|
}
|
2011-01-15 11:00:50 -08:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
nsINode *parent = node->GetNodeParent();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
if (!parent || parent == mRoot || parent == mCurrentNode) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-15 11:00:50 -08:00
|
|
|
node = parent;
|
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
} while (node);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-07-21 15:05:23 -07:00
|
|
|
* Implements NextSibling and PreviousSibling which only vary in which
|
|
|
|
* direction they search.
|
|
|
|
* @param aReversed Controls whether we search forwards or backwards
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param _retval Returned node. Null if no child is found
|
|
|
|
* @returns Errorcode
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult nsTreeWalker::NextSiblingInternal(bool aReversed, nsIDOMNode **_retval)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult rv;
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t filtered;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
*_retval = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
nsCOMPtr<nsINode> node = mCurrentNode;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
if (node == mRoot)
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
while (1) {
|
2011-02-23 15:58:55 -08:00
|
|
|
nsINode* sibling = aReversed ? node->GetPreviousSibling()
|
|
|
|
: node->GetNextSibling();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
while (sibling) {
|
2011-02-23 15:58:55 -08:00
|
|
|
node = sibling;
|
|
|
|
|
|
|
|
rv = TestNode(node, &filtered);
|
2010-07-21 15:05:23 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-02-23 15:58:55 -08:00
|
|
|
if (filtered == nsIDOMNodeFilter::FILTER_ACCEPT) {
|
|
|
|
// Node found
|
|
|
|
mCurrentNode.swap(node);
|
|
|
|
return CallQueryInterface(mCurrentNode, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If rejected or no children, try a sibling
|
|
|
|
if (filtered == nsIDOMNodeFilter::FILTER_REJECT ||
|
|
|
|
!(sibling = aReversed ? node->GetLastChild()
|
|
|
|
: node->GetFirstChild())) {
|
|
|
|
sibling = aReversed ? node->GetPreviousSibling()
|
|
|
|
: node->GetNextSibling();
|
2010-07-21 15:05:23 -07:00
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
node = node->GetNodeParent();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
if (!node || node == mRoot)
|
2011-02-23 15:58:55 -08:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-21 15:05:23 -07:00
|
|
|
// Is parent transparent in filtered view?
|
|
|
|
rv = TestNode(node, &filtered);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (filtered == nsIDOMNodeFilter::FILTER_ACCEPT)
|
2011-02-23 15:58:55 -08:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|