michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * internal abstract interface for containers (roughly origins within michael@0: * the CSS cascade) that provide style rules matching an element or michael@0: * pseudo-element michael@0: */ michael@0: michael@0: #ifndef nsIStyleRuleProcessor_h___ michael@0: #define nsIStyleRuleProcessor_h___ michael@0: michael@0: #include "mozilla/MemoryReporting.h" michael@0: #include "nsISupports.h" michael@0: #include "nsChangeHint.h" michael@0: michael@0: struct RuleProcessorData; michael@0: struct ElementDependentRuleProcessorData; michael@0: struct ElementRuleProcessorData; michael@0: struct PseudoElementRuleProcessorData; michael@0: struct AnonBoxRuleProcessorData; michael@0: #ifdef MOZ_XUL michael@0: struct XULTreeRuleProcessorData; michael@0: #endif michael@0: struct StateRuleProcessorData; michael@0: struct PseudoElementStateRuleProcessorData; michael@0: struct AttributeRuleProcessorData; michael@0: class nsPresContext; michael@0: michael@0: // IID for the nsIStyleRuleProcessor interface michael@0: // {c1d6001e-4fcb-4c40-bce1-5eba80bfd8f3} michael@0: #define NS_ISTYLE_RULE_PROCESSOR_IID \ michael@0: { 0xc1d6001e, 0x4fcb, 0x4c40, \ michael@0: {0xbc, 0xe1, 0x5e, 0xba, 0x80, 0xbf, 0xd8, 0xf3} } michael@0: michael@0: michael@0: /* The style rule processor interface is a mechanism to separate the matching michael@0: * of style rules from style sheet instances. michael@0: * Simple style sheets can and will act as their own processor. michael@0: * Sheets where rule ordering interlaces between multiple sheets, will need to michael@0: * share a single rule processor between them (CSS sheets do this for cascading order) michael@0: * michael@0: * @see nsIStyleRule (for significantly more detailed comments) michael@0: */ michael@0: class nsIStyleRuleProcessor : public nsISupports { michael@0: public: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_PROCESSOR_IID) michael@0: michael@0: // Shorthand for: michael@0: // nsCOMArray::nsCOMArrayEnumFunc michael@0: typedef bool (* EnumFunc)(nsIStyleRuleProcessor*, void*); michael@0: michael@0: /** michael@0: * Find the |nsIStyleRule|s matching the given content node and michael@0: * position the given |nsRuleWalker| at the |nsRuleNode| in the rule michael@0: * tree representing that ordered list of rules (with higher michael@0: * precedence being farther from the root of the lexicographic tree). michael@0: */ michael@0: virtual void RulesMatching(ElementRuleProcessorData* aData) = 0; michael@0: michael@0: /** michael@0: * Just like the previous |RulesMatching|, except for a given content michael@0: * node and pseudo-element. michael@0: */ michael@0: virtual void RulesMatching(PseudoElementRuleProcessorData* aData) = 0; michael@0: michael@0: /** michael@0: * Just like the previous |RulesMatching|, except for a given anonymous box. michael@0: */ michael@0: virtual void RulesMatching(AnonBoxRuleProcessorData* aData) = 0; michael@0: michael@0: #ifdef MOZ_XUL michael@0: /** michael@0: * Just like the previous |RulesMatching|, except for a given content michael@0: * node and tree pseudo. michael@0: */ michael@0: virtual void RulesMatching(XULTreeRuleProcessorData* aData) = 0; michael@0: #endif michael@0: michael@0: /** michael@0: * Return whether style can depend on a change of the given document state. michael@0: * michael@0: * Document states are defined in nsIDocument.h. michael@0: */ michael@0: virtual bool michael@0: HasDocumentStateDependentStyle(StateRuleProcessorData* aData) = 0; michael@0: michael@0: /** michael@0: * Return how (as described by nsRestyleHint) style can depend on a michael@0: * change of the given content state on the given content node. This michael@0: * test is used for optimization only, and may err on the side of michael@0: * reporting more dependencies than really exist. michael@0: * michael@0: * Event states are defined in mozilla/EventStates.h. michael@0: */ michael@0: virtual nsRestyleHint michael@0: HasStateDependentStyle(StateRuleProcessorData* aData) = 0; michael@0: virtual nsRestyleHint michael@0: HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData) = 0; michael@0: michael@0: /** michael@0: * This method will be called twice for every attribute change. michael@0: * During the first call, aData->mAttrHasChanged will be false and michael@0: * the attribute change will not have happened yet. During the michael@0: * second call, aData->mAttrHasChanged will be true and the michael@0: * change will have already happened. The bitwise OR of the two michael@0: * return values must describe the style changes that are needed due michael@0: * to the attribute change. It's up to the rule processor michael@0: * implementation to decide how to split the bits up amongst the two michael@0: * return values. For example, it could return the bits needed by michael@0: * rules that might stop matching the node from the first call and michael@0: * the bits needed by rules that might have started matching the michael@0: * node from the second call. This test is used for optimization michael@0: * only, and may err on the side of reporting more dependencies than michael@0: * really exist. michael@0: */ michael@0: virtual nsRestyleHint michael@0: HasAttributeDependentStyle(AttributeRuleProcessorData* aData) = 0; michael@0: michael@0: /** michael@0: * Do any processing that needs to happen as a result of a change in michael@0: * the characteristics of the medium, and return whether this rule michael@0: * processor's rules have changed (e.g., because of media queries). michael@0: */ michael@0: virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) = 0; michael@0: michael@0: /** michael@0: * Report the size of this style rule processor to about:memory. A michael@0: * processor may return 0. michael@0: */ michael@0: virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const = 0; michael@0: virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const = 0; michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleRuleProcessor, michael@0: NS_ISTYLE_RULE_PROCESSOR_IID) michael@0: michael@0: #endif /* nsIStyleRuleProcessor_h___ */