Back to index

lightning-sunbird  0.9+nobinonly
nsIParserService.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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 Communicator client 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 
00038 #ifndef nsIParserService_h__
00039 #define nsIParserService_h__
00040 
00041 #include "nsISupports.h"
00042 #include "nsString.h"
00043 #include "nsHTMLTags.h"
00044 #include "nsIElementObserver.h"
00045 
00046 class nsIParser;
00047 class nsIParserNode;
00048 
00049 #define NS_PARSERSERVICE_CONTRACTID "@mozilla.org/parser/parser-service;1"
00050 
00051 // {90a92e37-abd6-441b-9b39-4064d98e1ede}
00052 #define NS_IPARSERSERVICE_IID \
00053 { 0x90a92e37, 0xabd6, 0x441b, { 0x9b, 0x39, 0x40, 0x64, 0xd9, 0x8e, 0x1e, 0xde } };
00054 
00055 // {78081E70-AD53-11d5-8498-0010A4E0C706}
00056 #define NS_IOBSERVERENTRY_IID \
00057 { 0x78081e70, 0xad53, 0x11d5, { 0x84, 0x98, 0x00, 0x10, 0xa4, 0xe0, 0xc7, 0x06 } };
00058 
00059 
00060 class nsIObserverEntry : public nsISupports {
00061  public:
00062   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IOBSERVERENTRY_IID)
00063 
00064   NS_IMETHOD Notify(nsIParserNode* aNode,
00065                     nsIParser* aParser,
00066                     nsISupports* aWebShell,
00067                     const PRUint32 aFlags) = 0;
00068 
00069 };
00070 
00071 
00072 class nsIParserService : public nsISupports {
00073  public:
00074   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPARSERSERVICE_IID)
00075 
00076   
00086   virtual PRInt32 HTMLAtomTagToId(nsIAtom* aAtom) const = 0;
00087 
00097   virtual PRInt32 HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom) const = 0;
00098 
00109   virtual PRInt32 HTMLStringTagToId(const nsAString& aTag) const = 0;
00110 
00122   virtual const PRUnichar *HTMLIdToStringTag(PRInt32 aId) const = 0;
00123 
00135   virtual nsIAtom *HTMLIdToAtomTag(PRInt32 aId) const = 0;
00136   
00137   NS_IMETHOD HTMLConvertEntityToUnicode(const nsAString& aEntity, 
00138                                         PRInt32* aUnicode) const = 0;
00139 
00140   NS_IMETHOD HTMLConvertUnicodeToEntity(PRInt32 aUnicode,
00141                                         nsCString& aEntity) const = 0;
00142 
00143   NS_IMETHOD IsContainer(PRInt32 aId, PRBool& aIsContainer) const = 0;
00144   NS_IMETHOD IsBlock(PRInt32 aId, PRBool& aIsBlock) const = 0;
00145 
00146   // Observer mechanism
00147   NS_IMETHOD RegisterObserver(nsIElementObserver* aObserver,
00148                               const nsAString& aTopic,
00149                               const eHTMLTags* aTags = nsnull) = 0;
00150 
00151   NS_IMETHOD UnregisterObserver(nsIElementObserver* aObserver,
00152                                 const nsAString& aTopic) = 0;
00153   NS_IMETHOD GetTopicObservers(const nsAString& aTopic,
00154                                nsIObserverEntry** aEntry) = 0;
00155 
00156   virtual nsresult CheckQName(const nsASingleFragmentString& aQName,
00157                               PRBool aNamespaceAware,
00158                               const PRUnichar** aColon) = 0;
00159   virtual PRBool IsXMLLetter(PRUnichar aChar) = 0;
00160   virtual PRBool IsXMLNCNameChar(PRUnichar aChar) = 0;
00161 };
00162 
00169 #define NS_IPARSERSERVICE_MOZILLA_1_8_BRANCH_IID \
00170 { 0x9b70db61, 0x3fd2, 0x4a2e, { 0x99, 0x25, 0x76, 0xdf, 0x06, 0x18, 0xd6, 0x6d } }
00171 
00172 class nsIParserService_MOZILLA_1_8_BRANCH : public nsIParserService {
00173 public:
00174   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPARSERSERVICE_MOZILLA_1_8_BRANCH_IID)
00175 
00176   
00191   virtual PRUint32 DecodeEntity(const PRUnichar* aStart, const PRUnichar* aEnd,
00192                                 const PRUnichar** aNext,
00193                                 PRUnichar* aResult) = 0;
00194 };
00195 
00196 #endif // nsIParserService_h__