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"
|
1998-11-11 22:06:16 +00:00
|
|
|
|
|
|
|
class nsIDocument;
|
|
|
|
class nsIScriptObjectOwner;
|
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,
|
2000-02-02 23:04:47 +00:00
|
|
|
public nsIStreamLoaderObserver
|
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
|
2000-02-02 23:04:47 +00:00
|
|
|
NS_DECL_NSISTREAMLOADEROBSERVER
|
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; }
|
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);
|
|
|
|
|
1999-06-28 14:17:30 +00:00
|
|
|
// nsIObserver
|
|
|
|
NS_IMETHOD Observe(nsISupports *aSubject,
|
|
|
|
const PRUnichar *aTopic,
|
|
|
|
const PRUnichar *someData);
|
|
|
|
|
1998-12-18 01:36:41 +00:00
|
|
|
NS_IMETHOD ResumeParsing();
|
2000-06-15 02:33:22 +00:00
|
|
|
NS_IMETHOD EvaluateScript(nsString& aScript, nsIURI *aScriptURI, PRUint32 aLineNo, const char* aVersion);
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
const char* mScriptLanguageVersion;
|
1998-12-18 01:36:41 +00:00
|
|
|
|
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);
|
|
|
|
|
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
|
|
|
|
|
|
|
nsScrollPreference mOriginalScrollPreference;
|
|
|
|
|
|
|
|
PRUnichar* mText;
|
|
|
|
PRInt32 mTextLength;
|
|
|
|
PRInt32 mTextSize;
|
1998-11-12 23:55:47 +00:00
|
|
|
PRBool mConstrainSize;
|
|
|
|
|
|
|
|
// XXX Special processing for HTML SCRIPT tags. We may need
|
|
|
|
// something similar for STYLE.
|
|
|
|
PRBool mInScript;
|
|
|
|
PRUint32 mScriptLineNo;
|
1998-12-27 08:24:04 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
nsString mRef; // ScrollTo #ref
|
1998-11-11 22:06:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsXMLContentSink_h__
|