Bug 1890793: Assert CallArgs::newTarget is not gray. r=spidermonkey-reviewers,sfink...
[gecko.git] / layout / style / ServoStyleConstsForwards.h
blob5bf87d83301542b3ec4b8a4dbcf2ecf6f381a2df
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/. */
5 /*
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
8 * it needs.
9 */
11 #ifndef mozilla_ServoStyleConsts_h
12 # error "This file is only meant to be included from ServoStyleConsts.h"
13 #endif
15 #ifndef mozilla_ServoStyleConstsForwards_h
16 # define mozilla_ServoStyleConstsForwards_h
18 # include "nsColor.h"
19 # include "nsCoord.h"
20 # include "mozilla/AtomArray.h"
21 # include "mozilla/IntegerRange.h"
22 # include "mozilla/Span.h"
23 # include "Units.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"
32 # include "nsIURI.h"
33 # include "mozilla/image/Resolution.h"
34 # include <atomic>
36 struct RawServoAnimationValueTable;
38 class nsAtom;
39 class nsIFrame;
40 class nsINode;
41 class nsIContent;
42 class nsCSSPropertyIDSet;
43 class nsPresContext;
44 class nsSimpleContentList;
45 class imgRequestProxy;
46 struct nsCSSValueSharedList;
48 class gfxFontFeatureValueSet;
49 struct gfxFontFeature;
50 struct GeckoFontMetrics;
51 namespace mozilla {
52 namespace gfx {
53 struct FontVariation;
54 } // namespace gfx
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;
65 template <typename T>
66 class nsMainThreadPtrHolder;
68 namespace mozilla {
70 class ComputedStyle;
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;
80 struct Keyframe;
81 struct PropertyStyleAnimationValuePair;
83 using ComputedKeyframeValues = nsTArray<PropertyStyleAnimationValuePair>;
85 class ComputedStyle;
86 enum class LogicalAxis : uint8_t;
87 class SeenPtrs;
88 class SharedFontList;
89 class StyleSheet;
90 class WritingMode;
91 class ServoElementSnapshotTable;
93 template <typename T>
94 struct StyleForgottenArcSlicePtr;
96 struct AnimatedPropertyID;
97 struct AnimationPropertySegment;
98 struct AspectRatio;
99 struct ComputedTiming;
100 struct URLExtraData;
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;
108 namespace css {
109 class Loader;
110 class LoaderReusableStyleSheets;
111 class SheetLoadData;
112 using SheetLoadDataHolder = nsMainThreadPtrHolder<SheetLoadData>;
113 enum SheetParsingMode : uint8_t;
114 } // namespace css
116 namespace dom {
117 enum class IterationCompositeOperation : uint8_t;
118 enum class CallerType : uint32_t;
120 class Element;
121 class Document;
122 class ImageTracker;
124 } // namespace dom
126 namespace ipc {
127 class ByteBuf;
128 } // namespace ipc
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>
135 struct StyleBox {
136 explicit StyleBox(UniquePtr<T> aPtr) : mRaw(aPtr.release()) {
137 MOZ_DIAGNOSTIC_ASSERT(mRaw);
140 ~StyleBox() {
141 MOZ_DIAGNOSTIC_ASSERT(mRaw);
142 delete mRaw;
145 StyleBox(const StyleBox& aOther) : StyleBox(MakeUnique<T>(*aOther)) {}
147 StyleBox& operator=(const StyleBox& aOther) const {
148 delete mRaw;
149 mRaw = MakeUnique<T>(*aOther).release();
150 return *this;
153 const T* operator->() const {
154 MOZ_DIAGNOSTIC_ASSERT(mRaw);
155 return mRaw;
158 const T& operator*() const {
159 MOZ_DIAGNOSTIC_ASSERT(mRaw);
160 return *mRaw;
163 T* operator->() {
164 MOZ_DIAGNOSTIC_ASSERT(mRaw);
165 return mRaw;
168 T& operator*() {
169 MOZ_DIAGNOSTIC_ASSERT(mRaw);
170 return *mRaw;
173 bool operator==(const StyleBox& aOther) const { return *(*this) == *aOther; }
175 bool operator!=(const StyleBox& aOther) const { return *(*this) != *aOther; }
177 private:
178 T* mRaw;
181 // Work-around weird cbindgen renaming / avoiding moving stuff outside its
182 // namespace.
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
233 # endif
234 # define CBINDGEN_IS_GECKO
236 #endif