2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-17 21:52:36 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 01:32:19 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-17 21:52:36 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-25 01:32:19 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-17 21:52:36 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 01:32:19 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-17 21:52:36 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 01:32:19 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-25 05:47:31 +00:00
|
|
|
|
|
|
|
/* parsing of CSS stylesheets, based on a token stream from the CSS scanner */
|
|
|
|
|
|
|
|
#ifndef nsICSSParser_h___
|
|
|
|
#define nsICSSParser_h___
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
#include "nsISupports.h"
|
2002-03-23 22:56:05 +00:00
|
|
|
#include "nsAString.h"
|
2004-06-08 01:32:29 +00:00
|
|
|
#include "nsCSSProperty.h"
|
2005-04-18 02:51:40 +00:00
|
|
|
#include "nsColor.h"
|
2005-10-15 20:21:20 +00:00
|
|
|
#include "nsCOMArray.h"
|
2002-08-24 14:41:28 +00:00
|
|
|
|
2003-10-30 01:40:33 +00:00
|
|
|
class nsICSSStyleRule;
|
1998-11-26 01:34:53 +00:00
|
|
|
class nsICSSStyleSheet;
|
1998-04-13 20:24:54 +00:00
|
|
|
class nsIUnicharInputStream;
|
1999-06-23 03:29:44 +00:00
|
|
|
class nsIURI;
|
2002-01-15 22:43:37 +00:00
|
|
|
class nsCSSDeclaration;
|
1999-05-18 23:09:47 +00:00
|
|
|
class nsICSSLoader;
|
2001-09-06 13:14:35 +00:00
|
|
|
class nsICSSRule;
|
2005-03-30 00:36:57 +00:00
|
|
|
class nsMediaList;
|
2007-05-03 01:15:53 +00:00
|
|
|
class nsIPrincipal;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
#define NS_ICSS_PARSER_IID \
|
2008-02-15 04:21:57 +00:00
|
|
|
{ 0xad4a3778, 0xdae0, 0x4640, \
|
|
|
|
{ 0xb2, 0x5a, 0x24, 0xff, 0x09, 0xc3, 0x70, 0xef } }
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2001-09-06 13:14:35 +00:00
|
|
|
// Rule processing function
|
|
|
|
typedef void (*PR_CALLBACK RuleAppendFunc) (nsICSSRule* aRule, void* aData);
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Interface to the css parser.
|
|
|
|
class nsICSSParser : public nsISupports {
|
|
|
|
public:
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSS_PARSER_IID)
|
1999-06-30 19:47:42 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Set a style sheet for the parser to fill in. The style sheet must
|
2008-02-15 04:21:57 +00:00
|
|
|
// implement the nsICSSStyleSheet interface. Null can be passed in to clear
|
|
|
|
// out an existing stylesheet reference.
|
1998-11-26 01:34:53 +00:00
|
|
|
NS_IMETHOD SetStyleSheet(nsICSSStyleSheet* aSheet) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-12-21 05:58:58 +00:00
|
|
|
// Set whether or not tags & classes are case sensitive or uppercased
|
|
|
|
NS_IMETHOD SetCaseSensitive(PRBool aCaseSensitive) = 0;
|
1998-12-11 02:48:40 +00:00
|
|
|
|
1999-07-07 01:28:04 +00:00
|
|
|
// Set whether or not to emulate Nav quirks
|
|
|
|
NS_IMETHOD SetQuirkMode(PRBool aQuirkMode) = 0;
|
|
|
|
|
2004-08-10 00:02:47 +00:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
// Set whether or not we are in an SVG element
|
|
|
|
NS_IMETHOD SetSVGMode(PRBool aSVGMode) = 0;
|
|
|
|
#endif
|
|
|
|
|
1999-05-18 23:09:47 +00:00
|
|
|
// Set loader to use for child sheets
|
|
|
|
NS_IMETHOD SetChildLoader(nsICSSLoader* aChildLoader) = 0;
|
|
|
|
|
2006-06-15 03:20:19 +00:00
|
|
|
/**
|
2008-02-15 04:21:57 +00:00
|
|
|
* Parse aInput into the stylesheet that was previously set by calling
|
|
|
|
* SetStyleSheet. Calling this method without calling SetStyleSheet first is
|
|
|
|
* an error.
|
|
|
|
*
|
|
|
|
* @param aInput the data to parse
|
|
|
|
* @param aSheetURL the URI to use as the sheet URI (for error reporting).
|
|
|
|
* This must match the URI of the sheet passed to
|
|
|
|
* SetStyleSheet.
|
|
|
|
* @param aBaseURI the URI to use for relative URI resolution
|
|
|
|
* @param aSheetPrincipal the principal of the stylesheet. This must match
|
|
|
|
* the principal of the sheet passed to SetStyleSheet.
|
|
|
|
* @param aLineNumber the line number of the first line of the sheet.
|
2006-06-15 03:20:19 +00:00
|
|
|
* @param aAllowUnsafeRules see aEnableUnsafeRules in
|
2008-02-15 04:21:57 +00:00
|
|
|
* nsICSSLoader::LoadSheetSync
|
2006-06-15 03:20:19 +00:00
|
|
|
*/
|
1998-05-28 18:39:08 +00:00
|
|
|
NS_IMETHOD Parse(nsIUnicharInputStream* aInput,
|
2004-09-10 06:45:59 +00:00
|
|
|
nsIURI* aSheetURL,
|
|
|
|
nsIURI* aBaseURI,
|
2007-05-03 01:15:53 +00:00
|
|
|
nsIPrincipal* aSheetPrincipal,
|
2004-09-09 17:32:35 +00:00
|
|
|
PRUint32 aLineNumber,
|
2008-02-15 04:21:57 +00:00
|
|
|
PRBool aAllowUnsafeRules) = 0;
|
1998-05-28 18:39:08 +00:00
|
|
|
|
2001-09-17 23:59:30 +00:00
|
|
|
// Parse HTML style attribute or its equivalent in other markup
|
|
|
|
// languages. aBaseURL is the base url to use for relative links in
|
|
|
|
// the declaration.
|
2002-03-23 22:56:05 +00:00
|
|
|
NS_IMETHOD ParseStyleAttribute(const nsAString& aAttributeValue,
|
2004-09-10 23:31:48 +00:00
|
|
|
nsIURI* aDocURL,
|
2001-09-17 23:59:30 +00:00
|
|
|
nsIURI* aBaseURL,
|
2007-05-03 01:15:53 +00:00
|
|
|
nsIPrincipal* aNodePrincipal,
|
2003-10-30 01:40:33 +00:00
|
|
|
nsICSSStyleRule** aResult) = 0;
|
1998-09-25 00:51:45 +00:00
|
|
|
|
2002-03-23 22:56:05 +00:00
|
|
|
NS_IMETHOD ParseAndAppendDeclaration(const nsAString& aBuffer,
|
2004-09-10 23:31:48 +00:00
|
|
|
nsIURI* aSheetURL,
|
2000-08-23 17:27:06 +00:00
|
|
|
nsIURI* aBaseURL,
|
2007-05-03 01:15:53 +00:00
|
|
|
nsIPrincipal* aSheetPrincipal,
|
2002-01-15 22:43:37 +00:00
|
|
|
nsCSSDeclaration* aDeclaration,
|
2000-08-23 17:27:06 +00:00
|
|
|
PRBool aParseOnlyOneDecl,
|
2003-06-30 21:39:22 +00:00
|
|
|
PRBool* aChanged,
|
2003-06-07 22:14:42 +00:00
|
|
|
PRBool aClearOldDecl) = 0;
|
1998-09-25 00:51:45 +00:00
|
|
|
|
2005-10-15 20:21:20 +00:00
|
|
|
NS_IMETHOD ParseRule(const nsAString& aRule,
|
|
|
|
nsIURI* aSheetURL,
|
|
|
|
nsIURI* aBaseURL,
|
2007-05-03 01:15:53 +00:00
|
|
|
nsIPrincipal* aSheetPrincipal,
|
2005-10-15 20:21:20 +00:00
|
|
|
nsCOMArray<nsICSSRule>& aResult) = 0;
|
2001-09-28 01:38:36 +00:00
|
|
|
|
2004-06-08 01:32:29 +00:00
|
|
|
NS_IMETHOD ParseProperty(const nsCSSProperty aPropID,
|
2002-03-23 22:56:05 +00:00
|
|
|
const nsAString& aPropValue,
|
2004-09-10 23:31:48 +00:00
|
|
|
nsIURI* aSheetURL,
|
2001-09-28 01:38:36 +00:00
|
|
|
nsIURI* aBaseURL,
|
2007-05-03 01:15:53 +00:00
|
|
|
nsIPrincipal* aSheetPrincipal,
|
2002-01-15 22:43:37 +00:00
|
|
|
nsCSSDeclaration* aDeclaration,
|
2003-06-30 21:39:22 +00:00
|
|
|
PRBool* aChanged) = 0;
|
2005-03-30 00:36:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse aBuffer into a media list |aMediaList|, which must be
|
|
|
|
* non-null, replacing its current contents. If aHTMLMode is true,
|
|
|
|
* parse according to HTML rules, with commas as the most important
|
|
|
|
* delimiter. Otherwise, parse according to CSS rules, with
|
|
|
|
* parentheses and strings more important than commas.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD ParseMediaList(const nsSubstring& aBuffer,
|
|
|
|
nsIURI* aURL, // for error reporting
|
|
|
|
PRUint32 aLineNumber, // for error reporting
|
|
|
|
nsMediaList* aMediaList,
|
|
|
|
PRBool aHTMLMode) = 0;
|
2005-04-18 02:51:40 +00:00
|
|
|
|
|
|
|
/**
|
2008-02-21 08:37:27 +00:00
|
|
|
* Parse aBuffer into a nscolor |aColor|. The alpha component of the
|
|
|
|
* resulting aColor may vary due to rgba()/hsla(). Will return
|
|
|
|
* NS_ERROR_FAILURE if aBuffer is not a valid CSS color specification.
|
2005-04-18 02:51:40 +00:00
|
|
|
*
|
|
|
|
* Will also currently return NS_ERROR_FAILURE if it is not
|
|
|
|
* self-contained (i.e. doesn't reference any external style state,
|
|
|
|
* such as "initial" or "inherit").
|
|
|
|
*/
|
|
|
|
NS_IMETHOD ParseColorString(const nsSubstring& aBuffer,
|
|
|
|
nsIURI* aURL, // for error reporting
|
|
|
|
PRUint32 aLineNumber, // for error reporting
|
|
|
|
nscolor* aColor) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSParser, NS_ICSS_PARSER_IID)
|
|
|
|
|
2003-03-05 15:08:41 +00:00
|
|
|
nsresult
|
|
|
|
NS_NewCSSParser(nsICSSParser** aInstancePtrResult);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2006-03-25 05:47:31 +00:00
|
|
|
#endif /* nsICSSParser_h___ */
|