Line data Source code
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/. */
6 :
7 : #ifndef mozilla_ServoTypes_h
8 : #define mozilla_ServoTypes_h
9 :
10 : #include "mozilla/TypedEnumBits.h"
11 :
12 : /*
13 : * Type definitions used to interact with Servo. This gets included by nsINode,
14 : * so don't add significant include dependencies to this file.
15 : */
16 :
17 : struct ServoNodeData;
18 : namespace mozilla {
19 :
20 : /*
21 : * Replaced types. These get mapped to associated Servo types in bindgen.
22 : */
23 :
24 : template<typename T>
25 : struct ServoUnsafeCell {
26 : T value;
27 :
28 : // Ensure that primitive types (i.e. pointers) get zero-initialized.
29 3168 : ServoUnsafeCell() : value() {};
30 : };
31 :
32 : template<typename T>
33 : struct ServoCell {
34 : ServoUnsafeCell<T> value;
35 956 : T Get() const { return value.value; }
36 : void Set(T arg) { value.value = arg; }
37 3168 : ServoCell() : value() {};
38 : };
39 :
40 : // Indicates whether the Servo style system should expect the style on an element
41 : // to have already been resolved (i.e. via a parallel traversal), or whether it
42 : // may be lazily computed.
43 : enum class LazyComputeBehavior {
44 : Allow,
45 : Assert,
46 : };
47 :
48 : // Indicates whether the Servo style system should perform normal processing or
49 : // whether it should only process unstyled children of the root and their
50 : // descendants.
51 : enum class TraversalRootBehavior {
52 : Normal,
53 : UnstyledChildrenOnly,
54 : };
55 :
56 : // Indicates whether the Servo style system should perform normal processing,
57 : // animation-only processing (so we can flush any throttled animation styles),
58 : // or whether it should traverse in a mode that doesn't generate any change
59 : // hints, which is what's required when handling frame reconstruction.
60 : // The change hints in this case are unneeded, since the old frames have
61 : // already been destroyed.
62 : // Indicates how the Servo style system should perform.
63 : enum class TraversalRestyleBehavior {
64 : // Normal processing.
65 : Normal,
66 : // Normal processing, but tolerant to calls to restyle elements in unstyled
67 : // or display:none subtrees (which can occur when styling elements with
68 : // newly applied XBL bindings).
69 : ForNewlyBoundElement,
70 : // Traverses in a mode that doesn't generate any change hints, which is what's
71 : // required when handling frame reconstruction. The change hints in this case
72 : // are unneeded, since the old frames have already been destroyed.
73 : ForReconstruct,
74 : // Processes animation-only restyle.
75 : ForAnimationOnly,
76 : // Traverses as normal mode but tries to update all CSS animations.
77 : ForCSSRuleChanges,
78 : };
79 :
80 : // Indicates which rules should be included when performing selecting matching
81 : // on an element. DefaultOnly is used to exclude all rules except for those
82 : // that come from UA style sheets, and is used to implemented
83 : // getDefaultComputedStyle.
84 : enum class StyleRuleInclusion {
85 : All,
86 : DefaultOnly,
87 : };
88 :
89 : // Represents which tasks are performed in a SequentialTask of UpdateAnimations.
90 : enum class UpdateAnimationsTasks : uint8_t {
91 : CSSAnimations = 1 << 0,
92 : CSSTransitions = 1 << 1,
93 : EffectProperties = 1 << 2,
94 : CascadeResults = 1 << 3,
95 : };
96 :
97 0 : MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(UpdateAnimationsTasks)
98 :
99 : // The mode to use when parsing values.
100 : enum class ParsingMode : uint8_t {
101 : // In CSS, lengths must have units, except for zero values, where the unit can
102 : // be omitted.
103 : // https://www.w3.org/TR/css3-values/#lengths
104 : Default = 0,
105 : // In SVG, a coordinate or length value without a unit identifier (e.g., "25")
106 : // is assumed to be in user units (px).
107 : // https://www.w3.org/TR/SVG/coords.html#Units
108 : AllowUnitlessLength = 1 << 0,
109 : // In SVG, out-of-range values are not treated as an error in parsing.
110 : // https://www.w3.org/TR/SVG/implnote.html#RangeClamping
111 : AllowAllNumericValues = 1 << 1,
112 : };
113 :
114 0 : MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ParsingMode)
115 :
116 : // The kind of style we're generating when requesting Servo to give us an
117 : // inherited style.
118 : enum class InheritTarget {
119 : // We're requesting a text style.
120 : Text,
121 : // We're requesting a first-letter continuation frame style.
122 : FirstLetterContinuation,
123 : // We're requesting a style for a placeholder frame.
124 : PlaceholderFrame,
125 : };
126 :
127 : } // namespace mozilla
128 :
129 : #endif // mozilla_ServoTypes_h
|