1998-11-11 22:06:16 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* 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/
|
1998-11-11 22:06:16 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* 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.
|
1998-11-11 22:06:16 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
1999-11-06 03:40:37 +00:00
|
|
|
* Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-11-11 22:06:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsXMLContentSink_h__
|
|
|
|
#define nsXMLContentSink_h__
|
|
|
|
|
|
|
|
#include "nsIXMLContentSink.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsIScrollableView.h"
|
1999-06-28 14:17:30 +00:00
|
|
|
#include "nsIObserver.h"
|
1999-12-07 14:06:36 +00:00
|
|
|
#include "nsWeakReference.h"
|
1999-06-28 14:17:30 +00:00
|
|
|
#include "nsITransformMediator.h"
|
1999-11-02 06:49:44 +00:00
|
|
|
#include "nsIUnicharInputStream.h"
|
2000-02-02 23:04:47 +00:00
|
|
|
#include "nsIStreamLoader.h"
|
2000-01-21 01:32:32 +00:00
|
|
|
#include "nsISupportsArray.h"
|
2000-05-10 13:13:39 +00:00
|
|
|
#include "nsINodeInfo.h"
|
2001-02-03 01:16:20 +00:00
|
|
|
#include "nsIDOMHTMLTextAreaElement.h"
|
2001-02-28 23:51:35 +00:00
|
|
|
class nsICSSStyleSheet;
|
|
|
|
#include "nsICSSLoaderObserver.h"
|
|
|
|
#include "nsIHTMLContent.h"
|
2001-05-17 05:54:16 +00:00
|
|
|
#include "nsIDOMHTMLScriptElement.h"
|
|
|
|
#include "nsIScriptLoader.h"
|
|
|
|
#include "nsIScriptLoaderObserver.h"
|
|
|
|
#include "nsSupportsArray.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
class nsIDocument;
|
1999-06-23 03:29:44 +00:00
|
|
|
class nsIURI;
|
1998-11-11 22:06:16 +00:00
|
|
|
class nsIWebShell;
|
|
|
|
class nsIContent;
|
|
|
|
class nsVoidArray;
|
|
|
|
class nsIXMLDocument;
|
|
|
|
class nsIUnicharInputStream;
|
1998-12-11 17:02:37 +00:00
|
|
|
class nsIParser;
|
1999-01-12 16:37:24 +00:00
|
|
|
class nsINameSpace;
|
1999-05-26 23:58:06 +00:00
|
|
|
class nsICSSLoader;
|
2000-01-19 04:44:10 +00:00
|
|
|
class nsINameSpaceManager;
|
|
|
|
class nsIElementFactory;
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
eXMLContentSinkState_InProlog,
|
|
|
|
eXMLContentSinkState_InDocumentElement,
|
|
|
|
eXMLContentSinkState_InEpilog
|
|
|
|
} XMLContentSinkState;
|
|
|
|
|
|
|
|
// XXX Till the parser knows a little bit more about XML,
|
|
|
|
// this is a HTMLContentSink.
|
1999-11-02 06:49:44 +00:00
|
|
|
class nsXMLContentSink : public nsIXMLContentSink,
|
|
|
|
public nsIObserver,
|
1999-12-07 14:06:36 +00:00
|
|
|
public nsSupportsWeakReference,
|
2001-05-17 05:54:16 +00:00
|
|
|
public nsIScriptLoaderObserver,
|
2001-02-28 23:51:35 +00:00
|
|
|
public nsICSSLoaderObserver
|
1999-06-28 14:17:30 +00:00
|
|
|
{
|
1998-11-11 22:06:16 +00:00
|
|
|
public:
|
|
|
|
nsXMLContentSink();
|
1999-02-12 17:45:58 +00:00
|
|
|
virtual ~nsXMLContentSink();
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
nsresult Init(nsIDocument* aDoc,
|
1999-06-23 03:29:44 +00:00
|
|
|
nsIURI* aURL,
|
1998-11-11 22:06:16 +00:00
|
|
|
nsIWebShell* aContainer);
|
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
2001-05-17 05:54:16 +00:00
|
|
|
NS_DECL_NSISCRIPTLOADEROBSERVER
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
// nsIContentSink
|
|
|
|
NS_IMETHOD WillBuildModel(void);
|
|
|
|
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel);
|
|
|
|
NS_IMETHOD WillInterrupt(void);
|
|
|
|
NS_IMETHOD WillResume(void);
|
1998-12-11 17:02:37 +00:00
|
|
|
NS_IMETHOD SetParser(nsIParser* aParser);
|
1998-11-11 22:06:16 +00:00
|
|
|
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);
|
1999-03-31 20:49:25 +00:00
|
|
|
NS_IMETHOD AddCDATASection(const nsIParserNode& aNode);
|
1999-03-06 02:01:11 +00:00
|
|
|
NS_IMETHOD NotifyError(const nsParserError* aError);
|
1999-07-28 06:56:05 +00:00
|
|
|
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
|
2000-01-24 06:43:15 +00:00
|
|
|
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
|
2001-06-29 22:56:58 +00:00
|
|
|
NS_IMETHOD SetDocumentCharset(nsAWritableString& aCharset);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
// nsIXMLContentSink
|
1999-07-28 06:56:05 +00:00
|
|
|
NS_IMETHOD AddXMLDecl(const nsIParserNode& aNode);
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_IMETHOD AddCharacterData(const nsIParserNode& aNode);
|
|
|
|
NS_IMETHOD AddUnparsedEntity(const nsIParserNode& aNode);
|
|
|
|
NS_IMETHOD AddNotation(const nsIParserNode& aNode);
|
|
|
|
NS_IMETHOD AddEntityReference(const nsIParserNode& aNode);
|
|
|
|
|
2001-02-28 23:51:35 +00:00
|
|
|
// nsICSSLoaderObserver
|
|
|
|
NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify);
|
|
|
|
|
1999-06-28 14:17:30 +00:00
|
|
|
// nsIObserver
|
|
|
|
NS_IMETHOD Observe(nsISupports *aSubject,
|
|
|
|
const PRUnichar *aTopic,
|
|
|
|
const PRUnichar *someData);
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
protected:
|
|
|
|
void StartLayout();
|
|
|
|
|
1998-11-12 23:55:47 +00:00
|
|
|
nsresult FlushText(PRBool aCreateTextNode=PR_TRUE,
|
|
|
|
PRBool* aDidFlush=nsnull);
|
1998-12-20 01:21:23 +00:00
|
|
|
nsresult AddAttributes(const nsIParserNode& aNode,
|
|
|
|
nsIContent* aContent,
|
|
|
|
PRBool aIsHTML);
|
1998-11-11 22:06:16 +00:00
|
|
|
nsresult AddContentAsLeaf(nsIContent *aContent);
|
1998-12-11 02:53:49 +00:00
|
|
|
void PushNameSpacesFrom(const nsIParserNode& aNode);
|
|
|
|
nsIAtom* CutNameSpacePrefix(nsString& aString);
|
|
|
|
PRInt32 GetNameSpaceId(nsIAtom* aPrefix);
|
1999-01-12 16:37:24 +00:00
|
|
|
nsINameSpace* PopNameSpaces();
|
1998-11-11 22:06:16 +00:00
|
|
|
PRBool IsHTMLNameSpace(PRInt32 aId);
|
|
|
|
|
|
|
|
nsIContent* GetCurrentContent();
|
|
|
|
PRInt32 PushContent(nsIContent *aContent);
|
|
|
|
nsIContent* PopContent();
|
|
|
|
|
1998-11-12 23:55:47 +00:00
|
|
|
nsresult ProcessEndSCRIPTTag(const nsIParserNode& aNode);
|
|
|
|
nsresult ProcessStartSCRIPTTag(const nsIParserNode& aNode);
|
2001-02-28 23:51:35 +00:00
|
|
|
nsresult ProcessSTYLETag(const nsIParserNode& aNode);
|
1998-11-12 23:55:47 +00:00
|
|
|
|
2001-04-30 23:35:09 +00:00
|
|
|
nsresult ProcessBASETag();
|
|
|
|
nsresult ProcessMETATag();
|
|
|
|
nsresult ProcessLINKTag();
|
|
|
|
nsresult ProcessHeaderData(nsIAtom* aHeader,const nsAReadableString& aValue,nsIHTMLContent* aContent);
|
|
|
|
|
1999-05-13 20:27:47 +00:00
|
|
|
nsresult RefreshIfEnabled(nsIViewManager* vm);
|
1999-06-28 14:17:30 +00:00
|
|
|
|
|
|
|
nsresult ProcessCSSStyleLink(nsIContent* aElement,
|
|
|
|
const nsString& aHref, PRBool aAlternate,
|
|
|
|
const nsString& aTitle, const nsString& aType,
|
|
|
|
const nsString& aMedia);
|
1999-05-26 23:58:06 +00:00
|
|
|
nsresult ProcessStyleLink(nsIContent* aElement,
|
|
|
|
const nsString& aHref, PRBool aAlternate,
|
|
|
|
const nsString& aTitle, const nsString& aType,
|
|
|
|
const nsString& aMedia);
|
1999-06-28 14:17:30 +00:00
|
|
|
|
|
|
|
nsresult ProcessXSLStyleLink(nsIContent* aElement,
|
|
|
|
const nsString& aHref, PRBool aAlternate,
|
|
|
|
const nsString& aTitle, const nsString& aType,
|
|
|
|
const nsString& aMedia);
|
2000-09-04 05:55:00 +00:00
|
|
|
nsresult CreateStyleSheetURL(nsIURI** aUrl, const nsAReadableString& aHref);
|
1999-06-28 14:17:30 +00:00
|
|
|
nsresult LoadXSLStyleSheet(nsIURI* aUrl, const nsString& aType);
|
|
|
|
nsresult SetupTransformMediator();
|
2000-12-12 21:58:13 +00:00
|
|
|
nsresult AddText(const nsAReadableString& aString);
|
1999-02-26 17:13:51 +00:00
|
|
|
|
2000-01-19 04:44:10 +00:00
|
|
|
static void
|
|
|
|
GetElementFactory(PRInt32 aNameSpaceID, nsIElementFactory** aResult);
|
|
|
|
|
2000-10-24 01:03:31 +00:00
|
|
|
void ScrollToRef();
|
|
|
|
|
2000-01-19 04:44:10 +00:00
|
|
|
static nsINameSpaceManager* gNameSpaceManager;
|
|
|
|
static PRUint32 gRefCnt;
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
nsIDocument* mDocument;
|
1999-06-23 03:29:44 +00:00
|
|
|
nsIURI* mDocumentURL;
|
|
|
|
nsIURI* mDocumentBaseURL; // can be set via HTTP headers
|
1998-11-11 22:06:16 +00:00
|
|
|
nsIWebShell* mWebShell;
|
1998-12-11 17:02:37 +00:00
|
|
|
nsIParser* mParser;
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
nsIContent* mRootElement;
|
|
|
|
nsIContent* mDocElement;
|
|
|
|
XMLContentSinkState mState;
|
|
|
|
|
2000-01-21 01:32:32 +00:00
|
|
|
nsCOMPtr<nsISupportsArray> mContentStack;
|
1998-12-11 02:53:49 +00:00
|
|
|
nsVoidArray* mNameSpaceStack;
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
PRUnichar* mText;
|
|
|
|
PRInt32 mTextLength;
|
|
|
|
PRInt32 mTextSize;
|
2001-01-04 00:30:11 +00:00
|
|
|
PRPackedBool mConstrainSize;
|
1998-11-12 23:55:47 +00:00
|
|
|
|
2001-01-04 00:30:11 +00:00
|
|
|
PRPackedBool mInScript;
|
2001-02-03 01:16:20 +00:00
|
|
|
PRPackedBool mInTitle;
|
2001-02-28 23:51:35 +00:00
|
|
|
nsString mStyleText;
|
1998-11-12 23:55:47 +00:00
|
|
|
PRUint32 mScriptLineNo;
|
1998-12-27 08:24:04 +00:00
|
|
|
|
2001-05-17 05:54:16 +00:00
|
|
|
PRBool mNeedToBlockParser;
|
|
|
|
nsSupportsArray mScriptElements;
|
|
|
|
|
1999-05-26 23:58:06 +00:00
|
|
|
nsString mPreferredStyle;
|
|
|
|
PRInt32 mStyleSheetCount;
|
|
|
|
nsICSSLoader* mCSSLoader;
|
2000-05-10 13:13:39 +00:00
|
|
|
nsCOMPtr<nsINodeInfoManager> mNodeInfoManager;
|
2000-09-02 15:34:07 +00:00
|
|
|
nsCOMPtr<nsITransformMediator> mXSLTransformMediator;
|
2000-10-24 01:03:31 +00:00
|
|
|
|
2001-02-03 01:16:20 +00:00
|
|
|
nsString mRef; // ScrollTo #ref
|
|
|
|
nsString mTitleText;
|
|
|
|
nsString mTextareaText;
|
|
|
|
nsCOMPtr<nsIDOMHTMLTextAreaElement> mTextAreaElement;
|
2001-02-28 23:51:35 +00:00
|
|
|
nsCOMPtr<nsIHTMLContent> mStyleElement;
|
2001-04-30 23:35:09 +00:00
|
|
|
nsCOMPtr<nsIHTMLContent> mBaseElement;
|
|
|
|
nsCOMPtr<nsIHTMLContent> mMetaElement;
|
|
|
|
nsCOMPtr<nsIHTMLContent> mLinkElement;
|
1998-11-11 22:06:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsXMLContentSink_h__
|