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
|
1999-10-08 07:09:31 +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/
|
1999-10-08 07:09:31 +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.
|
1999-10-08 07:09:31 +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):
|
2008-06-03 07:17:35 +04:00
|
|
|
* L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
|
|
/*
|
|
|
|
* internal abstract interface for containers (roughly origins within
|
|
|
|
* the CSS cascade) that provide style rules matching an element or
|
|
|
|
* pseudo-element
|
|
|
|
*/
|
|
|
|
|
1999-10-08 07:09:31 +04:00
|
|
|
#ifndef nsIStyleRuleProcessor_h___
|
|
|
|
#define nsIStyleRuleProcessor_h___
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
2004-01-14 04:36:35 +03:00
|
|
|
#include "nsChangeHint.h"
|
2009-07-13 15:48:06 +04:00
|
|
|
#include "nsIContent.h"
|
1999-10-08 07:09:31 +04:00
|
|
|
|
2009-08-01 19:53:40 +04:00
|
|
|
struct RuleProcessorData;
|
|
|
|
struct ElementRuleProcessorData;
|
2009-12-11 10:37:40 +03:00
|
|
|
struct PseudoElementRuleProcessorData;
|
2009-12-11 10:37:40 +03:00
|
|
|
struct AnonBoxRuleProcessorData;
|
2009-12-11 10:37:40 +03:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
struct XULTreeRuleProcessorData;
|
|
|
|
#endif
|
2009-08-01 19:53:40 +04:00
|
|
|
struct StateRuleProcessorData;
|
|
|
|
struct AttributeRuleProcessorData;
|
2004-08-01 03:15:21 +04:00
|
|
|
class nsPresContext;
|
2001-11-11 02:51:45 +03:00
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
// IID for the nsIStyleRuleProcessor interface
|
2011-12-09 09:01:52 +04:00
|
|
|
// {c1d6001e-4fcb-4c40-bce1-5eba80bfd8f3}
|
1999-10-08 07:09:31 +04:00
|
|
|
#define NS_ISTYLE_RULE_PROCESSOR_IID \
|
2011-12-09 09:01:52 +04:00
|
|
|
{ 0xc1d6001e, 0x4fcb, 0x4c40, \
|
|
|
|
{0xbc, 0xe1, 0x5e, 0xba, 0x80, 0xbf, 0xd8, 0xf3} }
|
2010-07-19 01:20:40 +04:00
|
|
|
|
1999-10-08 07:09:31 +04:00
|
|
|
|
2003-03-24 07:15:34 +03:00
|
|
|
/* The style rule processor interface is a mechanism to separate the matching
|
1999-10-08 07:09:31 +04:00
|
|
|
* of style rules from style sheet instances.
|
|
|
|
* Simple style sheets can and will act as their own processor.
|
|
|
|
* Sheets where rule ordering interlaces between multiple sheets, will need to
|
|
|
|
* share a single rule processor between them (CSS sheets do this for cascading order)
|
2005-07-26 06:28:02 +04:00
|
|
|
*
|
|
|
|
* @see nsIStyleRule (for significantly more detailed comments)
|
1999-10-08 07:09:31 +04:00
|
|
|
*/
|
|
|
|
class nsIStyleRuleProcessor : public nsISupports {
|
|
|
|
public:
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_PROCESSOR_IID)
|
1999-10-08 07:09:31 +04:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
// Shorthand for:
|
|
|
|
// nsCOMArray<nsIStyleRuleProcessor>::nsCOMArrayEnumFunc
|
2011-09-29 10:19:26 +04:00
|
|
|
typedef bool (* EnumFunc)(nsIStyleRuleProcessor*, void*);
|
2004-01-08 01:30:53 +03:00
|
|
|
|
2005-07-26 06:28:02 +04:00
|
|
|
/**
|
|
|
|
* Find the |nsIStyleRule|s matching the given content node and
|
|
|
|
* position the given |nsRuleWalker| at the |nsRuleNode| in the rule
|
|
|
|
* tree representing that ordered list of rules (with higher
|
|
|
|
* precedence being farther from the root of the lexicographic tree).
|
|
|
|
*/
|
2010-07-19 01:20:40 +04:00
|
|
|
virtual void RulesMatching(ElementRuleProcessorData* aData) = 0;
|
2001-11-11 02:51:45 +03:00
|
|
|
|
2005-07-26 06:28:02 +04:00
|
|
|
/**
|
|
|
|
* Just like the previous |RulesMatching|, except for a given content
|
|
|
|
* node <em>and pseudo-element</em>.
|
|
|
|
*/
|
2010-07-19 01:20:40 +04:00
|
|
|
virtual void RulesMatching(PseudoElementRuleProcessorData* aData) = 0;
|
2009-12-11 10:37:40 +03:00
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
/**
|
|
|
|
* Just like the previous |RulesMatching|, except for a given anonymous box.
|
|
|
|
*/
|
2010-07-19 01:20:40 +04:00
|
|
|
virtual void RulesMatching(AnonBoxRuleProcessorData* aData) = 0;
|
2009-12-11 10:37:40 +03:00
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
#ifdef MOZ_XUL
|
2009-12-11 10:37:40 +03:00
|
|
|
/**
|
|
|
|
* Just like the previous |RulesMatching|, except for a given content
|
2009-12-11 10:37:40 +03:00
|
|
|
* node <em>and tree pseudo</em>.
|
2009-12-11 10:37:40 +03:00
|
|
|
*/
|
2010-07-19 01:20:40 +04:00
|
|
|
virtual void RulesMatching(XULTreeRuleProcessorData* aData) = 0;
|
2009-12-11 10:37:40 +03:00
|
|
|
#endif
|
1999-10-08 07:09:31 +04:00
|
|
|
|
2010-03-17 20:10:57 +03:00
|
|
|
/**
|
|
|
|
* Return whether style can depend on a change of the given document state.
|
|
|
|
*
|
|
|
|
* Document states are defined in nsIDocument.h.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool
|
2010-03-17 20:10:57 +03:00
|
|
|
HasDocumentStateDependentStyle(StateRuleProcessorData* aData) = 0;
|
|
|
|
|
2004-02-26 00:04:50 +03:00
|
|
|
/**
|
2010-04-01 04:43:32 +04:00
|
|
|
* Return how (as described by nsRestyleHint) style can depend on a
|
2005-07-26 06:28:02 +04:00
|
|
|
* change of the given content state on the given content node. This
|
|
|
|
* test is used for optimization only, and may err on the side of
|
|
|
|
* reporting more dependencies than really exist.
|
2004-02-26 00:04:50 +03:00
|
|
|
*
|
2011-04-21 21:35:52 +04:00
|
|
|
* Event states are defined in nsEventStates.h.
|
2004-02-26 00:04:50 +03:00
|
|
|
*/
|
2010-04-01 04:43:32 +04:00
|
|
|
virtual nsRestyleHint
|
2009-12-12 09:36:34 +03:00
|
|
|
HasStateDependentStyle(StateRuleProcessorData* aData) = 0;
|
2004-02-26 00:04:50 +03:00
|
|
|
|
|
|
|
/**
|
2009-12-11 01:36:03 +03:00
|
|
|
* This method will be called twice for every attribute change.
|
|
|
|
* During the first call, aData->mAttrHasChanged will be false and
|
|
|
|
* the attribute change will not have happened yet. During the
|
|
|
|
* second call, aData->mAttrHasChanged will be true and the
|
|
|
|
* change will have already happened. The bitwise OR of the two
|
|
|
|
* return values must describe the style changes that are needed due
|
|
|
|
* to the attribute change. It's up to the rule processor
|
|
|
|
* implementation to decide how to split the bits up amongst the two
|
|
|
|
* return values. For example, it could return the bits needed by
|
|
|
|
* rules that might stop matching the node from the first call and
|
|
|
|
* the bits needed by rules that might have started matching the
|
|
|
|
* node from the second call. This test is used for optimization
|
|
|
|
* only, and may err on the side of reporting more dependencies than
|
|
|
|
* really exist.
|
2004-02-26 00:04:50 +03:00
|
|
|
*/
|
2010-04-01 04:43:32 +04:00
|
|
|
virtual nsRestyleHint
|
2009-12-11 01:36:03 +03:00
|
|
|
HasAttributeDependentStyle(AttributeRuleProcessorData* aData) = 0;
|
2008-07-26 20:14:48 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Do any processing that needs to happen as a result of a change in
|
|
|
|
* the characteristics of the medium, and return whether this rule
|
|
|
|
* processor's rules have changed (e.g., because of media queries).
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) = 0;
|
2011-08-01 22:25:20 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Report the size of this style rule processor to about:memory. A
|
|
|
|
* processor may return 0.
|
|
|
|
*/
|
2011-12-09 09:01:52 +04:00
|
|
|
virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun mallocSizeOf) const = 0;
|
|
|
|
virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) const = 0;
|
1999-10-08 07:09:31 +04:00
|
|
|
};
|
|
|
|
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleRuleProcessor,
|
|
|
|
NS_ISTYLE_RULE_PROCESSOR_IID)
|
|
|
|
|
1999-10-08 07:09:31 +04:00
|
|
|
#endif /* nsIStyleRuleProcessor_h___ */
|