1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 * internal abstract interface for objects providing immutable style
43 #ifndef nsIStyleRule_h___
44 #define nsIStyleRule_h___
48 #include "nsISupports.h"
55 // IID for the nsIStyleRule interface {40ae5c90-ad6a-11d1-8031-006008159b5a}
56 #define NS_ISTYLE_RULE_IID \
57 {0x40ae5c90, 0xad6a, 0x11d1, {0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
60 * An object implementing |nsIStyleRule| (henceforth, a rule) represents
61 * immutable stylistic information that either applies or does not apply
62 * to a given element. It belongs to an object or group of objects that
63 * implement |nsIStyleSheet| and |nsIStyleRuleProcessor| (henceforth, a
66 * A rule becomes relevant to the computation of style data when
67 * |nsIStyleRuleProcessor::RulesMatching| creates a rule node that
68 * points to the rule. (A rule node, |nsRuleNode|, is a node in the
69 * rule tree, which is a lexicographic tree indexed by rules. The path
70 * from the root of the rule tree to the |nsRuleNode| for a given
71 * |nsStyleContext| contains exactly the rules that match the element
72 * that the style context is for, in priority (weight, origin,
73 * specificity) order.)
75 * The computation of style data uses the rule tree, which calls
76 * |nsIStyleRule::MapRuleInfoInto| below.
78 * It is worth emphasizing that the data represented by a rule
79 * implementation are immutable. When the data need to be changed, a
80 * new rule object must be created. Failing to do this will lead to
81 * bugs in the handling of dynamic style changes, since the rule tree
82 * caches the results of |MapRuleInfoInto|.
84 * |nsIStyleRule| objects are owned by |nsRuleNode| objects (in addition
85 * to typically being owned by their sheet), which are in turn garbage
86 * collected (with the garbage collection roots being style contexts).
90 class nsIStyleRule
: public nsISupports
{
92 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_IID
)
95 * |nsIStyleRule::MapRuleInfoInto| is a request to copy all stylistic
96 * data represented by the rule that:
97 * + are relevant for any structs in |aRuleData->mSIDs| (style
99 * + are not already filled into the data struct
100 * into the appropriate data struct in |aRuleData|. It is important
101 * that only empty data are filled in, since the rule tree is walked
102 * from highest priority rule to least, so that the walk can stop if
103 * all needed data are found. Thus overwriting non-empty data will
104 * break CSS cascading rules.
106 NS_IMETHOD
MapRuleInfoInto(nsRuleData
* aRuleData
)=0;
109 NS_IMETHOD
List(FILE* out
= stdout
, PRInt32 aIndent
= 0) const = 0;
113 NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleRule
, NS_ISTYLE_RULE_IID
)
115 #endif /* nsIStyleRule_h___ */