From 0856f160b3cc00c5ffec2ac895288707edff3e4f Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Thu, 17 Feb 2022 01:41:18 -0600 Subject: Manually Revert "[DOM XSLT] Use a request to stop transforming." Causes a hang on Windows and simply a blank page on unix when viewing XML --- dom/xslt/xslt/txExecutionState.cpp | 21 ++++---- dom/xslt/xslt/txExecutionState.h | 4 +- dom/xslt/xslt/txMozillaXSLTProcessor.cpp | 85 -------------------------------- dom/xslt/xslt/txXSLTProcessor.cpp | 19 ++----- 4 files changed, 15 insertions(+), 114 deletions(-) diff --git a/dom/xslt/xslt/txExecutionState.cpp b/dom/xslt/xslt/txExecutionState.cpp index 0ca6143a9..5caaf77f0 100644 --- a/dom/xslt/xslt/txExecutionState.cpp +++ b/dom/xslt/xslt/txExecutionState.cpp @@ -480,18 +480,15 @@ txExecutionState::getCurrentTemplateRule() return &mTemplateRules[mTemplateRules.Length() - 1]; } -nsresult -txExecutionState::getNextInstruction(txInstruction* aInstruction) { - if (mStopProcessing) { - return NS_ERROR_FAILURE; - } - - aInstruction = mNextInstruction; - if (aInstruction) { - mNextInstruction = aInstruction->mNext; - } - - return NS_OK; +txInstruction* +txExecutionState::getNextInstruction() +{ + txInstruction* instr = mNextInstruction; + if (instr) { + mNextInstruction = instr->mNext; + } + + return instr; } nsresult diff --git a/dom/xslt/xslt/txExecutionState.h b/dom/xslt/xslt/txExecutionState.h index 68436424f..cd5467179 100644 --- a/dom/xslt/xslt/txExecutionState.h +++ b/dom/xslt/xslt/txExecutionState.h @@ -131,7 +131,7 @@ public: } // state-modification functions - nsresult getNextInstruction(txInstruction* aInstruction); + txInstruction* getNextInstruction(); nsresult runTemplate(txInstruction* aInstruction); nsresult runTemplate(txInstruction* aInstruction, txInstruction* aReturnTo); @@ -140,7 +140,6 @@ public: nsresult bindVariable(const txExpandedName& aName, txAExprResult* aValue); void removeVariable(const txExpandedName& aName); - void stopProcessing() { mStopProcessing = true; } txAXMLEventHandler* mOutputHandler; txAXMLEventHandler* mResultHandler; @@ -175,7 +174,6 @@ private: txKeyHash mKeyHash; RefPtr mRecycler; bool mDisableLoads; - bool mStopProcessing = false; static const int32_t kMaxRecursionDepth; }; diff --git a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp index 18e86f45a..6aec6052f 100644 --- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp +++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp @@ -653,69 +653,6 @@ txMozillaXSLTProcessor::TransformToDocument(nsIDOMNode *aSource, return TransformToDoc(aResult, true); } -class XSLTProcessRequest final : public nsIRequest { - public: - explicit XSLTProcessRequest(txExecutionState* aState) : mState(aState) {} - - NS_DECL_ISUPPORTS - NS_DECL_NSIREQUEST - - void Done() { mState = nullptr; } - - private: - ~XSLTProcessRequest() {} - txExecutionState* mState; -}; -NS_IMPL_ISUPPORTS(XSLTProcessRequest, nsIRequest) - -NS_IMETHODIMP -XSLTProcessRequest::GetName(nsACString& aResult) { - aResult.AssignLiteral("about:xslt-load-blocker"); - return NS_OK; -} - -NS_IMETHODIMP -XSLTProcessRequest::IsPending(bool* _retval) { - *_retval = true; - return NS_OK; -} - -NS_IMETHODIMP -XSLTProcessRequest::GetStatus(nsresult* status) { - *status = NS_OK; - return NS_OK; -} - -NS_IMETHODIMP -XSLTProcessRequest::Cancel(nsresult status) { - mState->stopProcessing(); - return NS_OK; -} - -NS_IMETHODIMP -XSLTProcessRequest::Suspend(void) { return NS_OK; } - -NS_IMETHODIMP -XSLTProcessRequest::Resume(void) { return NS_OK; } - -NS_IMETHODIMP -XSLTProcessRequest::GetLoadGroup(nsILoadGroup** aLoadGroup) { - *aLoadGroup = nullptr; - return NS_OK; -} - -NS_IMETHODIMP -XSLTProcessRequest::SetLoadGroup(nsILoadGroup* aLoadGroup) { return NS_OK; } - -NS_IMETHODIMP -XSLTProcessRequest::GetLoadFlags(nsLoadFlags* aLoadFlags) { - *aLoadFlags = nsIRequest::LOAD_NORMAL; - return NS_OK; -} - -NS_IMETHODIMP -XSLTProcessRequest::SetLoadFlags(nsLoadFlags aLoadFlags) { return NS_OK; } - nsresult txMozillaXSLTProcessor::TransformToDoc(nsIDOMDocument **aResult, bool aCreateDataDocument) @@ -729,25 +666,6 @@ txMozillaXSLTProcessor::TransformToDoc(nsIDOMDocument **aResult, txExecutionState es(mStylesheet, IsLoadDisabled()); - nsIDocument* sourceDoc = mSource->OwnerDoc(); - nsCOMPtr loadGroup = sourceDoc->GetDocumentLoadGroup(); - if (!loadGroup) { - nsCOMPtr win = do_QueryInterface(mOwner); - if (win && win->IsCurrentInnerWindow()) { - nsIDocument* doc = win->GetDoc(); - if (doc) { - loadGroup = doc->GetDocumentLoadGroup(); - } - } - - if (!loadGroup) { - return NS_ERROR_FAILURE; - } - } - - RefPtr xsltProcessRequest = new XSLTProcessRequest(&es); - loadGroup->AddRequest(xsltProcessRequest, nullptr); - // XXX Need to add error observers // If aResult is non-null, we're a data document @@ -762,9 +680,6 @@ txMozillaXSLTProcessor::TransformToDoc(nsIDOMDocument **aResult, rv = txXSLTProcessor::execute(es); } - xsltProcessRequest->Done(); - loadGroup->RemoveRequest(xsltProcessRequest, nullptr, NS_OK); - nsresult endRv = es.end(rv); if (NS_SUCCEEDED(rv)) { rv = endRv; diff --git a/dom/xslt/xslt/txXSLTProcessor.cpp b/dom/xslt/xslt/txXSLTProcessor.cpp index cd1030de4..7335d7b84 100644 --- a/dom/xslt/xslt/txXSLTProcessor.cpp +++ b/dom/xslt/xslt/txXSLTProcessor.cpp @@ -43,21 +43,12 @@ txXSLTProcessor::shutdown() nsresult txXSLTProcessor::execute(txExecutionState& aEs) { - nsresult rv; - do { + nsresult rv = NS_OK; txInstruction* instr; - nsresult rv = aEs.getNextInstruction(instr); - if (NS_FAILED(rv)) { - return rv; + while ((instr = aEs.getNextInstruction())) { + rv = instr->execute(aEs); + NS_ENSURE_SUCCESS(rv, rv); } - if (!instr) { - // reached null, no more instructions. - return NS_OK; - } - - rv = instr->execute(aEs); - } while (NS_SUCCEEDED(rv)); - - return rv; + return NS_OK; } -- cgit v1.2.3