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"
35 struct RawServoAnimationValueTable
;
36 struct RawServoAnimationValueMap
;
42 class nsCSSPropertyIDSet
;
44 class nsSimpleContentList
;
45 class imgRequestProxy
;
46 struct nsCSSValueSharedList
;
47 struct nsTimingFunction
;
49 class gfxFontFeatureValueSet
;
50 struct gfxFontFeature
;
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 LogicalAxis
: uint8_t;
91 class ServoElementSnapshotTable
;
94 struct StyleForgottenArcSlicePtr
;
96 struct AnimationPropertySegment
;
98 struct ComputedTiming
;
101 enum HalfCorner
: uint8_t;
102 enum LogicalSide
: uint8_t;
103 enum class PseudoStyleType
: uint8_t;
104 enum class OriginFlags
: uint8_t;
105 enum class UseBoxSizing
: uint8_t;
109 class LoaderReusableStyleSheets
;
111 using SheetLoadDataHolder
= nsMainThreadPtrHolder
<SheetLoadData
>;
112 enum SheetParsingMode
: uint8_t;
116 enum class IterationCompositeOperation
: uint8_t;
117 enum class CallerType
: uint32_t;
129 // Replacement for a Rust Box<T> for a non-dynamically-sized-type.
131 // TODO(emilio): If this was some sort of nullable box then this could be made
132 // to work with moves, and also reduce memory layout size of stuff, potentially.
133 template <typename T
>
135 explicit StyleBox(UniquePtr
<T
> aPtr
) : mRaw(aPtr
.release()) {
136 MOZ_DIAGNOSTIC_ASSERT(mRaw
);
140 MOZ_DIAGNOSTIC_ASSERT(mRaw
);
144 StyleBox(const StyleBox
& aOther
) : StyleBox(MakeUnique
<T
>(*aOther
)) {}
146 StyleBox
& operator=(const StyleBox
& aOther
) const {
148 mRaw
= MakeUnique
<T
>(*aOther
).release();
152 const T
* operator->() const {
153 MOZ_DIAGNOSTIC_ASSERT(mRaw
);
157 const T
& operator*() const {
158 MOZ_DIAGNOSTIC_ASSERT(mRaw
);
163 MOZ_DIAGNOSTIC_ASSERT(mRaw
);
168 MOZ_DIAGNOSTIC_ASSERT(mRaw
);
172 bool operator==(const StyleBox
& aOther
) const { return *(*this) == *aOther
; }
174 bool operator!=(const StyleBox
& aOther
) const { return *(*this) != *aOther
; }
180 // Work-around weird cbindgen renaming / avoiding moving stuff outside its
183 using StyleImageTracker
= dom::ImageTracker
;
184 using StyleLoader
= css::Loader
;
185 using StyleLoaderReusableStyleSheets
= css::LoaderReusableStyleSheets
;
186 using StyleCallerType
= dom::CallerType
;
187 using StyleSheetParsingMode
= css::SheetParsingMode
;
188 using StyleSheetLoadData
= css::SheetLoadData
;
189 using StyleSheetLoadDataHolder
= css::SheetLoadDataHolder
;
190 using StyleGeckoMallocSizeOf
= MallocSizeOf
;
191 using StyleDomStyleSheet
= StyleSheet
;
193 using StyleRawGeckoNode
= nsINode
;
194 using StyleRawGeckoElement
= dom::Element
;
195 using StyleDocument
= dom::Document
;
196 using StyleComputedValues
= ComputedStyle
;
197 using StyleIterationCompositeOperation
= dom::IterationCompositeOperation
;
199 using StyleMatrixTransformOperator
=
200 nsStyleTransformMatrix::MatrixTransformOperator
;
202 # define SERVO_ARC_TYPE(name_, type_) using Style##type_ = type_;
203 # include "mozilla/ServoArcTypeList.h"
204 # undef SERVO_ARC_TYPE
206 # define SERVO_BOXED_TYPE(name_, type_) using Style##type_ = type_;
207 # include "mozilla/ServoBoxedTypeList.h"
208 # undef SERVO_BOXED_TYPE
210 using StyleAtomicUsize
= std::atomic
<size_t>;
212 } // namespace mozilla
214 # ifndef HAVE_64BIT_BUILD
215 static_assert(sizeof(void*) == 4, "");
216 # define SERVO_32_BITS 1
218 # define CBINDGEN_IS_GECKO