Back to index

lightning-sunbird  0.9+nobinonly
COtherDTD.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00096 #ifndef NS_OTHERDTD__
00097 #define NS_OTHERDTD__
00098 
00099 #include "nsIDTD.h"
00100 #include "nsISupports.h"
00101 #include "nsIParser.h"
00102 #include "nsHTMLTokens.h"
00103 #include "nsVoidArray.h"
00104 #include "nsDeque.h"
00105 #include "nsParserCIID.h"
00106 
00107 #define NS_IOTHERHTML_DTD_IID      \
00108   {0x8a5e89c0, 0xd16d,  0x11d1,  \
00109   {0x80, 0x22, 0x00,    0x60, 0x8, 0x14, 0x98, 0x89}}
00110 
00111 class nsIHTMLContentSink;
00112 class nsIParserNode;
00113 class nsParser;
00114 class nsDTDContext;
00115 class nsEntryStack;
00116 class nsITokenizer;
00117 class nsIParserNode;
00118 class nsTokenAllocator;
00119 class nsNodeAllocator;
00120 
00121 /***************************************************************
00122   Now the main event: COtherDTD.
00123 
00124   This not so simple class performs all the duties of token 
00125   construction and model building. It works in conjunction with
00126   an nsParser.
00127  ***************************************************************/
00128 
00129 #ifdef _MSC_VER
00130 #pragma warning( disable : 4275 )
00131 #endif
00132 
00133 class COtherDTD : public nsIDTD
00134 {
00135 
00136 #ifdef _MSC_VER
00137 #pragma warning( default : 4275 )
00138 #endif
00139 
00140   public:
00141     NS_DECL_ISUPPORTS
00142     NS_DECL_NSIDTD
00143 
00150     COtherDTD();
00151 
00156     virtual ~COtherDTD();
00157 
00165     nsresult    HandleStartToken(CToken* aToken);
00166     nsresult    HandleEndToken(CToken* aToken);
00167     nsresult    HandleEntityToken(CToken* aToken);
00168 
00169     //*************************************************
00170     //these cover methods mimic the sink, and are used
00171     //by the parser to manage its context-stack.
00172     //*************************************************
00173     
00174 protected:
00175 
00176               nsresult        CollectAttributes(nsIParserNode& aNode,eHTMLTags aTag,PRInt32 aCount);
00177     nsresult        WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsIParserNode& aNode);
00178     nsresult        DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag);
00179     nsIParserNode*  CreateNode(CToken* aToken=nsnull,PRInt32 aLineNumber=1,nsTokenAllocator* aTokenAllocator=0);
00180 
00181     nsIHTMLContentSink* mSink;
00182 
00183     nsDTDContext*       mBodyContext;
00184     PRInt32             mHasOpenHead;
00185     PRPackedBool        mHasOpenForm;
00186     PRPackedBool        mHasOpenMap;
00187     PRPackedBool        mHasOpenBody;
00188     PRPackedBool        mHadFrameset;
00189     PRPackedBool        mHadBody;
00190     PRPackedBool        mHasOpenScript;
00191     PRPackedBool        mEnableStrict;
00192     nsString            mFilename;
00193     PRInt32             mLineNumber;
00194     nsParser*           mParser;
00195     nsITokenizer*       mTokenizer; // weak
00196     nsTokenAllocator*   mTokenAllocator;
00197     nsNodeAllocator*    mNodeAllocator;
00198     eHTMLTags           mSkipTarget;
00199     nsresult            mDTDState;
00200     nsDTDMode           mDTDMode;
00201     eParserCommands     mParserCommand;   //tells us to viewcontent/viewsource/viewerrors...
00202 
00203     PRUint32            mComputedCRC32;
00204     PRUint32            mExpectedCRC32;
00205     nsString            mScratch;  //used for various purposes; non-persistent
00206     eParserDocType      mDocType;
00207 
00208 };
00209 
00210 extern nsresult NS_NewOtherHTMLDTD(nsIDTD** aInstancePtrResult);
00211 
00212 
00213 class CTransitionalDTD : public COtherDTD
00214 {
00215   public:
00216     CTransitionalDTD();
00217     virtual ~CTransitionalDTD();
00218 };
00219 
00220 #endif //NS_OTHERDTD__
00221 
00222 
00223