1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6 * This file contains forward declarations and typedefs for types that cbindgen
7 * cannot understand but renames / prefixes, and includes for some of the types
11 #ifndef mozilla_ServoStyleConsts_h
12 # error "This file is only meant to be included from ServoStyleConsts.h"
15 #ifndef mozilla_ServoStyleConstsForwards_h
16 # define mozilla_ServoStyleConstsForwards_h
20 # include "mozilla/AtomArray.h"
21 # include "mozilla/IntegerRange.h"
22 # include "mozilla/Span.h"
24 # include "mozilla/gfx/Types.h"
25 # include "mozilla/CORSMode.h"
26 # include "mozilla/MemoryReporting.h"
27 # include "mozilla/ServoTypes.h"
28 # include "mozilla/ServoBindingTypes.h"
29 # include "mozilla/Vector.h"
30 # include "nsCSSPropertyID.h"
31 # include "nsCompatibility.h"
33 # include "mozilla/image/Resolution.h"
36 struct RawServoAnimationValueTable
;
42 class nsCSSPropertyIDSet
;
44 class nsSimpleContentList
;
45 class imgRequestProxy
;
46 struct nsCSSValueSharedList
;
48 class gfxFontFeatureValueSet
;
49 struct gfxFontFeature
;
50 struct GeckoFontMetrics
;
55 } // namespace mozilla
56 typedef mozilla::gfx::FontVariation gfxFontVariation
;
58 enum nsCSSUnit
: uint32_t;
59 enum nsChangeHint
: uint32_t;
61 namespace nsStyleTransformMatrix
{
62 enum class MatrixTransformOperator
: uint8_t;
66 class nsMainThreadPtrHolder
;
72 using Matrix4x4Components
= float[16];
73 using StyleMatrix4x4Components
= Matrix4x4Components
;
75 // This is sound because std::num::NonZeroUsize is repr(transparent).
77 // It is just the case that cbindgen doesn't understand it natively.
78 using StyleNonZeroUsize
= uintptr_t;
81 struct PropertyStyleAnimationValuePair
;
83 using ComputedKeyframeValues
= nsTArray
<PropertyStyleAnimationValuePair
>;
86 enum class LogicalAxis
: uint8_t;
91 class ServoElementSnapshotTable
;
94 struct StyleForgottenArcSlicePtr
;
96 struct AnimatedPropertyID
;
97 struct AnimationPropertySegment
;
99 struct ComputedTiming
;
102 enum HalfCorner
: uint8_t;
103 enum class LogicalSide
: uint8_t;
104 enum class PseudoStyleType
: uint8_t;
105 enum class OriginFlags
: uint8_t;
106 enum class UseBoxSizing
: uint8_t;
110 class LoaderReusableStyleSheets
;
112 using SheetLoadDataHolder
= nsMainThreadPtrHolder
<SheetLoadData
>;
113 enum SheetParsingMode
: uint8_t;
117 enum class IterationCompositeOperation
: uint8_t;
118 enum class CallerType
: uint32_t;
130 // Replacement for a Rust Box<T> for a non-dynamically-sized-type.
132 // TODO(emilio): If this was some sort of nullable box then this could be made
133 // to work with moves, and also reduce memory layout size of stuff, potentially.
134 template <typename T
>
136 explicit StyleBox(UniquePtr
<T
> aPtr
) : mRaw(aPtr
.release()) {
137 MOZ_DIAGNOSTIC_ASSERT(mRaw
);
141 MOZ_DIAGNOSTIC_ASSERT(mRaw
);
145 StyleBox(const StyleBox
& aOther
) : StyleBox(MakeUnique
<T
>(*aOther
)) {}
147 StyleBox
& operator=(const StyleBox
& aOther
) const {
149 mRaw
= MakeUnique
<T
>(*aOther
).release();
153 const T
* operator->() const {
154 MOZ_DIAGNOSTIC_ASSERT(mRaw
);
158 const T
& operator*() const {
159 MOZ_DIAGNOSTIC_ASSERT(mRaw
);
164 MOZ_DIAGNOSTIC_ASSERT(mRaw
);
169 MOZ_DIAGNOSTIC_ASSERT(mRaw
);
173 bool operator==(const StyleBox
& aOther
) const { return *(*this) == *aOther
; }
175 bool operator!=(const StyleBox
& aOther
) const { return *(*this) != *aOther
; }
181 // Work-around weird cbindgen renaming / avoiding moving stuff outside its
184 using StyleImageTracker
= dom::ImageTracker
;
185 using StyleLoader
= css::Loader
;
186 using StyleLoaderReusableStyleSheets
= css::LoaderReusableStyleSheets
;
187 using StyleCallerType
= dom::CallerType
;
188 using StyleSheetParsingMode
= css::SheetParsingMode
;
189 using StyleSheetLoadData
= css::SheetLoadData
;
190 using StyleSheetLoadDataHolder
= css::SheetLoadDataHolder
;
191 using StyleGeckoMallocSizeOf
= MallocSizeOf
;
192 using StyleDomStyleSheet
= StyleSheet
;
194 using StyleRawGeckoNode
= nsINode
;
195 using StyleRawGeckoElement
= dom::Element
;
196 using StyleDocument
= dom::Document
;
197 using StyleComputedValues
= ComputedStyle
;
198 using StyleIterationCompositeOperation
= dom::IterationCompositeOperation
;
200 using StyleMatrixTransformOperator
=
201 nsStyleTransformMatrix::MatrixTransformOperator
;
203 # define SERVO_LOCKED_ARC_TYPE(name_) struct StyleLocked##type_;
204 # include "mozilla/ServoLockedArcTypeList.h"
205 # undef SERVO_LOCKED_ARC_TYPE
207 # define SERVO_BOXED_TYPE(name_, type_) struct Style##type_;
208 # include "mozilla/ServoBoxedTypeList.h"
209 # undef SERVO_BOXED_TYPE
211 using StyleAtomicUsize
= std::atomic
<size_t>;
213 # define SERVO_FIXED_POINT_HELPERS(T, RawT, FractionBits) \
214 static constexpr RawT kPointFive = 1 << (FractionBits - 1); \
215 static constexpr uint16_t kScale = 1 << FractionBits; \
216 static constexpr float kInverseScale = 1.0f / kScale; \
217 static T FromRaw(RawT aRaw) { return {{aRaw}}; } \
218 static T FromFloat(float aFloat) { \
219 return FromRaw(RawT(aFloat * kScale)); \
221 static T FromInt(RawT aInt) { return FromRaw(RawT(aInt * kScale)); } \
222 RawT Raw() const { return _0.value; } \
223 uint16_t UnsignedRaw() const { return uint16_t(Raw()); } \
224 float ToFloat() const { return Raw() * kInverseScale; } \
225 RawT ToIntRounded() const { return (Raw() + kPointFive) >> FractionBits; } \
226 inline void ToString(nsACString&) const;
228 } // namespace mozilla
230 # ifndef HAVE_64BIT_BUILD
231 static_assert(sizeof(void*) == 4, "");
232 # define SERVO_32_BITS 1
234 # define CBINDGEN_IS_GECKO