2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 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___
|
|
|
|
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
1999-10-08 07:09:31 +04:00
|
|
|
#include "nsISupports.h"
|
2004-01-14 04:36:35 +03:00
|
|
|
#include "nsChangeHint.h"
|
1999-10-08 07:09:31 +04:00
|
|
|
|
2009-08-01 19:53:40 +04:00
|
|
|
struct RuleProcessorData;
|
2013-11-28 10:46:39 +04:00
|
|
|
struct ElementDependentRuleProcessorData;
|
2009-08-01 19:53:40 +04:00
|
|
|
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;
|
2013-11-28 10:46:39 +04:00
|
|
|
struct PseudoElementStateRuleProcessorData;
|
2009-08-01 19:53:40 +04:00
|
|
|
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
|
|
|
*
|
2014-04-03 08:18:36 +04:00
|
|
|
* Event states are defined in mozilla/EventStates.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;
|
2013-11-28 10:46:39 +04:00
|
|
|
virtual nsRestyleHint
|
|
|
|
HasStateDependentStyle(PseudoElementStateRuleProcessorData* 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.
|
|
|
|
*/
|
2013-06-23 16:03:39 +04:00
|
|
|
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const = 0;
|
|
|
|
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf 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___ */
|