1header = """/* 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/. */
4
5// See the comment in ServoBindings.h about the same.
6#pragma GCC diagnostic push
7#ifdef __clang__
8#  pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"
9#endif
10// Work-around silly windows.h define.
11#pragma push_macro("STRICT")
12#undef STRICT
13"""
14trailer = """
15#pragma pop_macro("STRICT")
16#pragma GCC diagnostic pop
17#include "mozilla/ServoStyleConstsInlines.h"
18"""
19autogen_warning = """/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.
20 * To generate this file:
21 *   1. Get the latest cbindgen using `cargo install --force cbindgen`
22 *      a. Alternatively, you can clone `https://github.com/eqrion/cbindgen` and use a tagged release
23 *   2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate style -o layout/style/ServoStyleConsts.h`
24 */
25"""
26include_guard = "mozilla_ServoStyleConsts_h"
27include_version = true
28braces = "SameLine"
29line_length = 80
30tab_width = 2
31language = "C++"
32namespaces = ["mozilla"]
33includes = ["mozilla/ServoStyleConstsForwards.h", "mozilla/ServoStyleSet.h"]
34
35[parse]
36parse_deps = true
37extra_bindings = ["style"]
38include = ["style", "cssparser", "style_traits", "servo_arc"]
39
40[struct]
41associated_constants_in_body = true
42derive_eq = true
43derive_neq = true
44
45[defines]
46# These will actually never be defined, but is handy to avoid cbindgen
47# generating Servo-only types.
48"feature = servo" = "CBINDGEN_IS_SERVO"
49"feature = servo-layout-2013" = "CBINDGEN_IS_SERVO"
50"feature = servo-layout-2020" = "CBINDGEN_IS_SERVO"
51# These will always be defined.
52"feature = gecko" = "CBINDGEN_IS_GECKO"
53"feature = cbindgen" = "CBINDGEN_IS_GECKO"
54# These depend on the build.
55"target_pointer_width = 32" = "SERVO_32_BITS"
56"target_pointer_width = 64" = "HAVE_64BIT_BUILD"
57
58[macro_expansion]
59bitflags = true
60
61[enum]
62derive_helper_methods = true
63derive_const_casts = true
64derive_tagged_enum_destructor = true
65derive_tagged_enum_copy_constructor = true
66derive_tagged_enum_copy_assignment = true
67private_default_tagged_enum_constructor = true
68cast_assert_name = "MOZ_DIAGNOSTIC_ASSERT"
69
70[export]
71prefix = "Style"
72exclude = [
73  "NS_LogCtor",
74  "NS_LogDtor",
75]
76include = [
77  "Appearance",
78  "BreakBetween",
79  "BreakWithin",
80  "BorderStyle",
81  "OutlineStyle",
82  "CaptionSide",
83  "FontSizeAdjust",
84  "ComputedFontStretchRange",
85  "ComputedFontStyleDescriptor",
86  "ComputedFontWeightRange",
87  "ComputedTimingFunction",
88  "ComputedValueFlags",
89  "CursorKind",
90  "DisplayOutside",
91  "DisplayInside",
92  "DisplayMode",
93  "PrefersColorScheme",
94  "PrefersContrast",
95  "FillRule",
96  "FontDisplay",
97  "FontFaceSourceListComponent",
98  "FontLanguageOverride",
99  "GenericFontFamily",
100  "FontFamily",
101  "FontFamilyNameSyntax",
102  "OverflowWrap",
103  "TimingFunction",
104  "OffsetPath",
105  "OffsetRotate",
106  "UnicodeRange",
107  "UserSelect",
108  "Float",
109  "OverscrollBehavior",
110  "ScrollSnapAlign",
111  "ScrollSnapAxis",
112  "ScrollSnapStrictness",
113  "ScrollSnapType",
114  "OverflowAnchor",
115  "OverflowClipBox",
116  "Resize",
117  "Overflow",
118  "LengthPercentage",
119  "LetterSpacing",
120  "NonNegativeLengthPercentage",
121  "LengthPercentageOrAuto",
122  "LineHeight",
123  "NonNegativeLengthPercentageOrAuto",
124  "NonNegativeLengthPercentageOrNormal",
125  "LengthOrAuto",
126  "NonNegativeLengthOrAuto",
127  "TextDecorationSkipInk",
128  "TextDecorationLength",
129  "Rect",
130  "IntersectionObserverRootMargin",
131  "Size",
132  "MaxSize",
133  "FlexBasis",
134  "Position",
135  "PositionOrAuto",
136  "BackgroundSize",
137  "BorderImageSlice",
138  "BorderSpacing",
139  "BorderRadius",
140  "NonNegativeLengthOrNumberRect",
141  "Perspective",
142  "ZIndex",
143  "TransformOrigin",
144  "LineBreak",
145  "WordBreak",
146  "Contain",
147  "Origin",
148  "RestyleHint",
149  "TouchAction",
150  "WillChange",
151  "TextDecorationLine",
152  "TextUnderlinePosition",
153  "TextTransform",
154  "TextJustify",
155  "TextOverflow",
156  "MozControlCharacterVisibility",
157  "RubyPosition",
158  "MozListReversed",
159  "Owned",
160  "OwnedOrNull",
161  "Strong",
162  "ScrollbarColor",
163  "CaretColor",
164  "Color",
165  "ColorOrAuto",
166  "SystemColor",
167  "SystemColorScheme",
168  "SystemFont",
169  "GradientItem",
170  "VerticalAlign",
171  "BasicShape",
172  "ShapeRadius",
173  "ArcSlice",
174  "ForgottenArcSlicePtr",
175  "HeaderWithLength",
176  "MozContextProperties",
177  "Quotes",
178  "BoxShadow",
179  "SimpleShadow",
180  "Transform",
181  "Rotate",
182  "Scale",
183  "Translate",
184  "BorderImageWidth",
185  "ComputedUrl",
186  "ComputedImageUrl",
187  "UrlOrNone",
188  "Filter",
189  "Gradient",
190  "GridTemplateAreas",
191  "GridLine",
192  "TrackSize",
193  "TrackBreadth",
194  "ImplicitGridTracks",
195  "SVGPaint",
196  "SVGPaintKind",
197  "GridTemplateComponent",
198  "TextEmphasisStyle",
199  "VariantAlternatesList",
200  "PaintOrder",
201  "SVGPaintOrder",
202  "ClipRectOrAuto",
203  "CounterSetOrReset",
204  "CounterIncrement",
205  "WritingMode",
206  "Content",
207  "ContentItem",
208  "AlignSelf",
209  "JustifySelf",
210  "AlignItems",
211  "ComputedJustifyItems",
212  "AlignContent",
213  "JustifyContent",
214  "AlignTracks",
215  "JustifyTracks",
216  "TransformStyle",
217  "Image",
218  "ClipPath",
219  "ShapeOutside",
220  "GridAutoFlow",
221  "Cursor",
222  "SVGStrokeDashArray",
223  "SVGLength",
224  "SVGOpacity",
225  "SVGWidth",
226  "TextAlign",
227  "TextAlignLast",
228  "FontSizeKeyword",
229  "AspectRatio",
230  "DefaultFontSizes",
231  "RuleChangeKind",
232  "PageSize",
233  "DProperty",
234]
235item_types = ["enums", "structs", "unions", "typedefs", "functions", "constants"]
236renaming_overrides_prefixing = true
237
238# Prevent some renaming for Gecko types that cbindgen doesn't otherwise understand.
239[export.rename]
240"nscolor" = "nscolor"
241"nsAtom" = "nsAtom"
242"nsIURI" = "nsIURI"
243"imgRequestProxy" = "imgRequestProxy"
244"nsCompatibility" = "nsCompatibility"
245"nsSimpleContentList" = "nsSimpleContentList"
246"nsACString" = "nsACString"
247"nsAString" = "nsAString"
248"nsString" = "nsString"
249"CopyableTArray" = "CopyableTArray"
250"nsTArray" = "nsTArray"
251"nsPresContext" = "nsPresContext"
252"ComputedTiming" = "ComputedTiming"
253"CountedUnknownProperty" = "CountedUnknownProperty"
254"RefPtr" = "RefPtr"
255"nsCSSPropertyID" = "nsCSSPropertyID"
256"nsCSSPropertyIDSet" = "nsCSSPropertyIDSet"
257"nsCSSValueSharedList" = "nsCSSValueSharedList"
258"AnimationPropertySegment" = "AnimationPropertySegment"
259"RawServoAnimationValueMap" = "RawServoAnimationValueMap"
260"RawServoAnimationValueTable" = "RawServoAnimationValueTable"
261"nsCSSUnit" = "nsCSSUnit"
262"ParsingMode" = "ParsingMode"
263"InheritTarget" = "InheritTarget"
264"PseudoStyleType" = "PseudoStyleType"
265"DeclarationBlockMutationClosure" = "DeclarationBlockMutationClosure"
266"AtomArray" = "AtomArray"
267"UpdateAnimationsTasks" = "UpdateAnimationsTasks"
268"StyleRuleInclusion" = "StyleRuleInclusion"
269"nsFontFaceRuleContainer" = "nsFontFaceRuleContainer"
270"MediumFeaturesChangedResult" = "MediumFeaturesChangedResult"
271"FontSizePrefs" = "FontSizePrefs"
272"nsCSSFontDesc" = "nsCSSFontDesc"
273"nsresult" = "nsresult"
274"gfxFontFeature" = "gfxFontFeature"
275"gfxFontFeatureValueSet" = "gfxFontFeatureValueSet"
276"SeenPtrs" = "SeenPtrs"
277"gfxFontVariation" = "gfxFontVariation"
278"URLExtraData" = "URLExtraData"
279"Keyframe" = "Keyframe"
280"nsChangeHint" = "nsChangeHint"
281"ServoElementSnapshotTable" = "ServoElementSnapshotTable"
282"nsTimingFunction" = "nsTimingFunction"
283"Keyframe" = "Keyframe"
284"ComputedKeyframeValues" = "ComputedKeyframeValues"
285"OriginFlags" = "OriginFlags"
286"ServoTraversalFlags" = "ServoTraversalFlags"
287"ServoStyleSetSizes" = "ServoStyleSetSizes"
288
289[export.body]
290"CSSPixelLength" = """
291  static StyleCSSPixelLength FromPixels(CSSCoord aCoord) { return {aCoord}; }
292  static StyleCSSPixelLength Zero() { return FromPixels(0.0f); }
293
294  inline nscoord ToAppUnits() const;
295  inline bool IsZero() const;
296  CSSCoord ToCSSPixels() const { return _0; }
297  inline void ScaleBy(float);
298  inline StyleCSSPixelLength ScaledBy(float) const;
299"""
300
301"GenericCalcNode" = """
302 private:
303
304  template <typename ResultT, typename PercentageConverter>
305  ResultT ResolveInternal(ResultT aPercentageBasis,
306                          PercentageConverter aPercentageConverter) const;
307
308 public:
309  CSSCoord ResolveToCSSPixels(CSSCoord aPercentageBasis) const;
310
311  using CoordPercentageRounder = nscoord(*)(float);
312  nscoord Resolve(nscoord aBasis, CoordPercentageRounder) const;
313
314  void ScaleLengthsBy(float);
315"""
316
317"LengthPercentageUnion" = """
318  using Self = StyleLengthPercentageUnion;
319
320  // TODO(emilio): cbindgen should be able to generate these in the body of the
321  // union, but it seems it's only implemented for structs, not unions.
322  static const uint8_t TAG_CALC = StyleLengthPercentageUnion_TAG_CALC;
323  static const uint8_t TAG_LENGTH = StyleLengthPercentageUnion_TAG_LENGTH;
324  static const uint8_t TAG_PERCENTAGE = StyleLengthPercentageUnion_TAG_PERCENTAGE;
325  static const uint8_t TAG_MASK = StyleLengthPercentageUnion_TAG_MASK;
326
327 private:
328  uint8_t Tag() const {
329    return tag.tag & TAG_MASK;
330  }
331
332 public:
333  // We need to do all this manually because cbingen can't reason about unions.
334  inline StyleLengthPercentageUnion();
335  inline StyleLengthPercentageUnion(const Self&);
336  inline ~StyleLengthPercentageUnion();
337  inline Self& operator=(const Self&);
338
339  inline bool operator==(const Self& aOther) const;
340  inline bool operator!=(const Self& aOther) const;
341
342  inline bool IsLength() const;
343  inline bool IsPercentage() const;
344  inline bool IsCalc() const;
345
346  inline const StyleLength& AsLength() const;
347  inline StyleLength& AsLength();
348
349  inline const StylePercentage& AsPercentage() const;
350  inline StylePercentage& AsPercentage();
351
352  inline const StyleCalcLengthPercentage& AsCalc() const;
353  inline StyleCalcLengthPercentage& AsCalc();
354
355  static inline Self Zero();
356  static inline Self FromAppUnits(nscoord);
357  static inline Self FromPixels(CSSCoord);
358  static inline Self FromPercentage(float);
359
360  inline void ScaleLengthsBy(float);
361  inline bool HasPercent() const;
362  inline bool ConvertsToLength() const;
363  inline nscoord ToLength() const;
364  inline CSSCoord ToLengthInCSSPixels() const;
365  inline bool ConvertsToPercentage() const;
366  inline bool HasLengthAndPercentage() const;
367  inline float ToPercentage() const;
368  inline bool IsDefinitelyZero() const;
369  inline CSSCoord ResolveToCSSPixels(CSSCoord aPercentageBasisInCSSPixels) const;
370  template<typename T> inline CSSCoord ResolveToCSSPixelsWith(T aPercentageGetter) const;
371  template<typename T, typename U>
372  inline nscoord Resolve(T aPercentageGetter, U aPercentRoundingFunction) const;
373  template<typename T>
374  inline nscoord Resolve(nscoord aPercentageBasis, T aPercentRoundingFunction) const;
375  template<typename T> inline nscoord Resolve(T aPercentageGetter) const;
376  inline nscoord Resolve(nscoord aPercentageBasis) const;
377"""
378
379"GenericLengthPercentageOrAuto" = """
380  inline bool ConvertsToLength() const;
381  inline nscoord ToLength() const;
382  inline bool ConvertsToPercentage() const;
383  inline float ToPercentage() const;
384  inline bool HasPercent() const;
385  inline bool HasLengthAndPercentage() const;
386
387  // Just some convenient aliases for LengthOrAuto, to avoid confusing naming.
388  inline bool IsLength() const;
389  inline const StyleLength& AsLength() const;
390"""
391
392"GenericSize" = """
393  inline bool ConvertsToLength() const;
394  inline nscoord ToLength() const;
395  inline bool ConvertsToPercentage() const;
396  inline float ToPercentage() const;
397  inline bool HasPercent() const;
398  inline bool HasLengthAndPercentage() const;
399  inline bool BehavesLikeInitialValueOnBlockAxis() const;
400"""
401
402"GenericFlexBasis" = """
403  inline bool IsAuto() const;
404"""
405
406"GenericMaxSize" = """
407  inline bool ConvertsToLength() const;
408  inline nscoord ToLength() const;
409  inline bool ConvertsToPercentage() const;
410  inline float ToPercentage() const;
411  inline bool HasPercent() const;
412  inline bool HasLengthAndPercentage() const;
413  inline bool BehavesLikeInitialValueOnBlockAxis() const;
414"""
415
416"GenericPosition" = """
417  inline bool HasPercent() const;
418  inline bool DependsOnPositioningAreaSize() const;
419  static inline StyleGenericPosition FromPercentage(float);
420"""
421
422"GenericBackgroundSize" = """
423  bool IsInitialValue() const;
424"""
425
426"Rect" = """
427  template<typename Predicate> inline bool All(Predicate) const;
428  template<typename Predicate> inline bool Any(Predicate) const;
429
430  // Defined in WritingModes.h
431  inline const T& Get(mozilla::Side) const;
432  inline const T& Get(WritingMode, LogicalSide) const;
433  inline const T& GetIStart(WritingMode) const;
434  inline const T& GetBStart(WritingMode) const;
435  inline const T& Start(LogicalAxis, WritingMode) const;
436  inline const T& GetIEnd(WritingMode) const;
437  inline const T& GetBEnd(WritingMode) const;
438  inline const T& End(LogicalAxis, WritingMode) const;
439
440  inline T& Get(mozilla::Side);
441  inline T& Get(WritingMode, LogicalSide);
442  inline T& GetIStart(WritingMode);
443  inline T& GetBStart(WritingMode);
444  inline T& GetIEnd(WritingMode);
445  inline T& GetBEnd(WritingMode);
446"""
447
448"GenericBorderRadius" = """
449  inline const StyleLengthPercentage& Get(HalfCorner) const;
450"""
451
452"RestyleHint" = """
453  static inline StyleRestyleHint RestyleSubtree();
454  static inline StyleRestyleHint RecascadeSubtree();
455  static inline StyleRestyleHint ForAnimations();
456  // Returns true if this change hint is guaranteed to at least recascade all
457  // elements in the subtree of the element it is applied to.
458  inline bool DefinitelyRecascadesAllSubtree() const;
459"""
460
461"TextTransform" = """
462  static inline StyleTextTransform None();
463  inline bool IsNone() const;
464"""
465
466"TextUnderlinePosition" = """
467  inline bool IsAuto() const;
468  inline bool IsFromFont() const;
469  inline bool IsUnder() const;
470  inline bool IsLeft() const;
471  inline bool IsRight() const;
472"""
473
474# TODO(emilio): Add hooks to cbindgen to be able to generate MOZ_MUST_USE_TYPE
475# or [[nodiscard]] on the functions.
476"Owned" = """
477  UniquePtr<GeckoType> Consume() {
478    UniquePtr<GeckoType> ret(ptr);
479    ptr = nullptr;
480    return ret;
481  }
482"""
483
484"OwnedOrNull" = """
485  UniquePtr<GeckoType> Consume() {
486    UniquePtr<GeckoType> ret(ptr);
487    ptr = nullptr;
488    return ret;
489  }
490"""
491
492"Strong" = """
493  already_AddRefed<GeckoType> Consume() {
494    already_AddRefed<GeckoType> ret(const_cast<GeckoType*>(ptr));
495    ptr = nullptr;
496    return ret;
497  }
498"""
499
500"GenericColor" = """
501  static inline StyleGenericColor CurrentColor();
502  static inline StyleGenericColor FromColor(nscolor);
503  static inline StyleGenericColor Black();
504  static inline StyleGenericColor White();
505  static inline StyleGenericColor Transparent();
506  bool MaybeTransparent() const;
507  /**
508   * Compute the final color, taking into account the foreground color from the
509   * frame's ComputedStyle.
510   */
511  nscolor CalcColor(const nsIFrame*) const;
512  /**
513   * Compute the final color, taking into account the foreground color from the
514   * style.
515   */
516  nscolor CalcColor(const ComputedStyle&) const;
517  /**
518   * Compute the final color, making the argument the foreground color.
519   */
520  nscolor CalcColor(nscolor) const;
521  nscolor CalcColor(const StyleRGBA&) const;
522"""
523
524"RGBA" = """
525  static inline StyleRGBA Transparent();
526  static inline StyleRGBA FromColor(nscolor);
527
528  inline nscolor ToColor() const;
529"""
530
531"OwnedSlice" = """
532  StyleOwnedSlice() :
533    ptr((T*)alignof(T)),
534    len(0) {}
535
536  inline void Clear();
537  inline void CopyFrom(const StyleOwnedSlice&);
538  inline void SwapElements(StyleOwnedSlice&);
539
540  StyleOwnedSlice& operator=(const StyleOwnedSlice&);
541  StyleOwnedSlice& operator=(StyleOwnedSlice&&);
542
543  inline StyleOwnedSlice(const StyleOwnedSlice&);
544  inline StyleOwnedSlice(StyleOwnedSlice&&);
545  inline explicit StyleOwnedSlice(Vector<T>&&);
546
547  inline ~StyleOwnedSlice();
548
549  Span<const T> AsSpan() const {
550    return {ptr, len};
551  }
552
553  size_t Length() const {
554    return len;
555  }
556
557  bool IsEmpty() const { return Length() == 0; }
558
559  bool operator==(const StyleOwnedSlice& other) const {
560    return AsSpan() == other.AsSpan();
561  }
562
563  bool operator!=(const StyleOwnedSlice& other) const {
564    return !(*this == other);
565  }
566"""
567
568"ArcInner" = """
569  // Increase the reference count.
570  inline void IncrementRef();
571  // Release the reference count, and return whether the result must be freed or not.
572  [[nodiscard]] inline bool DecrementRef();
573"""
574
575"ArcSlice" = """
576  inline StyleArcSlice();
577  inline StyleArcSlice(const StyleArcSlice& aOther);
578
579  inline StyleArcSlice& operator=(const StyleArcSlice&);
580  inline StyleArcSlice& operator=(StyleArcSlice&&);
581
582  inline explicit StyleArcSlice(const StyleForgottenArcSlicePtr<T>& aPtr);
583 private:
584  inline void Release();
585 public:
586  inline ~StyleArcSlice();
587  inline Span<const T> AsSpan() const;
588  inline size_t Length() const;
589  inline bool IsEmpty() const;
590  inline bool operator==(const StyleArcSlice& other) const;
591  inline bool operator!=(const StyleArcSlice& other) const;
592"""
593
594"Arc" = """
595  StyleArc() = delete;
596  inline StyleArc(const StyleArc& Other);
597 private:
598  inline void Release();
599 public:
600  inline ~StyleArc();
601
602  inline StyleArc& operator=(const StyleArc&);
603  inline StyleArc& operator=(StyleArc&&);
604
605  const T* operator->() const {
606    MOZ_DIAGNOSTIC_ASSERT(p, "Arc shouldn't be null");
607    return &p->data;
608  }
609  const T& operator*() const {
610    MOZ_DIAGNOSTIC_ASSERT(p, "Arc shouldn't be null");
611    return p->data;
612  }
613  bool operator==(const StyleArc& other) const {
614    return p == other.p || *(*this) == *other;
615  }
616  bool operator!=(const StyleArc& other) const {
617    return !(*this == other);
618  }
619"""
620
621"CustomIdent" = """
622  inline nsAtom* AsAtom() const;
623"""
624
625"Atom" = """
626  StyleAtom(size_t) = delete;
627  StyleAtom() = delete;
628
629  inline bool IsStatic() const;
630  inline nsAtom* AsAtom() const;
631
632 private:
633  inline void AddRef();
634  inline void Release();
635
636 public:
637  inline explicit StyleAtom(already_AddRefed<nsAtom> aAtom);
638  inline StyleAtom(const StyleAtom& aOther);
639  inline StyleAtom& operator=(const StyleAtom&);
640  inline ~StyleAtom();
641"""
642
643"OwnedStr" = """
644  inline nsDependentCSubstring AsString() const;
645"""
646
647"GenericTransformOrigin" = """
648  inline bool HasPercent() const;
649"""
650
651"GenericTransform" = """
652  inline Span<const T> Operations() const;
653  inline bool IsNone() const;
654  bool HasPercent() const;
655"""
656
657"Angle" = """
658  inline static StyleAngle Zero();
659  inline float ToDegrees() const;
660  inline double ToRadians() const;
661  StyleAngle operator+(const StyleAngle& aAngle) const {
662    return StyleAngle{_0 + aAngle._0};
663  }
664  StyleAngle operator-(const StyleAngle& aAngle) const {
665    return StyleAngle{_0 - aAngle._0};
666  }
667"""
668
669"CoordPair" = """
670  explicit StyleCoordPair(const gfx::Point& aPoint): _0(aPoint.x), _1(aPoint.y) {}
671"""
672
673"TextOverflow" = """
674  StyleTextOverflow()
675    : first(StyleTextOverflowSide::Clip()),
676      second(StyleTextOverflowSide::Clip()),
677      sides_are_logical(true) {}
678"""
679
680"UrlExtraData" = """
681  StyleUrlExtraData() = delete;
682
683  // Could be implemented if wanted.
684  StyleUrlExtraData(const StyleUrlExtraData&) = delete;
685  StyleUrlExtraData& operator=(const StyleUrlExtraData&) = delete;
686
687  inline bool IsShared() const;
688
689  inline ~StyleUrlExtraData();
690  inline const URLExtraData& get() const;
691"""
692
693"CssUrlData" = """
694  // Implemented in nsStyleStruct.cpp
695  bool operator==(const StyleCssUrlData& other) const;
696  bool operator!=(const StyleCssUrlData& other) const {
697    return !(*this == other);
698  }
699"""
700
701"LoadData" = """
702  ~StyleLoadData();
703"""
704
705"CssUrl" = """
706  inline nsDependentCSubstring SpecifiedSerialization() const;
707  inline const URLExtraData& ExtraData() const;
708  inline StyleLoadData& LoadData() const;
709  inline nsIURI* GetURI() const;
710"""
711
712"ComputedUrl" = """
713  // Forwarded from CssUrl.
714  inline nsDependentCSubstring SpecifiedSerialization() const;
715  inline const URLExtraData& ExtraData() const;
716  inline nsIURI* GetURI() const;
717  inline StyleLoadData& LoadData() const;
718
719  inline bool IsLocalRef() const;
720  inline bool HasRef() const;
721  inline StyleCorsMode CorsMode() const;
722  already_AddRefed<nsIURI> ResolveLocalRef(nsIURI* aBase) const;
723  already_AddRefed<nsIURI> ResolveLocalRef(const nsIContent* aContent) const;
724
725  // Only relevant for images.
726  inline bool IsImageResolved() const;
727  inline imgRequestProxy* GetImage() const;
728  void ResolveImage(dom::Document&, const StyleComputedUrl* aOldImage);
729"""
730
731"GenericGradient" = """
732  inline bool Repeating() const;
733  bool IsOpaque() const;
734"""
735
736"GenericGridLine" = """
737  // Returns the `auto` value.
738  inline StyleGenericGridLine();
739  inline bool IsAuto() const;
740  // The line name, or nsGkAtoms::_empty if not present.
741  inline nsAtom* LineName() const;
742"""
743
744"GenericTrackBreadth" = """
745  inline bool HasPercent() const;
746"""
747
748"GenericTrackSize" = """
749  // Implemented in nsGridContainerFrame.cpp
750  inline const StyleGenericTrackBreadth<L>& GetMin() const;
751  inline const StyleGenericTrackBreadth<L>& GetMax() const;
752"""
753
754"GenericGridTemplateComponent" = """
755  inline Maybe<size_t> RepeatAutoIndex() const;
756  inline const StyleGenericTrackRepeat<L, I>* GetRepeatAutoValue() const;
757  inline bool HasRepeatAuto() const;
758  inline Span<const StyleOwnedSlice<StyleCustomIdent>> LineNameLists(bool aIsSubgrid) const;
759  inline Span<const StyleGenericTrackListValue<L, I>> TrackListValues() const;
760"""
761
762"GenericClipRect" = """
763  // Get the layout rect, replacing auto right / bottom values for aAutoSize.
764  inline nsRect ToLayoutRect(nscoord aAutoSize = NS_MAXSIZE) const;
765"""
766
767"GenericRotate" = """
768 public:
769  // The implementation of IPC LayersMessages needs this to be public.
770  StyleGenericRotate(): tag(Tag::None) {}
771"""
772
773"GenericScale" = """
774 public:
775  // The implementation of IPC LayersMessages needs this to be public.
776  StyleGenericScale(): tag(Tag::None) {}
777"""
778
779"GenericTranslate" = """
780 public:
781  // The implementation of IPC LayersMessages needs this to be public.
782  StyleGenericTranslate(): tag(Tag::None) {}
783"""
784
785"GenericOffsetPath" = """
786 public:
787  // The implementation of IPC LayersMessages needs this to be public.
788  StyleGenericOffsetPath(): tag(Tag::None) {}
789"""
790
791"GenericPositionOrAuto" = """
792 public:
793  // The implementation of IPC LayersMessages needs this to be public.
794  StyleGenericPositionOrAuto(): tag(Tag::Auto) {}
795"""
796
797"GenericImage" = """
798 public:
799  // Returns the intrinsic resolution of the image.
800  //
801  // The resolution is in dppx, and should be used to impact the intrinsic
802  // size of the image.
803  ImageResolution GetResolution() const;
804
805  // Returns the intrinsic size of the image, if there's one, accounting for
806  // resolution as needed.
807  Maybe<CSSIntSize> GetIntrinsicSize() const;
808
809  // If this is an image-set(), the final image we've selected, otherwise it
810  // returns *this.
811  const StyleGenericImage& FinalImage() const;
812
813  // Whether this image may have an image request associated with it.
814  bool IsImageRequestType() const;
815
816  // Gets the image request URL.
817  const StyleComputedImageUrl* GetImageRequestURLValue() const;
818
819  // Gets the image data of this image if it has any image request.
820  imgRequestProxy* GetImageRequest() const;
821
822  // Returns true if this image is fully loaded, and its size is calculated.
823  // Always returns true if there's no image request involved and this image
824  // is not `none`.
825  bool IsComplete() const;
826
827  // Returns true if this image has an available size and hasn't errored.
828  // Always returns true if there's no image request involved and this image
829  // is not `none`.
830  bool IsSizeAvailable() const;
831
832  // Returns true if the item is definitely opaque --- i.e., paints every
833  // pixel within its bounds opaquely, and the bounds contains at least a pixel.
834  bool IsOpaque() const;
835
836  struct ActualCropRect {
837    nsIntRect mRect; // in image pixels
838    bool mIsEntireImage;
839  };
840
841  Maybe<ActualCropRect> ComputeActualCropRect() const;
842
843  // Resolves the underlying image request if any.
844  void ResolveImage(dom::Document&, const StyleGenericImage* aOld);
845
846  // Returns whether this image has been resolved.
847  bool IsResolved() const;
848"""
849
850"Ratio" = """
851  inline AspectRatio ToLayoutRatio(UseBoxSizing aUseBoxSizing) const;
852"""
853
854"GenericAspectRatio" = """
855  bool HasRatio() const { return ratio.IsRatio(); }
856  bool HasFiniteRatio() const { return static_cast<bool>(ToLayoutRatio()); }
857  bool BehavesAsAuto() const { return auto_ || !HasFiniteRatio(); }
858  inline AspectRatio ToLayoutRatio() const;
859
860  static StyleGenericAspectRatio Auto() {
861    return {true, StylePreferredRatio<N>::None()};
862  }
863"""
864
865"FontFamilyList" = """
866  // Whether the `fallback` generic is already on the family list.
867  inline bool ContainsFallback() const;
868  static StyleFontFamilyList WithOneUnquotedFamily(const nsACString&);
869  // Constructs a font family list with a list of names.
870  static StyleFontFamilyList WithNames(nsTArray<StyleSingleFontFamily>&&);
871"""
872
873"SingleFontFamily" = """
874  static StyleSingleFontFamily Parse(const nsACString& aName);
875  void AppendToString(nsACString& aFamily, bool aIncludeQuotes = true) const;
876  bool IsNamedFamily(const nsAString&) const;
877"""
878