Back to index

lightning-sunbird  0.9+nobinonly
nsICSSParser.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.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 #ifndef nsCSS1Parser_h___
00038 #define nsCSS1Parser_h___
00039 
00040 #include "nsISupports.h"
00041 #include "nsAString.h"
00042 #include "nsCSSProperty.h"
00043 #include "nsColor.h"
00044 
00045 class nsICSSStyleRule;
00046 class nsICSSStyleSheet;
00047 class nsIUnicharInputStream;
00048 class nsIURI;
00049 class nsCSSDeclaration;
00050 class nsICSSLoader;
00051 class nsICSSRule;
00052 class nsISupportsArray;
00053 class nsMediaList;
00054 
00055 #define NS_ICSS_PARSER_IID    \
00056 { 0x94d1d921, 0xd6f6, 0x435f, \
00057   {0xa5, 0xe8, 0x85, 0x3f, 0x6e, 0x34, 0x57, 0xf6} }
00058 
00059 // Rule processing function
00060 typedef void (*PR_CALLBACK RuleAppendFunc) (nsICSSRule* aRule, void* aData);
00061 
00062 // Interface to the css parser.
00063 class nsICSSParser : public nsISupports {
00064 public:
00065   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICSS_PARSER_IID)
00066 
00067   // Set a style sheet for the parser to fill in. The style sheet must
00068   // implement the nsICSSStyleSheet interface
00069   NS_IMETHOD SetStyleSheet(nsICSSStyleSheet* aSheet) = 0;
00070 
00071   // Set whether or not tags & classes are case sensitive or uppercased
00072   NS_IMETHOD SetCaseSensitive(PRBool aCaseSensitive) = 0;
00073 
00074   // Set whether or not to emulate Nav quirks
00075   NS_IMETHOD SetQuirkMode(PRBool aQuirkMode) = 0;
00076 
00077 #ifdef  MOZ_SVG
00078   // Set whether or not we are in an SVG element
00079   NS_IMETHOD SetSVGMode(PRBool aSVGMode) = 0;
00080 #endif
00081 
00082   // Set loader to use for child sheets
00083   NS_IMETHOD SetChildLoader(nsICSSLoader* aChildLoader) = 0;
00084 
00085   NS_IMETHOD Parse(nsIUnicharInputStream* aInput,
00086                    nsIURI*                aSheetURL,
00087                    nsIURI*                aBaseURI,
00088                    PRUint32               aLineNumber,
00089                    nsICSSStyleSheet*&     aResult) = 0;
00090 
00091   // Parse HTML style attribute or its equivalent in other markup
00092   // languages.  aBaseURL is the base url to use for relative links in
00093   // the declaration.
00094   NS_IMETHOD ParseStyleAttribute(const nsAString&         aAttributeValue,
00095                                  nsIURI*                  aDocURL,
00096                                  nsIURI*                  aBaseURL,
00097                                  nsICSSStyleRule**        aResult) = 0;
00098 
00099   NS_IMETHOD ParseAndAppendDeclaration(const nsAString&         aBuffer,
00100                                        nsIURI*                  aSheetURL,
00101                                        nsIURI*                  aBaseURL,
00102                                        nsCSSDeclaration*        aDeclaration,
00103                                        PRBool                   aParseOnlyOneDecl,
00104                                        PRBool*                  aChanged,
00105                                        PRBool                   aClearOldDecl) = 0;
00106 
00107   NS_IMETHOD ParseRule(const nsAString&   aRule,
00108                        nsIURI*            aSheetURL,
00109                        nsIURI*            aBaseURL,
00110                        nsISupportsArray** aResult) = 0;
00111 
00112   NS_IMETHOD ParseProperty(const nsCSSProperty aPropID,
00113                            const nsAString& aPropValue,
00114                            nsIURI* aSheetURL,
00115                            nsIURI* aBaseURL,
00116                            nsCSSDeclaration* aDeclaration,
00117                            PRBool* aChanged) = 0;
00118 
00126   NS_IMETHOD ParseMediaList(const nsSubstring& aBuffer,
00127                             nsIURI* aURL, // for error reporting
00128                             PRUint32 aLineNumber, // for error reporting
00129                             nsMediaList* aMediaList,
00130                             PRBool aHTMLMode) = 0;
00131 
00141   NS_IMETHOD ParseColorString(const nsSubstring& aBuffer,
00142                               nsIURI* aURL, // for error reporting
00143                               PRUint32 aLineNumber, // for error reporting
00144                               PRBool aHandleAlphaColors,
00145                               nscolor* aColor) = 0;
00146 };
00147 
00148 // IID for the nsICSSParser_MOZILLA_1_8_BRANCH interface
00149 // fcef7cd9-9ac4-4283-91f6-8eea74c15892
00150 #define NS_ICSS_PARSER_MOZILLA_1_8_BRANCH_IID     \
00151 {0xfcef7cd9, 0x9ac4, 0x4283, {0x91, 0xf6, 0x8e, 0xea, 0x74, 0xc1, 0x58, 0x92}}
00152 
00153 class nsICSSParser_MOZILLA_1_8_BRANCH : public nsISupports {
00154 public:
00155   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICSS_PARSER_MOZILLA_1_8_BRANCH_IID)
00156 
00157   
00161   NS_IMETHOD Parse(nsIUnicharInputStream* aInput,
00162                    nsIURI*                aSheetURL,
00163                    nsIURI*                aBaseURI,
00164                    PRUint32               aLineNumber,
00165                    PRBool                 aAllowUnsafeRules,
00166                    nsICSSStyleSheet*&     aResult) = 0;
00167 };
00168 
00169 nsresult
00170 NS_NewCSSParser(nsICSSParser** aInstancePtrResult);
00171 
00172 #endif /* nsCSS1Parser_h___ */