Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /*
7 * internal abstract interface for objects providing immutable style
8 * information
9 */
11 #ifndef nsIStyleRule_h___
12 #define nsIStyleRule_h___
14 #include <stdio.h>
16 #include "nsISupports.h"
18 struct nsRuleData;
20 // IID for the nsIStyleRule interface {f75f3f70-435d-43a6-a01b-65970489ca26}
21 #define NS_ISTYLE_RULE_IID \
22 { 0xf75f3f70, 0x435d, 0x43a6, \
23 { 0xa0, 0x1b, 0x65, 0x97, 0x04, 0x89, 0xca, 0x26 } }
25 /**
26 * An object implementing |nsIStyleRule| (henceforth, a rule) represents
27 * immutable stylistic information that either applies or does not apply
28 * to a given element. It belongs to an object or group of objects that
29 * implement |nsIStyleSheet| and |nsIStyleRuleProcessor| (henceforth, a
30 * sheet).
31 *
32 * A rule becomes relevant to the computation of style data when
33 * |nsIStyleRuleProcessor::RulesMatching| creates a rule node that
34 * points to the rule. (A rule node, |nsRuleNode|, is a node in the
35 * rule tree, which is a lexicographic tree indexed by rules. The path
36 * from the root of the rule tree to the |nsRuleNode| for a given
37 * |nsStyleContext| contains exactly the rules that match the element
38 * that the style context is for, in priority (weight, origin,
39 * specificity) order.)
40 *
41 * The computation of style data uses the rule tree, which calls
42 * |nsIStyleRule::MapRuleInfoInto| below.
43 *
44 * It is worth emphasizing that the data represented by a rule
45 * implementation are immutable. When the data need to be changed, a
46 * new rule object must be created. Failing to do this will lead to
47 * bugs in the handling of dynamic style changes, since the rule tree
48 * caches the results of |MapRuleInfoInto|.
49 *
50 * |nsIStyleRule| objects are owned by |nsRuleNode| objects (in addition
51 * to typically being owned by their sheet), which are in turn garbage
52 * collected (with the garbage collection roots being style contexts).
53 */
56 class nsIStyleRule : public nsISupports {
57 public:
58 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_IID)
60 /**
61 * |nsIStyleRule::MapRuleInfoInto| is a request to copy all stylistic
62 * data represented by the rule that:
63 * + are relevant for any structs in |aRuleData->mSIDs| (style
64 * struct ID bits)
65 * + are not already filled into the data struct
66 * into the appropriate data struct in |aRuleData|. It is important
67 * that only empty data are filled in, since the rule tree is walked
68 * from highest priority rule to least, so that the walk can stop if
69 * all needed data are found. Thus overwriting non-empty data will
70 * break CSS cascading rules.
71 */
72 virtual void MapRuleInfoInto(nsRuleData* aRuleData)=0;
74 #ifdef DEBUG
75 virtual void List(FILE* out = stdout, int32_t aIndent = 0) const = 0;
76 #endif
77 };
79 NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleRule, NS_ISTYLE_RULE_IID)
81 #endif /* nsIStyleRule_h___ */