2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-17 21:52:36 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-11-11 22:06:16 +00:00
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* 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/
|
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.
|
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 01:32:19 +00:00
|
|
|
* 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
|
2004-04-17 21:52:36 +00:00
|
|
|
* either of 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"),
|
2001-09-25 01:32:19 +00:00
|
|
|
* 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
|
2004-04-17 21:52:36 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 01:32:19 +00:00
|
|
|
* 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
|
2004-04-17 21:52:36 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 01:32:19 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
#ifndef nsXMLContentSink_h__
|
|
|
|
#define nsXMLContentSink_h__
|
|
|
|
|
2003-10-05 07:29:50 +00:00
|
|
|
#include "nsContentSink.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsIXMLContentSink.h"
|
2002-01-09 01:37:50 +00:00
|
|
|
#include "nsIExpatSink.h"
|
Landing XSLT branch. Tracking bug is 155578, fixes bugs 46633, 54659, 73492, 70369, 85408, 90157, 130161, 109918, 150916 and 170097
* New scriptable interfaces to XSLT
* Make HTML-output create real html
* cleanup the XSLTProcessor class
Patch by sicking, pike and peterv
r=sicking/pike, sr=peterv, a=asa
2002-10-21 21:35:23 +00:00
|
|
|
#include "nsIDocumentTransformer.h"
|
2007-01-30 21:21:06 +00:00
|
|
|
#include "nsTArray.h"
|
2003-07-03 05:34:26 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2007-02-02 02:12:48 +00:00
|
|
|
#include "nsCRT.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2003-10-05 11:28:06 +00:00
|
|
|
|
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 nsIContent;
|
2003-10-05 07:29:50 +00:00
|
|
|
class nsINodeInfo;
|
1998-12-11 17:02:37 +00:00
|
|
|
class nsIParser;
|
2003-10-05 07:29:50 +00:00
|
|
|
class nsIViewManager;
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
eXMLContentSinkState_InProlog,
|
|
|
|
eXMLContentSinkState_InDocumentElement,
|
|
|
|
eXMLContentSinkState_InEpilog
|
|
|
|
} XMLContentSinkState;
|
|
|
|
|
2007-01-30 21:21:06 +00:00
|
|
|
struct StackNode {
|
|
|
|
nsCOMPtr<nsIContent> mContent;
|
|
|
|
PRUint32 mNumFlushed;
|
|
|
|
};
|
|
|
|
|
2003-10-05 07:29:50 +00:00
|
|
|
class nsXMLContentSink : public nsContentSink,
|
|
|
|
public nsIXMLContentSink,
|
2002-06-20 12:04:22 +00:00
|
|
|
public nsITransformObserver,
|
2003-10-05 11:28:06 +00:00
|
|
|
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
|
|
|
|
2007-02-02 02:12:48 +00:00
|
|
|
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
nsresult Init(nsIDocument* aDoc,
|
1999-06-23 03:29:44 +00:00
|
|
|
nsIURI* aURL,
|
2003-04-03 18:57:33 +00:00
|
|
|
nsISupports* aContainer,
|
2002-03-27 06:19:14 +00:00
|
|
|
nsIChannel* aChannel);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
// nsISupports
|
2003-10-05 07:29:50 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2002-01-09 01:37:50 +00:00
|
|
|
NS_DECL_NSIEXPATSINK
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
// nsIContentSink
|
2007-01-30 21:21:06 +00:00
|
|
|
NS_IMETHOD WillTokenize(void);
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_IMETHOD WillBuildModel(void);
|
2003-07-22 18:38:08 +00:00
|
|
|
NS_IMETHOD DidBuildModel(void);
|
1998-11-11 22:06:16 +00:00
|
|
|
NS_IMETHOD WillInterrupt(void);
|
|
|
|
NS_IMETHOD WillResume(void);
|
1998-12-11 17:02:37 +00:00
|
|
|
NS_IMETHOD SetParser(nsIParser* aParser);
|
2007-01-30 21:21:06 +00:00
|
|
|
virtual void FlushPendingNotifications(mozFlushType aType);
|
2003-06-17 16:40:34 +00:00
|
|
|
NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
|
2004-11-02 19:52:32 +00:00
|
|
|
virtual nsISupports *GetTarget();
|
1998-11-11 22:06:16 +00:00
|
|
|
|
Landing XSLT branch. Tracking bug is 155578, fixes bugs 46633, 54659, 73492, 70369, 85408, 90157, 130161, 109918, 150916 and 170097
* New scriptable interfaces to XSLT
* Make HTML-output create real html
* cleanup the XSLTProcessor class
Patch by sicking, pike and peterv
r=sicking/pike, sr=peterv, a=asa
2002-10-21 21:35:23 +00:00
|
|
|
// nsITransformObserver
|
2006-10-03 02:22:22 +00:00
|
|
|
NS_IMETHOD OnDocumentCreated(nsIDocument *aResultDocument);
|
|
|
|
NS_IMETHOD OnTransformDone(nsresult aResult, nsIDocument *aResultDocument);
|
Landing XSLT branch. Tracking bug is 155578, fixes bugs 46633, 54659, 73492, 70369, 85408, 90157, 130161, 109918, 150916 and 170097
* New scriptable interfaces to XSLT
* Make HTML-output create real html
* cleanup the XSLTProcessor class
Patch by sicking, pike and peterv
r=sicking/pike, sr=peterv, a=asa
2002-10-21 21:35:23 +00:00
|
|
|
|
2007-05-31 01:42:48 +00:00
|
|
|
// nsICSSLoaderObserver
|
|
|
|
NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet* aSheet, PRBool aWasAlternate,
|
|
|
|
nsresult aStatus);
|
2006-03-17 14:38:57 +00:00
|
|
|
static void ParsePIData(const nsString &aData, nsString &aHref,
|
|
|
|
nsString &aTitle, nsString &aMedia,
|
|
|
|
PRBool &aIsAlternate);
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
protected:
|
2007-04-20 22:59:18 +00:00
|
|
|
// Start layout. If aIgnorePendingSheets is true, this will happen even if
|
|
|
|
// we still have stylesheet loads pending. Otherwise, we'll wait until the
|
|
|
|
// stylesheets are all done loading.
|
|
|
|
virtual void MaybeStartLayout(PRBool aIgnorePendingSheets);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2006-08-12 04:46:43 +00:00
|
|
|
virtual nsresult AddAttributes(const PRUnichar** aNode, nsIContent* aContent);
|
2002-01-09 01:37:50 +00:00
|
|
|
nsresult AddText(const PRUnichar* aString, PRInt32 aLength);
|
|
|
|
|
|
|
|
virtual PRBool OnOpenContainer(const PRUnichar **aAtts,
|
|
|
|
PRUint32 aAttsCount,
|
|
|
|
PRInt32 aNameSpaceID,
|
2003-06-24 01:20:40 +00:00
|
|
|
nsIAtom* aTagName,
|
|
|
|
PRUint32 aLineNumber) { return PR_TRUE; }
|
2004-09-30 22:27:45 +00:00
|
|
|
// Set the given content as the root element for the created document
|
|
|
|
// don't set if root element was already set.
|
|
|
|
// return TRUE if this call set the root element
|
|
|
|
virtual PRBool SetDocElement(PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom *aTagName,
|
|
|
|
nsIContent *aContent);
|
2002-12-02 23:24:57 +00:00
|
|
|
virtual nsresult CreateElement(const PRUnichar** aAtts, PRUint32 aAttsCount,
|
|
|
|
nsINodeInfo* aNodeInfo, PRUint32 aLineNumber,
|
|
|
|
nsIContent** aResult, PRBool* aAppendContent);
|
|
|
|
|
2005-06-02 02:38:20 +00:00
|
|
|
// aParent is allowed to be null here if this is the root content
|
|
|
|
// being closed
|
2006-11-04 05:45:02 +00:00
|
|
|
virtual nsresult CloseElement(nsIContent* aContent);
|
2002-01-09 01:37:50 +00:00
|
|
|
|
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
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
nsIContent* GetCurrentContent();
|
2007-01-30 21:21:06 +00:00
|
|
|
StackNode & GetCurrentStackNode();
|
|
|
|
nsresult PushContent(nsIContent *aContent);
|
|
|
|
void PopContent();
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2002-12-02 23:24:57 +00:00
|
|
|
nsresult ProcessBASETag(nsIContent* aContent);
|
2001-04-30 23:35:09 +00:00
|
|
|
|
2007-01-30 21:21:06 +00:00
|
|
|
nsresult FlushTags();
|
|
|
|
|
|
|
|
void UpdateChildCounts();
|
|
|
|
|
|
|
|
void DidAddContent()
|
|
|
|
{
|
|
|
|
if (IsTimeToNotify()) {
|
|
|
|
FlushTags();
|
|
|
|
}
|
|
|
|
}
|
1999-06-28 14:17:30 +00:00
|
|
|
|
2003-10-05 07:29:50 +00:00
|
|
|
// nsContentSink override
|
|
|
|
virtual nsresult ProcessStyleLink(nsIContent* aElement,
|
2005-03-30 00:36:57 +00:00
|
|
|
const nsSubstring& aHref,
|
2003-10-05 07:29:50 +00:00
|
|
|
PRBool aAlternate,
|
2005-03-30 00:36:57 +00:00
|
|
|
const nsSubstring& aTitle,
|
|
|
|
const nsSubstring& aType,
|
|
|
|
const nsSubstring& aMedia);
|
1999-06-28 14:17:30 +00:00
|
|
|
|
2001-11-02 10:13:05 +00:00
|
|
|
nsresult LoadXSLStyleSheet(nsIURI* aUrl);
|
|
|
|
|
2007-01-30 21:21:06 +00:00
|
|
|
PRBool CanStillPrettyPrint();
|
|
|
|
|
2002-10-09 07:03:15 +00:00
|
|
|
nsresult MaybePrettyPrint();
|
2002-09-04 06:57:25 +00:00
|
|
|
|
2007-01-30 21:21:06 +00:00
|
|
|
PRBool IsMonolithicContainer(nsINodeInfo* aNodeInfo);
|
|
|
|
|
2002-01-09 01:37:50 +00:00
|
|
|
nsIContent* mDocElement;
|
|
|
|
PRUnichar* mText;
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
XMLContentSinkState mState;
|
|
|
|
|
2002-01-09 01:37:50 +00:00
|
|
|
nsString mTitleText;
|
|
|
|
|
1998-11-11 22:06:16 +00:00
|
|
|
PRInt32 mTextLength;
|
|
|
|
PRInt32 mTextSize;
|
2002-01-09 01:37:50 +00:00
|
|
|
|
2007-01-30 21:21:06 +00:00
|
|
|
PRInt32 mNotifyLevel;
|
|
|
|
|
2004-04-20 17:12:48 +00:00
|
|
|
PRUint8 mConstrainSize : 1;
|
|
|
|
PRUint8 mPrettyPrintXML : 1;
|
|
|
|
PRUint8 mPrettyPrintHasSpecialRoot : 1;
|
|
|
|
PRUint8 mPrettyPrintHasFactoredElements : 1;
|
|
|
|
PRUint8 mHasProcessedBase : 1;
|
|
|
|
PRUint8 mAllowAutoXLinks : 1;
|
2007-05-31 01:42:48 +00:00
|
|
|
PRUint8 mPrettyPrinting : 1; // True if we called PrettyPrint() and it
|
|
|
|
// decided we should in fact prettyprint.
|
|
|
|
PRUint8 unused : 1; // bits available if someone needs one
|
2004-04-20 17:12:48 +00:00
|
|
|
|
2007-01-30 21:21:06 +00:00
|
|
|
nsTArray<StackNode> mContentStack;
|
|
|
|
|
2003-07-03 05:34:26 +00:00
|
|
|
nsCOMPtr<nsIDocumentTransformer> mXSLTProcessor;
|
1998-11-11 22:06:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsXMLContentSink_h__
|