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;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
#define NS_ICSS_PARSER_IID \
|
2006-06-15 07:20:19 +04:00
|
|
|
{ 0x2cb34728, 0x0f17, 0x4753, \
|
|
|
|
{0x8e, 0xad, 0xec, 0x73, 0xe5, 0x69, 0xcd, 0xcd} }
|
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
|
|
|
|
// implement the nsICSSStyleSheet interface
|
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
|
|
|
/**
|
|
|
|
* @param aAllowUnsafeRules see aEnableUnsafeRules in
|
|
|
|
* nsICSSLoader::LoadSheetSync
|
|
|
|
*/
|
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,
|
2004-09-09 21:32:35 +04:00
|
|
|
PRUint32 aLineNumber,
|
2006-06-15 07:20:19 +04:00
|
|
|
PRBool aAllowUnsafeRules,
|
1998-11-26 04:34:53 +03:00
|
|
|
nsICSSStyleSheet*& aResult) = 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,
|
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,
|
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,
|
|
|
|
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,
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse aBuffer into a nscolor |aColor|. If aHandleAlphaColors is
|
|
|
|
* set, handle rgba()/hsla(). Will return NS_ERROR_FAILURE if
|
|
|
|
* aBuffer is not a valid CSS color specification.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
PRBool aHandleAlphaColors,
|
|
|
|
nscolor* aColor) = 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___ */
|