Loading dom/xml/nsXMLContentSink.cpp +49 −41 Original line number Diff line number Diff line Loading @@ -322,22 +322,23 @@ nsXMLContentSink::DidBuildModel(bool aTerminated) { return NS_OK; } NS_IMETHODIMP nsXMLContentSink::OnDocumentCreated(Document* aResultDocument) { NS_ENSURE_ARG(aResultDocument); nsresult nsXMLContentSink::OnDocumentCreated(Document* aSourceDocument, Document* aResultDocument) { aResultDocument->SetDocWriteDisabled(true); nsCOMPtr<nsIContentViewer> contentViewer; mDocShell->GetContentViewer(getter_AddRefs(contentViewer)); if (contentViewer) { // Make sure that we haven't loaded a new document into the contentviewer // after starting the XSLT transform. if (contentViewer && contentViewer->GetDocument() == aSourceDocument) { return contentViewer->SetDocumentInternal(aResultDocument, true); } return NS_OK; } NS_IMETHODIMP nsXMLContentSink::OnTransformDone(nsresult aResult, Document* aResultDocument) { nsresult nsXMLContentSink::OnTransformDone(Document* aSourceDocument, nsresult aResult, Document* aResultDocument) { MOZ_ASSERT(aResultDocument, "Don't notify about transform end without a document."); Loading @@ -346,22 +347,28 @@ nsXMLContentSink::OnTransformDone(nsresult aResult, Document* aResultDocument) { nsCOMPtr<nsIContentViewer> contentViewer; mDocShell->GetContentViewer(getter_AddRefs(contentViewer)); if (NS_FAILED(aResult) && contentViewer) { RefPtr<Document> originalDocument = mDocument; bool blockingOnload = mIsBlockingOnload; // Make sure that we haven't loaded a new document into the contentviewer // after starting the XSLT transform. if (contentViewer && (contentViewer->GetDocument() == aSourceDocument || contentViewer->GetDocument() == aResultDocument)) { if (NS_FAILED(aResult)) { // Transform failed. aResultDocument->SetMayStartLayout(false); // We have an error document. contentViewer->SetDocument(aResultDocument); } RefPtr<Document> originalDocument = mDocument; bool blockingOnload = mIsBlockingOnload; if (!mRunsToCompletion) { // This BlockOnload call corresponds to the UnblockOnload call in // nsContentSink::DropParserAndPerfHint. aResultDocument->BlockOnload(); mIsBlockingOnload = true; } // Transform succeeded, or it failed and we have an error document to display. // Transform succeeded, or it failed and we have an error document to // display. mDocument = aResultDocument; aResultDocument->SetDocWriteDisabled(false); Loading @@ -382,6 +389,7 @@ nsXMLContentSink::OnTransformDone(nsresult aResult, Document* aResultDocument) { StartLayout(false); ScrollToRef(); } originalDocument->EndLoad(); if (blockingOnload) { Loading dom/xml/nsXMLContentSink.h +4 −3 Original line number Diff line number Diff line Loading @@ -78,9 +78,10 @@ class nsXMLContentSink : public nsContentSink, } // nsITransformObserver NS_IMETHOD OnDocumentCreated( nsresult OnDocumentCreated(mozilla::dom::Document* aSourceDocument, mozilla::dom::Document* aResultDocument) override; NS_IMETHOD OnTransformDone(nsresult aResult, nsresult OnTransformDone(mozilla::dom::Document* aSourceDocument, nsresult aResult, mozilla::dom::Document* aResultDocument) override; // nsICSSLoaderObserver Loading dom/xslt/nsIDocumentTransformer.h +6 −3 Original line number Diff line number Diff line Loading @@ -33,9 +33,12 @@ class nsITransformObserver : public nsISupports { public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITRANSFORMOBSERVER_IID) NS_IMETHOD OnDocumentCreated(mozilla::dom::Document* aResultDocument) = 0; virtual nsresult OnDocumentCreated( mozilla::dom::Document* aSourceDocument, mozilla::dom::Document* aResultDocument) = 0; NS_IMETHOD OnTransformDone(nsresult aResult, virtual nsresult OnTransformDone(mozilla::dom::Document* aSourceDocument, nsresult aResult, mozilla::dom::Document* aResultDocument) = 0; }; Loading dom/xslt/xslt/txMozillaTextOutput.cpp +10 −8 Original line number Diff line number Diff line Loading @@ -21,8 +21,11 @@ using namespace mozilla; using namespace mozilla::dom; txMozillaTextOutput::txMozillaTextOutput(nsITransformObserver* aObserver) : mObserver(do_GetWeakReference(aObserver)), mCreatedDocument(false) { txMozillaTextOutput::txMozillaTextOutput(Document* aSourceDocument, nsITransformObserver* aObserver) : mSourceDocument(aSourceDocument), mObserver(do_GetWeakReference(aObserver)), mCreatedDocument(false) { MOZ_COUNT_CTOR(txMozillaTextOutput); } Loading Loading @@ -86,7 +89,7 @@ nsresult txMozillaTextOutput::endDocument(nsresult aResult) { if (NS_SUCCEEDED(aResult)) { nsCOMPtr<nsITransformObserver> observer = do_QueryReferent(mObserver); if (observer) { observer->OnTransformDone(aResult, mDocument); observer->OnTransformDone(mSourceDocument, aResult, mDocument); } } Loading @@ -102,8 +105,7 @@ nsresult txMozillaTextOutput::processingInstruction(const nsString& aTarget, nsresult txMozillaTextOutput::startDocument() { return NS_OK; } nsresult txMozillaTextOutput::createResultDocument(Document* aSourceDocument, bool aLoadedAsData) { nsresult txMozillaTextOutput::createResultDocument(bool aLoadedAsData) { /* * Create an XHTML document to hold the text. * Loading Loading @@ -131,13 +133,13 @@ nsresult txMozillaTextOutput::createResultDocument(Document* aSourceDocument, mDocument->SetReadyStateInternal(Document::READYSTATE_LOADING); bool hasHadScriptObject = false; nsIScriptGlobalObject* sgo = aSourceDocument->GetScriptHandlingObject(hasHadScriptObject); mSourceDocument->GetScriptHandlingObject(hasHadScriptObject); NS_ENSURE_STATE(sgo || !hasHadScriptObject); NS_ASSERTION(mDocument, "Need document"); // Reset and set up document URIUtils::ResetWithSource(mDocument, aSourceDocument); URIUtils::ResetWithSource(mDocument, mSourceDocument); // Only do this after resetting the document to ensure we have the // correct principal. mDocument->SetScriptHandlingObject(sgo); Loading @@ -154,7 +156,7 @@ nsresult txMozillaTextOutput::createResultDocument(Document* aSourceDocument, // Notify the contentsink that the document is created nsCOMPtr<nsITransformObserver> observer = do_QueryReferent(mObserver); if (observer) { rv = observer->OnDocumentCreated(mDocument); rv = observer->OnDocumentCreated(mSourceDocument, mDocument); NS_ENSURE_SUCCESS(rv, rv); } Loading dom/xslt/xslt/txMozillaTextOutput.h +4 −3 Original line number Diff line number Diff line Loading @@ -24,19 +24,20 @@ class Element; class txMozillaTextOutput : public txAOutputXMLEventHandler { public: explicit txMozillaTextOutput(nsITransformObserver* aObserver); explicit txMozillaTextOutput(mozilla::dom::Document* aSourceDocument, nsITransformObserver* aObserver); explicit txMozillaTextOutput(mozilla::dom::DocumentFragment* aDest); virtual ~txMozillaTextOutput(); TX_DECL_TXAXMLEVENTHANDLER TX_DECL_TXAOUTPUTXMLEVENTHANDLER nsresult createResultDocument(mozilla::dom::Document* aSourceDocument, bool aLoadedAsData); nsresult createResultDocument(bool aLoadedAsData); private: nsresult createXHTMLElement(nsAtom* aName, mozilla::dom::Element** aResult); nsCOMPtr<mozilla::dom::Document> mSourceDocument; nsCOMPtr<nsIContent> mTextParent; nsWeakPtr mObserver; RefPtr<mozilla::dom::Document> mDocument; Loading Loading
dom/xml/nsXMLContentSink.cpp +49 −41 Original line number Diff line number Diff line Loading @@ -322,22 +322,23 @@ nsXMLContentSink::DidBuildModel(bool aTerminated) { return NS_OK; } NS_IMETHODIMP nsXMLContentSink::OnDocumentCreated(Document* aResultDocument) { NS_ENSURE_ARG(aResultDocument); nsresult nsXMLContentSink::OnDocumentCreated(Document* aSourceDocument, Document* aResultDocument) { aResultDocument->SetDocWriteDisabled(true); nsCOMPtr<nsIContentViewer> contentViewer; mDocShell->GetContentViewer(getter_AddRefs(contentViewer)); if (contentViewer) { // Make sure that we haven't loaded a new document into the contentviewer // after starting the XSLT transform. if (contentViewer && contentViewer->GetDocument() == aSourceDocument) { return contentViewer->SetDocumentInternal(aResultDocument, true); } return NS_OK; } NS_IMETHODIMP nsXMLContentSink::OnTransformDone(nsresult aResult, Document* aResultDocument) { nsresult nsXMLContentSink::OnTransformDone(Document* aSourceDocument, nsresult aResult, Document* aResultDocument) { MOZ_ASSERT(aResultDocument, "Don't notify about transform end without a document."); Loading @@ -346,22 +347,28 @@ nsXMLContentSink::OnTransformDone(nsresult aResult, Document* aResultDocument) { nsCOMPtr<nsIContentViewer> contentViewer; mDocShell->GetContentViewer(getter_AddRefs(contentViewer)); if (NS_FAILED(aResult) && contentViewer) { RefPtr<Document> originalDocument = mDocument; bool blockingOnload = mIsBlockingOnload; // Make sure that we haven't loaded a new document into the contentviewer // after starting the XSLT transform. if (contentViewer && (contentViewer->GetDocument() == aSourceDocument || contentViewer->GetDocument() == aResultDocument)) { if (NS_FAILED(aResult)) { // Transform failed. aResultDocument->SetMayStartLayout(false); // We have an error document. contentViewer->SetDocument(aResultDocument); } RefPtr<Document> originalDocument = mDocument; bool blockingOnload = mIsBlockingOnload; if (!mRunsToCompletion) { // This BlockOnload call corresponds to the UnblockOnload call in // nsContentSink::DropParserAndPerfHint. aResultDocument->BlockOnload(); mIsBlockingOnload = true; } // Transform succeeded, or it failed and we have an error document to display. // Transform succeeded, or it failed and we have an error document to // display. mDocument = aResultDocument; aResultDocument->SetDocWriteDisabled(false); Loading @@ -382,6 +389,7 @@ nsXMLContentSink::OnTransformDone(nsresult aResult, Document* aResultDocument) { StartLayout(false); ScrollToRef(); } originalDocument->EndLoad(); if (blockingOnload) { Loading
dom/xml/nsXMLContentSink.h +4 −3 Original line number Diff line number Diff line Loading @@ -78,9 +78,10 @@ class nsXMLContentSink : public nsContentSink, } // nsITransformObserver NS_IMETHOD OnDocumentCreated( nsresult OnDocumentCreated(mozilla::dom::Document* aSourceDocument, mozilla::dom::Document* aResultDocument) override; NS_IMETHOD OnTransformDone(nsresult aResult, nsresult OnTransformDone(mozilla::dom::Document* aSourceDocument, nsresult aResult, mozilla::dom::Document* aResultDocument) override; // nsICSSLoaderObserver Loading
dom/xslt/nsIDocumentTransformer.h +6 −3 Original line number Diff line number Diff line Loading @@ -33,9 +33,12 @@ class nsITransformObserver : public nsISupports { public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITRANSFORMOBSERVER_IID) NS_IMETHOD OnDocumentCreated(mozilla::dom::Document* aResultDocument) = 0; virtual nsresult OnDocumentCreated( mozilla::dom::Document* aSourceDocument, mozilla::dom::Document* aResultDocument) = 0; NS_IMETHOD OnTransformDone(nsresult aResult, virtual nsresult OnTransformDone(mozilla::dom::Document* aSourceDocument, nsresult aResult, mozilla::dom::Document* aResultDocument) = 0; }; Loading
dom/xslt/xslt/txMozillaTextOutput.cpp +10 −8 Original line number Diff line number Diff line Loading @@ -21,8 +21,11 @@ using namespace mozilla; using namespace mozilla::dom; txMozillaTextOutput::txMozillaTextOutput(nsITransformObserver* aObserver) : mObserver(do_GetWeakReference(aObserver)), mCreatedDocument(false) { txMozillaTextOutput::txMozillaTextOutput(Document* aSourceDocument, nsITransformObserver* aObserver) : mSourceDocument(aSourceDocument), mObserver(do_GetWeakReference(aObserver)), mCreatedDocument(false) { MOZ_COUNT_CTOR(txMozillaTextOutput); } Loading Loading @@ -86,7 +89,7 @@ nsresult txMozillaTextOutput::endDocument(nsresult aResult) { if (NS_SUCCEEDED(aResult)) { nsCOMPtr<nsITransformObserver> observer = do_QueryReferent(mObserver); if (observer) { observer->OnTransformDone(aResult, mDocument); observer->OnTransformDone(mSourceDocument, aResult, mDocument); } } Loading @@ -102,8 +105,7 @@ nsresult txMozillaTextOutput::processingInstruction(const nsString& aTarget, nsresult txMozillaTextOutput::startDocument() { return NS_OK; } nsresult txMozillaTextOutput::createResultDocument(Document* aSourceDocument, bool aLoadedAsData) { nsresult txMozillaTextOutput::createResultDocument(bool aLoadedAsData) { /* * Create an XHTML document to hold the text. * Loading Loading @@ -131,13 +133,13 @@ nsresult txMozillaTextOutput::createResultDocument(Document* aSourceDocument, mDocument->SetReadyStateInternal(Document::READYSTATE_LOADING); bool hasHadScriptObject = false; nsIScriptGlobalObject* sgo = aSourceDocument->GetScriptHandlingObject(hasHadScriptObject); mSourceDocument->GetScriptHandlingObject(hasHadScriptObject); NS_ENSURE_STATE(sgo || !hasHadScriptObject); NS_ASSERTION(mDocument, "Need document"); // Reset and set up document URIUtils::ResetWithSource(mDocument, aSourceDocument); URIUtils::ResetWithSource(mDocument, mSourceDocument); // Only do this after resetting the document to ensure we have the // correct principal. mDocument->SetScriptHandlingObject(sgo); Loading @@ -154,7 +156,7 @@ nsresult txMozillaTextOutput::createResultDocument(Document* aSourceDocument, // Notify the contentsink that the document is created nsCOMPtr<nsITransformObserver> observer = do_QueryReferent(mObserver); if (observer) { rv = observer->OnDocumentCreated(mDocument); rv = observer->OnDocumentCreated(mSourceDocument, mDocument); NS_ENSURE_SUCCESS(rv, rv); } Loading
dom/xslt/xslt/txMozillaTextOutput.h +4 −3 Original line number Diff line number Diff line Loading @@ -24,19 +24,20 @@ class Element; class txMozillaTextOutput : public txAOutputXMLEventHandler { public: explicit txMozillaTextOutput(nsITransformObserver* aObserver); explicit txMozillaTextOutput(mozilla::dom::Document* aSourceDocument, nsITransformObserver* aObserver); explicit txMozillaTextOutput(mozilla::dom::DocumentFragment* aDest); virtual ~txMozillaTextOutput(); TX_DECL_TXAXMLEVENTHANDLER TX_DECL_TXAOUTPUTXMLEVENTHANDLER nsresult createResultDocument(mozilla::dom::Document* aSourceDocument, bool aLoadedAsData); nsresult createResultDocument(bool aLoadedAsData); private: nsresult createXHTMLElement(nsAtom* aName, mozilla::dom::Element** aResult); nsCOMPtr<mozilla::dom::Document> mSourceDocument; nsCOMPtr<nsIContent> mTextParent; nsWeakPtr mObserver; RefPtr<mozilla::dom::Document> mDocument; Loading