Bug 1698786: part 2) Change some compile-time dependent `printf`s to `MOZ_LOG` in...
[gecko.git] / layout / style / ServoTypes.h
blob3d532bd32e62dd86801433baeb5325832f460383
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* types defined to pass values through Gecko_* and Servo_* FFI functions */
9 #ifndef mozilla_ServoTypes_h
10 #define mozilla_ServoTypes_h
12 #include "mozilla/RefPtr.h"
13 #include "mozilla/TypedEnumBits.h"
14 #include "nsCoord.h"
16 struct RawServoFontFaceRule;
18 namespace mozilla {
19 enum class StyleOrigin : uint8_t;
20 struct LangGroupFontPrefs;
21 } // namespace mozilla
23 // used for associating origin with specific @font-face rules
24 struct nsFontFaceRuleContainer {
25 RefPtr<RawServoFontFaceRule> mRule;
26 mozilla::StyleOrigin mOrigin;
29 namespace mozilla {
31 // Indicates whether the Servo style system should expect the style on an
32 // element to have already been resolved (i.e. via a parallel traversal), or
33 // whether it may be lazily computed.
34 enum class LazyComputeBehavior {
35 Allow,
36 Assert,
39 // Various flags for the servo traversal.
40 enum class ServoTraversalFlags : uint32_t {
41 Empty = 0,
42 // Perform animation processing but not regular styling.
43 AnimationOnly = 1 << 0,
44 // Traverses as normal mode but tries to update all CSS animations.
45 ForCSSRuleChanges = 1 << 1,
46 // The final animation-only traversal, which shouldn't really care about other
47 // style changes anymore.
48 FinalAnimationTraversal = 1 << 2,
49 // Allows the traversal to run in parallel if there are sufficient cores on
50 // the machine.
51 ParallelTraversal = 1 << 7,
52 // Flush throttled animations. By default, we only update throttled animations
53 // when we have other non-throttled work to do. With this flag, we
54 // unconditionally tick and process them.
55 FlushThrottledAnimations = 1 << 8,
58 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ServoTraversalFlags)
60 // Indicates which rules should be included when performing selecting matching
61 // on an element. DefaultOnly is used to exclude all rules except for those
62 // that come from UA style sheets, and is used to implemented
63 // getDefaultComputedStyle.
64 enum class StyleRuleInclusion {
65 All,
66 DefaultOnly,
69 // Represents which tasks are performed in a SequentialTask of UpdateAnimations.
70 enum class UpdateAnimationsTasks : uint8_t {
71 CSSAnimations = 1 << 0,
72 CSSTransitions = 1 << 1,
73 EffectProperties = 1 << 2,
74 CascadeResults = 1 << 3,
75 DisplayChangedFromNone = 1 << 4,
78 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(UpdateAnimationsTasks)
80 // The mode to use when parsing values.
81 enum class ParsingMode : uint8_t {
82 // In CSS, lengths must have units, except for zero values, where the unit can
83 // be omitted.
84 // https://www.w3.org/TR/css3-values/#lengths
85 Default = 0,
86 // In SVG, a coordinate or length value without a unit identifier (e.g., "25")
87 // is assumed to be in user units (px).
88 // https://www.w3.org/TR/SVG/coords.html#Units
89 AllowUnitlessLength = 1 << 0,
90 // In SVG, out-of-range values are not treated as an error in parsing.
91 // https://www.w3.org/TR/SVG/implnote.html#RangeClamping
92 AllowAllNumericValues = 1 << 1,
95 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ParsingMode)
97 // The kind of style we're generating when requesting Servo to give us an
98 // inherited style.
99 enum class InheritTarget {
100 // We're requesting a text style.
101 Text,
102 // We're requesting a first-letter continuation frame style.
103 FirstLetterContinuation,
104 // We're requesting a style for a placeholder frame.
105 PlaceholderFrame,
108 // Represents values for interaction media features.
109 // https://drafts.csswg.org/mediaqueries-4/#mf-interaction
110 enum class PointerCapabilities : uint8_t {
111 None = 0,
112 Coarse = 1 << 0,
113 Fine = 1 << 1,
114 Hover = 1 << 2,
117 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(PointerCapabilities)
119 // These measurements are obtained for both the UA cache and the Stylist, but
120 // not all the fields are used in both cases.
121 class ServoStyleSetSizes {
122 public:
123 size_t mRuleTree; // Stylist-only
124 size_t mPrecomputedPseudos; // UA cache-only
125 size_t mElementAndPseudosMaps; // Used for both
126 size_t mInvalidationMap; // Used for both
127 size_t mRevalidationSelectors; // Used for both
128 size_t mOther; // Used for both
130 ServoStyleSetSizes()
131 : mRuleTree(0),
132 mPrecomputedPseudos(0),
133 mElementAndPseudosMaps(0),
134 mInvalidationMap(0),
135 mRevalidationSelectors(0),
136 mOther(0) {}
139 // A callback that can be sent via FFI which will be invoked _right before_
140 // being mutated, and at most once.
141 struct DeclarationBlockMutationClosure {
142 // The callback function. The argument is `data`.
143 void (*function)(void*) = nullptr;
144 void* data = nullptr;
147 struct MediumFeaturesChangedResult {
148 bool mAffectsDocumentRules;
149 bool mAffectsNonDocumentRules;
150 bool mUsesViewportUnits;
153 } // namespace mozilla
155 #endif // mozilla_ServoTypes_h