From 473737daaa17d5be95d50d62705265b865368771 Mon Sep 17 00:00:00 2001 From: "peterv%netscape.com" Date: Thu, 20 Jun 2002 12:04:22 +0000 Subject: [PATCH] Fix for bug 142108 (Crash when reloading XML+XSLT Trunk, M100, N70PR1, M11A [@ nsXMLContentSink::Observe][@ 0x00000001]). r=Pike, sr=jst. git-svn-id: svn://10.0.0.236/trunk@123686 18797224-902f-48f8-a5cc-f745e15eee43 --- .../mac/build_scripts/MozillaBuildList.pm | 3 +- mozilla/config/module2dir.pl | 1 - .../content/base/public/nsIDocumentViewer.h | 3 - mozilla/content/base/src/Makefile.in | 1 - mozilla/content/base/src/makefile.win | 1 - mozilla/content/base/src/nsDocumentViewer.cpp | 18 +- mozilla/content/macbuild/contentIDL.xml | 34 +++- .../xml/document/src/nsXMLContentSink.cpp | 172 +++++++----------- .../xml/document/src/nsXMLContentSink.h | 11 +- mozilla/content/xsl/document/Makefile.in | 2 +- mozilla/content/xsl/document/makefile.win | 2 +- mozilla/content/xsl/document/public/MANIFEST | 5 + .../xsl/document/{src => public}/MANIFEST_IDL | 1 + .../content/xsl/document/public/Makefile.in | 55 ++++++ .../content/xsl/document/public/makefile.win | 50 +++++ .../nsIDocumentTransformer.idl | 30 +-- .../{src => public}/nsITransformMediator.h | 28 +-- .../document/public/nsITransformObserver.idl | 49 +++++ mozilla/content/xsl/document/src/Makefile.in | 10 +- mozilla/content/xsl/document/src/makefile.win | 14 +- .../xsl/document/src/nsTransformMediator.cpp | 42 ++--- .../xsl/document/src/nsTransformMediator.h | 15 +- .../xsl/document/src/nsXSLContentSink.cpp | 35 ++-- .../extensions/transformiix/build/Makefile.in | 1 - .../transformiix/build/makefile.win | 1 - .../transformiix/source/xslt/Makefile.in | 1 - .../source/xslt/XSLTProcessor.cpp | 29 +-- .../transformiix/source/xslt/XSLTProcessor.h | 6 +- .../transformiix/source/xslt/makefile.win | 1 - mozilla/layout/base/nsDocumentViewer.cpp | 18 +- mozilla/layout/base/nsIDocumentViewer.h | 3 - .../xpinstall/packager/packages-static-unix | 2 +- .../xpinstall/packager/packages-static-win | 2 +- mozilla/xpinstall/packager/packages-unix | 2 +- mozilla/xpinstall/packager/packages-win | 2 +- 35 files changed, 370 insertions(+), 280 deletions(-) create mode 100644 mozilla/content/xsl/document/public/MANIFEST rename mozilla/content/xsl/document/{src => public}/MANIFEST_IDL (82%) create mode 100644 mozilla/content/xsl/document/public/Makefile.in create mode 100644 mozilla/content/xsl/document/public/makefile.win rename mozilla/content/xsl/document/{src => public}/nsIDocumentTransformer.idl (66%) rename mozilla/content/xsl/document/{src => public}/nsITransformMediator.h (76%) create mode 100644 mozilla/content/xsl/document/public/nsITransformObserver.idl diff --git a/mozilla/build/mac/build_scripts/MozillaBuildList.pm b/mozilla/build/mac/build_scripts/MozillaBuildList.pm index 6d65ac718d6..48a9f300014 100644 --- a/mozilla/build/mac/build_scripts/MozillaBuildList.pm +++ b/mozilla/build/mac/build_scripts/MozillaBuildList.pm @@ -941,7 +941,8 @@ sub BuildClientDist() InstallFromManifest(":mozilla:content:xbl:public:MANIFEST", "$distdirectory:content:"); InstallFromManifest(":mozilla:content:xml:content:public:MANIFEST", "$distdirectory:content:"); InstallFromManifest(":mozilla:content:xml:document:public:MANIFEST", "$distdirectory:content:"); - InstallFromManifest(":mozilla:content:xsl:document:src:MANIFEST_IDL", "$distdirectory:idl:"); + InstallFromManifest(":mozilla:content:xsl:document:public:MANIFEST", "$distdirectory:content:"); + InstallFromManifest(":mozilla:content:xsl:document:public:MANIFEST_IDL", "$distdirectory:idl:"); InstallFromManifest(":mozilla:content:xul:content:public:MANIFEST", "$distdirectory:content:"); InstallFromManifest(":mozilla:content:xul:document:public:MANIFEST", "$distdirectory:content:"); InstallFromManifest(":mozilla:content:xul:document:public:MANIFEST_IDL", "$distdirectory:idl:"); diff --git a/mozilla/config/module2dir.pl b/mozilla/config/module2dir.pl index f81261b57f5..6d1998aa523 100755 --- a/mozilla/config/module2dir.pl +++ b/mozilla/config/module2dir.pl @@ -40,7 +40,6 @@ my %map = ( 'commandhandler', 'embedding/components/commandhandler', 'composer', 'editor/composer', 'content', 'content', - 'content_xsl', 'content/xsl/document', 'cookie', 'extensions/cookie', 'ctl', 'extensions/ctl', 'dbm', 'dbm', diff --git a/mozilla/content/base/public/nsIDocumentViewer.h b/mozilla/content/base/public/nsIDocumentViewer.h index 4dfb623de81..058c6dc8dd9 100644 --- a/mozilla/content/base/public/nsIDocumentViewer.h +++ b/mozilla/content/base/public/nsIDocumentViewer.h @@ -44,7 +44,6 @@ class nsIDocument; class nsIPresContext; class nsIPresShell; class nsIStyleSheet; -class nsITransformMediator; #define NS_IDOCUMENT_VIEWER_IID \ { 0xa6cf9057, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} @@ -68,8 +67,6 @@ public: NS_IMETHOD CreateDocumentViewerUsing(nsIPresContext* aPresContext, nsIDocumentViewer*& aResult) = 0; - - NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator)=0; }; #endif /* nsIDocumentViewer_h___ */ diff --git a/mozilla/content/base/src/Makefile.in b/mozilla/content/base/src/Makefile.in index c38ba65576a..e260cccb050 100644 --- a/mozilla/content/base/src/Makefile.in +++ b/mozilla/content/base/src/Makefile.in @@ -49,7 +49,6 @@ REQUIRES = xpcom \ xpconnect \ util \ unicharutil \ - content_xsl \ xuldoc \ intl \ windowwatcher \ diff --git a/mozilla/content/base/src/makefile.win b/mozilla/content/base/src/makefile.win index 5b44dd33307..91b2c519166 100644 --- a/mozilla/content/base/src/makefile.win +++ b/mozilla/content/base/src/makefile.win @@ -51,7 +51,6 @@ REQUIRES = xpcom \ layout \ gfx \ layout_xul \ - content_xsl \ content_xul \ windowwatcher \ intl \ diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 4bef747c2a9..14836311485 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -184,8 +184,6 @@ const char* kPrintingPromptService = "@mozilla.org/embedcomp/printingprompt-serv #include "nsIDOMFocusListener.h" #include "nsISelectionController.h" -#include "nsITransformMediator.h" - #ifdef IBMBIDI #include "nsBidiUtils.h" #endif @@ -511,7 +509,6 @@ public: NS_IMETHOD GetPresContext(nsIPresContext*& aResult); NS_IMETHOD CreateDocumentViewerUsing(nsIPresContext* aPresContext, nsIDocumentViewer*& aResult); - NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator); // nsIContentViewerEdit NS_DECL_NSICONTENTVIEWEREDIT @@ -698,9 +695,8 @@ protected: nsISupports* mContainer; // [WEAK] it owns me! nsCOMPtr mDeviceContext; // ??? can't hurt, but... - // the following seven items are explicitly in this order + // the following six items are explicitly in this order // so they will be destroyed in the reverse order (pinkerton, scc) - nsCOMPtr mTransformMediator; nsCOMPtr mDocument; nsCOMPtr mWindow; // ??? should we really own it? nsCOMPtr mViewManager; @@ -1389,8 +1385,6 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget, const nsRect& aBounds, PRBool aDoCreation) { - mTransformMediator = nsnull; - #ifdef NS_PRINT_PREVIEW mParentWidget = aParentWidget; // not ref counted #endif @@ -5343,16 +5337,6 @@ nsresult DocumentViewerImpl::DocumentReadyForPrinting() return rv; } -NS_IMETHODIMP -DocumentViewerImpl::SetTransformMediator(nsITransformMediator* aMediator) -{ - NS_ASSERTION(!mTransformMediator || !aMediator, - "nsXMLDocument::SetTransformMediator(): \ - Cannot set a second transform mediator\n"); - mTransformMediator = aMediator; - return NS_OK; -} - #ifdef XP_MAC #pragma mark - #endif diff --git a/mozilla/content/macbuild/contentIDL.xml b/mozilla/content/macbuild/contentIDL.xml index c1679539c79..0d8e32f0b8c 100644 --- a/mozilla/content/macbuild/contentIDL.xml +++ b/mozilla/content/macbuild/contentIDL.xml @@ -347,7 +347,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password25jysun5jyay2Ù±ÀÑ“( + MWFTP_Post_password0 MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -897,6 +897,13 @@ Text + + Name + nsITransformObserver.idl + MacOS + Text + + @@ -1004,6 +1011,11 @@ nsIDragDropOverride.idl MacOS + + Name + nsITransformObserver.idl + MacOS + @@ -1300,7 +1312,7 @@ MWFTP_Post_hostName MWFTP_Post_username - MWFTP_Post_password25jysun5jyay2Ù±ÀÑ“( + MWFTP_Post_password0 MWFTP_Post_remoteDir MWFTP_Post_ftp_PathVersion1 MWFTP_Post_ftp_PathType0 @@ -1850,6 +1862,13 @@ Text + + Name + nsITransformObserver.idl + MacOS + Text + + @@ -1957,6 +1976,11 @@ nsIDragDropOverride.idl MacOS + + Name + nsITransformObserver.idl + MacOS + @@ -2093,6 +2117,12 @@ nsIDragDropOverride.idl MacOS + + headers + Name + nsITransformObserver.idl + MacOS + diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index dde5f9017df..98e71e26482 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -88,7 +88,6 @@ #include "nsXSLContentSink.h" #include "nsParserCIID.h" #include "nsParserUtils.h" -#include "nsIDocumentViewer.h" #include "nsIScrollable.h" #include "nsRect.h" #include "nsGenericElement.h" @@ -260,7 +259,7 @@ NS_INTERFACE_MAP_BEGIN(nsXMLContentSink) NS_INTERFACE_MAP_ENTRY(nsIXMLContentSink) NS_INTERFACE_MAP_ENTRY(nsIContentSink) NS_INTERFACE_MAP_ENTRY(nsIExpatSink) - NS_INTERFACE_MAP_ENTRY(nsIObserver) + NS_INTERFACE_MAP_ENTRY(nsITransformObserver) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_ENTRY(nsIScriptLoaderObserver) NS_INTERFACE_MAP_ENTRY(nsICSSLoaderObserver) @@ -362,13 +361,14 @@ nsXMLContentSink::DidBuildModel(PRInt32 aQualityLevel) rv = SetupTransformMediator(); } - nsCOMPtr loader; - mDocument->GetScriptLoader(getter_AddRefs(loader)); - if (loader) { - loader->RemoveObserver(this); - } - + // Kick off layout for non-XSLT transformed documents. if (!mXSLTransformMediator || NS_FAILED(rv)) { + nsCOMPtr loader; + mDocument->GetScriptLoader(getter_AddRefs(loader)); + if (loader) { + loader->RemoveObserver(this); + } + StartLayout(); #if 0 /* Disable until this works for XML */ @@ -392,7 +392,7 @@ nsXMLContentSink::DidBuildModel(PRInt32 aQualityLevel) // Do this hack to make sure that the parser // doesn't get destroyed, accidently, before // the circularity, between sink & parser, is - // actually borken. + // actually broken. nsCOMPtr kungFuDeathGrip(mParser); // Drop our reference to the parser to get rid of a circular @@ -402,88 +402,71 @@ nsXMLContentSink::DidBuildModel(PRInt32 aQualityLevel) return NS_OK; } -// The observe method is called on completion of the transform. The nsISupports argument is an -// nsIContent interface to the root node of the output content model. NS_IMETHODIMP -nsXMLContentSink::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) +nsXMLContentSink::OnTransformDone(nsresult aResult, + nsIDOMDocument* aResultDocument) { - nsresult rv = NS_OK; + NS_ASSERTION(NS_FAILED(aResult) || aResultDocument, + "Don't notify about transform success without a document."); - if (!nsCRT::strcmp(aTopic, "xslt-done")) { - nsCOMPtr docShell(do_QueryInterface(mWebShell)); - nsCOMPtr contentViewer; - docShell->GetContentViewer(getter_AddRefs(contentViewer)); + // Reset the observer on the transform mediator + mXSLTransformMediator->SetTransformObserver(nsnull); - // Set the output content model on the document - nsCOMPtr content = do_QueryInterface(aSubject, &rv); - if (NS_SUCCEEDED(rv)) { - nsCOMPtr resultDOMDoc; - mXSLTransformMediator->GetResultDocument(getter_AddRefs(resultDOMDoc)); - nsCOMPtr resultDoc = do_QueryInterface(resultDOMDoc); + nsCOMPtr docShell(do_QueryInterface(mWebShell)); + nsCOMPtr contentViewer; + docShell->GetContentViewer(getter_AddRefs(contentViewer)); - nsCOMPtr sourceDoc = mDocument; - NS_RELEASE(mDocument); - - mDocument = resultDoc; - NS_ADDREF(mDocument); - nsCOMPtr root; - mDocument->GetRootContent(getter_AddRefs(root)); - if (!root) - mDocument->SetRootContent(content); - - // Reset the observer on the transform mediator - mXSLTransformMediator->SetTransformObserver(nsnull); - - // Start the layout process - StartLayout(); - -#if 0 /* Disable until this works for XML */ - // Scroll to Anchor only if the document was *not* loaded through history means. - PRUint32 documentLoadType = 0; - docShell->GetLoadType(&documentLoadType); - if (!(documentLoadType & nsIDocShell::LOAD_CMD_HISTORY)) { - ScrollToRef(); - } -#else - ScrollToRef(); -#endif - - sourceDoc->EndLoad(); - - if (contentViewer) { - contentViewer->LoadComplete(NS_OK); - } + if (NS_FAILED(aResult) && contentViewer) { + // Transform failed. + if (aResultDocument) { + // We have an error document. + contentViewer->SetDOMDocument(aResultDocument); } - else - { - // Transform failed - nsCOMPtr documentViewer(do_QueryInterface(contentViewer)); - if (documentViewer) { - documentViewer->SetTransformMediator(nsnull); - } - - mDocument->SetRootContent(mDocElement); - - // Start the layout process - StartLayout(); - -#if 0 /* Disable until this works for XML */ - // Scroll to Anchor only if the document was *not* loaded through history means. - PRUint32 documentLoadType = 0; - docShell->GetLoadType(&documentLoadType); - if (!(documentLoadType & nsIDocShell::LOAD_CMD_HISTORY)) { - ScrollToRef(); - } -#else - ScrollToRef(); -#endif - - mDocument->EndLoad(); + else { + // We don't have an error document, display the + // untransformed source document. + nsCOMPtr document = do_QueryInterface(mDocument); + contentViewer->SetDOMDocument(document); } - - mXSLTransformMediator = nsnull; } - return rv; + + nsCOMPtr originalDocument = mDocument; + if (NS_SUCCEEDED(aResult) || aResultDocument) { + // Transform succeeded or it failed and we have an error + // document to display. + NS_RELEASE(mDocument); + CallQueryInterface(aResultDocument, &mDocument); // addrefs + } + else + { + // Transform failed and we don't have an error document, display the + // untransformed source document. + mDocument->SetRootContent(mDocElement); + } + + nsCOMPtr loader; + originalDocument->GetScriptLoader(getter_AddRefs(loader)); + if (loader) { + loader->RemoveObserver(this); + } + + // Start the layout process + StartLayout(); + +#if 0 /* Disable until this works for XML */ + // Scroll to Anchor only if the document was *not* loaded through history means. + PRUint32 documentLoadType = 0; + docShell->GetLoadType(&documentLoadType); + if (!(documentLoadType & nsIDocShell::LOAD_CMD_HISTORY)) { + ScrollToRef(); + } +#else + ScrollToRef(); +#endif + + originalDocument->EndLoad(); + + return NS_OK; } @@ -512,13 +495,10 @@ nsXMLContentSink::SetupTransformMediator() rv = NS_NewDOMDocument(getter_AddRefs(resultDOMDoc), emptyStr, emptyStr, nsnull, url); if (NS_FAILED(rv)) return rv; - nsCOMPtr resultXMLDoc(do_QueryInterface(resultDOMDoc)); - resultXMLDoc->SetDefaultStylesheets(url); - nsCOMPtr docShell(do_QueryInterface(mWebShell)); nsCOMPtr contentViewer; - rv = docShell->GetContentViewer(getter_AddRefs(contentViewer)); - if (NS_SUCCEEDED(rv) && contentViewer) { + docShell->GetContentViewer(getter_AddRefs(contentViewer)); + if (contentViewer) { contentViewer->SetDOMDocument(resultDOMDoc); } @@ -651,15 +631,6 @@ nsXMLContentSink::LoadXSLStyleSheet(nsIURI* aUrl) // this state by calling the various setters on nsITransformMediator. mXSLTransformMediator->SetEnabled(PR_TRUE); - // The document viewer owns the transform mediator. - nsCOMPtr docShell(do_QueryInterface(mWebShell)); - nsCOMPtr contentViewer; - rv = docShell->GetContentViewer(getter_AddRefs(contentViewer)); - nsCOMPtr documentViewer(do_QueryInterface(contentViewer)); - if (documentViewer) { - documentViewer->SetTransformMediator(mXSLTransformMediator); - } - // Create the XSL stylesheet document nsCOMPtr styleDOMDoc; nsAutoString emptyStr; @@ -1972,13 +1943,6 @@ nsXMLContentSink::ReportError(const PRUnichar* aErrorText, if (mXSLTransformMediator) { // Get rid of the transform mediator. - nsCOMPtr docShell(do_QueryInterface(mWebShell)); - nsCOMPtr contentViewer; - rv = docShell->GetContentViewer(getter_AddRefs(contentViewer)); - nsCOMPtr documentViewer(do_QueryInterface(contentViewer)); - if (documentViewer) { - documentViewer->SetTransformMediator(nsnull); - } mXSLTransformMediator->SetEnabled(PR_FALSE); mXSLTransformMediator = nsnull; } diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.h b/mozilla/content/xml/document/src/nsXMLContentSink.h index 41e7d5f2f4a..f2b4c1c17ed 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.h +++ b/mozilla/content/xml/document/src/nsXMLContentSink.h @@ -42,7 +42,6 @@ #include "nsIXMLContentSink.h" #include "nsIViewManager.h" #include "nsIScrollableView.h" -#include "nsIObserver.h" #include "nsWeakReference.h" #include "nsITransformMediator.h" #include "nsIUnicharInputStream.h" @@ -58,6 +57,7 @@ class nsICSSStyleSheet; #include "nsIScriptLoaderObserver.h" #include "nsSupportsArray.h" #include "nsIExpatSink.h" +#include "nsITransformObserver.h" class nsIDocument; class nsIURI; @@ -81,7 +81,7 @@ typedef enum { // XXX Till the parser knows a little bit more about XML, // this is a HTMLContentSink. class nsXMLContentSink : public nsIXMLContentSink, - public nsIObserver, + public nsITransformObserver, public nsSupportsWeakReference, public nsIScriptLoaderObserver, public nsICSSLoaderObserver, @@ -99,7 +99,7 @@ public: // nsISupports NS_DECL_ISUPPORTS NS_DECL_NSISCRIPTLOADEROBSERVER - + NS_DECL_NSITRANSFORMOBSERVER NS_DECL_NSIEXPATSINK // nsIContentSink @@ -114,11 +114,6 @@ public: // nsICSSLoaderObserver NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify); - // nsIObserver - NS_IMETHOD Observe(nsISupports *aSubject, - const char *aTopic, - const PRUnichar *someData); - protected: void StartLayout(); diff --git a/mozilla/content/xsl/document/Makefile.in b/mozilla/content/xsl/document/Makefile.in index e98c66370c1..b120f610dea 100755 --- a/mozilla/content/xsl/document/Makefile.in +++ b/mozilla/content/xsl/document/Makefile.in @@ -21,7 +21,7 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS = src +DIRS = public src include $(topsrcdir)/config/config.mk diff --git a/mozilla/content/xsl/document/makefile.win b/mozilla/content/xsl/document/makefile.win index 841cfcbc222..09d593e23d0 100644 --- a/mozilla/content/xsl/document/makefile.win +++ b/mozilla/content/xsl/document/makefile.win @@ -21,6 +21,6 @@ DEPTH=..\..\.. -DIRS=src +DIRS=public src include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/content/xsl/document/public/MANIFEST b/mozilla/content/xsl/document/public/MANIFEST new file mode 100644 index 00000000000..bb0dde600b6 --- /dev/null +++ b/mozilla/content/xsl/document/public/MANIFEST @@ -0,0 +1,5 @@ +# +# This is a list of local files which get copied to the mozilla:dist:content directory +# + +nsITransformMediator.h diff --git a/mozilla/content/xsl/document/src/MANIFEST_IDL b/mozilla/content/xsl/document/public/MANIFEST_IDL similarity index 82% rename from mozilla/content/xsl/document/src/MANIFEST_IDL rename to mozilla/content/xsl/document/public/MANIFEST_IDL index b7cea946ca0..329cd8ec792 100644 --- a/mozilla/content/xsl/document/src/MANIFEST_IDL +++ b/mozilla/content/xsl/document/public/MANIFEST_IDL @@ -3,3 +3,4 @@ # nsIDocumentTransformer.idl +nsITransformObserver.idl diff --git a/mozilla/content/xsl/document/public/Makefile.in b/mozilla/content/xsl/document/public/Makefile.in new file mode 100644 index 00000000000..12d36bbceec --- /dev/null +++ b/mozilla/content/xsl/document/public/Makefile.in @@ -0,0 +1,55 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 2002 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Peter Van der Beken (original author) +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = content +XPIDL_MODULE = content_xslt + +XPIDLSRCS = nsIDocumentTransformer.idl \ + nsITransformObserver.idl \ + $(NULL) + +EXPORTS = nsITransformMediator.h \ + $(NULL) + +include $(topsrcdir)/config/rules.mk diff --git a/mozilla/content/xsl/document/public/makefile.win b/mozilla/content/xsl/document/public/makefile.win new file mode 100644 index 00000000000..d280b12f96e --- /dev/null +++ b/mozilla/content/xsl/document/public/makefile.win @@ -0,0 +1,50 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 2002 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Peter Van der Beken (original author) +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH=..\..\..\.. + +MODULE = content +XPIDL_MODULE = content_xslt + +XPIDLSRCS = .\nsIDocumentTransformer.idl \ + .\nsITransformObserver.idl \ + $(NULL) + +EXPORTS = nsITransformMediator.h \ + $(NULL) + +include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/content/xsl/document/src/nsIDocumentTransformer.idl b/mozilla/content/xsl/document/public/nsIDocumentTransformer.idl similarity index 66% rename from mozilla/content/xsl/document/src/nsIDocumentTransformer.idl rename to mozilla/content/xsl/document/public/nsIDocumentTransformer.idl index bb067abc0a8..63c0b880fcb 100644 --- a/mozilla/content/xsl/document/src/nsIDocumentTransformer.idl +++ b/mozilla/content/xsl/document/public/nsIDocumentTransformer.idl @@ -1,11 +1,11 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License @@ -14,12 +14,14 @@ * * The Original Code is mozilla.org code. * - * The Initial Developer of the Original Code is + * The Initial Developer of the Original Code is * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 + * Portions created by the Initial Developer are Copyright (C) 2002 * the Initial Developer. All Rights Reserved. * * Contributor(s): + * Nisheeth Ranjan (original author) + * Peter Van der Beken * * * Alternatively, the contents of this file may be used under the terms of @@ -28,11 +30,11 @@ * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your + * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. + * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ @@ -40,7 +42,7 @@ interface nsIDOMNode; interface nsIDOMDocument; -interface nsIObserver; +interface nsITransformObserver; /** * This interface should be implemented by any object that wants to @@ -53,9 +55,9 @@ interface nsIObserver; interface nsIDocumentTransformer : nsISupports { void transformDocument(in nsIDOMNode aSourceDOM, - in nsIDOMNode aStyleDOM, - in nsIDOMDocument aOutputDOC, - in nsIObserver aObserver); + in nsIDOMNode aStyleDOM, + in nsIDOMDocument aOutputDOC, + in nsITransformObserver aObserver); }; diff --git a/mozilla/content/xsl/document/src/nsITransformMediator.h b/mozilla/content/xsl/document/public/nsITransformMediator.h similarity index 76% rename from mozilla/content/xsl/document/src/nsITransformMediator.h rename to mozilla/content/xsl/document/public/nsITransformMediator.h index 1ba32b54922..25b5906ac03 100644 --- a/mozilla/content/xsl/document/src/nsITransformMediator.h +++ b/mozilla/content/xsl/document/public/nsITransformMediator.h @@ -1,25 +1,27 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * - * The Original Code is Mozilla Communicator client code. + * The Original Code is mozilla.org code. * - * The Initial Developer of the Original Code is + * The Initial Developer of the Original Code is * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 + * Portions created by the Initial Developer are Copyright (C) 2002 * the Initial Developer. All Rights Reserved. * * Contributor(s): + * Nisheeth Ranjan (original author) + * Peter Van der Beken * * * Alternatively, the contents of this file may be used under the terms of @@ -28,11 +30,11 @@ * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your + * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. + * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ @@ -44,7 +46,7 @@ class nsIDOMNode; class nsIDOMDocument; -class nsIObserver; +class nsITransformObserver; class nsIXMLContentSink; /* 6f4c2d0e-2cdf-11d3-aef3-00108300ff91 */ @@ -52,7 +54,7 @@ class nsIXMLContentSink; { 0x6f4c2d0e, 0x2cdf, 0x11d3, {0xae, 0xf3, 0x00, 0x10, 0x83, 0x00, 0xff, 0x91} } /** - * This interface represents a mediator between raptor and an external + * This interface represents a mediator between Gecko and an external * transformation engine. The following process of document transformation * is assumed : a source document, a stylesheet specifying the transform, * and an output document are passed to a transformation engine. All three @@ -70,7 +72,7 @@ public: NS_IMETHOD SetStyleSheetContentModel(nsIDOMNode* aStyle) = 0; NS_IMETHOD SetResultDocument(nsIDOMDocument* aDoc) = 0; NS_IMETHOD GetResultDocument(nsIDOMDocument** aDoc) = 0; - NS_IMETHOD SetTransformObserver(nsIObserver* aObserver) = 0; + NS_IMETHOD SetTransformObserver(nsITransformObserver* aObserver) = 0; NS_IMETHOD SetStyleInvalid(PRBool aInvalid) = 0; }; diff --git a/mozilla/content/xsl/document/public/nsITransformObserver.idl b/mozilla/content/xsl/document/public/nsITransformObserver.idl new file mode 100644 index 00000000000..5458b7e3681 --- /dev/null +++ b/mozilla/content/xsl/document/public/nsITransformObserver.idl @@ -0,0 +1,49 @@ +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Peter Van der Beken (original author) + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" + +interface nsIDOMDocument; + +[scriptable, uuid(cce88481-6eb3-11d6-a7f2-8d82cd2af37c)] +interface nsITransformObserver : nsISupports +{ + void onTransformDone(in nsresult aResult, + in nsIDOMDocument aResultDocument); +}; diff --git a/mozilla/content/xsl/document/src/Makefile.in b/mozilla/content/xsl/document/src/Makefile.in index 87115a00656..205b99e96f1 100755 --- a/mozilla/content/xsl/document/src/Makefile.in +++ b/mozilla/content/xsl/document/src/Makefile.in @@ -22,7 +22,7 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -MODULE = content_xsl +MODULE = content LIBRARY_NAME = gkconxsldoc_s REQUIRES = xpcom \ string \ @@ -44,19 +44,11 @@ ifeq ($(OS_ARCH),WINNT) DEFINES += -DWIN32_LEAN_AND_MEAN endif -XPIDLSRCS= \ - nsIDocumentTransformer.idl \ - $(NULL) - CPPSRCS = \ nsXSLContentSink.cpp \ nsTransformMediator.cpp \ $(NULL) -EXPORTS = \ - nsITransformMediator.h \ - $(NULL) - LOCAL_INCLUDES = \ -I$(srcdir)/../../../xml/document/src \ $(NULL) diff --git a/mozilla/content/xsl/document/src/makefile.win b/mozilla/content/xsl/document/src/makefile.win index 1b33815e501..6638979308a 100644 --- a/mozilla/content/xsl/document/src/makefile.win +++ b/mozilla/content/xsl/document/src/makefile.win @@ -21,9 +21,10 @@ DEPTH=..\..\..\.. -LIBRARY_NAME=contentxsldoc_s -MODULE=content_xsl -REQUIRES = xpcom \ +LIBRARY_NAME = contentxsldoc_s +MODULE = content + +REQUIRES = xpcom \ string \ htmlparser \ view \ @@ -37,18 +38,11 @@ REQUIRES = xpcom \ DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN -XPIDLSRCS= .\nsIDocumentTransformer.idl \ - $(NULL) - CPP_OBJS= \ .\$(OBJDIR)\nsXSLContentSink.obj \ .\$(OBJDIR)\nsTransformMediator.obj \ $(NULL) -EXPORTS = \ - nsITransformMediator.h \ - $(NULL) - LINCS= -I..\..\..\html\style\src -I..\..\..\html\base\src \ -I..\..\..\html\content\src -I..\..\..\html\document\src \ -I..\..\..\xul\content\src -I..\..\..\xml\document\src \ diff --git a/mozilla/content/xsl/document/src/nsTransformMediator.cpp b/mozilla/content/xsl/document/src/nsTransformMediator.cpp index 8d10b0e5cf1..a4a225fba28 100644 --- a/mozilla/content/xsl/document/src/nsTransformMediator.cpp +++ b/mozilla/content/xsl/document/src/nsTransformMediator.cpp @@ -38,11 +38,6 @@ #include "nsTransformMediator.h" #include "nsIComponentManager.h" -#include "nsIContent.h" -#include "nsIDocument.h" -#include "nsIDOMElement.h" -#include "nsIServiceManagerUtils.h" -#include "nsObserverService.h" #include "nsString.h" nsresult @@ -102,37 +97,24 @@ NS_IMPL_ISUPPORTS1(nsTransformMediator, nsITransformMediator) void nsTransformMediator::TryToTransform() { - if (mSourceDOM && mStyleDOM && mResultDoc && mObserver) + nsCOMPtr observer = do_QueryReferent(mObserver); + if (mSourceDOM && mStyleDOM && mResultDoc && observer) { if (mEnabled && mTransformer) { mTransformer->TransformDocument(mSourceDOM, mStyleDOM, mResultDoc, - mObserver); + observer); } else if (mStyleInvalid) { - // Copy the error message from the stylesheet document to the result - // result document and notify the observer. - nsCOMPtr docElement; - mResultDoc->GetDocumentElement(getter_AddRefs(docElement)); - nsCOMPtr newRoot, root; - mResultDoc->ImportNode(mStyleDOM, PR_TRUE, getter_AddRefs(newRoot)); - if (docElement) { - nsCOMPtr origRoot; - root = newRoot; - mResultDoc->ReplaceChild(docElement, root, getter_AddRefs(origRoot)); - } - else { - mResultDoc->AppendChild(newRoot, getter_AddRefs(root)); - } + // Avoid recursion. + mStyleInvalid = PR_FALSE; - nsresult rv; - nsCOMPtr anObserverService = - do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv)) { - anObserverService->AddObserver(mObserver, "xslt-done", PR_TRUE); - anObserverService->NotifyObservers(root, "xslt-done", nsnull); - } + // Notify the observer with the stylesheet which contains + // the error message. + nsCOMPtr errorDoc; + mStyleDOM->GetOwnerDocument(getter_AddRefs(errorDoc)); + observer->OnTransformDone(NS_ERROR_FAILURE, errorDoc); } } } @@ -179,9 +161,9 @@ nsTransformMediator::GetResultDocument(nsIDOMDocument** aDoc) } NS_IMETHODIMP -nsTransformMediator::SetTransformObserver(nsIObserver* aObserver) +nsTransformMediator::SetTransformObserver(nsITransformObserver* aObserver) { - mObserver = aObserver; + mObserver = do_GetWeakReference(aObserver); TryToTransform(); return NS_OK; } diff --git a/mozilla/content/xsl/document/src/nsTransformMediator.h b/mozilla/content/xsl/document/src/nsTransformMediator.h index f13fb8d5582..8c631eba2e1 100644 --- a/mozilla/content/xsl/document/src/nsTransformMediator.h +++ b/mozilla/content/xsl/document/src/nsTransformMediator.h @@ -44,7 +44,8 @@ #include "nsIDocumentTransformer.h" #include "nsIDOMNode.h" #include "nsIDOMDocument.h" -#include "nsIObserver.h" +#include "nsITransformObserver.h" +#include "nsWeakPtr.h" class nsTransformMediator : public nsITransformMediator { public: @@ -62,7 +63,7 @@ public: NS_IMETHOD SetStyleSheetContentModel(nsIDOMNode* aStyle); NS_IMETHOD SetResultDocument(nsIDOMDocument* aDoc); NS_IMETHOD GetResultDocument(nsIDOMDocument** aDoc); - NS_IMETHOD SetTransformObserver(nsIObserver* aObserver); + NS_IMETHOD SetTransformObserver(nsITransformObserver* aObserver); NS_IMETHOD SetStyleInvalid(PRBool aInvalid); protected: @@ -70,11 +71,11 @@ protected: PRBool mEnabled; PRBool mStyleInvalid; - nsCOMPtr mTransformer; // Strong reference - nsCOMPtr mSourceDOM; // Strong reference - nsCOMPtr mStyleDOM; // Strong reference - nsCOMPtr mResultDoc; // Strong reference - nsCOMPtr mObserver; // Strong reference + nsCOMPtr mTransformer; + nsCOMPtr mSourceDOM; + nsCOMPtr mStyleDOM; + nsCOMPtr mResultDoc; + nsWeakPtr mObserver; }; #endif // nsTransformMediator_h__ diff --git a/mozilla/content/xsl/document/src/nsXSLContentSink.cpp b/mozilla/content/xsl/document/src/nsXSLContentSink.cpp index 51272058b8b..595f7800ddd 100644 --- a/mozilla/content/xsl/document/src/nsXSLContentSink.cpp +++ b/mozilla/content/xsl/document/src/nsXSLContentSink.cpp @@ -41,6 +41,7 @@ #include "nsIDocument.h" #include "nsIDOMDocument.h" #include "nsIDOMElement.h" +#include "nsILoadGroup.h" #include "nsIParser.h" #include "nsIStyleSheetLinkingElement.h" #include "nsITransformMediator.h" @@ -55,21 +56,17 @@ NS_NewXSLContentSink(nsIXMLContentSink** aResult, nsIURI* aURL, nsIWebShell* aWebShell) { - NS_PRECONDITION(nsnull != aResult, "null ptr"); - if (nsnull == aResult) { - return NS_ERROR_NULL_POINTER; - } + NS_ENSURE_ARG(aResult); + nsXSLContentSink* it; NS_NEWXPCOM(it, nsXSLContentSink); - if (nsnull == it) { - return NS_ERROR_OUT_OF_MEMORY; - } + NS_ENSURE_TRUE(it, NS_ERROR_OUT_OF_MEMORY); + + nsCOMPtr sink = it; nsresult rv = it->Init(aTM, aDoc, aURL, aWebShell); - if (NS_OK != rv) { - delete it; - return rv; - } - return it->QueryInterface(NS_GET_IID(nsIXMLContentSink), (void **)aResult); + NS_ENSURE_SUCCESS(rv, rv); + + return CallQueryInterface(it, aResult); } nsXSLContentSink::nsXSLContentSink() @@ -82,15 +79,13 @@ nsXSLContentSink::~nsXSLContentSink() // Empty } - nsresult nsXSLContentSink::Init(nsITransformMediator* aTM, nsIDocument* aDoc, nsIURI* aURL, nsIWebShell* aContainer) { - nsresult rv; - rv = nsXMLContentSink::Init(aDoc, aURL, aContainer, nsnull); + nsresult rv = nsXMLContentSink::Init(aDoc, aURL, aContainer, nsnull); NS_ENSURE_SUCCESS(rv, rv); mXSLTransformMediator = aTM; @@ -98,7 +93,10 @@ nsXSLContentSink::Init(nsITransformMediator* aTM, nsCOMPtr loader; rv = mDocument->GetScriptLoader(getter_AddRefs(loader)); NS_ENSURE_SUCCESS(rv, rv); + loader->Suspend(); + loader->RemoveObserver(this); + return rv; } @@ -140,6 +138,7 @@ nsXSLContentSink::DidBuildModel(PRInt32 aQualityLevel) if (mXSLTransformMediator) { // Pass the style content model to the tranform mediator. mXSLTransformMediator->SetStyleSheetContentModel(styleNode); + mXSLTransformMediator = nsnull; } // Drop our reference to the parser to get rid of a circular @@ -222,6 +221,12 @@ nsXSLContentSink::ReportError(const PRUnichar* aErrorText, // nsXMLContentSink::ReportError sets mXSLTransformMediator to nsnull nsCOMPtr mediator = mXSLTransformMediator; + nsCOMPtr channel; + nsCOMPtr loadGroup; + mParser->GetChannel(getter_AddRefs(channel)); + mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + mDocument->Reset(channel, loadGroup); + nsXMLContentSink::ReportError(aErrorText, aSourceText); if (mediator) { diff --git a/mozilla/extensions/transformiix/build/Makefile.in b/mozilla/extensions/transformiix/build/Makefile.in index 26005622a20..2f27300cd46 100644 --- a/mozilla/extensions/transformiix/build/Makefile.in +++ b/mozilla/extensions/transformiix/build/Makefile.in @@ -37,7 +37,6 @@ REQUIRES = xpcom \ dom \ layout \ content \ - content_xsl \ widget \ necko \ js \ diff --git a/mozilla/extensions/transformiix/build/makefile.win b/mozilla/extensions/transformiix/build/makefile.win index 36c39245b3c..54ac744396e 100644 --- a/mozilla/extensions/transformiix/build/makefile.win +++ b/mozilla/extensions/transformiix/build/makefile.win @@ -25,7 +25,6 @@ REQUIRES = xpcom \ string \ dom \ widget \ - content_xsl \ necko \ content \ xpconnect \ diff --git a/mozilla/extensions/transformiix/source/xslt/Makefile.in b/mozilla/extensions/transformiix/source/xslt/Makefile.in index 8694f050c51..52a9961dcfb 100644 --- a/mozilla/extensions/transformiix/source/xslt/Makefile.in +++ b/mozilla/extensions/transformiix/source/xslt/Makefile.in @@ -35,7 +35,6 @@ REQUIRES = string \ dom \ layout \ content \ - content_xsl \ widget \ necko \ unicharutil \ diff --git a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp index a2c4e6509e8..2eaa5abd930 100644 --- a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp +++ b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp @@ -2275,7 +2275,7 @@ NS_IMETHODIMP XSLTProcessor::TransformDocument(nsIDOMNode* aSourceDOM, nsIDOMNode* aStyleDOM, nsIDOMDocument* aOutputDoc, - nsIObserver* aObserver) + nsITransformObserver* aObserver) { // We need source and result documents but no stylesheet. NS_ENSURE_ARG(aSourceDOM); @@ -2402,7 +2402,7 @@ XSLTProcessor::TransformDocument(nsIDOMNode* aSourceDOM, document->ContentInserted(nsnull, root, 0); } - mObserver = aObserver; + mObserver = do_GetWeakReference(aObserver); SignalTransformEnd(); return NS_OK; @@ -2442,7 +2442,8 @@ XSLTProcessor::ScriptEvaluated(nsresult aResult, void XSLTProcessor::SignalTransformEnd() { - if (!mObserver) + nsCOMPtr observer = do_QueryReferent(mObserver); + if (!observer) return; if (!mOutputHandler || !mOutputHandler->isDone()) @@ -2453,15 +2454,21 @@ XSLTProcessor::SignalTransformEnd() mScriptLoader = nsnull; } - nsresult rv; - nsCOMPtr anObserverService = do_GetService("@mozilla.org/observer-service;1", &rv); - if (NS_SUCCEEDED(rv)) { - nsCOMPtr rootContent; - mOutputHandler->getRootContent(getter_AddRefs(rootContent)); - anObserverService->AddObserver(mObserver, "xslt-done", PR_TRUE); - anObserverService->NotifyObservers(rootContent, "xslt-done", nsnull); - } mObserver = nsnull; + + // XXX Need a better way to determine transform success/failure + nsCOMPtr rootContent; + mOutputHandler->getRootContent(getter_AddRefs(rootContent)); + nsCOMPtr root = do_QueryInterface(rootContent); + if (root) { + nsCOMPtr resultDoc; + root->GetOwnerDocument(getter_AddRefs(resultDoc)); + observer->OnTransformDone(NS_OK, resultDoc); + } + else { + // XXX Need better error message and code. + observer->OnTransformDone(NS_ERROR_FAILURE, nsnull); + } } // XXX diff --git a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.h b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.h index 16be7563675..e9c04615556 100644 --- a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.h +++ b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.h @@ -41,10 +41,10 @@ #include "nsICSSLoaderObserver.h" #include "nsIDocumentTransformer.h" #include "nsIDOMHTMLScriptElement.h" -#include "nsIObserver.h" #include "nsIScriptLoader.h" #include "nsIScriptLoaderObserver.h" - +#include "nsITransformObserver.h" +#include "nsWeakPtr.h" #include "txMozillaTextOutput.h" #include "txMozillaXMLOutput.h" #endif @@ -374,7 +374,7 @@ private: void SignalTransformEnd(); nsCOMPtr mScriptLoader; - nsCOMPtr mObserver; + nsWeakPtr mObserver; #endif }; //-- XSLTProcessor diff --git a/mozilla/extensions/transformiix/source/xslt/makefile.win b/mozilla/extensions/transformiix/source/xslt/makefile.win index 83d05c18595..18f916e62c7 100644 --- a/mozilla/extensions/transformiix/source/xslt/makefile.win +++ b/mozilla/extensions/transformiix/source/xslt/makefile.win @@ -26,7 +26,6 @@ REQUIRES = string \ dom \ widget \ necko \ - content_xsl \ content \ unicharutil \ xpconnect \ diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 4bef747c2a9..14836311485 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -184,8 +184,6 @@ const char* kPrintingPromptService = "@mozilla.org/embedcomp/printingprompt-serv #include "nsIDOMFocusListener.h" #include "nsISelectionController.h" -#include "nsITransformMediator.h" - #ifdef IBMBIDI #include "nsBidiUtils.h" #endif @@ -511,7 +509,6 @@ public: NS_IMETHOD GetPresContext(nsIPresContext*& aResult); NS_IMETHOD CreateDocumentViewerUsing(nsIPresContext* aPresContext, nsIDocumentViewer*& aResult); - NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator); // nsIContentViewerEdit NS_DECL_NSICONTENTVIEWEREDIT @@ -698,9 +695,8 @@ protected: nsISupports* mContainer; // [WEAK] it owns me! nsCOMPtr mDeviceContext; // ??? can't hurt, but... - // the following seven items are explicitly in this order + // the following six items are explicitly in this order // so they will be destroyed in the reverse order (pinkerton, scc) - nsCOMPtr mTransformMediator; nsCOMPtr mDocument; nsCOMPtr mWindow; // ??? should we really own it? nsCOMPtr mViewManager; @@ -1389,8 +1385,6 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget, const nsRect& aBounds, PRBool aDoCreation) { - mTransformMediator = nsnull; - #ifdef NS_PRINT_PREVIEW mParentWidget = aParentWidget; // not ref counted #endif @@ -5343,16 +5337,6 @@ nsresult DocumentViewerImpl::DocumentReadyForPrinting() return rv; } -NS_IMETHODIMP -DocumentViewerImpl::SetTransformMediator(nsITransformMediator* aMediator) -{ - NS_ASSERTION(!mTransformMediator || !aMediator, - "nsXMLDocument::SetTransformMediator(): \ - Cannot set a second transform mediator\n"); - mTransformMediator = aMediator; - return NS_OK; -} - #ifdef XP_MAC #pragma mark - #endif diff --git a/mozilla/layout/base/nsIDocumentViewer.h b/mozilla/layout/base/nsIDocumentViewer.h index 4dfb623de81..058c6dc8dd9 100644 --- a/mozilla/layout/base/nsIDocumentViewer.h +++ b/mozilla/layout/base/nsIDocumentViewer.h @@ -44,7 +44,6 @@ class nsIDocument; class nsIPresContext; class nsIPresShell; class nsIStyleSheet; -class nsITransformMediator; #define NS_IDOCUMENT_VIEWER_IID \ { 0xa6cf9057, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} @@ -68,8 +67,6 @@ public: NS_IMETHOD CreateDocumentViewerUsing(nsIPresContext* aPresContext, nsIDocumentViewer*& aResult) = 0; - - NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator)=0; }; #endif /* nsIDocumentViewer_h___ */ diff --git a/mozilla/xpinstall/packager/packages-static-unix b/mozilla/xpinstall/packager/packages-static-unix index 395880e6acc..fe299f94c5d 100644 --- a/mozilla/xpinstall/packager/packages-static-unix +++ b/mozilla/xpinstall/packager/packages-static-unix @@ -93,7 +93,7 @@ bin/components/jar.xpt bin/components/jsconsole-clhandler.js bin/components/content_base.xpt bin/components/content_html.xpt -bin/components/content_xsl.xpt +bin/components/content_xslt.xpt bin/components/webBrowser_core.xpt bin/components/locale.xpt bin/components/mozbrwsr.xpt diff --git a/mozilla/xpinstall/packager/packages-static-win b/mozilla/xpinstall/packager/packages-static-win index 7e5bf07ffc4..dcd3bf3c81d 100644 --- a/mozilla/xpinstall/packager/packages-static-win +++ b/mozilla/xpinstall/packager/packages-static-win @@ -101,7 +101,7 @@ bin\components\gfx.xpt bin\components\gfx2.xpt bin\components\content_base.xpt bin\components\content_html.xpt -bin\components\content_xsl.xpt +bin\components\content_xslt.xpt bin\components\xuldoc.xpt bin\components\xultmpl.xpt bin\components\imglib2.xpt diff --git a/mozilla/xpinstall/packager/packages-unix b/mozilla/xpinstall/packager/packages-unix index 005fbf77325..836904ea1b6 100644 --- a/mozilla/xpinstall/packager/packages-unix +++ b/mozilla/xpinstall/packager/packages-unix @@ -140,7 +140,7 @@ bin/components/libprofile.so bin/components/libgkcontent.so bin/components/content_base.xpt bin/components/content_html.xpt -bin/components/content_xsl.xpt +bin/components/content_xslt.xpt bin/components/libgklayout.so bin/components/libgkplugin.so bin/components/libhtmlpars.so diff --git a/mozilla/xpinstall/packager/packages-win b/mozilla/xpinstall/packager/packages-win index c11840c233b..1ebca4f8566 100644 --- a/mozilla/xpinstall/packager/packages-win +++ b/mozilla/xpinstall/packager/packages-win @@ -127,7 +127,7 @@ bin\components\gfx2.dll bin\components\gkcontent.dll bin\components\content_base.xpt bin\components\content_html.xpt -bin\components\content_xsl.xpt +bin\components\content_xslt.xpt bin\components\xuldoc.xpt bin\components\xultmpl.xpt bin\components\gklayout.dll