2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 01:52:36 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2004-04-18 01:52:36 +04: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-14 00:24:54 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04: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-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 05:32:19 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 01:52:36 +04: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 05:32:19 +04: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-18 01:52:36 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 05:32:19 +04: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-18 01:52:36 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-25 08:47:31 +03:00
|
|
|
|
|
|
|
/* parsing of CSS stylesheets, based on a token stream from the CSS scanner */
|
|
|
|
|
|
|
|
#ifndef nsICSSParser_h___
|
|
|
|
#define nsICSSParser_h___
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
#include "nsISupports.h"
|
2002-03-24 01:56:05 +03:00
|
|
|
#include "nsAString.h"
|
2004-06-08 05:32:29 +04:00
|
|
|
#include "nsCSSProperty.h"
|
2005-04-18 06:51:40 +04:00
|
|
|
#include "nsColor.h"
|
2005-10-16 00:21:20 +04:00
|
|
|
#include "nsCOMArray.h"
|
2002-08-24 18:41:28 +04:00
|
|
|
|
2003-10-30 04:40:33 +03:00
|
|
|
class nsICSSStyleRule;
|
1998-11-26 04:34:53 +03:00
|
|
|
class nsICSSStyleSheet;
|
1998-04-14 00:24:54 +04:00
|
|
|
class nsIUnicharInputStream;
|
1999-06-23 07:29:44 +04:00
|
|
|
class nsIURI;
|
2002-01-16 01:43:37 +03:00
|
|
|
class nsCSSDeclaration;
|
1999-05-19 03:09:47 +04:00
|
|
|
class nsICSSLoader;
|
2001-09-06 17:14:35 +04:00
|
|
|
class nsICSSRule;
|
2005-03-30 04:36:57 +04:00
|
|
|
class nsMediaList;
|
2007-05-03 05:15:53 +04:00
|
|
|
class nsIPrincipal;
|
2008-07-22 04:55:52 +04:00
|
|
|
struct nsCSSSelectorList;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
#define NS_ICSS_PARSER_IID \
|
2008-02-15 07:21:57 +03:00
|
|
|
{ 0xad4a3778, 0xdae0, 0x4640, \
|
|
|
|
{ 0xb2, 0x5a, 0x24, 0xff, 0x09, 0xc3, 0x70, 0xef } }
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-09-06 17:14:35 +04:00
|
|
|
// Rule processing function
|
|
|
|
typedef void (*PR_CALLBACK RuleAppendFunc) (nsICSSRule* aRule, void* aData);
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Interface to the css parser.
|
|
|
|
class nsICSSParser : public nsISupports {
|
|
|
|
public:
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSS_PARSER_IID)
|
1999-06-30 23:47:42 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Set a style sheet for the parser to fill in. The style sheet must
|
2008-02-15 07:21:57 +03:00
|
|
|
// implement the nsICSSStyleSheet interface. Null can be passed in to clear
|
|
|
|
// out an existing stylesheet reference.
|
1998-11-26 04:34:53 +03:00
|
|
|
NS_IMETHOD SetStyleSheet(nsICSSStyleSheet* aSheet) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-21 08:58:58 +03:00
|
|
|
// Set whether or not tags & classes are case sensitive or uppercased
|
|
|
|
NS_IMETHOD SetCaseSensitive(PRBool aCaseSensitive) = 0;
|
1998-12-11 05:48:40 +03:00
|
|
|
|
1999-07-07 05:28:04 +04:00
|
|
|
// Set whether or not to emulate Nav quirks
|
|
|
|
NS_IMETHOD SetQuirkMode(PRBool aQuirkMode) = 0;
|
|
|
|
|
2004-08-10 04:02:47 +04:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
// Set whether or not we are in an SVG element
|
|
|
|
NS_IMETHOD SetSVGMode(PRBool aSVGMode) = 0;
|
|
|
|
#endif
|
|
|
|
|
1999-05-19 03:09:47 +04:00
|
|
|
// Set loader to use for child sheets
|
|
|
|
NS_IMETHOD SetChildLoader(nsICSSLoader* aChildLoader) = 0;
|
|
|
|
|
2006-06-15 07:20:19 +04:00
|
|
|
/**
|
2008-02-15 07:21:57 +03: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 07:20:19 +04:00
|
|
|
* @param aAllowUnsafeRules see aEnableUnsafeRules in
|
2008-02-15 07:21:57 +03:00
|
|
|
* nsICSSLoader::LoadSheetSync
|
2006-06-15 07:20:19 +04:00
|
|
|
*/
|
1998-05-28 22:39:08 +04:00
|
|
|
NS_IMETHOD Parse(nsIUnicharInputStream* aInput,
|
2004-09-10 10:45:59 +04:00
|
|
|
nsIURI* aSheetURL,
|
|
|
|
nsIURI* aBaseURI,
|
2007-05-03 05:15:53 +04:00
|
|
|
nsIPrincipal* aSheetPrincipal,
|
2004-09-09 21:32:35 +04:00
|
|
|
PRUint32 aLineNumber,
|
2008-02-15 07:21:57 +03:00
|
|
|
PRBool aAllowUnsafeRules) = 0;
|
1998-05-28 22:39:08 +04:00
|
|
|
|
2001-09-18 03:59:30 +04: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-24 01:56:05 +03:00
|
|
|
NS_IMETHOD ParseStyleAttribute(const nsAString& aAttributeValue,
|
2004-09-11 03:31:48 +04:00
|
|
|
nsIURI* aDocURL,
|
2001-09-18 03:59:30 +04:00
|
|
|
nsIURI* aBaseURL,
|
2007-05-03 05:15:53 +04:00
|
|
|
nsIPrincipal* aNodePrincipal,
|
2003-10-30 04:40:33 +03:00
|
|
|
nsICSSStyleRule** aResult) = 0;
|
1998-09-25 04:51:45 +04:00
|
|
|
|
2002-03-24 01:56:05 +03:00
|
|
|
NS_IMETHOD ParseAndAppendDeclaration(const nsAString& aBuffer,
|
2004-09-11 03:31:48 +04:00
|
|
|
nsIURI* aSheetURL,
|
2000-08-23 21:27:06 +04:00
|
|
|
nsIURI* aBaseURL,
|
2007-05-03 05:15:53 +04:00
|
|
|
nsIPrincipal* aSheetPrincipal,
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration* aDeclaration,
|
2000-08-23 21:27:06 +04:00
|
|
|
PRBool aParseOnlyOneDecl,
|
2003-07-01 01:39:22 +04:00
|
|
|
PRBool* aChanged,
|
2003-06-08 02:14:42 +04:00
|
|
|
PRBool aClearOldDecl) = 0;
|
1998-09-25 04:51:45 +04:00
|
|
|
|
2005-10-16 00:21:20 +04:00
|
|
|
NS_IMETHOD ParseRule(const nsAString& aRule,
|
|
|
|
nsIURI* aSheetURL,
|
|
|
|
nsIURI* aBaseURL,
|
2007-05-03 05:15:53 +04:00
|
|
|
nsIPrincipal* aSheetPrincipal,
|
2005-10-16 00:21:20 +04:00
|
|
|
nsCOMArray<nsICSSRule>& aResult) = 0;
|
2001-09-28 05:38:36 +04:00
|
|
|
|
2004-06-08 05:32:29 +04:00
|
|
|
NS_IMETHOD ParseProperty(const nsCSSProperty aPropID,
|
2002-03-24 01:56:05 +03:00
|
|
|
const nsAString& aPropValue,
|
2004-09-11 03:31:48 +04:00
|
|
|
nsIURI* aSheetURL,
|
2001-09-28 05:38:36 +04:00
|
|
|
nsIURI* aBaseURL,
|
2007-05-03 05:15:53 +04:00
|
|
|
nsIPrincipal* aSheetPrincipal,
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration* aDeclaration,
|
2003-07-01 01:39:22 +04:00
|
|
|
PRBool* aChanged) = 0;
|
2005-03-30 04:36:57 +04: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 06:51:40 +04:00
|
|
|
|
|
|
|
/**
|
2008-02-21 11:37:27 +03: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 06:51:40 +04: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;
|
2008-07-22 04:55:52 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse aBuffer into a selector list. On success, caller must
|
|
|
|
* delete *aSelectorList when done with it.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD ParseSelectorString(const nsSubstring& aSelectorString,
|
|
|
|
nsIURI* aURL, // for error reporting
|
|
|
|
PRUint32 aLineNumber, // for error reporting
|
|
|
|
nsCSSSelectorList **aSelectorList) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSParser, NS_ICSS_PARSER_IID)
|
|
|
|
|
2003-03-05 18:08:41 +03:00
|
|
|
nsresult
|
|
|
|
NS_NewCSSParser(nsICSSParser** aInstancePtrResult);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2006-03-25 08:47:31 +03:00
|
|
|
#endif /* nsICSSParser_h___ */
|