зеркало из https://github.com/mozilla/gecko-dev.git
Fix XSLT hooks (Preparation for bug #42228). r=jst@netscape.com, a=waterson@netscape.com.
This commit is contained in:
Родитель
197d30c82b
Коммит
d41d21ad60
|
@ -28,6 +28,9 @@ class nsIDocument;
|
|||
class nsIPresContext;
|
||||
class nsIPresShell;
|
||||
class nsIStyleSheet;
|
||||
#ifdef MOZ_XSL
|
||||
class nsITransformMediator;
|
||||
#endif
|
||||
|
||||
#define NS_IDOCUMENT_VIEWER_IID \
|
||||
{ 0xa6cf9057, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
@ -51,6 +54,10 @@ public:
|
|||
|
||||
NS_IMETHOD CreateDocumentViewerUsing(nsIPresContext* aPresContext,
|
||||
nsIDocumentViewer*& aResult) = 0;
|
||||
|
||||
#ifdef MOZ_XSL
|
||||
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator)=0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* nsIDocumentViewer_h___ */
|
||||
|
|
|
@ -43,9 +43,7 @@ class nsIXMLDocument : public nsISupports {
|
|||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IXMLDOCUMENT_IID; return iid; }
|
||||
|
||||
#ifdef MOZ_XSL
|
||||
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator)=0;
|
||||
#endif
|
||||
NS_IMETHOD SetDefaultStylesheets(nsIURI* aUrl)=0;
|
||||
};
|
||||
|
||||
#endif // nsIXMLDocument_h___
|
||||
|
|
|
@ -77,24 +77,10 @@
|
|||
#include "nsXULAtoms.h"
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
|
||||
static NS_DEFINE_IID(kIHTMLContentContainerIID, NS_IHTMLCONTENTCONTAINER_IID);
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID);
|
||||
static NS_DEFINE_IID(kIDOMProcessingInstructionIID, NS_IDOMPROCESSINGINSTRUCTION_IID);
|
||||
static NS_DEFINE_IID(kIDOMCDATASectionIID, NS_IDOMCDATASECTION_IID);
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
|
||||
#define DETECTOR_PROGID_MAX 127
|
||||
static char g_detector_progid[DETECTOR_PROGID_MAX + 1];
|
||||
static PRBool gInitDetector = PR_FALSE;
|
||||
static PRBool gPlugDetector = PR_FALSE;
|
||||
static NS_DEFINE_IID(kIParserFilterIID, NS_IPARSERFILTER_IID);
|
||||
|
||||
static const char* kLoadAsData = "loadAsData";
|
||||
|
||||
|
@ -163,7 +149,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
|||
}
|
||||
}
|
||||
|
||||
return doc->QueryInterface(kIDOMDocumentIID, (void**) aInstancePtrResult);
|
||||
return doc->QueryInterface(NS_GET_IID(nsIDOMDocument), (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
|
@ -173,7 +159,7 @@ NS_NewXMLDocument(nsIDocument** aInstancePtrResult)
|
|||
nsXMLDocument* doc = new nsXMLDocument();
|
||||
if (doc == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return doc->QueryInterface(kIDocumentIID, (void**) aInstancePtrResult);
|
||||
return doc->QueryInterface(NS_GET_IID(nsIDocument), (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsXMLDocument::nsXMLDocument()
|
||||
|
@ -182,10 +168,6 @@ nsXMLDocument::nsXMLDocument()
|
|||
mAttrStyleSheet = nsnull;
|
||||
mInlineStyleSheet = nsnull;
|
||||
mCSSLoader = nsnull;
|
||||
|
||||
#ifdef MOZ_XSL
|
||||
mTransformMediator = nsnull;
|
||||
#endif
|
||||
}
|
||||
|
||||
nsXMLDocument::~nsXMLDocument()
|
||||
|
@ -203,9 +185,6 @@ nsXMLDocument::~nsXMLDocument()
|
|||
mCSSLoader->DropDocumentReference();
|
||||
NS_RELEASE(mCSSLoader);
|
||||
}
|
||||
#ifdef MOZ_XSL
|
||||
NS_IF_RELEASE(mTransformMediator);
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -215,12 +194,12 @@ nsXMLDocument::QueryInterface(REFNSIID aIID,
|
|||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIXMLDocumentIID)) {
|
||||
if (aIID.Equals(NS_GET_IID(nsIXMLDocument))) {
|
||||
NS_ADDREF_THIS();
|
||||
*aInstancePtr = (void**) (nsIXMLDocument *)this;
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIHTMLContentContainerIID)) {
|
||||
if (aIID.Equals(NS_GET_IID(nsIHTMLContentContainer))) {
|
||||
NS_ADDREF_THIS();
|
||||
*aInstancePtr = (void**) (nsIHTMLContentContainer *)this;
|
||||
return NS_OK;
|
||||
|
@ -258,17 +237,7 @@ nsXMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
|
|||
NS_RELEASE(mInlineStyleSheet);
|
||||
}
|
||||
|
||||
if (url) {
|
||||
result = NS_NewHTMLStyleSheet(&mAttrStyleSheet, url, this);
|
||||
if (NS_OK == result) {
|
||||
AddStyleSheet(mAttrStyleSheet); // tell the world about our new style sheet
|
||||
|
||||
result = NS_NewHTMLCSSStyleSheet(&mInlineStyleSheet, url, this);
|
||||
if (NS_OK == result) {
|
||||
AddStyleSheet(mInlineStyleSheet); // tell the world about our new style sheet
|
||||
}
|
||||
}
|
||||
}
|
||||
result = SetDefaultStylesheets(url);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -544,7 +513,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
if(NS_SUCCEEDED( rv_detect =
|
||||
nsComponentManager::CreateInstance(
|
||||
NS_CHARSET_DETECTION_ADAPTOR_PROGID, nsnull,
|
||||
kIParserFilterIID, (void**)&cdetflt)))
|
||||
NS_GET_IID(nsIParserFilter), (void**)&cdetflt)))
|
||||
{
|
||||
if(cdetflt &&
|
||||
NS_SUCCEEDED( rv_detect=
|
||||
|
@ -594,8 +563,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
|
||||
if (NS_OK == rv) {
|
||||
// Set the parser as the stream listener for the document loader...
|
||||
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
rv = mParser->QueryInterface(kIStreamListenerIID, (void**)aDocListener);
|
||||
rv = mParser->QueryInterface(NS_GET_IID(nsIStreamListener), (void**)aDocListener);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
|
||||
|
@ -703,7 +671,7 @@ nsXMLDocument::CreateCDATASection(const nsAReadableString& aData, nsIDOMCDATASec
|
|||
nsresult rv = NS_NewXMLCDATASection(&content);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
rv = content->QueryInterface(kIDOMCDATASectionIID, (void**)aReturn);
|
||||
rv = content->QueryInterface(NS_GET_IID(nsIDOMCDATASection), (void**)aReturn);
|
||||
(*aReturn)->AppendData(aData);
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
|
@ -730,7 +698,7 @@ nsXMLDocument::CreateProcessingInstruction(const nsAReadableString& aTarget,
|
|||
return rv;
|
||||
}
|
||||
|
||||
rv = content->QueryInterface(kIDOMProcessingInstructionIID, (void**)aReturn);
|
||||
rv = content->QueryInterface(NS_GET_IID(nsIDOMProcessingInstruction), (void**)aReturn);
|
||||
NS_RELEASE(content);
|
||||
|
||||
return rv;
|
||||
|
@ -754,7 +722,7 @@ nsXMLDocument::CreateElement(const nsAReadableString& aTagName,
|
|||
rv = NS_NewXMLElement(&content, nodeInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = content->QueryInterface(kIDOMElementIID, (void**)aReturn);
|
||||
rv = content->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aReturn);
|
||||
NS_RELEASE(content);
|
||||
|
||||
return rv;
|
||||
|
@ -878,7 +846,7 @@ nsXMLDocument::CreateElementNS(const nsAReadableString& aNamespaceURI,
|
|||
|
||||
content->SetContentID(mNextContentID++);
|
||||
|
||||
return content->QueryInterface(kIDOMElementIID, (void**)aReturn);
|
||||
return content->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aReturn);
|
||||
}
|
||||
|
||||
static nsIContent *
|
||||
|
@ -949,17 +917,24 @@ nsXMLDocument::GetElementById(const nsAReadableString& aElementId,
|
|||
}
|
||||
|
||||
// nsIXMLDocument
|
||||
#ifdef MOZ_XSL
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::SetTransformMediator(nsITransformMediator* aMediator)
|
||||
nsXMLDocument::SetDefaultStylesheets(nsIURI* aUrl)
|
||||
{
|
||||
NS_ASSERTION(nsnull == mTransformMediator, "nsXMLDocument::SetTransformMediator(): \
|
||||
Cannot set a second transform mediator\n");
|
||||
mTransformMediator = aMediator;
|
||||
NS_IF_ADDREF(mTransformMediator);
|
||||
return NS_OK;
|
||||
nsresult result = NS_OK;
|
||||
if (aUrl) {
|
||||
result = NS_NewHTMLStyleSheet(&mAttrStyleSheet, aUrl, this);
|
||||
if (NS_OK == result) {
|
||||
AddStyleSheet(mAttrStyleSheet); // tell the world about our new style sheet
|
||||
|
||||
result = NS_NewHTMLCSSStyleSheet(&mInlineStyleSheet, aUrl, this);
|
||||
if (NS_OK == result) {
|
||||
AddStyleSheet(mInlineStyleSheet); // tell the world about our new style sheet
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetCSSLoader(nsICSSLoader*& aLoader)
|
||||
|
|
|
@ -83,9 +83,7 @@ public:
|
|||
NS_IMETHOD Load(const nsAReadableString& aUrl);
|
||||
|
||||
// nsIXMLDocument interface
|
||||
#ifdef MOZ_XSL
|
||||
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator);
|
||||
#endif
|
||||
NS_IMETHOD SetDefaultStylesheets(nsIURI* aUrl);
|
||||
|
||||
// nsIHTMLContentContainer
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
|
||||
|
@ -103,9 +101,6 @@ protected:
|
|||
|
||||
nsIParser *mParser;
|
||||
nsICSSLoader* mCSSLoader;
|
||||
#ifdef MOZ_XSL
|
||||
nsITransformMediator* mTransformMediator;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMElement;
|
||||
interface nsIDOMNode;
|
||||
interface nsIDOMDocument;
|
||||
interface nsIObserver;
|
||||
|
||||
|
@ -36,8 +36,8 @@ interface nsIObserver;
|
|||
[scriptable, uuid(3fbff728-2d20-11d3-aef3-00108300ff91)]
|
||||
interface nsIDocumentTransformer : nsISupports
|
||||
{
|
||||
void TransformDocument(in nsIDOMElement aSourceDOM,
|
||||
in nsIDOMElement aStyleDOM,
|
||||
void transformDocument(in nsIDOMNode aSourceDOM,
|
||||
in nsIDOMNode aStyleDOM,
|
||||
in nsIDOMDocument aOutputDOC,
|
||||
in nsIObserver aObserver);
|
||||
};
|
||||
|
@ -46,4 +46,4 @@ interface nsIDocumentTransformer : nsISupports
|
|||
%{ C++
|
||||
extern nsresult
|
||||
NS_NewDocumentTransformer(nsIDocumentTransformer** aDocTransformer);
|
||||
%}
|
||||
%}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNode;
|
||||
class nsIDOMDocument;
|
||||
class nsIObserver;
|
||||
class nsIXMLContentSink;
|
||||
|
@ -47,11 +47,13 @@ class nsString;
|
|||
|
||||
class nsITransformMediator : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ITRANSFORM_MEDIATOR_IID; return iid; }
|
||||
|
||||
NS_IMETHOD SetEnabled(PRBool aValue)=0;
|
||||
NS_IMETHOD SetSourceContentModel(nsIDOMElement* aSource)=0;
|
||||
NS_IMETHOD SetStyleSheetContentModel(nsIDOMElement* aStyle)=0;
|
||||
NS_IMETHOD SetCurrentDocument(nsIDOMDocument* aDoc)=0;
|
||||
NS_IMETHOD SetSourceContentModel(nsIDOMNode* aSource)=0;
|
||||
NS_IMETHOD SetStyleSheetContentModel(nsIDOMNode* aStyle)=0;
|
||||
NS_IMETHOD SetResultDocument(nsIDOMDocument* aDoc)=0;
|
||||
NS_IMETHOD GetResultDocument(nsIDOMDocument** aDoc)=0;
|
||||
NS_IMETHOD SetTransformObserver(nsIObserver* aObserver)=0;
|
||||
|
||||
};
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
#include "nsTransformMediator.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
static NS_DEFINE_IID(kITransformMediatorIID, NS_ITRANSFORM_MEDIATOR_IID);
|
||||
|
||||
const char* kTransformerProgIDPrefix = "component://netscape/document-transformer?type=";
|
||||
|
||||
nsresult
|
||||
|
@ -45,27 +43,17 @@ NS_NewTransformMediator(nsITransformMediator** aResult,
|
|||
delete it;
|
||||
return rv;
|
||||
}
|
||||
return it->QueryInterface(kITransformMediatorIID, (void **)aResult);
|
||||
return it->QueryInterface(NS_GET_IID(nsITransformMediator), (void **)aResult);
|
||||
}
|
||||
|
||||
nsTransformMediator::nsTransformMediator()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mEnabled = PR_FALSE;
|
||||
mTransformer = nsnull;
|
||||
mSourceDOM = nsnull;
|
||||
mStyleDOM = nsnull;
|
||||
mCurrentDoc = nsnull;
|
||||
mObserver = nsnull;
|
||||
}
|
||||
|
||||
nsTransformMediator::~nsTransformMediator()
|
||||
{
|
||||
NS_IF_RELEASE(mTransformer);
|
||||
NS_IF_RELEASE(mSourceDOM);
|
||||
NS_IF_RELEASE(mStyleDOM);
|
||||
mCurrentDoc = nsnull;
|
||||
NS_IF_RELEASE(mObserver);
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -101,19 +89,19 @@ nsTransformMediator::Init(const nsString& aMimeType)
|
|||
}
|
||||
|
||||
// nsISupports
|
||||
NS_IMPL_ISUPPORTS(nsTransformMediator, kITransformMediatorIID)
|
||||
NS_IMPL_ISUPPORTS(nsTransformMediator, NS_GET_IID(nsITransformMediator))
|
||||
|
||||
|
||||
void
|
||||
nsTransformMediator::TryToTransform()
|
||||
{
|
||||
if (mEnabled && mSourceDOM &&
|
||||
mStyleDOM && mCurrentDoc &&
|
||||
mStyleDOM && mResultDoc &&
|
||||
mObserver && mTransformer)
|
||||
{
|
||||
mTransformer->TransformDocument(mSourceDOM,
|
||||
mStyleDOM,
|
||||
mCurrentDoc,
|
||||
mResultDoc,
|
||||
mObserver);
|
||||
}
|
||||
}
|
||||
|
@ -128,39 +116,41 @@ nsTransformMediator::SetEnabled(PRBool aValue)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransformMediator::SetSourceContentModel(nsIDOMElement* aSource)
|
||||
nsTransformMediator::SetSourceContentModel(nsIDOMNode* aSource)
|
||||
{
|
||||
NS_IF_RELEASE(mSourceDOM);
|
||||
mSourceDOM = aSource;
|
||||
NS_IF_ADDREF(mSourceDOM);
|
||||
TryToTransform();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransformMediator::SetStyleSheetContentModel(nsIDOMElement* aStyle)
|
||||
nsTransformMediator::SetStyleSheetContentModel(nsIDOMNode* aStyle)
|
||||
{
|
||||
NS_IF_RELEASE(mStyleDOM);
|
||||
mStyleDOM = aStyle;
|
||||
NS_IF_ADDREF(mStyleDOM);
|
||||
TryToTransform();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransformMediator::SetCurrentDocument(nsIDOMDocument* aDoc)
|
||||
nsTransformMediator::SetResultDocument(nsIDOMDocument* aDoc)
|
||||
{
|
||||
mCurrentDoc = aDoc;
|
||||
mResultDoc = aDoc;
|
||||
TryToTransform();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransformMediator::GetResultDocument(nsIDOMDocument** aDoc)
|
||||
{
|
||||
*aDoc = mResultDoc;
|
||||
NS_IF_ADDREF(*aDoc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransformMediator::SetTransformObserver(nsIObserver* aObserver)
|
||||
{
|
||||
NS_IF_RELEASE(mObserver);
|
||||
mObserver = aObserver;
|
||||
NS_IF_ADDREF(mObserver);
|
||||
TryToTransform();
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "nsITransformMediator.h"
|
||||
#include "nsIDocumentTransformer.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIObserver.h"
|
||||
|
||||
|
@ -41,20 +41,21 @@ public:
|
|||
|
||||
// nsITransformMediator
|
||||
NS_IMETHOD SetEnabled(PRBool aValue);
|
||||
NS_IMETHOD SetSourceContentModel(nsIDOMElement* aSource);
|
||||
NS_IMETHOD SetStyleSheetContentModel(nsIDOMElement* aStyle);
|
||||
NS_IMETHOD SetCurrentDocument(nsIDOMDocument* aDoc);
|
||||
NS_IMETHOD SetSourceContentModel(nsIDOMNode* aSource);
|
||||
NS_IMETHOD SetStyleSheetContentModel(nsIDOMNode* aStyle);
|
||||
NS_IMETHOD SetResultDocument(nsIDOMDocument* aDoc);
|
||||
NS_IMETHOD GetResultDocument(nsIDOMDocument** aDoc);
|
||||
NS_IMETHOD SetTransformObserver(nsIObserver* aObserver);
|
||||
|
||||
|
||||
protected:
|
||||
void TryToTransform();
|
||||
|
||||
PRBool mEnabled;
|
||||
nsIDocumentTransformer* mTransformer; // Strong reference
|
||||
nsIDOMElement* mSourceDOM; // Weak reference
|
||||
nsIDOMElement* mStyleDOM; // Weak reference
|
||||
nsIDOMDocument* mCurrentDoc; // Weak reference
|
||||
nsIObserver* mObserver; // Weak reference
|
||||
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
|
||||
};
|
||||
|
||||
#endif // nsTransformMediator_h__
|
||||
|
|
|
@ -21,12 +21,10 @@
|
|||
*/
|
||||
|
||||
#include "nsXSLContentSink.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsITransformMediator.h"
|
||||
|
||||
static NS_DEFINE_IID(kIXMLContentSinkIID, NS_IXMLCONTENT_SINK_IID);
|
||||
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
||||
#include "nsIParser.h"
|
||||
|
||||
nsresult
|
||||
NS_NewXSLContentSink(nsIXMLContentSink** aResult,
|
||||
|
@ -49,7 +47,7 @@ NS_NewXSLContentSink(nsIXMLContentSink** aResult,
|
|||
delete it;
|
||||
return rv;
|
||||
}
|
||||
return it->QueryInterface(kIXMLContentSinkIID, (void **)aResult);
|
||||
return it->QueryInterface(NS_GET_IID(nsIXMLContentSink), (void **)aResult);
|
||||
}
|
||||
|
||||
nsXSLContentSink::nsXSLContentSink()
|
||||
|
@ -86,144 +84,19 @@ nsXSLContentSink::WillBuildModel(void)
|
|||
NS_IMETHODIMP
|
||||
nsXSLContentSink::DidBuildModel(PRInt32 aQualityLevel)
|
||||
{
|
||||
nsIDOMElement* style;
|
||||
nsCOMPtr<nsIDOMNode> styleDoc;
|
||||
nsresult rv;
|
||||
|
||||
rv = mDocElement->QueryInterface(kIDOMElementIID, (void **) &style);
|
||||
mDocument->SetRootContent(mDocElement);
|
||||
styleDoc = do_QueryInterface(mDocument, &rv);
|
||||
if (NS_SUCCEEDED(rv) && mXSLTransformMediator) {
|
||||
// Pass the style content model to the tranform mediator.
|
||||
mXSLTransformMediator->SetStyleSheetContentModel(style);
|
||||
NS_RELEASE(style);
|
||||
mXSLTransformMediator->SetStyleSheetContentModel(styleDoc);
|
||||
}
|
||||
|
||||
// Drop our reference to the parser to get rid of a circular
|
||||
// reference.
|
||||
NS_IF_RELEASE(mParser);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::WillInterrupt(void)
|
||||
{
|
||||
// We'll use nsXMLContentSink::SetParser() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::WillResume(void)
|
||||
{
|
||||
// We'll use nsXMLContentSink::SetParser() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::SetParser(nsIParser* aParser)
|
||||
{
|
||||
// We'll use nsXMLContentSink::SetParser() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::OpenContainer(const nsIParserNode& aNode)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
result = nsXMLContentSink::OpenContainer(aNode);
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::CloseContainer(const nsIParserNode& aNode)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
result = nsXMLContentSink::CloseContainer(aNode);
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddLeaf(const nsIParserNode& aNode)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
result = nsXMLContentSink::AddLeaf(aNode);
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddComment(const nsIParserNode& aNode)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
result = nsXMLContentSink::AddComment(aNode);
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddProcessingInstruction(const nsIParserNode& aNode)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
result = nsXMLContentSink::AddProcessingInstruction(aNode);
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::NotifyError(const nsParserError* aError)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
result = nsXMLContentSink::NotifyError(aError);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
|
||||
{
|
||||
// We'll use nsXMLContentSink::AddDocTypeDecl() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// nsIXMLContentSink
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddXMLDecl(const nsIParserNode& aNode)
|
||||
{
|
||||
// We'll use nsXMLContentSink::AddXMLDecl() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddCharacterData(const nsIParserNode& aNode)
|
||||
{
|
||||
// We'll use nsXMLContentSink::AddCharacterData() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddUnparsedEntity(const nsIParserNode& aNode)
|
||||
{
|
||||
// We'll use nsXMLContentSink::AddUnparsedEntity() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddNotation(const nsIParserNode& aNode)
|
||||
{
|
||||
// We'll use nsXMLContentSink::AddNotation() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddEntityReference(const nsIParserNode& aNode)
|
||||
{
|
||||
// We'll use nsXMLContentSink::AddEntityReference() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
|
@ -48,12 +48,12 @@ public:
|
|||
//NS_IMETHOD WillInterrupt(void);
|
||||
//NS_IMETHOD WillResume(void);
|
||||
//NS_IMETHOD SetParser(nsIParser* aParser);
|
||||
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddComment(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
|
||||
NS_IMETHOD NotifyError(const nsParserError* aError);
|
||||
//NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
//NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
|
||||
//NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
//NS_IMETHOD AddComment(const nsIParserNode& aNode);
|
||||
//NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
|
||||
//NS_IMETHOD NotifyError(const nsParserError* aError);
|
||||
//NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
|
||||
|
||||
// nsIXMLContentSink
|
||||
|
|
|
@ -2155,15 +2155,13 @@ nsXULDocument::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
// nsIXMLDocument interface
|
||||
//
|
||||
|
||||
#ifdef MOZ_XSL
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::SetTransformMediator(nsITransformMediator* aMediator)
|
||||
nsXULDocument::SetDefaultStylesheets(nsIURI* aUrl)
|
||||
{
|
||||
NS_ASSERTION(0,"not implemented");
|
||||
NS_NOTREACHED("nsXULDocument::SetTransformMediator");
|
||||
NS_NOTREACHED("nsXULDocument::SetDefaultStylesheets");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -305,9 +305,7 @@ public:
|
|||
nsEventStatus* aEventStatus);
|
||||
|
||||
// nsIXMLDocument interface
|
||||
#ifdef MOZ_XSL
|
||||
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator);
|
||||
#endif
|
||||
NS_IMETHOD SetDefaultStylesheets(nsIURI* aUrl);
|
||||
|
||||
// nsIXULDocument interface
|
||||
NS_IMETHOD AddElementForID(const nsAReadableString& aID, nsIContent* aElement);
|
||||
|
|
|
@ -28,6 +28,9 @@ class nsIDocument;
|
|||
class nsIPresContext;
|
||||
class nsIPresShell;
|
||||
class nsIStyleSheet;
|
||||
#ifdef MOZ_XSL
|
||||
class nsITransformMediator;
|
||||
#endif
|
||||
|
||||
#define NS_IDOCUMENT_VIEWER_IID \
|
||||
{ 0xa6cf9057, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
@ -51,6 +54,10 @@ public:
|
|||
|
||||
NS_IMETHOD CreateDocumentViewerUsing(nsIPresContext* aPresContext,
|
||||
nsIDocumentViewer*& aResult) = 0;
|
||||
|
||||
#ifdef MOZ_XSL
|
||||
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator)=0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* nsIDocumentViewer_h___ */
|
||||
|
|
|
@ -28,6 +28,9 @@ class nsIDocument;
|
|||
class nsIPresContext;
|
||||
class nsIPresShell;
|
||||
class nsIStyleSheet;
|
||||
#ifdef MOZ_XSL
|
||||
class nsITransformMediator;
|
||||
#endif
|
||||
|
||||
#define NS_IDOCUMENT_VIEWER_IID \
|
||||
{ 0xa6cf9057, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
@ -51,6 +54,10 @@ public:
|
|||
|
||||
NS_IMETHOD CreateDocumentViewerUsing(nsIPresContext* aPresContext,
|
||||
nsIDocumentViewer*& aResult) = 0;
|
||||
|
||||
#ifdef MOZ_XSL
|
||||
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator)=0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* nsIDocumentViewer_h___ */
|
||||
|
|
|
@ -43,9 +43,7 @@ class nsIXMLDocument : public nsISupports {
|
|||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IXMLDOCUMENT_IID; return iid; }
|
||||
|
||||
#ifdef MOZ_XSL
|
||||
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator)=0;
|
||||
#endif
|
||||
NS_IMETHOD SetDefaultStylesheets(nsIURI* aUrl)=0;
|
||||
};
|
||||
|
||||
#endif // nsIXMLDocument_h___
|
||||
|
|
|
@ -77,24 +77,10 @@
|
|||
#include "nsXULAtoms.h"
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
|
||||
static NS_DEFINE_IID(kIHTMLContentContainerIID, NS_IHTMLCONTENTCONTAINER_IID);
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID);
|
||||
static NS_DEFINE_IID(kIDOMProcessingInstructionIID, NS_IDOMPROCESSINGINSTRUCTION_IID);
|
||||
static NS_DEFINE_IID(kIDOMCDATASectionIID, NS_IDOMCDATASECTION_IID);
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
|
||||
#define DETECTOR_PROGID_MAX 127
|
||||
static char g_detector_progid[DETECTOR_PROGID_MAX + 1];
|
||||
static PRBool gInitDetector = PR_FALSE;
|
||||
static PRBool gPlugDetector = PR_FALSE;
|
||||
static NS_DEFINE_IID(kIParserFilterIID, NS_IPARSERFILTER_IID);
|
||||
|
||||
static const char* kLoadAsData = "loadAsData";
|
||||
|
||||
|
@ -163,7 +149,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
|||
}
|
||||
}
|
||||
|
||||
return doc->QueryInterface(kIDOMDocumentIID, (void**) aInstancePtrResult);
|
||||
return doc->QueryInterface(NS_GET_IID(nsIDOMDocument), (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
|
@ -173,7 +159,7 @@ NS_NewXMLDocument(nsIDocument** aInstancePtrResult)
|
|||
nsXMLDocument* doc = new nsXMLDocument();
|
||||
if (doc == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return doc->QueryInterface(kIDocumentIID, (void**) aInstancePtrResult);
|
||||
return doc->QueryInterface(NS_GET_IID(nsIDocument), (void**) aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsXMLDocument::nsXMLDocument()
|
||||
|
@ -182,10 +168,6 @@ nsXMLDocument::nsXMLDocument()
|
|||
mAttrStyleSheet = nsnull;
|
||||
mInlineStyleSheet = nsnull;
|
||||
mCSSLoader = nsnull;
|
||||
|
||||
#ifdef MOZ_XSL
|
||||
mTransformMediator = nsnull;
|
||||
#endif
|
||||
}
|
||||
|
||||
nsXMLDocument::~nsXMLDocument()
|
||||
|
@ -203,9 +185,6 @@ nsXMLDocument::~nsXMLDocument()
|
|||
mCSSLoader->DropDocumentReference();
|
||||
NS_RELEASE(mCSSLoader);
|
||||
}
|
||||
#ifdef MOZ_XSL
|
||||
NS_IF_RELEASE(mTransformMediator);
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -215,12 +194,12 @@ nsXMLDocument::QueryInterface(REFNSIID aIID,
|
|||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIXMLDocumentIID)) {
|
||||
if (aIID.Equals(NS_GET_IID(nsIXMLDocument))) {
|
||||
NS_ADDREF_THIS();
|
||||
*aInstancePtr = (void**) (nsIXMLDocument *)this;
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIHTMLContentContainerIID)) {
|
||||
if (aIID.Equals(NS_GET_IID(nsIHTMLContentContainer))) {
|
||||
NS_ADDREF_THIS();
|
||||
*aInstancePtr = (void**) (nsIHTMLContentContainer *)this;
|
||||
return NS_OK;
|
||||
|
@ -258,17 +237,7 @@ nsXMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
|
|||
NS_RELEASE(mInlineStyleSheet);
|
||||
}
|
||||
|
||||
if (url) {
|
||||
result = NS_NewHTMLStyleSheet(&mAttrStyleSheet, url, this);
|
||||
if (NS_OK == result) {
|
||||
AddStyleSheet(mAttrStyleSheet); // tell the world about our new style sheet
|
||||
|
||||
result = NS_NewHTMLCSSStyleSheet(&mInlineStyleSheet, url, this);
|
||||
if (NS_OK == result) {
|
||||
AddStyleSheet(mInlineStyleSheet); // tell the world about our new style sheet
|
||||
}
|
||||
}
|
||||
}
|
||||
result = SetDefaultStylesheets(url);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -544,7 +513,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
if(NS_SUCCEEDED( rv_detect =
|
||||
nsComponentManager::CreateInstance(
|
||||
NS_CHARSET_DETECTION_ADAPTOR_PROGID, nsnull,
|
||||
kIParserFilterIID, (void**)&cdetflt)))
|
||||
NS_GET_IID(nsIParserFilter), (void**)&cdetflt)))
|
||||
{
|
||||
if(cdetflt &&
|
||||
NS_SUCCEEDED( rv_detect=
|
||||
|
@ -594,8 +563,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
|
||||
if (NS_OK == rv) {
|
||||
// Set the parser as the stream listener for the document loader...
|
||||
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
rv = mParser->QueryInterface(kIStreamListenerIID, (void**)aDocListener);
|
||||
rv = mParser->QueryInterface(NS_GET_IID(nsIStreamListener), (void**)aDocListener);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
|
||||
|
@ -703,7 +671,7 @@ nsXMLDocument::CreateCDATASection(const nsAReadableString& aData, nsIDOMCDATASec
|
|||
nsresult rv = NS_NewXMLCDATASection(&content);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
rv = content->QueryInterface(kIDOMCDATASectionIID, (void**)aReturn);
|
||||
rv = content->QueryInterface(NS_GET_IID(nsIDOMCDATASection), (void**)aReturn);
|
||||
(*aReturn)->AppendData(aData);
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
|
@ -730,7 +698,7 @@ nsXMLDocument::CreateProcessingInstruction(const nsAReadableString& aTarget,
|
|||
return rv;
|
||||
}
|
||||
|
||||
rv = content->QueryInterface(kIDOMProcessingInstructionIID, (void**)aReturn);
|
||||
rv = content->QueryInterface(NS_GET_IID(nsIDOMProcessingInstruction), (void**)aReturn);
|
||||
NS_RELEASE(content);
|
||||
|
||||
return rv;
|
||||
|
@ -754,7 +722,7 @@ nsXMLDocument::CreateElement(const nsAReadableString& aTagName,
|
|||
rv = NS_NewXMLElement(&content, nodeInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = content->QueryInterface(kIDOMElementIID, (void**)aReturn);
|
||||
rv = content->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aReturn);
|
||||
NS_RELEASE(content);
|
||||
|
||||
return rv;
|
||||
|
@ -878,7 +846,7 @@ nsXMLDocument::CreateElementNS(const nsAReadableString& aNamespaceURI,
|
|||
|
||||
content->SetContentID(mNextContentID++);
|
||||
|
||||
return content->QueryInterface(kIDOMElementIID, (void**)aReturn);
|
||||
return content->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aReturn);
|
||||
}
|
||||
|
||||
static nsIContent *
|
||||
|
@ -949,17 +917,24 @@ nsXMLDocument::GetElementById(const nsAReadableString& aElementId,
|
|||
}
|
||||
|
||||
// nsIXMLDocument
|
||||
#ifdef MOZ_XSL
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::SetTransformMediator(nsITransformMediator* aMediator)
|
||||
nsXMLDocument::SetDefaultStylesheets(nsIURI* aUrl)
|
||||
{
|
||||
NS_ASSERTION(nsnull == mTransformMediator, "nsXMLDocument::SetTransformMediator(): \
|
||||
Cannot set a second transform mediator\n");
|
||||
mTransformMediator = aMediator;
|
||||
NS_IF_ADDREF(mTransformMediator);
|
||||
return NS_OK;
|
||||
nsresult result = NS_OK;
|
||||
if (aUrl) {
|
||||
result = NS_NewHTMLStyleSheet(&mAttrStyleSheet, aUrl, this);
|
||||
if (NS_OK == result) {
|
||||
AddStyleSheet(mAttrStyleSheet); // tell the world about our new style sheet
|
||||
|
||||
result = NS_NewHTMLCSSStyleSheet(&mInlineStyleSheet, aUrl, this);
|
||||
if (NS_OK == result) {
|
||||
AddStyleSheet(mInlineStyleSheet); // tell the world about our new style sheet
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetCSSLoader(nsICSSLoader*& aLoader)
|
||||
|
|
|
@ -83,9 +83,7 @@ public:
|
|||
NS_IMETHOD Load(const nsAReadableString& aUrl);
|
||||
|
||||
// nsIXMLDocument interface
|
||||
#ifdef MOZ_XSL
|
||||
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator);
|
||||
#endif
|
||||
NS_IMETHOD SetDefaultStylesheets(nsIURI* aUrl);
|
||||
|
||||
// nsIHTMLContentContainer
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
|
||||
|
@ -103,9 +101,6 @@ protected:
|
|||
|
||||
nsIParser *mParser;
|
||||
nsICSSLoader* mCSSLoader;
|
||||
#ifdef MOZ_XSL
|
||||
nsITransformMediator* mTransformMediator;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMElement;
|
||||
interface nsIDOMNode;
|
||||
interface nsIDOMDocument;
|
||||
interface nsIObserver;
|
||||
|
||||
|
@ -36,8 +36,8 @@ interface nsIObserver;
|
|||
[scriptable, uuid(3fbff728-2d20-11d3-aef3-00108300ff91)]
|
||||
interface nsIDocumentTransformer : nsISupports
|
||||
{
|
||||
void TransformDocument(in nsIDOMElement aSourceDOM,
|
||||
in nsIDOMElement aStyleDOM,
|
||||
void transformDocument(in nsIDOMNode aSourceDOM,
|
||||
in nsIDOMNode aStyleDOM,
|
||||
in nsIDOMDocument aOutputDOC,
|
||||
in nsIObserver aObserver);
|
||||
};
|
||||
|
@ -46,4 +46,4 @@ interface nsIDocumentTransformer : nsISupports
|
|||
%{ C++
|
||||
extern nsresult
|
||||
NS_NewDocumentTransformer(nsIDocumentTransformer** aDocTransformer);
|
||||
%}
|
||||
%}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNode;
|
||||
class nsIDOMDocument;
|
||||
class nsIObserver;
|
||||
class nsIXMLContentSink;
|
||||
|
@ -47,11 +47,13 @@ class nsString;
|
|||
|
||||
class nsITransformMediator : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ITRANSFORM_MEDIATOR_IID; return iid; }
|
||||
|
||||
NS_IMETHOD SetEnabled(PRBool aValue)=0;
|
||||
NS_IMETHOD SetSourceContentModel(nsIDOMElement* aSource)=0;
|
||||
NS_IMETHOD SetStyleSheetContentModel(nsIDOMElement* aStyle)=0;
|
||||
NS_IMETHOD SetCurrentDocument(nsIDOMDocument* aDoc)=0;
|
||||
NS_IMETHOD SetSourceContentModel(nsIDOMNode* aSource)=0;
|
||||
NS_IMETHOD SetStyleSheetContentModel(nsIDOMNode* aStyle)=0;
|
||||
NS_IMETHOD SetResultDocument(nsIDOMDocument* aDoc)=0;
|
||||
NS_IMETHOD GetResultDocument(nsIDOMDocument** aDoc)=0;
|
||||
NS_IMETHOD SetTransformObserver(nsIObserver* aObserver)=0;
|
||||
|
||||
};
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
#include "nsTransformMediator.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
static NS_DEFINE_IID(kITransformMediatorIID, NS_ITRANSFORM_MEDIATOR_IID);
|
||||
|
||||
const char* kTransformerProgIDPrefix = "component://netscape/document-transformer?type=";
|
||||
|
||||
nsresult
|
||||
|
@ -45,27 +43,17 @@ NS_NewTransformMediator(nsITransformMediator** aResult,
|
|||
delete it;
|
||||
return rv;
|
||||
}
|
||||
return it->QueryInterface(kITransformMediatorIID, (void **)aResult);
|
||||
return it->QueryInterface(NS_GET_IID(nsITransformMediator), (void **)aResult);
|
||||
}
|
||||
|
||||
nsTransformMediator::nsTransformMediator()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mEnabled = PR_FALSE;
|
||||
mTransformer = nsnull;
|
||||
mSourceDOM = nsnull;
|
||||
mStyleDOM = nsnull;
|
||||
mCurrentDoc = nsnull;
|
||||
mObserver = nsnull;
|
||||
}
|
||||
|
||||
nsTransformMediator::~nsTransformMediator()
|
||||
{
|
||||
NS_IF_RELEASE(mTransformer);
|
||||
NS_IF_RELEASE(mSourceDOM);
|
||||
NS_IF_RELEASE(mStyleDOM);
|
||||
mCurrentDoc = nsnull;
|
||||
NS_IF_RELEASE(mObserver);
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -101,19 +89,19 @@ nsTransformMediator::Init(const nsString& aMimeType)
|
|||
}
|
||||
|
||||
// nsISupports
|
||||
NS_IMPL_ISUPPORTS(nsTransformMediator, kITransformMediatorIID)
|
||||
NS_IMPL_ISUPPORTS(nsTransformMediator, NS_GET_IID(nsITransformMediator))
|
||||
|
||||
|
||||
void
|
||||
nsTransformMediator::TryToTransform()
|
||||
{
|
||||
if (mEnabled && mSourceDOM &&
|
||||
mStyleDOM && mCurrentDoc &&
|
||||
mStyleDOM && mResultDoc &&
|
||||
mObserver && mTransformer)
|
||||
{
|
||||
mTransformer->TransformDocument(mSourceDOM,
|
||||
mStyleDOM,
|
||||
mCurrentDoc,
|
||||
mResultDoc,
|
||||
mObserver);
|
||||
}
|
||||
}
|
||||
|
@ -128,39 +116,41 @@ nsTransformMediator::SetEnabled(PRBool aValue)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransformMediator::SetSourceContentModel(nsIDOMElement* aSource)
|
||||
nsTransformMediator::SetSourceContentModel(nsIDOMNode* aSource)
|
||||
{
|
||||
NS_IF_RELEASE(mSourceDOM);
|
||||
mSourceDOM = aSource;
|
||||
NS_IF_ADDREF(mSourceDOM);
|
||||
TryToTransform();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransformMediator::SetStyleSheetContentModel(nsIDOMElement* aStyle)
|
||||
nsTransformMediator::SetStyleSheetContentModel(nsIDOMNode* aStyle)
|
||||
{
|
||||
NS_IF_RELEASE(mStyleDOM);
|
||||
mStyleDOM = aStyle;
|
||||
NS_IF_ADDREF(mStyleDOM);
|
||||
TryToTransform();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransformMediator::SetCurrentDocument(nsIDOMDocument* aDoc)
|
||||
nsTransformMediator::SetResultDocument(nsIDOMDocument* aDoc)
|
||||
{
|
||||
mCurrentDoc = aDoc;
|
||||
mResultDoc = aDoc;
|
||||
TryToTransform();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransformMediator::GetResultDocument(nsIDOMDocument** aDoc)
|
||||
{
|
||||
*aDoc = mResultDoc;
|
||||
NS_IF_ADDREF(*aDoc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransformMediator::SetTransformObserver(nsIObserver* aObserver)
|
||||
{
|
||||
NS_IF_RELEASE(mObserver);
|
||||
mObserver = aObserver;
|
||||
NS_IF_ADDREF(mObserver);
|
||||
TryToTransform();
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "nsITransformMediator.h"
|
||||
#include "nsIDocumentTransformer.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIObserver.h"
|
||||
|
||||
|
@ -41,20 +41,21 @@ public:
|
|||
|
||||
// nsITransformMediator
|
||||
NS_IMETHOD SetEnabled(PRBool aValue);
|
||||
NS_IMETHOD SetSourceContentModel(nsIDOMElement* aSource);
|
||||
NS_IMETHOD SetStyleSheetContentModel(nsIDOMElement* aStyle);
|
||||
NS_IMETHOD SetCurrentDocument(nsIDOMDocument* aDoc);
|
||||
NS_IMETHOD SetSourceContentModel(nsIDOMNode* aSource);
|
||||
NS_IMETHOD SetStyleSheetContentModel(nsIDOMNode* aStyle);
|
||||
NS_IMETHOD SetResultDocument(nsIDOMDocument* aDoc);
|
||||
NS_IMETHOD GetResultDocument(nsIDOMDocument** aDoc);
|
||||
NS_IMETHOD SetTransformObserver(nsIObserver* aObserver);
|
||||
|
||||
|
||||
protected:
|
||||
void TryToTransform();
|
||||
|
||||
PRBool mEnabled;
|
||||
nsIDocumentTransformer* mTransformer; // Strong reference
|
||||
nsIDOMElement* mSourceDOM; // Weak reference
|
||||
nsIDOMElement* mStyleDOM; // Weak reference
|
||||
nsIDOMDocument* mCurrentDoc; // Weak reference
|
||||
nsIObserver* mObserver; // Weak reference
|
||||
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
|
||||
};
|
||||
|
||||
#endif // nsTransformMediator_h__
|
||||
|
|
|
@ -21,12 +21,10 @@
|
|||
*/
|
||||
|
||||
#include "nsXSLContentSink.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsITransformMediator.h"
|
||||
|
||||
static NS_DEFINE_IID(kIXMLContentSinkIID, NS_IXMLCONTENT_SINK_IID);
|
||||
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
||||
#include "nsIParser.h"
|
||||
|
||||
nsresult
|
||||
NS_NewXSLContentSink(nsIXMLContentSink** aResult,
|
||||
|
@ -49,7 +47,7 @@ NS_NewXSLContentSink(nsIXMLContentSink** aResult,
|
|||
delete it;
|
||||
return rv;
|
||||
}
|
||||
return it->QueryInterface(kIXMLContentSinkIID, (void **)aResult);
|
||||
return it->QueryInterface(NS_GET_IID(nsIXMLContentSink), (void **)aResult);
|
||||
}
|
||||
|
||||
nsXSLContentSink::nsXSLContentSink()
|
||||
|
@ -86,144 +84,19 @@ nsXSLContentSink::WillBuildModel(void)
|
|||
NS_IMETHODIMP
|
||||
nsXSLContentSink::DidBuildModel(PRInt32 aQualityLevel)
|
||||
{
|
||||
nsIDOMElement* style;
|
||||
nsCOMPtr<nsIDOMNode> styleDoc;
|
||||
nsresult rv;
|
||||
|
||||
rv = mDocElement->QueryInterface(kIDOMElementIID, (void **) &style);
|
||||
mDocument->SetRootContent(mDocElement);
|
||||
styleDoc = do_QueryInterface(mDocument, &rv);
|
||||
if (NS_SUCCEEDED(rv) && mXSLTransformMediator) {
|
||||
// Pass the style content model to the tranform mediator.
|
||||
mXSLTransformMediator->SetStyleSheetContentModel(style);
|
||||
NS_RELEASE(style);
|
||||
mXSLTransformMediator->SetStyleSheetContentModel(styleDoc);
|
||||
}
|
||||
|
||||
// Drop our reference to the parser to get rid of a circular
|
||||
// reference.
|
||||
NS_IF_RELEASE(mParser);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::WillInterrupt(void)
|
||||
{
|
||||
// We'll use nsXMLContentSink::SetParser() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::WillResume(void)
|
||||
{
|
||||
// We'll use nsXMLContentSink::SetParser() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::SetParser(nsIParser* aParser)
|
||||
{
|
||||
// We'll use nsXMLContentSink::SetParser() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::OpenContainer(const nsIParserNode& aNode)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
result = nsXMLContentSink::OpenContainer(aNode);
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::CloseContainer(const nsIParserNode& aNode)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
result = nsXMLContentSink::CloseContainer(aNode);
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddLeaf(const nsIParserNode& aNode)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
result = nsXMLContentSink::AddLeaf(aNode);
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddComment(const nsIParserNode& aNode)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
result = nsXMLContentSink::AddComment(aNode);
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddProcessingInstruction(const nsIParserNode& aNode)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
result = nsXMLContentSink::AddProcessingInstruction(aNode);
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::NotifyError(const nsParserError* aError)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
result = nsXMLContentSink::NotifyError(aError);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
|
||||
{
|
||||
// We'll use nsXMLContentSink::AddDocTypeDecl() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// nsIXMLContentSink
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddXMLDecl(const nsIParserNode& aNode)
|
||||
{
|
||||
// We'll use nsXMLContentSink::AddXMLDecl() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddCharacterData(const nsIParserNode& aNode)
|
||||
{
|
||||
// We'll use nsXMLContentSink::AddCharacterData() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddUnparsedEntity(const nsIParserNode& aNode)
|
||||
{
|
||||
// We'll use nsXMLContentSink::AddUnparsedEntity() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddNotation(const nsIParserNode& aNode)
|
||||
{
|
||||
// We'll use nsXMLContentSink::AddNotation() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsXSLContentSink::AddEntityReference(const nsIParserNode& aNode)
|
||||
{
|
||||
// We'll use nsXMLContentSink::AddEntityReference() for now...
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
|
@ -48,12 +48,12 @@ public:
|
|||
//NS_IMETHOD WillInterrupt(void);
|
||||
//NS_IMETHOD WillResume(void);
|
||||
//NS_IMETHOD SetParser(nsIParser* aParser);
|
||||
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddComment(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
|
||||
NS_IMETHOD NotifyError(const nsParserError* aError);
|
||||
//NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
//NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
|
||||
//NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
//NS_IMETHOD AddComment(const nsIParserNode& aNode);
|
||||
//NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
|
||||
//NS_IMETHOD NotifyError(const nsParserError* aError);
|
||||
//NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
|
||||
|
||||
// nsIXMLContentSink
|
||||
|
|
|
@ -2155,15 +2155,13 @@ nsXULDocument::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
// nsIXMLDocument interface
|
||||
//
|
||||
|
||||
#ifdef MOZ_XSL
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::SetTransformMediator(nsITransformMediator* aMediator)
|
||||
nsXULDocument::SetDefaultStylesheets(nsIURI* aUrl)
|
||||
{
|
||||
NS_ASSERTION(0,"not implemented");
|
||||
NS_NOTREACHED("nsXULDocument::SetTransformMediator");
|
||||
NS_NOTREACHED("nsXULDocument::SetDefaultStylesheets");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -305,9 +305,7 @@ public:
|
|||
nsEventStatus* aEventStatus);
|
||||
|
||||
// nsIXMLDocument interface
|
||||
#ifdef MOZ_XSL
|
||||
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator);
|
||||
#endif
|
||||
NS_IMETHOD SetDefaultStylesheets(nsIURI* aUrl);
|
||||
|
||||
// nsIXULDocument interface
|
||||
NS_IMETHOD AddElementForID(const nsAReadableString& aID, nsIContent* aElement);
|
||||
|
|
Загрузка…
Ссылка в новой задаче