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 objects providing immutable style michael@0: * information michael@0: */ michael@0: michael@0: #ifndef nsIStyleRule_h___ michael@0: #define nsIStyleRule_h___ michael@0: michael@0: #include michael@0: michael@0: #include "nsISupports.h" michael@0: michael@0: struct nsRuleData; michael@0: michael@0: // IID for the nsIStyleRule interface {f75f3f70-435d-43a6-a01b-65970489ca26} michael@0: #define NS_ISTYLE_RULE_IID \ michael@0: { 0xf75f3f70, 0x435d, 0x43a6, \ michael@0: { 0xa0, 0x1b, 0x65, 0x97, 0x04, 0x89, 0xca, 0x26 } } michael@0: michael@0: /** michael@0: * An object implementing |nsIStyleRule| (henceforth, a rule) represents michael@0: * immutable stylistic information that either applies or does not apply michael@0: * to a given element. It belongs to an object or group of objects that michael@0: * implement |nsIStyleSheet| and |nsIStyleRuleProcessor| (henceforth, a michael@0: * sheet). michael@0: * michael@0: * A rule becomes relevant to the computation of style data when michael@0: * |nsIStyleRuleProcessor::RulesMatching| creates a rule node that michael@0: * points to the rule. (A rule node, |nsRuleNode|, is a node in the michael@0: * rule tree, which is a lexicographic tree indexed by rules. The path michael@0: * from the root of the rule tree to the |nsRuleNode| for a given michael@0: * |nsStyleContext| contains exactly the rules that match the element michael@0: * that the style context is for, in priority (weight, origin, michael@0: * specificity) order.) michael@0: * michael@0: * The computation of style data uses the rule tree, which calls michael@0: * |nsIStyleRule::MapRuleInfoInto| below. michael@0: * michael@0: * It is worth emphasizing that the data represented by a rule michael@0: * implementation are immutable. When the data need to be changed, a michael@0: * new rule object must be created. Failing to do this will lead to michael@0: * bugs in the handling of dynamic style changes, since the rule tree michael@0: * caches the results of |MapRuleInfoInto|. michael@0: * michael@0: * |nsIStyleRule| objects are owned by |nsRuleNode| objects (in addition michael@0: * to typically being owned by their sheet), which are in turn garbage michael@0: * collected (with the garbage collection roots being style contexts). michael@0: */ michael@0: michael@0: michael@0: class nsIStyleRule : public nsISupports { michael@0: public: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_IID) michael@0: michael@0: /** michael@0: * |nsIStyleRule::MapRuleInfoInto| is a request to copy all stylistic michael@0: * data represented by the rule that: michael@0: * + are relevant for any structs in |aRuleData->mSIDs| (style michael@0: * struct ID bits) michael@0: * + are not already filled into the data struct michael@0: * into the appropriate data struct in |aRuleData|. It is important michael@0: * that only empty data are filled in, since the rule tree is walked michael@0: * from highest priority rule to least, so that the walk can stop if michael@0: * all needed data are found. Thus overwriting non-empty data will michael@0: * break CSS cascading rules. michael@0: */ michael@0: virtual void MapRuleInfoInto(nsRuleData* aRuleData)=0; michael@0: michael@0: #ifdef DEBUG michael@0: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const = 0; michael@0: #endif michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleRule, NS_ISTYLE_RULE_IID) michael@0: michael@0: #endif /* nsIStyleRule_h___ */