зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 142108 (Crash when reloading XML+XSLT Trunk, M100, N70PR1, M11A [@ nsXMLContentSink::Observe][@ 0x00000001]). r=Pike, sr=jst.
This commit is contained in:
Родитель
ecc891787d
Коммит
d5b273bc97
|
@ -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:");
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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___ */
|
||||
|
|
|
@ -49,7 +49,6 @@ REQUIRES = xpcom \
|
|||
xpconnect \
|
||||
util \
|
||||
unicharutil \
|
||||
content_xsl \
|
||||
xuldoc \
|
||||
intl \
|
||||
windowwatcher \
|
||||
|
|
|
@ -51,7 +51,6 @@ REQUIRES = xpcom \
|
|||
layout \
|
||||
gfx \
|
||||
layout_xul \
|
||||
content_xsl \
|
||||
content_xul \
|
||||
windowwatcher \
|
||||
intl \
|
||||
|
|
|
@ -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<nsIDeviceContext> 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<nsITransformMediator> mTransformMediator;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
nsCOMPtr<nsIWidget> mWindow; // ??? should we really own it?
|
||||
nsCOMPtr<nsIViewManager> 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
|
||||
|
|
|
@ -347,7 +347,7 @@
|
|||
<!-- Settings for "FTP Panel" panel -->
|
||||
<SETTING><NAME>MWFTP_Post_hostName</NAME><VALUE></VALUE></SETTING>
|
||||
<SETTING><NAME>MWFTP_Post_username</NAME><VALUE></VALUE></SETTING>
|
||||
<SETTING><NAME>MWFTP_Post_password</NAME><VALUE>25jysun5jyay2Ù±ÀÑ“(</VALUE></SETTING>
|
||||
<SETTING><NAME>MWFTP_Post_password</NAME><VALUE>0</VALUE></SETTING>
|
||||
<SETTING><NAME>MWFTP_Post_remoteDir</NAME><VALUE></VALUE></SETTING>
|
||||
<SETTING><NAME>MWFTP_Post_ftp_PathVersion</NAME><VALUE>1</VALUE></SETTING>
|
||||
<SETTING><NAME>MWFTP_Post_ftp_PathType</NAME><VALUE>0</VALUE></SETTING>
|
||||
|
@ -897,6 +897,13 @@
|
|||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsITransformObserver.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
</FILELIST>
|
||||
<LINKORDER>
|
||||
<FILEREF>
|
||||
|
@ -1004,6 +1011,11 @@
|
|||
<PATH>nsIDragDropOverride.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsITransformObserver.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</LINKORDER>
|
||||
</TARGET>
|
||||
<TARGET>
|
||||
|
@ -1300,7 +1312,7 @@
|
|||
<!-- Settings for "FTP Panel" panel -->
|
||||
<SETTING><NAME>MWFTP_Post_hostName</NAME><VALUE></VALUE></SETTING>
|
||||
<SETTING><NAME>MWFTP_Post_username</NAME><VALUE></VALUE></SETTING>
|
||||
<SETTING><NAME>MWFTP_Post_password</NAME><VALUE>25jysun5jyay2Ù±ÀÑ“(</VALUE></SETTING>
|
||||
<SETTING><NAME>MWFTP_Post_password</NAME><VALUE>0</VALUE></SETTING>
|
||||
<SETTING><NAME>MWFTP_Post_remoteDir</NAME><VALUE></VALUE></SETTING>
|
||||
<SETTING><NAME>MWFTP_Post_ftp_PathVersion</NAME><VALUE>1</VALUE></SETTING>
|
||||
<SETTING><NAME>MWFTP_Post_ftp_PathType</NAME><VALUE>0</VALUE></SETTING>
|
||||
|
@ -1850,6 +1862,13 @@
|
|||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsITransformObserver.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
</FILELIST>
|
||||
<LINKORDER>
|
||||
<FILEREF>
|
||||
|
@ -1957,6 +1976,11 @@
|
|||
<PATH>nsIDragDropOverride.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsITransformObserver.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</LINKORDER>
|
||||
</TARGET>
|
||||
</TARGETLIST>
|
||||
|
@ -2093,6 +2117,12 @@
|
|||
<PATH>nsIDragDropOverride.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<TARGETNAME>headers</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsITransformObserver.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</GROUPLIST>
|
||||
|
||||
</PROJECT>
|
||||
|
|
|
@ -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<nsIScriptLoader> 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<nsIScriptLoader> 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<nsIParser> 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<nsIDocShell> docShell(do_QueryInterface(mWebShell));
|
||||
nsCOMPtr<nsIContentViewer> 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<nsIContent> content = do_QueryInterface(aSubject, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIDOMDocument> resultDOMDoc;
|
||||
mXSLTransformMediator->GetResultDocument(getter_AddRefs(resultDOMDoc));
|
||||
nsCOMPtr<nsIDocument> resultDoc = do_QueryInterface(resultDOMDoc);
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
|
||||
nsCOMPtr<nsIContentViewer> contentViewer;
|
||||
docShell->GetContentViewer(getter_AddRefs(contentViewer));
|
||||
|
||||
nsCOMPtr<nsIDocument> sourceDoc = mDocument;
|
||||
NS_RELEASE(mDocument);
|
||||
|
||||
mDocument = resultDoc;
|
||||
NS_ADDREF(mDocument);
|
||||
nsCOMPtr<nsIContent> 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<nsIDocumentViewer> 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<nsIDOMDocument> document = do_QueryInterface(mDocument);
|
||||
contentViewer->SetDOMDocument(document);
|
||||
}
|
||||
|
||||
mXSLTransformMediator = nsnull;
|
||||
}
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDocument> 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<nsIScriptLoader> 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<nsIXMLDocument> resultXMLDoc(do_QueryInterface(resultDOMDoc));
|
||||
resultXMLDoc->SetDefaultStylesheets(url);
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
|
||||
nsCOMPtr<nsIContentViewer> 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<nsIDocShell> docShell(do_QueryInterface(mWebShell));
|
||||
nsCOMPtr<nsIContentViewer> contentViewer;
|
||||
rv = docShell->GetContentViewer(getter_AddRefs(contentViewer));
|
||||
nsCOMPtr<nsIDocumentViewer> documentViewer(do_QueryInterface(contentViewer));
|
||||
if (documentViewer) {
|
||||
documentViewer->SetTransformMediator(mXSLTransformMediator);
|
||||
}
|
||||
|
||||
// Create the XSL stylesheet document
|
||||
nsCOMPtr<nsIDOMDocument> styleDOMDoc;
|
||||
nsAutoString emptyStr;
|
||||
|
@ -1972,13 +1943,6 @@ nsXMLContentSink::ReportError(const PRUnichar* aErrorText,
|
|||
|
||||
if (mXSLTransformMediator) {
|
||||
// Get rid of the transform mediator.
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
|
||||
nsCOMPtr<nsIContentViewer> contentViewer;
|
||||
rv = docShell->GetContentViewer(getter_AddRefs(contentViewer));
|
||||
nsCOMPtr<nsIDocumentViewer> documentViewer(do_QueryInterface(contentViewer));
|
||||
if (documentViewer) {
|
||||
documentViewer->SetTransformMediator(nsnull);
|
||||
}
|
||||
mXSLTransformMediator->SetEnabled(PR_FALSE);
|
||||
mXSLTransformMediator = nsnull;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = src
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
|
|
|
@ -21,6 +21,6 @@
|
|||
|
||||
DEPTH=..\..\..
|
||||
|
||||
DIRS=src
|
||||
DIRS=public src
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Makefile
|
|
@ -0,0 +1,5 @@
|
|||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist:content directory
|
||||
#
|
||||
|
||||
nsITransformMediator.h
|
|
@ -3,3 +3,4 @@
|
|||
#
|
||||
|
||||
nsIDocumentTransformer.idl
|
||||
nsITransformObserver.idl
|
|
@ -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 <peterv@netscape.com> (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
|
|
@ -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 <peterv@netscape.com> (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>
|
|
@ -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 <nisheeth@netscape.com> (original author)
|
||||
* Peter Van der Beken <peterv@netscape.com>
|
||||
*
|
||||
*
|
||||
* 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);
|
||||
};
|
||||
|
||||
|
|
@ -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 <nisheeth@netscape.com> (original author)
|
||||
* Peter Van der Beken <peterv@netscape.com>
|
||||
*
|
||||
*
|
||||
* 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;
|
||||
};
|
||||
|
|
@ -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 <peterv@netscape.com> (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);
|
||||
};
|
|
@ -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)
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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<nsITransformObserver> 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<nsIDOMElement> docElement;
|
||||
mResultDoc->GetDocumentElement(getter_AddRefs(docElement));
|
||||
nsCOMPtr<nsIDOMNode> newRoot, root;
|
||||
mResultDoc->ImportNode(mStyleDOM, PR_TRUE, getter_AddRefs(newRoot));
|
||||
if (docElement) {
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIObserverService> 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<nsIDOMDocument> 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;
|
||||
}
|
||||
|
|
|
@ -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<nsIDocumentTransformer> mTransformer; // Strong reference
|
||||
nsCOMPtr<nsIDOMNode> mSourceDOM; // Strong reference
|
||||
nsCOMPtr<nsIDOMNode> mStyleDOM; // Strong reference
|
||||
nsCOMPtr<nsIDOMDocument> mResultDoc; // Strong reference
|
||||
nsCOMPtr<nsIObserver> mObserver; // Strong reference
|
||||
nsCOMPtr<nsIDocumentTransformer> mTransformer;
|
||||
nsCOMPtr<nsIDOMNode> mSourceDOM;
|
||||
nsCOMPtr<nsIDOMNode> mStyleDOM;
|
||||
nsCOMPtr<nsIDOMDocument> mResultDoc;
|
||||
nsWeakPtr mObserver;
|
||||
};
|
||||
|
||||
#endif // nsTransformMediator_h__
|
||||
|
|
|
@ -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<nsIXMLContentSink> 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<nsIScriptLoader> 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<nsITransformMediator> mediator = mXSLTransformMediator;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
mParser->GetChannel(getter_AddRefs(channel));
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
mDocument->Reset(channel, loadGroup);
|
||||
|
||||
nsXMLContentSink::ReportError(aErrorText, aSourceText);
|
||||
|
||||
if (mediator) {
|
||||
|
|
|
@ -37,7 +37,6 @@ REQUIRES = xpcom \
|
|||
dom \
|
||||
layout \
|
||||
content \
|
||||
content_xsl \
|
||||
widget \
|
||||
necko \
|
||||
js \
|
||||
|
|
|
@ -25,7 +25,6 @@ REQUIRES = xpcom \
|
|||
string \
|
||||
dom \
|
||||
widget \
|
||||
content_xsl \
|
||||
necko \
|
||||
content \
|
||||
xpconnect \
|
||||
|
|
|
@ -35,7 +35,6 @@ REQUIRES = string \
|
|||
dom \
|
||||
layout \
|
||||
content \
|
||||
content_xsl \
|
||||
widget \
|
||||
necko \
|
||||
unicharutil \
|
||||
|
|
|
@ -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<nsITransformObserver> observer = do_QueryReferent(mObserver);
|
||||
if (!observer)
|
||||
return;
|
||||
|
||||
if (!mOutputHandler || !mOutputHandler->isDone())
|
||||
|
@ -2453,15 +2454,21 @@ XSLTProcessor::SignalTransformEnd()
|
|||
mScriptLoader = nsnull;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> anObserverService = do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> rootContent;
|
||||
mOutputHandler->getRootContent(getter_AddRefs(rootContent));
|
||||
nsCOMPtr<nsIDOMNode> root = do_QueryInterface(rootContent);
|
||||
if (root) {
|
||||
nsCOMPtr<nsIDOMDocument> 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
|
||||
|
|
|
@ -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<nsIScriptLoader> mScriptLoader;
|
||||
nsCOMPtr<nsIObserver> mObserver;
|
||||
nsWeakPtr mObserver;
|
||||
#endif
|
||||
}; //-- XSLTProcessor
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ REQUIRES = string \
|
|||
dom \
|
||||
widget \
|
||||
necko \
|
||||
content_xsl \
|
||||
content \
|
||||
unicharutil \
|
||||
xpconnect \
|
||||
|
|
|
@ -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<nsIDeviceContext> 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<nsITransformMediator> mTransformMediator;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
nsCOMPtr<nsIWidget> mWindow; // ??? should we really own it?
|
||||
nsCOMPtr<nsIViewManager> 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
|
||||
|
|
|
@ -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___ */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче