2001-09-25 01:32:19 +00:00
|
|
|
/* -*- 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
|
1998-11-11 22:06:16 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +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
|
|
|
*
|
2001-09-25 01:32:19 +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.
|
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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 NPL, 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.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
#ifndef nsXMLContentSink_h__
|
|
|
|
#define nsXMLContentSink_h__
|
|
|
|
|
|
|
|
#include "nsIXMLContentSink.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsIScrollableView.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"
|
2002-01-09 01:37:50 +00:00
|
|
|
#include "nsIExpatSink.h"
|
2002-06-20 12:04:22 +00:00
|
|
|
#include "nsITransformObserver.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;
|
2001-09-06 19:16:03 +00:00
|
|
|
class nsAutoVoidArray;
|
1998-11-11 22:06:16 +00:00
|
|
|
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,
|
2002-06-20 12:04:22 +00:00
|
|
|
public nsITransformObserver,
|
1999-12-07 14:06:36 +00:00
|
|
|
public nsSupportsWeakReference,
|
2001-05-17 05:54:16 +00:00
|
|
|
public nsIScriptLoaderObserver,
|
2002-01-09 01:37:50 +00:00
|
|
|
public nsICSSLoaderObserver,
|
|
|
|
public nsIExpatSink
|
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,
|
2002-03-27 06:19:14 +00:00
|
|
|
nsIWebShell* aContainer,
|
|
|
|
nsIChannel* aChannel);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
2001-05-17 05:54:16 +00:00
|
|
|
NS_DECL_NSISCRIPTLOADEROBSERVER
|
2002-06-20 12:04:22 +00:00
|
|
|
NS_DECL_NSITRANSFORMOBSERVER
|
2002-01-09 01:37:50 +00:00
|
|
|
NS_DECL_NSIEXPATSINK
|
|
|
|
|
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);
|
2000-01-24 06:43:15 +00:00
|
|
|
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
|
2002-03-23 22:46:13 +00:00
|
|
|
NS_IMETHOD SetDocumentCharset(nsAString& aCharset);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2001-02-28 23:51:35 +00:00
|
|
|
// nsICSSLoaderObserver
|
|
|
|
NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify);
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
protected:
|
|
|
|
void StartLayout();
|
|
|
|
|
2002-01-09 01:37:50 +00:00
|
|
|
nsresult PushNameSpacesFrom(const PRUnichar** aAttributes);
|
|
|
|
nsresult AddAttributes(const PRUnichar** aNode, nsIContent* aContent,PRBool aIsHTML);
|
|
|
|
nsresult AddText(const PRUnichar* aString, PRInt32 aLength);
|
|
|
|
nsresult ProcessStartSCRIPTTag(PRUint32 aLineNo);
|
|
|
|
nsresult ProcessEndSCRIPTTag();
|
|
|
|
|
|
|
|
virtual PRBool OnOpenContainer(const PRUnichar **aAtts,
|
|
|
|
PRUint32 aAttsCount,
|
|
|
|
PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom* aTagName) { return PR_TRUE; }
|
|
|
|
virtual nsresult CreateElement(const PRUnichar** aAtts,
|
|
|
|
PRUint32 aAttsCount,
|
|
|
|
PRInt32 aNameSpaceID,
|
|
|
|
nsINodeInfo* aNodeInfo,
|
|
|
|
nsIContent** aResult);
|
|
|
|
|
2001-11-02 09:29:33 +00:00
|
|
|
virtual nsresult FlushText(PRBool aCreateTextNode=PR_TRUE,
|
|
|
|
PRBool* aDidFlush=nsnull);
|
2002-01-09 01:37:50 +00:00
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
nsresult AddContentAsLeaf(nsIContent *aContent);
|
2002-01-09 01:37:50 +00:00
|
|
|
|
2002-03-23 22:46:13 +00:00
|
|
|
static void SplitXMLName(const nsAString& aString, nsIAtom **aPrefix,
|
2001-10-16 05:55:04 +00:00
|
|
|
nsIAtom **aTagName);
|
1998-12-11 02:53:49 +00:00
|
|
|
PRInt32 GetNameSpaceId(nsIAtom* aPrefix);
|
1999-01-12 16:37:24 +00:00
|
|
|
nsINameSpace* PopNameSpaces();
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
nsIContent* GetCurrentContent();
|
|
|
|
PRInt32 PushContent(nsIContent *aContent);
|
|
|
|
nsIContent* PopContent();
|
|
|
|
|
1998-11-12 23:55:47 +00:00
|
|
|
|
2001-04-30 23:35:09 +00:00
|
|
|
nsresult ProcessBASETag();
|
|
|
|
nsresult ProcessMETATag();
|
|
|
|
nsresult ProcessLINKTag();
|
2002-03-27 06:19:14 +00:00
|
|
|
nsresult ProcessHeaderData(nsIAtom* aHeader, const nsAString& aValue,
|
|
|
|
nsIHTMLContent* aContent);
|
|
|
|
nsresult ProcessHTTPHeaders(nsIChannel* aChannel);
|
|
|
|
nsresult ProcessLink(nsIHTMLContent* aElement, const nsAString& aLinkData);
|
2001-04-30 23:35:09 +00:00
|
|
|
|
1999-05-13 20:27:47 +00:00
|
|
|
nsresult RefreshIfEnabled(nsIViewManager* vm);
|
1999-06-28 14:17:30 +00:00
|
|
|
|
2002-03-02 21:11:39 +00:00
|
|
|
NS_IMETHOD 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
|
|
|
|
2001-11-02 10:13:05 +00:00
|
|
|
nsresult LoadXSLStyleSheet(nsIURI* aUrl);
|
1999-06-28 14:17:30 +00:00
|
|
|
nsresult SetupTransformMediator();
|
2001-11-02 10:13:05 +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();
|
2002-01-09 01:37:50 +00:00
|
|
|
|
2002-10-09 07:03:15 +00:00
|
|
|
nsresult MaybePrettyPrint();
|
2002-09-04 06:57:25 +00:00
|
|
|
|
2000-01-19 04:44:10 +00:00
|
|
|
static nsINameSpaceManager* gNameSpaceManager;
|
|
|
|
static PRUint32 gRefCnt;
|
|
|
|
|
2002-01-09 01:37:50 +00:00
|
|
|
nsIDocument* mDocument;
|
|
|
|
nsIURI* mDocumentURL;
|
|
|
|
nsIURI* mDocumentBaseURL; // can be set via HTTP headers
|
|
|
|
nsIWebShell* mWebShell;
|
|
|
|
nsIParser* mParser;
|
|
|
|
nsIContent* mDocElement;
|
|
|
|
nsAutoVoidArray* mNameSpaceStack;
|
|
|
|
PRUnichar* mText;
|
|
|
|
nsICSSLoader* mCSSLoader;
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2002-01-09 01:37:50 +00:00
|
|
|
nsSupportsArray mScriptElements;
|
1998-11-11 22:06:16 +00:00
|
|
|
XMLContentSinkState mState;
|
|
|
|
|
2002-01-09 01:37:50 +00:00
|
|
|
nsString mRef; // ScrollTo #ref
|
|
|
|
nsString mTitleText;
|
|
|
|
|
|
|
|
PRInt32 mStyleSheetCount;
|
1998-11-11 22:06:16 +00:00
|
|
|
PRInt32 mTextLength;
|
|
|
|
PRInt32 mTextSize;
|
2002-01-09 01:37:50 +00:00
|
|
|
PRUint32 mScriptLineNo;
|
|
|
|
|
2001-01-04 00:30:11 +00:00
|
|
|
PRPackedBool mConstrainSize;
|
2001-02-03 01:16:20 +00:00
|
|
|
PRPackedBool mInTitle;
|
2001-07-04 19:35:23 +00:00
|
|
|
PRPackedBool mNeedToBlockParser;
|
2002-09-04 06:57:25 +00:00
|
|
|
PRPackedBool mPrettyPrintXML;
|
|
|
|
PRPackedBool mPrettyPrintHasSpecialRoot;
|
|
|
|
PRPackedBool mPrettyPrintHasFactoredElements;
|
2001-07-04 19:35:23 +00:00
|
|
|
|
2002-01-09 01:37:50 +00:00
|
|
|
nsCOMPtr<nsISupportsArray> mContentStack;
|
|
|
|
nsCOMPtr<nsINodeInfoManager> mNodeInfoManager;
|
|
|
|
nsCOMPtr<nsITransformMediator> mXSLTransformMediator;
|
|
|
|
nsCOMPtr<nsIHTMLContent> mBaseElement;
|
|
|
|
nsCOMPtr<nsIHTMLContent> mMetaElement;
|
|
|
|
nsCOMPtr<nsIHTMLContent> mLinkElement;
|
1998-11-11 22:06:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsXMLContentSink_h__
|