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