Bug 460926 A11y hierachy is broken on Ubuntu 8.10 (GNOME 2.24), r=Evan.Yan sr=roc
[wine-gecko.git] / layout / style / nsICSSParser.h
blob4e302908534bd0a2679e4f45d1098db2233f53ac
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 /* parsing of CSS stylesheets, based on a token stream from the CSS scanner */
40 #ifndef nsICSSParser_h___
41 #define nsICSSParser_h___
43 #include "nsISupports.h"
44 #include "nsAString.h"
45 #include "nsCSSProperty.h"
46 #include "nsColor.h"
47 #include "nsCOMArray.h"
49 class nsICSSStyleRule;
50 class nsICSSStyleSheet;
51 class nsIUnicharInputStream;
52 class nsIURI;
53 class nsCSSDeclaration;
54 class nsICSSLoader;
55 class nsICSSRule;
56 class nsMediaList;
57 class nsIPrincipal;
58 struct nsCSSSelectorList;
60 #define NS_ICSS_PARSER_IID \
61 { 0xad4a3778, 0xdae0, 0x4640, \
62 { 0xb2, 0x5a, 0x24, 0xff, 0x09, 0xc3, 0x70, 0xef } }
64 // Rule processing function
65 typedef void (* RuleAppendFunc) (nsICSSRule* aRule, void* aData);
67 // Interface to the css parser.
68 class nsICSSParser : public nsISupports {
69 public:
70 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSS_PARSER_IID)
72 // Set a style sheet for the parser to fill in. The style sheet must
73 // implement the nsICSSStyleSheet interface. Null can be passed in to clear
74 // out an existing stylesheet reference.
75 NS_IMETHOD SetStyleSheet(nsICSSStyleSheet* aSheet) = 0;
77 // Set whether or not tags & classes are case sensitive or uppercased
78 NS_IMETHOD SetCaseSensitive(PRBool aCaseSensitive) = 0;
80 // Set whether or not to emulate Nav quirks
81 NS_IMETHOD SetQuirkMode(PRBool aQuirkMode) = 0;
83 #ifdef MOZ_SVG
84 // Set whether or not we are in an SVG element
85 NS_IMETHOD SetSVGMode(PRBool aSVGMode) = 0;
86 #endif
88 // Set loader to use for child sheets
89 NS_IMETHOD SetChildLoader(nsICSSLoader* aChildLoader) = 0;
91 /**
92 * Parse aInput into the stylesheet that was previously set by calling
93 * SetStyleSheet. Calling this method without calling SetStyleSheet first is
94 * an error.
96 * @param aInput the data to parse
97 * @param aSheetURL the URI to use as the sheet URI (for error reporting).
98 * This must match the URI of the sheet passed to
99 * SetStyleSheet.
100 * @param aBaseURI the URI to use for relative URI resolution
101 * @param aSheetPrincipal the principal of the stylesheet. This must match
102 * the principal of the sheet passed to SetStyleSheet.
103 * @param aLineNumber the line number of the first line of the sheet.
104 * @param aAllowUnsafeRules see aEnableUnsafeRules in
105 * nsICSSLoader::LoadSheetSync
107 NS_IMETHOD Parse(nsIUnicharInputStream* aInput,
108 nsIURI* aSheetURL,
109 nsIURI* aBaseURI,
110 nsIPrincipal* aSheetPrincipal,
111 PRUint32 aLineNumber,
112 PRBool aAllowUnsafeRules) = 0;
114 // Parse HTML style attribute or its equivalent in other markup
115 // languages. aBaseURL is the base url to use for relative links in
116 // the declaration.
117 NS_IMETHOD ParseStyleAttribute(const nsAString& aAttributeValue,
118 nsIURI* aDocURL,
119 nsIURI* aBaseURL,
120 nsIPrincipal* aNodePrincipal,
121 nsICSSStyleRule** aResult) = 0;
123 NS_IMETHOD ParseAndAppendDeclaration(const nsAString& aBuffer,
124 nsIURI* aSheetURL,
125 nsIURI* aBaseURL,
126 nsIPrincipal* aSheetPrincipal,
127 nsCSSDeclaration* aDeclaration,
128 PRBool aParseOnlyOneDecl,
129 PRBool* aChanged,
130 PRBool aClearOldDecl) = 0;
132 NS_IMETHOD ParseRule(const nsAString& aRule,
133 nsIURI* aSheetURL,
134 nsIURI* aBaseURL,
135 nsIPrincipal* aSheetPrincipal,
136 nsCOMArray<nsICSSRule>& aResult) = 0;
138 NS_IMETHOD ParseProperty(const nsCSSProperty aPropID,
139 const nsAString& aPropValue,
140 nsIURI* aSheetURL,
141 nsIURI* aBaseURL,
142 nsIPrincipal* aSheetPrincipal,
143 nsCSSDeclaration* aDeclaration,
144 PRBool* aChanged) = 0;
147 * Parse aBuffer into a media list |aMediaList|, which must be
148 * non-null, replacing its current contents. If aHTMLMode is true,
149 * parse according to HTML rules, with commas as the most important
150 * delimiter. Otherwise, parse according to CSS rules, with
151 * parentheses and strings more important than commas.
153 NS_IMETHOD ParseMediaList(const nsSubstring& aBuffer,
154 nsIURI* aURL, // for error reporting
155 PRUint32 aLineNumber, // for error reporting
156 nsMediaList* aMediaList,
157 PRBool aHTMLMode) = 0;
160 * Parse aBuffer into a nscolor |aColor|. The alpha component of the
161 * resulting aColor may vary due to rgba()/hsla(). Will return
162 * NS_ERROR_FAILURE if aBuffer is not a valid CSS color specification.
164 * Will also currently return NS_ERROR_FAILURE if it is not
165 * self-contained (i.e. doesn't reference any external style state,
166 * such as "initial" or "inherit").
168 NS_IMETHOD ParseColorString(const nsSubstring& aBuffer,
169 nsIURI* aURL, // for error reporting
170 PRUint32 aLineNumber, // for error reporting
171 nscolor* aColor) = 0;
174 * Parse aBuffer into a selector list. On success, caller must
175 * delete *aSelectorList when done with it.
177 NS_IMETHOD ParseSelectorString(const nsSubstring& aSelectorString,
178 nsIURI* aURL, // for error reporting
179 PRUint32 aLineNumber, // for error reporting
180 nsCSSSelectorList **aSelectorList) = 0;
183 NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSParser, NS_ICSS_PARSER_IID)
185 nsresult
186 NS_NewCSSParser(nsICSSParser** aInstancePtrResult);
188 #endif /* nsICSSParser_h___ */