Backed out 2 changesets (bug 1941002) for causing build bustages in txMozillaXSLTProcessor.cpp. CLOSED TREE

Backed out changeset e22cf499b2e3 (bug 1941002)
Backed out changeset 11968b6c8b3f (bug 1941002)
This commit is contained in:
Stanca Serban
2025-02-21 11:36:40 +02:00
parent 835e8c5a02
commit e933df8d92
16 changed files with 236 additions and 228 deletions

View File

@@ -88,13 +88,11 @@ interface XSLTProcessor {
* the processor use the default-value for all parameters as specified in * the processor use the default-value for all parameters as specified in
* the stylesheet. * the stylesheet.
*/ */
[Throws]
undefined clearParameters(); undefined clearParameters();
/** /**
* Remove all parameters and stylesheets from this XSLTProcessor. * Remove all parameters and stylesheets from this XSLTProcessor.
*/ */
[Throws]
undefined reset(); undefined reset();
/** /**

View File

@@ -12,15 +12,16 @@
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIURI.h" #include "nsIURI.h"
using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
Result<txXPathNode, nsresult> txParseDocumentFromURI(const nsAString& aHref, nsresult txParseDocumentFromURI(const nsAString& aHref,
const txXPathNode& aLoader, const txXPathNode& aLoader, nsAString& aErrMsg,
nsAString& aErrMsg) { txXPathNode** aResult) {
NS_ENSURE_ARG_POINTER(aResult);
*aResult = nullptr;
nsCOMPtr<nsIURI> documentURI; nsCOMPtr<nsIURI> documentURI;
nsresult rv = NS_NewURI(getter_AddRefs(documentURI), aHref); nsresult rv = NS_NewURI(getter_AddRefs(documentURI), aHref);
NS_ENSURE_SUCCESS(rv, Err(rv)); NS_ENSURE_SUCCESS(rv, rv);
Document* loaderDocument = txXPathNativeNode::getDocument(aLoader); Document* loaderDocument = txXPathNativeNode::getDocument(aLoader);
@@ -31,7 +32,7 @@ Result<txXPathNode, nsresult> txParseDocumentFromURI(const nsAString& aHref,
// Raw pointer, we want the resulting txXPathNode to hold a reference to // Raw pointer, we want the resulting txXPathNode to hold a reference to
// the document. // the document.
nsCOMPtr<Document> theDocument; Document* theDocument = nullptr;
nsAutoSyncOperation sync(loaderDocument, nsAutoSyncOperation sync(loaderDocument,
SyncOperationBehavior::eSuspendInput); SyncOperationBehavior::eSuspendInput);
rv = nsSyncLoadService::LoadDocument( rv = nsSyncLoadService::LoadDocument(
@@ -39,14 +40,20 @@ Result<txXPathNode, nsresult> txParseDocumentFromURI(const nsAString& aHref,
loaderDocument->NodePrincipal(), loaderDocument->NodePrincipal(),
nsILoadInfo::SEC_REQUIRE_CORS_INHERITS_SEC_CONTEXT, loadGroup, nsILoadInfo::SEC_REQUIRE_CORS_INHERITS_SEC_CONTEXT, loadGroup,
loaderDocument->CookieJarSettings(), true, loaderDocument->CookieJarSettings(), true,
loaderDocument->GetReferrerPolicy(), getter_AddRefs(theDocument)); loaderDocument->GetReferrerPolicy(), &theDocument);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
aErrMsg.AppendLiteral("Document load of "); aErrMsg.AppendLiteral("Document load of ");
aErrMsg.Append(aHref); aErrMsg.Append(aHref);
aErrMsg.AppendLiteral(" failed."); aErrMsg.AppendLiteral(" failed.");
return Err(rv); return NS_FAILED(rv) ? rv : NS_ERROR_FAILURE;
} }
return txXPathNode(theDocument); *aResult = txXPathNativeNode::createXPathNode(theDocument);
if (!*aResult) {
NS_RELEASE(theDocument);
return NS_ERROR_FAILURE;
}
return NS_OK;
} }

View File

@@ -10,11 +10,6 @@
class txXPathNode; class txXPathNode;
namespace mozilla {
template <typename V, typename E>
class Result;
} // namespace mozilla
/** /**
* API to load XML files into DOM datastructures. * API to load XML files into DOM datastructures.
* Parsing is either done by expat, or by expat via the syncloaderservice * Parsing is either done by expat, or by expat via the syncloaderservice
@@ -24,7 +19,9 @@ class Result;
* Parse a document from the aHref location, with referrer URI on behalf * Parse a document from the aHref location, with referrer URI on behalf
* of the document aLoader. * of the document aLoader.
*/ */
mozilla::Result<txXPathNode, nsresult> txParseDocumentFromURI( extern "C" nsresult txParseDocumentFromURI(const nsAString& aHref,
const nsAString& aHref, const txXPathNode& aLoader, nsAString& aErrMsg); const txXPathNode& aLoader,
nsAString& aErrMsg,
txXPathNode** aResult);
#endif #endif

View File

@@ -23,9 +23,9 @@ namespace mozilla::dom {
class EvalContextImpl : public txIEvalContext { class EvalContextImpl : public txIEvalContext {
public: public:
EvalContextImpl(txXPathNode&& aContextNode, uint32_t aContextPosition, EvalContextImpl(const txXPathNode& aContextNode, uint32_t aContextPosition,
uint32_t aContextSize, txResultRecycler* aRecycler) uint32_t aContextSize, txResultRecycler* aRecycler)
: mContextNode(std::move(aContextNode)), : mContextNode(aContextNode),
mContextPosition(aContextPosition), mContextPosition(aContextPosition),
mContextSize(aContextSize), mContextSize(aContextSize),
mLastError(NS_OK), mLastError(NS_OK),
@@ -121,15 +121,15 @@ already_AddRefed<XPathResult> XPathExpression::EvaluateWithContext(
return nullptr; return nullptr;
} }
Maybe<txXPathNode> contextNode = UniquePtr<txXPathNode> contextNode(
txXPathNativeNode::createXPathNode(&aContextNode); txXPathNativeNode::createXPathNode(&aContextNode));
if (!contextNode) { if (!contextNode) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return nullptr; return nullptr;
} }
EvalContextImpl eContext(contextNode.extract(), aContextPosition, EvalContextImpl eContext(*contextNode, aContextPosition, aContextSize,
aContextSize, mRecycler); mRecycler);
RefPtr<txAExprResult> exprResult; RefPtr<txAExprResult> exprResult;
aRv = mExpression->evaluate(&eContext, getter_AddRefs(exprResult)); aRv = mExpression->evaluate(&eContext, getter_AddRefs(exprResult));
if (aRv.Failed()) { if (aRv.Failed()) {

View File

@@ -238,13 +238,13 @@ nsresult XPathResult::GetExprResult(txAExprResult** aExprResult) {
RefPtr<txNodeSet> nodeSet = new txNodeSet(nullptr); RefPtr<txNodeSet> nodeSet = new txNodeSet(nullptr);
uint32_t i, count = mResultNodes.Length(); uint32_t i, count = mResultNodes.Length();
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i) {
Maybe<txXPathNode> node( UniquePtr<txXPathNode> node(
txXPathNativeNode::createXPathNode(mResultNodes[i])); txXPathNativeNode::createXPathNode(mResultNodes[i]));
if (!node) { if (!node) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
nodeSet->append(node.extract()); nodeSet->append(*node);
} }
NS_ADDREF(*aExprResult = nodeSet); NS_ADDREF(*aExprResult = nodeSet);

View File

@@ -23,8 +23,8 @@
#include <stdint.h> #include <stdint.h>
#include <algorithm> #include <algorithm>
using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
using mozilla::Maybe;
txXPathTreeWalker::txXPathTreeWalker(const txXPathTreeWalker& aOther) = default; txXPathTreeWalker::txXPathTreeWalker(const txXPathTreeWalker& aOther) = default;
@@ -228,6 +228,24 @@ bool txXPathTreeWalker::moveToParent() {
return true; return true;
} }
txXPathNode::txXPathNode(const txXPathNode& aNode)
: mNode(aNode.mNode),
mRefCountRoot(aNode.mRefCountRoot),
mIndex(aNode.mIndex) {
MOZ_COUNT_CTOR(txXPathNode);
if (mRefCountRoot) {
NS_ADDREF(Root());
}
}
txXPathNode::~txXPathNode() {
MOZ_COUNT_DTOR(txXPathNode);
if (mRefCountRoot) {
nsINode* root = Root();
NS_RELEASE(root);
}
}
/* static */ /* static */
bool txXPathNodeUtils::getAttr(const txXPathNode& aNode, nsAtom* aLocalName, bool txXPathNodeUtils::getAttr(const txXPathNode& aNode, nsAtom* aLocalName,
int32_t aNSID, nsAString& aValue) { int32_t aNSID, nsAString& aValue) {
@@ -425,8 +443,8 @@ bool txXPathNodeUtils::isWhitespace(const txXPathNode& aNode) {
} }
/* static */ /* static */
txXPathNode txXPathNodeUtils::getOwnerDocument(const txXPathNode& aNode) { txXPathNode* txXPathNodeUtils::getOwnerDocument(const txXPathNode& aNode) {
return txXPathNode(aNode.mNode->OwnerDoc()); return new txXPathNode(aNode.mNode->OwnerDoc());
} }
const char gPrintfFmt[] = "id0x%" PRIxPTR; const char gPrintfFmt[] = "id0x%" PRIxPTR;
@@ -436,8 +454,7 @@ const char gPrintfFmtAttr[] = "id0x%" PRIxPTR "-%010i";
nsresult txXPathNodeUtils::getXSLTId(const txXPathNode& aNode, nsresult txXPathNodeUtils::getXSLTId(const txXPathNode& aNode,
const txXPathNode& aBase, const txXPathNode& aBase,
nsAString& aResult) { nsAString& aResult) {
uintptr_t nodeid = uintptr_t nodeid = ((uintptr_t)aNode.mNode) - ((uintptr_t)aBase.mNode);
((uintptr_t)aNode.mNode.get()) - ((uintptr_t)aBase.mNode.get());
if (!aNode.isAttribute()) { if (!aNode.isAttribute()) {
CopyASCIItoUTF16(nsPrintfCString(gPrintfFmt, nodeid), aResult); CopyASCIItoUTF16(nsPrintfCString(gPrintfFmt, nodeid), aResult);
} else { } else {
@@ -568,7 +585,16 @@ int txXPathNodeUtils::comparePosition(const txXPathNode& aNode,
} }
/* static */ /* static */
Maybe<txXPathNode> txXPathNativeNode::createXPathNode(nsINode* aNode) { txXPathNode* txXPathNativeNode::createXPathNode(nsIContent* aContent,
bool aKeepRootAlive) {
nsINode* root = aKeepRootAlive ? txXPathNode::RootOf(aContent) : nullptr;
return new txXPathNode(aContent, txXPathNode::eContent, root);
}
/* static */
txXPathNode* txXPathNativeNode::createXPathNode(nsINode* aNode,
bool aKeepRootAlive) {
uint16_t nodeType = aNode->NodeType(); uint16_t nodeType = aNode->NodeType();
if (nodeType == nsINode::ATTRIBUTE_NODE) { if (nodeType == nsINode::ATTRIBUTE_NODE) {
auto* attr = static_cast<Attr*>(aNode); auto* attr = static_cast<Attr*>(aNode);
@@ -576,30 +602,42 @@ Maybe<txXPathNode> txXPathNativeNode::createXPathNode(nsINode* aNode) {
NodeInfo* nodeInfo = attr->NodeInfo(); NodeInfo* nodeInfo = attr->NodeInfo();
Element* parent = attr->GetElement(); Element* parent = attr->GetElement();
if (!parent) { if (!parent) {
return Nothing(); return nullptr;
} }
nsINode* root = aKeepRootAlive ? txXPathNode::RootOf(parent) : nullptr;
uint32_t i, total = parent->GetAttrCount(); uint32_t i, total = parent->GetAttrCount();
for (i = 0; i < total; ++i) { for (i = 0; i < total; ++i) {
const nsAttrName* name = parent->GetAttrNameAt(i); const nsAttrName* name = parent->GetAttrNameAt(i);
if (nodeInfo->Equals(name->LocalName(), name->NamespaceID())) { if (nodeInfo->Equals(name->LocalName(), name->NamespaceID())) {
return Some(txXPathNode(parent, i)); return new txXPathNode(parent, i, root);
} }
} }
NS_ERROR("Couldn't find the attribute in its parent!"); NS_ERROR("Couldn't find the attribute in its parent!");
return Nothing(); return nullptr;
} }
uint32_t index; uint32_t index;
nsINode* root = aKeepRootAlive ? aNode : nullptr;
if (nodeType == nsINode::DOCUMENT_NODE) { if (nodeType == nsINode::DOCUMENT_NODE) {
index = txXPathNode::eDocument; index = txXPathNode::eDocument;
} else { } else {
index = txXPathNode::eContent; index = txXPathNode::eContent;
if (root) {
root = txXPathNode::RootOf(root);
}
} }
return Some(txXPathNode(aNode, index)); return new txXPathNode(aNode, index, root);
}
/* static */
txXPathNode* txXPathNativeNode::createXPathNode(Document* aDocument) {
return new txXPathNode(aDocument);
} }
/* static */ /* static */

View File

@@ -82,12 +82,12 @@ txNodeSet::~txNodeSet() {
} }
} }
nsresult txNodeSet::add(txXPathNode&& aNode) { nsresult txNodeSet::add(const txXPathNode& aNode) {
NS_ASSERTION(mDirection == kForward, NS_ASSERTION(mDirection == kForward,
"only append(aNode) is supported on reversed nodesets"); "only append(aNode) is supported on reversed nodesets");
if (isEmpty()) { if (isEmpty()) {
return append(std::move(aNode)); return append(aNode);
} }
bool dupe; bool dupe;
@@ -113,7 +113,7 @@ nsresult txNodeSet::add(txXPathNode&& aNode) {
memmove((void*)(pos + 1), pos, moveSize * sizeof(txXPathNode)); memmove((void*)(pos + 1), pos, moveSize * sizeof(txXPathNode));
} }
new (pos) txXPathNode(std::move(aNode)); new (pos) txXPathNode(aNode);
++mEnd; ++mEnd;
return NS_OK; return NS_OK;
@@ -295,19 +295,19 @@ nsresult txNodeSet::add(const txNodeSet& aNodes, transferOp aTransfer,
* order info operations will be performed. * order info operations will be performed.
*/ */
nsresult txNodeSet::append(txXPathNode&& aNode) { nsresult txNodeSet::append(const txXPathNode& aNode) {
if (!ensureGrowSize(1)) { if (!ensureGrowSize(1)) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
if (mDirection == kForward) { if (mDirection == kForward) {
new (mEnd) txXPathNode(std::move(aNode)); new (mEnd) txXPathNode(aNode);
++mEnd; ++mEnd;
return NS_OK; return NS_OK;
} }
new (--mStart) txXPathNode(std::move(aNode)); new (--mStart) txXPathNode(aNode);
return NS_OK; return NS_OK;
} }

View File

@@ -44,8 +44,7 @@ class txNodeSet : public txAExprResult {
* @param aNode the txXPathNode to add to the NodeSet * @param aNode the txXPathNode to add to the NodeSet
* @return errorcode. * @return errorcode.
*/ */
nsresult add(const txXPathNode& aNode) { return add(txXPathNode(aNode)); } nsresult add(const txXPathNode& aNode);
nsresult add(txXPathNode&& aNode);
/** /**
* Adds the nodes in specified NodeSet to this NodeSet. The resulting * Adds the nodes in specified NodeSet to this NodeSet. The resulting
@@ -73,10 +72,7 @@ class txNodeSet : public txAExprResult {
* @param aNode the Node to append to the NodeSet * @param aNode the Node to append to the NodeSet
* @return errorcode. * @return errorcode.
*/ */
nsresult append(const txXPathNode& aNode) { nsresult append(const txXPathNode& aNode);
return append(txXPathNode(aNode));
}
nsresult append(txXPathNode&& aNode);
/** /**
* Appends the nodes in the specified NodeSet to the end of this NodeSet * Appends the nodes in the specified NodeSet to the end of this NodeSet

View File

@@ -13,70 +13,35 @@
using txXPathNodeType = nsINode; using txXPathNodeType = nsINode;
/**
* txXPathNode represents a node in XPath's data model (which is a bit different
* from the DOM's). While XPath 1.0 has 7 node types, we essentially deal with 3
* kinds: a document node, any other node type that is backed by an
* implementation of nsIContent in Gecko, and attribute nodes. Because we try to
* avoid creating actual node objects for attribute nodes in Gecko's DOM, we
* store attribute nodes as a pointer to their owner element and an index into
* that element's attribute node list. So to represent the 3 kinds of node we
* need to store:
*
* - a pointer to a document (a nsIDocument as a nsINode pointer)
* - a pointer to a nsIContent object (as a nsINode pointer)
* - a pointer to a nsIContent object (a nsIContent as a nsINode pointer) and
* an index
*
* So we make txXPathNode store a |nsCOMPtr<nsINode>| and a uint32_t for the
* index. To be able to distinguish between the attribute nodes and other nodes
* we store a flag value for the other nodes in the index. To be able to quickly
* cast from the nsINode pointer to a nsIDocument or nsIContent pointer we
* actually use 2 different flag values (see txXPathNode::PositionType).
*
* We provide 2 fast constructors for txXPathNode, one that takes a nsIContent
* and one that takes a nsIDocument, since for those kinds of nodes we can
* simply store the pointer and the relevant flag value. For attribute nodes, or
* if you have just a nsINode pointer, then there is a helper function
* (txXPathNativeNode::createXPathNode) that either picks the right flag value
* or the correct index (for attribute nodes) when creating the txXPathNode.
*/
class txXPathNode { class txXPathNode {
public: public:
explicit txXPathNode(const txXPathNode& aNode)
: mNode(aNode.mNode), mIndex(aNode.mIndex) {
MOZ_COUNT_CTOR(txXPathNode);
}
txXPathNode(txXPathNode&& aNode)
: mNode(std::move(aNode.mNode)), mIndex(aNode.mIndex) {
MOZ_COUNT_CTOR(txXPathNode);
}
explicit txXPathNode(mozilla::dom::Document* aDocument)
: mNode(aDocument), mIndex(eDocument) {
MOZ_COUNT_CTOR(txXPathNode);
}
explicit txXPathNode(nsIContent* aContent)
: mNode(aContent), mIndex(eContent) {
MOZ_COUNT_CTOR(txXPathNode);
}
txXPathNode& operator=(txXPathNode&& aOther) = default;
bool operator==(const txXPathNode& aNode) const; bool operator==(const txXPathNode& aNode) const;
bool operator!=(const txXPathNode& aNode) const { return !(*this == aNode); } bool operator!=(const txXPathNode& aNode) const { return !(*this == aNode); }
~txXPathNode() { MOZ_COUNT_DTOR(txXPathNode); } ~txXPathNode();
private: private:
friend class txNodeSet;
friend class txXPathNativeNode; friend class txXPathNativeNode;
friend class txXPathNodeUtils; friend class txXPathNodeUtils;
friend class txXPathTreeWalker; friend class txXPathTreeWalker;
txXPathNode(nsINode* aNode, uint32_t aIndex) : mNode(aNode), mIndex(aIndex) { txXPathNode(const txXPathNode& aNode);
explicit txXPathNode(mozilla::dom::Document* aDocument)
: mNode(aDocument), mRefCountRoot(0), mIndex(eDocument) {
MOZ_COUNT_CTOR(txXPathNode); MOZ_COUNT_CTOR(txXPathNode);
} }
txXPathNode(nsINode* aNode, uint32_t aIndex, nsINode* aRoot)
: mNode(aNode), mRefCountRoot(aRoot ? 1 : 0), mIndex(aIndex) {
MOZ_COUNT_CTOR(txXPathNode);
if (aRoot) {
NS_ADDREF(aRoot);
}
}
static nsINode* RootOf(nsINode* aNode) { return aNode->SubtreeRoot(); } static nsINode* RootOf(nsINode* aNode) { return aNode->SubtreeRoot(); }
nsINode* Root() const { return RootOf(mNode); } nsINode* Root() const { return RootOf(mNode); }
nsINode* GetRootToAddRef() const { return mRefCountRoot ? Root() : nullptr; }
bool isDocument() const { return mIndex == eDocument; } bool isDocument() const { return mIndex == eDocument; }
bool isContent() const { return mIndex == eContent; } bool isContent() const { return mIndex == eContent; }
@@ -84,20 +49,18 @@ class txXPathNode {
nsIContent* Content() const { nsIContent* Content() const {
NS_ASSERTION(isContent() || isAttribute(), "wrong type"); NS_ASSERTION(isContent() || isAttribute(), "wrong type");
return static_cast<nsIContent*>(mNode.get()); return static_cast<nsIContent*>(mNode);
} }
mozilla::dom::Document* Document() const { mozilla::dom::Document* Document() const {
NS_ASSERTION(isDocument(), "wrong type"); NS_ASSERTION(isDocument(), "wrong type");
return static_cast<mozilla::dom::Document*>(mNode.get()); return static_cast<mozilla::dom::Document*>(mNode);
} }
enum PositionType : uint32_t { enum PositionType { eDocument = (1 << 30), eContent = eDocument - 1 };
eDocument = UINT32_MAX,
eContent = eDocument - 1
};
nsCOMPtr<nsINode> mNode; nsINode* mNode;
uint32_t mIndex; uint32_t mRefCountRoot : 1;
uint32_t mIndex : 31;
}; };
class txNamespaceManager { class txNamespaceManager {

View File

@@ -60,7 +60,7 @@ class txXPathNodeUtils {
static uint16_t getNodeType(const txXPathNode& aNode); static uint16_t getNodeType(const txXPathNode& aNode);
static void appendNodeValue(const txXPathNode& aNode, nsAString& aResult); static void appendNodeValue(const txXPathNode& aNode, nsAString& aResult);
static bool isWhitespace(const txXPathNode& aNode); static bool isWhitespace(const txXPathNode& aNode);
static txXPathNode getOwnerDocument(const txXPathNode& aNode); static txXPathNode* getOwnerDocument(const txXPathNode& aNode);
static int32_t getUniqueIdentifier(const txXPathNode& aNode); static int32_t getUniqueIdentifier(const txXPathNode& aNode);
static nsresult getXSLTId(const txXPathNode& aNode, const txXPathNode& aBase, static nsresult getXSLTId(const txXPathNode& aNode, const txXPathNode& aBase,
nsAString& aResult); nsAString& aResult);
@@ -86,10 +86,19 @@ class txXPathNodeUtils {
class txXPathNativeNode { class txXPathNativeNode {
public: public:
static mozilla::Maybe<txXPathNode> createXPathNode(nsINode* aNode); static txXPathNode* createXPathNode(nsINode* aNode,
bool aKeepRootAlive = false);
static txXPathNode* createXPathNode(nsIContent* aContent,
bool aKeepRootAlive = false);
static txXPathNode* createXPathNode(mozilla::dom::Document* aDocument);
static nsINode* getNode(const txXPathNode& aNode); static nsINode* getNode(const txXPathNode& aNode);
static nsIContent* getContent(const txXPathNode& aNode); static nsIContent* getContent(const txXPathNode& aNode);
static mozilla::dom::Document* getDocument(const txXPathNode& aNode); static mozilla::dom::Document* getDocument(const txXPathNode& aNode);
static void addRef(const txXPathNode& aNode) { NS_ADDREF(aNode.mNode); }
static void release(const txXPathNode& aNode) {
nsINode* node = aNode.mNode;
NS_RELEASE(node);
}
}; };
inline const txXPathNode& txXPathTreeWalker::getCurrentPosition() const { inline const txXPathNode& txXPathTreeWalker::getCurrentPosition() const {
@@ -114,8 +123,21 @@ inline void txXPathTreeWalker::getNodeName(nsAString& aName) const {
} }
inline void txXPathTreeWalker::moveTo(const txXPathTreeWalker& aWalker) { inline void txXPathTreeWalker::moveTo(const txXPathTreeWalker& aWalker) {
nsINode* root = nullptr;
if (mPosition.mRefCountRoot) {
root = mPosition.Root();
}
mPosition.mIndex = aWalker.mPosition.mIndex; mPosition.mIndex = aWalker.mPosition.mIndex;
mPosition.mRefCountRoot = aWalker.mPosition.mRefCountRoot;
mPosition.mNode = aWalker.mPosition.mNode; mPosition.mNode = aWalker.mPosition.mNode;
nsINode* newRoot = nullptr;
if (mPosition.mRefCountRoot) {
newRoot = mPosition.Root();
}
if (root != newRoot) {
NS_IF_ADDREF(newRoot);
NS_IF_RELEASE(root);
}
} }
inline bool txXPathTreeWalker::isOnNode(const txXPathNode& aNode) const { inline bool txXPathTreeWalker::isOnNode(const txXPathNode& aNode) const {
@@ -125,7 +147,12 @@ inline bool txXPathTreeWalker::isOnNode(const txXPathNode& aNode) const {
/* static */ /* static */
inline int32_t txXPathNodeUtils::getUniqueIdentifier(const txXPathNode& aNode) { inline int32_t txXPathNodeUtils::getUniqueIdentifier(const txXPathNode& aNode) {
MOZ_ASSERT(!aNode.isAttribute(), "Not implemented for attributes."); MOZ_ASSERT(!aNode.isAttribute(), "Not implemented for attributes.");
return NS_PTR_TO_INT32(aNode.mNode.get()); return NS_PTR_TO_INT32(aNode.mNode);
}
/* static */
inline void txXPathNodeUtils::release(txXPathNode* aNode) {
NS_RELEASE(aNode->mNode);
} }
/* static */ /* static */

View File

@@ -73,7 +73,11 @@ static nsresult convertRtfToNode(txIEvalContext* aContext,
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
// The txResultTreeFragment will own this. // The txResultTreeFragment will own this.
aRtf->setNode(new txXPathNode(domFragment)); const txXPathNode* node =
txXPathNativeNode::createXPathNode(domFragment, true);
NS_ENSURE_TRUE(node, NS_ERROR_OUT_OF_MEMORY);
aRtf->setNode(node);
return NS_OK; return NS_OK;
} }
@@ -91,7 +95,8 @@ static nsresult createTextNode(txIEvalContext* aContext, nsString& aValue,
nsresult rv = text->SetText(aValue, false); nsresult rv = text->SetText(aValue, false);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
*aResult = new txXPathNode(text); *aResult = txXPathNativeNode::createXPathNode(text, true);
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
return NS_OK; return NS_OK;
} }
@@ -121,10 +126,11 @@ static nsresult createAndAddToResult(nsAtom* aName, const nsAString& aValue,
return error.StealNSResult(); return error.StealNSResult();
} }
Maybe<txXPathNode> xpathNode(txXPathNativeNode::createXPathNode(elem)); UniquePtr<txXPathNode> xpathNode(
txXPathNativeNode::createXPathNode(elem, true));
NS_ENSURE_TRUE(xpathNode, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(xpathNode, NS_ERROR_OUT_OF_MEMORY);
aResultSet->append(xpathNode.extract()); aResultSet->append(*xpathNode);
return NS_OK; return NS_OK;
} }
@@ -699,7 +705,8 @@ nsresult txEXSLTRegExFunctionCall::evaluate(txIEvalContext* aContext,
UniquePtr<txXPathNode> node; UniquePtr<txXPathNode> node;
for (nsIContent* result = docFrag->GetFirstChild(); result; for (nsIContent* result = docFrag->GetFirstChild(); result;
result = result->GetNextSibling()) { result = result->GetNextSibling()) {
rv = resultSet->add(txXPathNode(result)); node = WrapUnique(txXPathNativeNode::createXPathNode(result, true));
rv = resultSet->add(*node);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }

View File

@@ -14,12 +14,14 @@
#include "txURIUtils.h" #include "txURIUtils.h"
#include "txXMLParser.h" #include "txXMLParser.h"
using namespace mozilla; using mozilla::UniquePtr;
using mozilla::Unused;
using mozilla::WrapUnique;
const int32_t txExecutionState::kMaxRecursionDepth = 20000; const int32_t txExecutionState::kMaxRecursionDepth = 20000;
nsresult txLoadedDocumentsHash::init(const txXPathNode& aSource) { nsresult txLoadedDocumentsHash::init(const txXPathNode& aSource) {
mSourceDocument = Some(txXPathNodeUtils::getOwnerDocument(aSource)); mSourceDocument = WrapUnique(txXPathNodeUtils::getOwnerDocument(aSource));
nsAutoString baseURI; nsAutoString baseURI;
nsresult rv = txXPathNodeUtils::getBaseURI(*mSourceDocument, baseURI); nsresult rv = txXPathNodeUtils::getBaseURI(*mSourceDocument, baseURI);
@@ -37,12 +39,24 @@ nsresult txLoadedDocumentsHash::init(const txXPathNode& aSource) {
// txMozillaXSLTProcessor::TransformToFragment) it makes more sense to return // txMozillaXSLTProcessor::TransformToFragment) it makes more sense to return
// the real root of the source tree, which is the node where the transform // the real root of the source tree, which is the node where the transform
// started. // started.
WithEntryHandle(baseURI, [&aSource](auto&& entry) { PutEntry(baseURI)->mDocument = WrapUnique(
entry.Insert(txLoadedDocumentEntry{txXPathNode(aSource)}); txXPathNativeNode::createXPathNode(txXPathNativeNode::getNode(aSource)));
});
return NS_OK; return NS_OK;
} }
txLoadedDocumentsHash::~txLoadedDocumentsHash() {
if (mSourceDocument) {
nsAutoString baseURI;
nsresult rv = txXPathNodeUtils::getBaseURI(*mSourceDocument, baseURI);
if (NS_SUCCEEDED(rv)) {
txLoadedDocumentEntry* entry = GetEntry(baseURI);
if (entry) {
delete entry->mDocument.release();
}
}
}
}
txExecutionState::txExecutionState(txStylesheet* aStylesheet, txExecutionState::txExecutionState(txStylesheet* aStylesheet,
bool aDisableLoads) bool aDisableLoads)
: mOutputHandler(nullptr), : mOutputHandler(nullptr),
@@ -344,24 +358,27 @@ const txXPathNode* txExecutionState::retrieveDocument(const nsAString& aUri) {
("Retrieve Document %s", NS_LossyConvertUTF16toASCII(aUri).get())); ("Retrieve Document %s", NS_LossyConvertUTF16toASCII(aUri).get()));
// try to get already loaded document // try to get already loaded document
const Variant<txXPathNode, nsresult>& result = txLoadedDocumentEntry* entry = mLoadedDocuments.PutEntry(aUri);
mLoadedDocuments.LookupOrInsertWith(aUri, [&] { if (!entry) {
// open URI return nullptr;
nsAutoString errMsg; }
// XXX we should get the loader from the actual node
// triggering the load, but this will do for the time being
Result<txXPathNode, nsresult> loadResult = txParseDocumentFromURI(
aUri, *mLoadedDocuments.mSourceDocument, errMsg);
if (loadResult.isErr()) { if (!entry->mDocument && !entry->LoadingFailed()) {
nsresult rv = loadResult.unwrapErr(); // open URI
receiveError( nsAutoString errMsg;
u"Couldn't load document '"_ns + aUri + u"': "_ns + errMsg, rv); // XXX we should get the loader from the actual node
return txLoadedDocumentEntry(rv); // triggering the load, but this will do for the time being
} entry->mLoadResult =
return txLoadedDocumentEntry(loadResult.unwrap()); txParseDocumentFromURI(aUri, *mLoadedDocuments.mSourceDocument, errMsg,
}); getter_Transfers(entry->mDocument));
return result.is<txXPathNode>() ? &result.as<txXPathNode>() : nullptr;
if (entry->LoadingFailed()) {
receiveError(u"Couldn't load document '"_ns + aUri + u"': "_ns + errMsg,
entry->mLoadResult);
}
}
return entry->mDocument.get();
} }
nsresult txExecutionState::getKeyNodes(const txExpandedName& aKeyName, nsresult txExecutionState::getKeyNodes(const txExpandedName& aKeyName,

View File

@@ -23,18 +23,41 @@ class txAOutputHandlerFactory;
class txAXMLEventHandler; class txAXMLEventHandler;
class txInstruction; class txInstruction;
using txLoadedDocumentEntry = mozilla::Variant<txXPathNode, nsresult>; class txLoadedDocumentEntry : public nsStringHashKey {
class txLoadedDocumentsHash
: public nsTHashMap<nsString, txLoadedDocumentEntry> {
public: public:
txLoadedDocumentsHash() : nsTHashMap<nsString, txLoadedDocumentEntry>(4) {} explicit txLoadedDocumentEntry(KeyTypePointer aStr)
: nsStringHashKey(aStr), mLoadResult(NS_OK) {}
txLoadedDocumentEntry(txLoadedDocumentEntry&& aOther)
: nsStringHashKey(std::move(aOther)),
mDocument(std::move(aOther.mDocument)),
mLoadResult(std::move(aOther.mLoadResult)) {
NS_ERROR("We're horked.");
}
~txLoadedDocumentEntry() {
if (mDocument) {
txXPathNodeUtils::release(mDocument.get());
}
}
bool LoadingFailed() {
NS_ASSERTION(NS_SUCCEEDED(mLoadResult) || !mDocument,
"Load failed but we still got a document?");
return NS_FAILED(mLoadResult);
}
mozilla::UniquePtr<txXPathNode> mDocument;
nsresult mLoadResult;
};
class txLoadedDocumentsHash : public nsTHashtable<txLoadedDocumentEntry> {
public:
txLoadedDocumentsHash() : nsTHashtable<txLoadedDocumentEntry>(4) {}
~txLoadedDocumentsHash();
[[nodiscard]] nsresult init(const txXPathNode& aSource); [[nodiscard]] nsresult init(const txXPathNode& aSource);
private: private:
friend class txExecutionState; friend class txExecutionState;
mozilla::Maybe<txXPathNode> mSourceDocument; mozilla::UniquePtr<txXPathNode> mSourceDocument;
}; };
class txExecutionState : public txIMatchContext { class txExecutionState : public txIMatchContext {

View File

@@ -5,7 +5,6 @@
#include "txMozillaXSLTProcessor.h" #include "txMozillaXSLTProcessor.h"
#include "nsError.h" #include "nsError.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
#include "nsIStringBundle.h" #include "nsIStringBundle.h"
@@ -329,11 +328,9 @@ txMozillaXSLTProcessor::AddXSLTParamNamespace(const nsString& aPrefix,
class txXSLTParamContext : public txIParseContext, public txIEvalContext { class txXSLTParamContext : public txIParseContext, public txIEvalContext {
public: public:
txXSLTParamContext(txNamespaceMap* aResolver, txXPathNode&& aContext, txXSLTParamContext(txNamespaceMap* aResolver, const txXPathNode& aContext,
txResultRecycler* aRecycler) txResultRecycler* aRecycler)
: mResolver(aResolver), : mResolver(aResolver), mContext(aContext), mRecycler(aRecycler) {}
mContext(std::move(aContext)),
mRecycler(aRecycler) {}
// txIParseContext // txIParseContext
int32_t resolveNamespacePrefix(nsAtom* aPrefix) override { int32_t resolveNamespacePrefix(nsAtom* aPrefix) override {
@@ -388,7 +385,7 @@ txMozillaXSLTProcessor::AddXSLTParam(const nsString& aName,
uint16_t resultType; uint16_t resultType;
if (!aSelect.IsVoid()) { if (!aSelect.IsVoid()) {
// Set up context // Set up context
Maybe<txXPathNode> contextNode( UniquePtr<txXPathNode> contextNode(
txXPathNativeNode::createXPathNode(aContext)); txXPathNativeNode::createXPathNode(aContext));
NS_ENSURE_TRUE(contextNode, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(contextNode, NS_ERROR_OUT_OF_MEMORY);
@@ -396,7 +393,7 @@ txMozillaXSLTProcessor::AddXSLTParam(const nsString& aName,
mRecycler = new txResultRecycler; mRecycler = new txResultRecycler;
} }
txXSLTParamContext paramContext(&mParamNamespaceMap, contextNode.extract(), txXSLTParamContext paramContext(&mParamNamespaceMap, *contextNode,
mRecycler); mRecycler);
// Parse // Parse
@@ -476,8 +473,6 @@ class nsTransformBlockerEvent : public mozilla::Runnable {
} }
NS_IMETHOD Run() override { NS_IMETHOD Run() override {
MOZ_RELEASE_ASSERT(mProcessor->mState ==
txMozillaXSLTProcessor::State::None);
mProcessor->TransformToDoc(nullptr, false); mProcessor->TransformToDoc(nullptr, false);
return NS_OK; return NS_OK;
} }
@@ -509,13 +504,6 @@ void txMozillaXSLTProcessor::ImportStylesheet(nsINode& aStyle,
return; return;
} }
if (mState != State::None) {
aRv.ThrowInvalidStateError("Invalid call.");
return;
}
mozilla::AutoRestore<State> restore(mState);
mState = State::Compiling;
MOZ_ASSERT(!mEmbeddedStylesheetRoot); MOZ_ASSERT(!mEmbeddedStylesheetRoot);
mCompileResult = NS_OK; mCompileResult = NS_OK;
@@ -559,21 +547,12 @@ already_AddRefed<Document> txMozillaXSLTProcessor::TransformToDocument(
return nullptr; return nullptr;
} }
if (mState != State::None) {
aRv.ThrowInvalidStateError("Invalid call.");
return nullptr;
}
nsresult rv = ensureStylesheet(); nsresult rv = ensureStylesheet();
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(rv); aRv.Throw(rv);
return nullptr; return nullptr;
} }
MOZ_RELEASE_ASSERT(mState == State::None);
mozilla::AutoRestore<State> restore(mState);
mState = State::Transforming;
mSource = aSource.CloneNode(true, aRv); mSource = aSource.CloneNode(true, aRv);
if (aRv.Failed()) { if (aRv.Failed()) {
return nullptr; return nullptr;
@@ -676,7 +655,8 @@ XSLTProcessRequest::SetTRRMode(nsIRequest::TRRMode aTRRMode) {
nsresult txMozillaXSLTProcessor::TransformToDoc(Document** aResult, nsresult txMozillaXSLTProcessor::TransformToDoc(Document** aResult,
bool aCreateDataDocument) { bool aCreateDataDocument) {
Maybe<txXPathNode> sourceNode(txXPathNativeNode::createXPathNode(mSource)); UniquePtr<txXPathNode> sourceNode(
txXPathNativeNode::createXPathNode(mSource));
if (!sourceNode) { if (!sourceNode) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
@@ -758,21 +738,12 @@ already_AddRefed<DocumentFragment> txMozillaXSLTProcessor::TransformToFragment(
return nullptr; return nullptr;
} }
if (mState != State::None) {
aRv.ThrowInvalidStateError("Invalid call.");
return nullptr;
}
nsresult rv = ensureStylesheet(); nsresult rv = ensureStylesheet();
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(rv); aRv.Throw(rv);
return nullptr; return nullptr;
} }
MOZ_RELEASE_ASSERT(mState == State::None);
mozilla::AutoRestore<State> restore(mState);
mState = State::Transforming;
nsCOMPtr<nsINode> source; nsCOMPtr<nsINode> source;
if (aCloneSource) { if (aCloneSource) {
source = aSource.CloneNode(true, aRv); source = aSource.CloneNode(true, aRv);
@@ -783,7 +754,7 @@ already_AddRefed<DocumentFragment> txMozillaXSLTProcessor::TransformToFragment(
source = &aSource; source = &aSource;
} }
Maybe<txXPathNode> sourceNode(txXPathNativeNode::createXPathNode(source)); UniquePtr<txXPathNode> sourceNode(txXPathNativeNode::createXPathNode(source));
if (!sourceNode) { if (!sourceNode) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY); aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr; return nullptr;
@@ -797,7 +768,7 @@ already_AddRefed<DocumentFragment> txMozillaXSLTProcessor::TransformToFragment(
txToFragmentHandlerFactory handlerFactory(frag); txToFragmentHandlerFactory handlerFactory(frag);
es.mOutputHandlerFactory = &handlerFactory; es.mOutputHandlerFactory = &handlerFactory;
rv = es.init(sourceNode.extract(), &mVariables); rv = es.init(*sourceNode, &mVariables);
// Process root of XML source document // Process root of XML source document
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
@@ -821,11 +792,6 @@ void txMozillaXSLTProcessor::SetParameter(const nsAString& aNamespaceURI,
const nsAString& aLocalName, const nsAString& aLocalName,
const XSLTParameterValue& aValue, const XSLTParameterValue& aValue,
ErrorResult& aError) { ErrorResult& aError) {
if (mState != State::None) {
aError.ThrowInvalidStateError("Invalid call.");
return;
}
if (aValue.IsNode()) { if (aValue.IsNode()) {
if (!nsContentUtils::CanCallerAccess(&aValue.GetAsNode())) { if (!nsContentUtils::CanCallerAccess(&aValue.GetAsNode())) {
aError.ThrowSecurityError("Caller is not allowed to access node."); aError.ThrowSecurityError("Caller is not allowed to access node.");
@@ -914,11 +880,6 @@ void txMozillaXSLTProcessor::GetParameter(
void txMozillaXSLTProcessor::RemoveParameter(const nsAString& aNamespaceURI, void txMozillaXSLTProcessor::RemoveParameter(const nsAString& aNamespaceURI,
const nsAString& aLocalName, const nsAString& aLocalName,
ErrorResult& aRv) { ErrorResult& aRv) {
if (mState != State::None) {
aRv.ThrowInvalidStateError("Invalid call.");
return;
}
int32_t nsId = kNameSpaceID_Unknown; int32_t nsId = kNameSpaceID_Unknown;
nsresult rv = nsresult rv =
nsNameSpaceManager::GetInstance()->RegisterNameSpace(aNamespaceURI, nsId); nsNameSpaceManager::GetInstance()->RegisterNameSpace(aNamespaceURI, nsId);
@@ -932,21 +893,9 @@ void txMozillaXSLTProcessor::RemoveParameter(const nsAString& aNamespaceURI,
mVariables.remove(varName); mVariables.remove(varName);
} }
void txMozillaXSLTProcessor::ClearParameters(ErrorResult& aError) { void txMozillaXSLTProcessor::ClearParameters() { mVariables.clear(); }
if (mState != State::None) {
aError.ThrowInvalidStateError("Invalid call.");
return;
}
mVariables.clear();
}
void txMozillaXSLTProcessor::Reset(ErrorResult& aError) {
if (mState != State::None) {
aError.ThrowInvalidStateError("Invalid call.");
return;
}
void txMozillaXSLTProcessor::Reset() {
if (mStylesheetDocument) { if (mStylesheetDocument) {
mStylesheetDocument->RemoveMutationObserver(this); mStylesheetDocument->RemoveMutationObserver(this);
} }
@@ -1106,12 +1055,6 @@ void txMozillaXSLTProcessor::notifyError() {
} }
nsresult txMozillaXSLTProcessor::ensureStylesheet() { nsresult txMozillaXSLTProcessor::ensureStylesheet() {
if (mState != State::None) {
return NS_ERROR_FAILURE;
}
mozilla::AutoRestore<State> restore(mState);
mState = State::Compiling;
if (mStylesheet) { if (mStylesheet) {
return NS_OK; return NS_OK;
} }
@@ -1242,7 +1185,7 @@ nsresult txVariable::convert(const OwningXSLTParameterValue& aUnionValue,
if (aUnionValue.IsNode()) { if (aUnionValue.IsNode()) {
nsINode& node = aUnionValue.GetAsNode(); nsINode& node = aUnionValue.GetAsNode();
Maybe<txXPathNode> xpathNode(txXPathNativeNode::createXPathNode(&node)); UniquePtr<txXPathNode> xpathNode(txXPathNativeNode::createXPathNode(&node));
if (!xpathNode) { if (!xpathNode) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@@ -1256,13 +1199,13 @@ nsresult txVariable::convert(const OwningXSLTParameterValue& aUnionValue,
const Sequence<OwningNonNull<nsINode>>& values = const Sequence<OwningNonNull<nsINode>>& values =
aUnionValue.GetAsNodeSequence(); aUnionValue.GetAsNodeSequence();
for (const auto& node : values) { for (const auto& node : values) {
Maybe<txXPathNode> xpathNode( UniquePtr<txXPathNode> xpathNode(
txXPathNativeNode::createXPathNode(node.get())); txXPathNativeNode::createXPathNode(node.get()));
if (!xpathNode) { if (!xpathNode) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nodeSet->append(xpathNode.extract()); nodeSet->append(*xpathNode);
} }
nodeSet.forget(aValue); nodeSet.forget(aValue);
return NS_OK; return NS_OK;

View File

@@ -92,17 +92,17 @@ class txMozillaXSLTProcessor final : public nsIDocumentTransformer,
static already_AddRefed<txMozillaXSLTProcessor> Constructor( static already_AddRefed<txMozillaXSLTProcessor> Constructor(
const mozilla::dom::GlobalObject& aGlobal); const mozilla::dom::GlobalObject& aGlobal);
void ImportStylesheet(nsINode& aStylesheet, mozilla::ErrorResult& aRv); void ImportStylesheet(nsINode& stylesheet, mozilla::ErrorResult& aRv);
already_AddRefed<mozilla::dom::DocumentFragment> TransformToFragment( already_AddRefed<mozilla::dom::DocumentFragment> TransformToFragment(
nsINode& aSource, mozilla::dom::Document& aOutput, nsINode& aSource, mozilla::dom::Document& aDocument,
mozilla::ErrorResult& aRv) { mozilla::ErrorResult& aRv) {
return TransformToFragment(aSource, true, aOutput, aRv); return TransformToFragment(aSource, true, aDocument, aRv);
} }
already_AddRefed<mozilla::dom::DocumentFragment> TransformToFragment( already_AddRefed<mozilla::dom::DocumentFragment> TransformToFragment(
nsINode& aSource, bool aCloneSource, mozilla::dom::Document& aOutput, nsINode& aSource, bool aCloneSource, mozilla::dom::Document& aOutput,
mozilla::ErrorResult& aRv); mozilla::ErrorResult& aRv);
already_AddRefed<mozilla::dom::Document> TransformToDocument( already_AddRefed<mozilla::dom::Document> TransformToDocument(
nsINode& aSource, mozilla::ErrorResult& aRv); nsINode& source, mozilla::ErrorResult& aRv);
void SetParameter(const nsAString& aNamespaceURI, const nsAString& aLocalName, void SetParameter(const nsAString& aNamespaceURI, const nsAString& aLocalName,
const XSLTParameterValue& aValue, const XSLTParameterValue& aValue,
@@ -112,8 +112,8 @@ class txMozillaXSLTProcessor final : public nsIDocumentTransformer,
mozilla::ErrorResult& aRv); mozilla::ErrorResult& aRv);
void RemoveParameter(const nsAString& aNamespaceURI, void RemoveParameter(const nsAString& aNamespaceURI,
const nsAString& aLocalName, mozilla::ErrorResult& aRv); const nsAString& aLocalName, mozilla::ErrorResult& aRv);
void ClearParameters(mozilla::ErrorResult& aError); void ClearParameters();
void Reset(mozilla::ErrorResult& aError); void Reset();
uint32_t Flags(mozilla::dom::SystemCallerGuarantee); uint32_t Flags(mozilla::dom::SystemCallerGuarantee);
void SetFlags(uint32_t aFlags, mozilla::dom::SystemCallerGuarantee); void SetFlags(uint32_t aFlags, mozilla::dom::SystemCallerGuarantee);
@@ -136,8 +136,6 @@ class txMozillaXSLTProcessor final : public nsIDocumentTransformer,
static void Shutdown(); static void Shutdown();
private: private:
friend class nsTransformBlockerEvent;
explicit txMozillaXSLTProcessor(nsISupports* aOwner); explicit txMozillaXSLTProcessor(nsISupports* aOwner);
/** /**
* Default destructor for txMozillaXSLTProcessor * Default destructor for txMozillaXSLTProcessor
@@ -164,13 +162,6 @@ class txMozillaXSLTProcessor final : public nsIDocumentTransformer,
RefPtr<txResultRecycler> mRecycler; RefPtr<txResultRecycler> mRecycler;
uint32_t mFlags; uint32_t mFlags;
enum class State {
None,
Compiling,
Transforming,
};
State mState = State::None;
}; };
extern nsresult TX_LoadSheet(nsIURI* aUri, txMozillaXSLTProcessor* aProcessor, extern nsresult TX_LoadSheet(nsIURI* aUri, txMozillaXSLTProcessor* aProcessor,

View File

@@ -329,11 +329,12 @@ void txIdPattern::toString(nsAString& aDest) {
nsresult txKeyPattern::matches(const txXPathNode& aNode, nsresult txKeyPattern::matches(const txXPathNode& aNode,
txIMatchContext* aContext, bool& aMatched) { txIMatchContext* aContext, bool& aMatched) {
txExecutionState* es = (txExecutionState*)aContext->getPrivateContext(); txExecutionState* es = (txExecutionState*)aContext->getPrivateContext();
txXPathNode contextDoc(txXPathNodeUtils::getOwnerDocument(aNode)); UniquePtr<txXPathNode> contextDoc(txXPathNodeUtils::getOwnerDocument(aNode));
NS_ENSURE_TRUE(contextDoc, NS_ERROR_FAILURE);
RefPtr<txNodeSet> nodes; RefPtr<txNodeSet> nodes;
nsresult rv = nsresult rv =
es->getKeyNodes(mName, contextDoc, mValue, true, getter_AddRefs(nodes)); es->getKeyNodes(mName, *contextDoc, mValue, true, getter_AddRefs(nodes));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
aMatched = nodes->contains(aNode); aMatched = nodes->contains(aNode);