Files
serge-sans-paille d58c18b09a Bug 2030235 - Decouple ServoStyleConsts from nsGkAtoms.h r=emilio,necko-reviewers,geckoview-reviewers,firefox-style-system-reviewers,firefox-svg-reviewers,layout-reviewers,kershaw,m_kato
And remove unused includes of nsGkAtoms.h in the process. The few
dependencies have been moved to ServoStyleConstsInlines.h

The used command to remove the now unused dependency was:

git grep -l nsGkAtoms.h | while read line; do grep -v nsGkAtoms.h $line | grep -q -E '\<nsGkAtoms\>' || sed -i -e '/nsGkAtoms.h/d' $line  ; done

Differential Revision: https://phabricator.services.mozilla.com/D292697
2026-04-09 10:05:25 +00:00

63 lines
1.8 KiB
C++

/*
* 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/. */
#include "nsTraversal.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/dom/NodeFilterBinding.h"
#include "nsError.h"
#include "nsINode.h"
using namespace mozilla;
using namespace mozilla::dom;
nsTraversal::nsTraversal(nsINode* aRoot, uint32_t aWhatToShow,
NodeFilter* aFilter)
: mRoot(aRoot),
mWhatToShow(aWhatToShow),
mFilter(aFilter),
mInAcceptNode(false) {
NS_ASSERTION(aRoot, "invalid root in call to nsTraversal constructor");
}
nsTraversal::~nsTraversal() = default;
/*
* Tests if and how a node should be filtered. Uses mWhatToShow and
* mFilter to test the node.
* @param aNode Node to test
* @param aResult Whether we succeeded
* @returns Filtervalue. See NodeFilter.webidl
*/
int16_t nsTraversal::TestNode(nsINode* aNode, mozilla::ErrorResult& aResult,
nsCOMPtr<nsINode>* aUnskippedNode) {
if (mInAcceptNode) {
aResult.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return 0;
}
uint16_t nodeType = aNode->NodeType();
if (nodeType <= 12 && !((1 << (nodeType - 1)) & mWhatToShow)) {
return NodeFilter_Binding::FILTER_SKIP;
}
if (aUnskippedNode) {
*aUnskippedNode = aNode;
}
if (!mFilter) {
// No filter, just accept
return NodeFilter_Binding::FILTER_ACCEPT;
}
AutoRestore<bool> inAcceptNode(mInAcceptNode);
mInAcceptNode = true;
// No need to pass in an execution reason, since the generated default,
// "NodeFilter.acceptNode", is pretty much exactly what we'd say anyway.
return mFilter->AcceptNode(*aNode, aResult, nullptr,
CallbackObject::eRethrowExceptions);
}