Merge mozilla-central and tracemonkey. (a=blockers)
[mozilla-central.git] / layout / base / nsChangeHint.h
blob15c3f81ca87710bd95ad573b2f288df826ce8fdf
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
13 * License.
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.
22 * Contributor(s):
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 ***** */
38 /* constants for what needs to be recomputed in response to style changes */
40 #ifndef nsChangeHint_h___
41 #define nsChangeHint_h___
43 #include "prtypes.h"
45 // Defines for various style related constants
47 enum nsChangeHint {
48 // change was visual only (e.g., COLOR=)
49 nsChangeHint_RepaintFrame = 0x01,
51 // For reflow, we want flags to give us arbitrary FrameNeedsReflow behavior.
52 // just do a FrameNeedsReflow
53 nsChangeHint_NeedReflow = 0x02,
55 // Invalidate intrinsic widths on the frame's ancestors. Must not be set
56 // without setting nsChangeHint_NeedReflow.
57 nsChangeHint_ClearAncestorIntrinsics = 0x04,
59 // Invalidate intrinsic widths on the frame's descendants. Must not be set
60 // without also setting nsChangeHint_ClearAncestorIntrinsics.
61 nsChangeHint_ClearDescendantIntrinsics = 0x08,
63 // Force unconditional reflow of all descendants. Must not be set without
64 // setting nsChangeHint_NeedReflow, but is independent of both the
65 // Clear*Intrinsics flags.
66 nsChangeHint_NeedDirtyReflow = 0x10,
68 // change requires view to be updated, if there is one (e.g., clip:)
69 nsChangeHint_SyncFrameView = 0x20,
71 // The currently shown mouse cursor needs to be updated
72 nsChangeHint_UpdateCursor = 0x40,
74 /**
75 * SVG filter/mask/clip effects need to be recomputed because the URI
76 * in the filter/mask/clip-path property has changed. This wipes
77 * out cached nsSVGPropertyBase and subclasses which hold a reference to
78 * the element referenced by the URI, and a mutation observer for
79 * the DOM subtree rooted at that element. Also, for filters they store a
80 * bounding-box for the filter result so that if the filter changes we can
81 * invalidate the old covered area.
83 nsChangeHint_UpdateEffects = 0x80,
85 /**
86 * Visual change only, but the change can be handled entirely by
87 * updating the layer(s) for the frame.
89 nsChangeHint_UpdateOpacityLayer = 0x100,
90 nsChangeHint_UpdateTransformLayer = 0x200,
92 // change requires frame change (e.g., display:).
93 // This subsumes all the above.
94 nsChangeHint_ReconstructFrame = 0x400
97 // Redefine these operators to return nothing. This will catch any use
98 // of these operators on hints. We should not be using these operators
99 // on nsChangeHints
100 inline void operator<(nsChangeHint s1, nsChangeHint s2) {}
101 inline void operator>(nsChangeHint s1, nsChangeHint s2) {}
102 inline void operator!=(nsChangeHint s1, nsChangeHint s2) {}
103 inline void operator==(nsChangeHint s1, nsChangeHint s2) {}
104 inline void operator<=(nsChangeHint s1, nsChangeHint s2) {}
105 inline void operator>=(nsChangeHint s1, nsChangeHint s2) {}
107 // Operators on nsChangeHints
109 // Merge two hints, taking the union
110 inline nsChangeHint NS_CombineHint(nsChangeHint aH1, nsChangeHint aH2) {
111 return (nsChangeHint)(aH1 | aH2);
114 // Merge two hints, taking the union
115 inline nsChangeHint NS_SubtractHint(nsChangeHint aH1, nsChangeHint aH2) {
116 return (nsChangeHint)(aH1 & ~aH2);
119 // Merge the "src" hint into the "dst" hint
120 // Returns true iff the destination changed
121 inline PRBool NS_UpdateHint(nsChangeHint& aDest, nsChangeHint aSrc) {
122 nsChangeHint r = (nsChangeHint)(aDest | aSrc);
123 PRBool changed = (int)r != (int)aDest;
124 aDest = r;
125 return changed;
128 // Returns true iff the second hint contains all the hints of the first hint
129 inline PRBool NS_IsHintSubset(nsChangeHint aSubset, nsChangeHint aSuperSet) {
130 return (aSubset & aSuperSet) == aSubset;
133 // Redefine the old NS_STYLE_HINT constants in terms of the new hint structure
134 #define NS_STYLE_HINT_NONE \
135 nsChangeHint(0)
136 #define NS_STYLE_HINT_VISUAL \
137 nsChangeHint(nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView)
138 #define nsChangeHint_ReflowFrame \
139 nsChangeHint(nsChangeHint_NeedReflow | \
140 nsChangeHint_ClearAncestorIntrinsics | \
141 nsChangeHint_ClearDescendantIntrinsics | \
142 nsChangeHint_NeedDirtyReflow)
143 #define NS_STYLE_HINT_REFLOW \
144 nsChangeHint(NS_STYLE_HINT_VISUAL | nsChangeHint_ReflowFrame)
145 #define NS_STYLE_HINT_FRAMECHANGE \
146 nsChangeHint(NS_STYLE_HINT_REFLOW | nsChangeHint_ReconstructFrame)
149 * |nsRestyleHint| is a bitfield for the result of
150 * |HasStateDependentStyle| and |HasAttributeDependentStyle|. When no
151 * restyling is necessary, use |nsRestyleHint(0)|.
153 enum nsRestyleHint {
154 eRestyle_Self = 0x1,
155 eRestyle_Subtree = 0x2, /* self and descendants */
156 eRestyle_LaterSiblings = 0x4 /* implies "and descendants" */
160 #endif /* nsChangeHint_h___ */