Bug 1698786: part 2) Change some compile-time dependent `printf`s to `MOZ_LOG` in...
[gecko.git] / layout / style / ServoStyleConstsForwards.h
blob58720ffb6baac3a8bfddd2178bb3ef3a708abd21
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 <atomic>
35 struct RawServoAnimationValueTable;
36 struct RawServoAnimationValueMap;
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;
47 struct nsTimingFunction;
49 class gfxFontFeatureValueSet;
50 struct gfxFontFeature;
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 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 AnimationPropertySegment;
97 struct AspectRatio;
98 struct ComputedTiming;
99 struct URLExtraData;
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;
107 namespace css {
108 class Loader;
109 class LoaderReusableStyleSheets;
110 class SheetLoadData;
111 using SheetLoadDataHolder = nsMainThreadPtrHolder<SheetLoadData>;
112 enum SheetParsingMode : uint8_t;
113 } // namespace css
115 namespace dom {
116 enum class IterationCompositeOperation : uint8_t;
117 enum class CallerType : uint32_t;
119 class Element;
120 class Document;
121 class ImageTracker;
123 } // namespace dom
125 namespace ipc {
126 class ByteBuf;
127 } // namespace ipc
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>
134 struct StyleBox {
135 explicit StyleBox(UniquePtr<T> aPtr) : mRaw(aPtr.release()) {
136 MOZ_DIAGNOSTIC_ASSERT(mRaw);
139 ~StyleBox() {
140 MOZ_DIAGNOSTIC_ASSERT(mRaw);
141 delete mRaw;
144 StyleBox(const StyleBox& aOther) : StyleBox(MakeUnique<T>(*aOther)) {}
146 StyleBox& operator=(const StyleBox& aOther) const {
147 delete mRaw;
148 mRaw = MakeUnique<T>(*aOther).release();
149 return *this;
152 const T* operator->() const {
153 MOZ_DIAGNOSTIC_ASSERT(mRaw);
154 return mRaw;
157 const T& operator*() const {
158 MOZ_DIAGNOSTIC_ASSERT(mRaw);
159 return *mRaw;
162 T* operator->() {
163 MOZ_DIAGNOSTIC_ASSERT(mRaw);
164 return mRaw;
167 T& operator*() {
168 MOZ_DIAGNOSTIC_ASSERT(mRaw);
169 return *mRaw;
172 bool operator==(const StyleBox& aOther) const { return *(*this) == *aOther; }
174 bool operator!=(const StyleBox& aOther) const { return *(*this) != *aOther; }
176 private:
177 T* mRaw;
180 // Work-around weird cbindgen renaming / avoiding moving stuff outside its
181 // namespace.
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
217 # endif
218 # define CBINDGEN_IS_GECKO
220 #endif