Back to index

lightning-sunbird  0.9+nobinonly
nsViewSourceHTML.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 
00045 #ifndef __NS_VIEWSOURCE_HTML_
00046 #define __NS_VIEWSOURCE_HTML_
00047 
00048 #include "nsIDTD.h"
00049 #include "nsISupports.h"
00050 #include "nsHTMLTokens.h"
00051 #include "nsIHTMLContentSink.h"
00052 #include "nsDTDUtils.h"
00053 #include "nsParserNode.h"
00054 
00055 #define NS_VIEWSOURCE_HTML_IID      \
00056   {0xb6003010, 0x7932, 0x11d2, \
00057   {0x80, 0x1b, 0x0, 0x60, 0x8, 0xbf, 0xc4, 0x89 }}
00058 
00059 
00060 class nsIParserNode;
00061 class nsParser;
00062 class nsITokenizer;
00063 class nsCParserNode;
00064 
00065 class CViewSourceHTML: public nsIDTD
00066 {
00067 public:
00068 
00069     NS_DECL_ISUPPORTS
00070     NS_DECL_NSIDTD
00071     
00072     CViewSourceHTML();
00073     virtual ~CViewSourceHTML();
00074 
00082     virtual void SetVerification(PRBool aEnable);
00083 
00084 private:
00085     nsresult WriteTag(PRInt32 tagType,
00086                       const nsSubstring &aText,
00087                       PRInt32 attrCount,
00088                       PRBool aTagInError);
00089     
00090     nsresult WriteAttributes(PRInt32 attrCount, PRBool aOwnerInError);
00091     nsresult GenerateSummary();
00092     void StartNewPreBlock(void);
00093     // Utility method for adding attributes to the nodes we generate
00094     void AddAttrToNode(nsCParserStartNode& aNode,
00095                        nsTokenAllocator* aAllocator,
00096                        const nsAString& aAttrName,
00097                        const nsAString& aAttrValue);
00098 
00099 protected:
00100 
00101     nsParser*           mParser;
00102     nsIHTMLContentSink* mSink;
00103     PRInt32             mLineNumber;
00104     nsITokenizer*       mTokenizer; // weak
00105 
00106     PRInt32             mStartTag;
00107     PRInt32             mEndTag;
00108     PRInt32             mCommentTag;
00109     PRInt32             mCDATATag;
00110     PRInt32             mMarkupDeclaration;
00111     PRInt32             mDocTypeTag;
00112     PRInt32             mPITag;
00113     PRInt32             mEntityTag;
00114     PRInt32             mText;
00115     PRInt32             mKey;
00116     PRInt32             mValue;
00117     PRInt32             mPopupTag;
00118     PRInt32             mSummaryTag;
00119     PRPackedBool        mSyntaxHighlight;
00120     PRPackedBool        mWrapLongLines;
00121     PRPackedBool        mHasOpenRoot;
00122     PRPackedBool        mHasOpenBody;
00123 
00124     nsDTDMode           mDTDMode;
00125     eParserCommands     mParserCommand;   //tells us to viewcontent/viewsource/viewerrors...
00126     eParserDocType      mDocType;
00127     nsCString           mMimeType;  
00128     PRInt32             mErrorCount;
00129     PRInt32             mTagCount;
00130 
00131     nsString            mFilename;
00132     nsString            mTags;
00133     nsString            mErrors;
00134 
00135     PRUint32            mTokenCount;
00136 };
00137 
00138 extern nsresult NS_NewViewSourceHTML(nsIDTD** aInstancePtrResult);
00139 
00140 #endif 
00141 
00142 
00143