2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-03-25 05:47:31 +00: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 03:09:31 +00:00
|
|
|
#ifndef nsIStyleRuleProcessor_h___
|
|
|
|
#define nsIStyleRuleProcessor_h___
|
|
|
|
|
2013-06-23 12:03:39 +00:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
1999-10-08 03:09:31 +00:00
|
|
|
#include "nsISupports.h"
|
2004-01-14 01:36:35 +00:00
|
|
|
#include "nsChangeHint.h"
|
1999-10-08 03:09:31 +00:00
|
|
|
|
2009-08-01 15:53:40 +00:00
|
|
|
struct RuleProcessorData;
|
|
|
|
struct ElementRuleProcessorData;
|
2009-12-11 07:37:40 +00:00
|
|
|
struct PseudoElementRuleProcessorData;
|
2009-12-11 07:37:40 +00:00
|
|
|
struct AnonBoxRuleProcessorData;
|
2009-12-11 07:37:40 +00:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
struct XULTreeRuleProcessorData;
|
|
|
|
#endif
|
2009-08-01 15:53:40 +00:00
|
|
|
struct StateRuleProcessorData;
|
2013-11-28 06:46:39 +00:00
|
|
|
struct PseudoElementStateRuleProcessorData;
|
2009-08-01 15:53:40 +00:00
|
|
|
struct AttributeRuleProcessorData;
|
2004-07-31 23:15:21 +00:00
|
|
|
class nsPresContext;
|
2001-11-10 23:51:45 +00:00
|
|
|
|
2009-12-11 07:37:40 +00:00
|
|
|
// IID for the nsIStyleRuleProcessor interface
|
2011-12-09 05:01:52 +00:00
|
|
|
// {c1d6001e-4fcb-4c40-bce1-5eba80bfd8f3}
|
1999-10-08 03:09:31 +00:00
|
|
|
#define NS_ISTYLE_RULE_PROCESSOR_IID \
|
2011-12-09 05:01:52 +00:00
|
|
|
{ 0xc1d6001e, 0x4fcb, 0x4c40, \
|
|
|
|
{0xbc, 0xe1, 0x5e, 0xba, 0x80, 0xbf, 0xd8, 0xf3} }
|
2010-07-18 21:20:40 +00:00
|
|
|
|
1999-10-08 03:09:31 +00:00
|
|
|
|
2003-03-24 04:15:34 +00:00
|
|
|
/* The style rule processor interface is a mechanism to separate the matching
|
1999-10-08 03:09:31 +00: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 02:28:02 +00:00
|
|
|
*
|
|
|
|
* @see nsIStyleRule (for significantly more detailed comments)
|
1999-10-08 03:09:31 +00:00
|
|
|
*/
|
|
|
|
class nsIStyleRuleProcessor : public nsISupports {
|
|
|
|
public:
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_PROCESSOR_IID)
|
1999-10-08 03:09:31 +00:00
|
|
|
|
2004-01-07 22:30:53 +00:00
|
|
|
// Shorthand for:
|
|
|
|
// nsCOMArray<nsIStyleRuleProcessor>::nsCOMArrayEnumFunc
|
2011-09-29 06:19:26 +00:00
|
|
|
typedef bool (* EnumFunc)(nsIStyleRuleProcessor*, void*);
|
2004-01-07 22:30:53 +00:00
|
|
|
|
2005-07-26 02:28:02 +00: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-18 21:20:40 +00:00
|
|
|
virtual void RulesMatching(ElementRuleProcessorData* aData) = 0;
|
2001-11-10 23:51:45 +00:00
|
|
|
|
2005-07-26 02:28:02 +00:00
|
|
|
/**
|
|
|
|
* Just like the previous |RulesMatching|, except for a given content
|
|
|
|
* node <em>and pseudo-element</em>.
|
|
|
|
*/
|
2010-07-18 21:20:40 +00:00
|
|
|
virtual void RulesMatching(PseudoElementRuleProcessorData* aData) = 0;
|
2009-12-11 07:37:40 +00:00
|
|
|
|
2009-12-11 07:37:40 +00:00
|
|
|
/**
|
|
|
|
* Just like the previous |RulesMatching|, except for a given anonymous box.
|
|
|
|
*/
|
2010-07-18 21:20:40 +00:00
|
|
|
virtual void RulesMatching(AnonBoxRuleProcessorData* aData) = 0;
|
2009-12-11 07:37:40 +00:00
|
|
|
|
2009-12-11 07:37:40 +00:00
|
|
|
#ifdef MOZ_XUL
|
2009-12-11 07:37:40 +00:00
|
|
|
/**
|
|
|
|
* Just like the previous |RulesMatching|, except for a given content
|
2009-12-11 07:37:40 +00:00
|
|
|
* node <em>and tree pseudo</em>.
|
2009-12-11 07:37:40 +00:00
|
|
|
*/
|
2010-07-18 21:20:40 +00:00
|
|
|
virtual void RulesMatching(XULTreeRuleProcessorData* aData) = 0;
|
2009-12-11 07:37:40 +00:00
|
|
|
#endif
|
1999-10-08 03:09:31 +00:00
|
|
|
|
2010-03-17 17:10:57 +00:00
|
|
|
/**
|
|
|
|
* Return whether style can depend on a change of the given document state.
|
|
|
|
*
|
|
|
|
* Document states are defined in nsIDocument.h.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool
|
2010-03-17 17:10:57 +00:00
|
|
|
HasDocumentStateDependentStyle(StateRuleProcessorData* aData) = 0;
|
|
|
|
|
2004-02-25 21:04:50 +00:00
|
|
|
/**
|
2010-04-01 00:43:32 +00:00
|
|
|
* Return how (as described by nsRestyleHint) style can depend on a
|
2005-07-26 02:28:02 +00: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-25 21:04:50 +00:00
|
|
|
*
|
2014-04-03 04:18:36 +00:00
|
|
|
* Event states are defined in mozilla/EventStates.h.
|
2004-02-25 21:04:50 +00:00
|
|
|
*/
|
2010-04-01 00:43:32 +00:00
|
|
|
virtual nsRestyleHint
|
2009-12-12 06:36:34 +00:00
|
|
|
HasStateDependentStyle(StateRuleProcessorData* aData) = 0;
|
2013-11-28 06:46:39 +00:00
|
|
|
virtual nsRestyleHint
|
|
|
|
HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData) = 0;
|
2004-02-25 21:04:50 +00:00
|
|
|
|
|
|
|
/**
|
2009-12-10 22:36:03 +00: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-25 21:04:50 +00:00
|
|
|
*/
|
2015-08-05 12:42:21 +00:00
|
|
|
virtual nsRestyleHint HasAttributeDependentStyle(
|
|
|
|
AttributeRuleProcessorData* aData,
|
|
|
|
mozilla::RestyleHintData& aRestyleHintDataResult) = 0;
|
2008-07-26 16:14:48 +00: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 06:19:26 +00:00
|
|
|
virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) = 0;
|
2011-08-01 18:25:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Report the size of this style rule processor to about:memory. A
|
|
|
|
* processor may return 0.
|
|
|
|
*/
|
2013-06-23 12:03:39 +00:00
|
|
|
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const = 0;
|
|
|
|
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const = 0;
|
1999-10-08 03:09:31 +00:00
|
|
|
};
|
|
|
|
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleRuleProcessor,
|
|
|
|
NS_ISTYLE_RULE_PROCESSOR_IID)
|
|
|
|
|
1999-10-08 03:09:31 +00:00
|
|
|
#endif /* nsIStyleRuleProcessor_h___ */
|