summaryrefslogtreecommitdiffstats
path: root/servo/ports/geckolib/cbindgen.toml
blob: d608840caecd89e95a5cc2135921e7d9306f4c16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
header = """/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */

// See the comment in ServoBindings.h about the same.
#pragma GCC diagnostic push
#ifdef __clang__
#  pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"
#endif
// Work-around silly windows.h define.
#pragma push_macro("STRICT")
#undef STRICT
#pragma push_macro("TRANSPARENT")
#undef TRANSPARENT
"""
trailer = """
#pragma pop_macro("STRICT")
#pragma pop_macro("TRANSPARENT")
#pragma GCC diagnostic pop
#include "mozilla/ServoStyleConstsInlines.h"
"""
autogen_warning = """/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.
 * To generate this file:
 *   1. Get the latest cbindgen using `cargo install --force cbindgen`
 *      a. Alternatively, you can clone `https://github.com/eqrion/cbindgen` and use a tagged release
 *   2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate style -o layout/style/ServoStyleConsts.h`
 */
"""
include_guard = "mozilla_ServoStyleConsts_h"
include_version = true
braces = "SameLine"
line_length = 80
tab_width = 2
language = "C++"
namespaces = ["mozilla"]
includes = ["mozilla/ServoStyleConstsForwards.h", "mozilla/ServoStyleSet.h"]

[parse]
parse_deps = true
extra_bindings = ["style"]
include = ["style", "app_units", "cssparser", "style_traits", "servo_arc"]

[struct]
associated_constants_in_body = true
derive_eq = true
derive_neq = true

[defines]
# These will actually never be defined, but is handy to avoid cbindgen
# generating Servo-only types.
"feature = servo" = "CBINDGEN_IS_SERVO"
"feature = servo-layout-2013" = "CBINDGEN_IS_SERVO"
"feature = servo-layout-2020" = "CBINDGEN_IS_SERVO"
"feature = track_alloc_size" = "CBINDGEN_IS_SERVO"
# These will always be defined.
"feature = gecko" = "CBINDGEN_IS_GECKO"
"feature = cbindgen" = "CBINDGEN_IS_GECKO"
# These depend on the build.
"target_pointer_width = 32" = "SERVO_32_BITS"
"target_pointer_width = 64" = "HAVE_64BIT_BUILD"
"unix" = "XP_UNIX"
"windows" = "XP_WIN"

[macro_expansion]
bitflags = true

[enum]
derive_helper_methods = true
derive_const_casts = true
derive_tagged_enum_destructor = true
derive_tagged_enum_copy_constructor = true
derive_tagged_enum_copy_assignment = true
private_default_tagged_enum_constructor = true
cast_assert_name = "MOZ_DIAGNOSTIC_ASSERT"

[export]
prefix = "Style"
exclude = [
  "NS_LogCtor",
  "NS_LogDtor",
  "SelectorList",
  "AuthorStyles",
]
include = [
  "AnimationTimeline",
  "AnimationIterationCount",
  "AnimationDirection",
  "AnimationFillMode",
  "AnimationPlayState",
  "AnimationComposition",
  "Appearance",
  "Au",
  "BreakBetween",
  "BreakWithin",
  "BorderStyle",
  "BoolInteger",
  "OutlineStyle",
  "CaptionSide",
  "FontSizeAdjust",
  "FontPalette",
  "ComputedFontStretchRange",
  "ComputedFontStyleDescriptor",
  "ComputedFontWeightRange",
  "ComputedTimingFunction",
  "ComputedValueFlags",
  "CursorKind",
  "Display",
  "DisplayOutside",
  "DisplayInside",
  "DisplayMode",
  "Platform",
  "GtkThemeFamily",
  "PrefersColorScheme",
  "PrefersContrast",
  "DynamicRange",
  "Scripting",
  "FillRule",
  "FontDisplay",
  "FontFaceSourceListComponent",
  "FontFaceSourceTechFlags",
  "FontLanguageOverride",
  "FontSynthesis",
  "GenericFontFamily",
  "FontFamily",
  "FontFamilyNameSyntax",
  "MozTheme",
  "OverflowWrap",
  "OffsetPath",
  "OffsetPathFunction",
  "OffsetPosition",
  "OffsetRotate",
  "RayFunction",
  "UnicodeRange",
  "UserSelect",
  "Float",
  "Clear",
  "OverscrollBehavior",
  "ScrollSnapAlign",
  "ScrollSnapAxis",
  "ScrollSnapStop",
  "ScrollSnapStrictness",
  "ScrollSnapType",
  "ScrollTimelineName",
  "TransitionBehavior",
  "ViewTimelineInset",
  "OverflowAnchor",
  "OverflowClipBox",
  "Resize",
  "Overflow",
  "LengthPercentage",
  "LetterSpacing",
  "NonNegativeLengthPercentage",
  "LengthPercentageOrAuto",
  "LineHeight",
  "NonNegativeLengthPercentageOrAuto",
  "NonNegativeLengthPercentageOrNormal",
  "LengthOrAuto",
  "NonNegativeLengthOrAuto",
  "TextDecorationSkipInk",
  "TextDecorationLength",
  "Time",
  "Rect",
  "IntersectionObserverRootMargin",
  "Size",
  "MaxSize",
  "FlexBasis",
  "Position",
  "PositionOrAuto",
  "BackgroundSize",
  "BaselineSource",
  "BorderImageSlice",
  "BorderSpacing",
  "BorderRadius",
  "ColorScheme",
  "NonNegativeLengthOrNumberRect",
  "Perspective",
  "ZIndex",
  "TransformBox",
  "TransformOrigin",
  "LineBreak",
  "LineClamp",
  "WordBreak",
  "Contain",
  "ContainerType",
  "ContainerName",
  "ContentVisibility",
  "ContainIntrinsicSize",
  "Origin",
  "RestyleHint",
  "TouchAction",
  "WillChange",
  "TextDecorationLine",
  "MasonryAutoFlow",
  "MasonryPlacement",
  "MasonryItemOrder",
  "TextUnderlinePosition",
  "TextTransform",
  "TextJustify",
  "TextOverflow",
  "TextIndent",
  "MozControlCharacterVisibility",
  "RubyPosition",
  "Owned",
  "OwnedOrNull",
  "Strong",
  "ScrollbarColor",
  "CaretColor",
  "Color",
  "ColorOrAuto",
  "SystemColor",
  "SystemColorScheme",
  "SystemFont",
  "GradientItem",
  "VerticalAlign",
  "BasicShape",
  "InsetRect",
  "ShapeRadius",
  "ShapeCommand",
  "ArcSlice",
  "ForgottenArcSlicePtr",
  "HeaderWithLength",
  "MozContextProperties",
  "Quotes",
  "BoxShadow",
  "SimpleShadow",
  "Transform",
  "Rotate",
  "Scale",
  "Translate",
  "BorderImageWidth",
  "ComputedUrl",
  "ComputedImageUrl",
  "UrlOrNone",
  "Filter",
  "Gradient",
  "GridTemplateAreas",
  "GridLine",
  "TrackSize",
  "TrackBreadth",
  "ImplicitGridTracks",
  "SVGPaint",
  "SVGPaintKind",
  "GridTemplateComponent",
  "TextEmphasisStyle",
  "TextEmphasisPosition",
  "FontVariantAlternates",
  "PaintOrder",
  "SVGPaintOrder",
  "ClipRectOrAuto",
  "CounterReset",
  "CounterSet",
  "CounterIncrement",
  "WritingMode",
  "Content",
  "ContentItem",
  "AlignSelf",
  "JustifySelf",
  "AlignItems",
  "ComputedJustifyItems",
  "AlignContent",
  "JustifyContent",
  "AlignTracks",
  "JustifyTracks",
  "TransformStyle",
  "Image",
  "ClipPath",
  "ShapeOutside",
  "GridAutoFlow",
  "Cursor",
  "SVGStrokeDashArray",
  "SVGLength",
  "SVGOpacity",
  "SVGWidth",
  "TextAlign",
  "TextAlignLast",
  "FontSizeKeyword",
  "AspectRatio",
  "DefaultFontSizes",
  "RuleChangeKind",
  "PageName",
  "PageOrientation",
  "PageSize",
  "DProperty",
  "ImageRendering",
  "PrintColorAdjust",
  "ForcedColorAdjust",
  "ScrollbarGutter",
  "ScrollDirection",
  "HyphenateCharacter",
  "ComputedLinearStop",
  "PiecewiseLinearFunction",
  "BeforeFlag",
  "XTextScale",
  "Zoom",
  "TransitionProperty",
]
item_types = ["enums", "structs", "unions", "typedefs", "functions", "constants"]
renaming_overrides_prefixing = true

# Prevent some renaming for Gecko types that cbindgen doesn't otherwise understand.
[export.rename]
"nscolor" = "nscolor"
"nsAtom" = "nsAtom"
"nsIURI" = "nsIURI"
"imgRequestProxy" = "imgRequestProxy"
"nsCompatibility" = "nsCompatibility"
"nsSimpleContentList" = "nsSimpleContentList"
"nsACString" = "nsACString"
"nsAString" = "nsAString"
"nsCString" = "nsCString"
"nsString" = "nsString"
"CopyableTArray" = "CopyableTArray"
"nsTArray" = "nsTArray"
"nsPresContext" = "nsPresContext"
"ComputedTiming" = "ComputedTiming"
"CountedUnknownProperty" = "CountedUnknownProperty"
"RefPtr" = "RefPtr"
"nsCSSPropertyID" = "nsCSSPropertyID"
"nsCSSPropertyIDSet" = "nsCSSPropertyIDSet"
"AnimatedPropertyID" = "AnimatedPropertyID"
"nsCSSValueSharedList" = "nsCSSValueSharedList"
"AnimationPropertySegment" = "AnimationPropertySegment"
"RawServoAnimationValueTable" = "RawServoAnimationValueTable"
"nsCSSUnit" = "nsCSSUnit"
"InheritTarget" = "InheritTarget"
"PseudoStyleType" = "PseudoStyleType"
"DeclarationBlockMutationClosure" = "DeclarationBlockMutationClosure"
"AtomArray" = "AtomArray"
"UpdateAnimationsTasks" = "UpdateAnimationsTasks"
"StyleRuleInclusion" = "StyleRuleInclusion"
"nsFontFaceRuleContainer" = "nsFontFaceRuleContainer"
"MediumFeaturesChangedResult" = "MediumFeaturesChangedResult"
"FontSizePrefs" = "FontSizePrefs"
"nsCSSFontDesc" = "nsCSSFontDesc"
"nsresult" = "nsresult"
"gfxFontFeature" = "gfxFontFeature"
"gfxFontFeatureValueSet" = "gfxFontFeatureValueSet"
"GeckoFontMetrics" = "GeckoFontMetrics"
"SeenPtrs" = "SeenPtrs"
"gfxFontVariation" = "gfxFontVariation"
"URLExtraData" = "URLExtraData"
"Keyframe" = "Keyframe"
"nsChangeHint" = "nsChangeHint"
"ServoElementSnapshotTable" = "ServoElementSnapshotTable"
"Keyframe" = "Keyframe"
"ComputedKeyframeValues" = "ComputedKeyframeValues"
"OriginFlags" = "OriginFlags"
"ServoTraversalFlags" = "ServoTraversalFlags"
"ServoStyleSetSizes" = "ServoStyleSetSizes"
"BeforeFlag" = "StyleEasingBeforeFlag"
"FontPaletteValueSet" = "gfx::FontPaletteValueSet"
"PaletteValues" = "gfx::FontPaletteValueSet::PaletteValues"
"ThinVec" = "CopyableTArray"
"RawPthread" = "pthread_t"
"RawHandle" = "void*"

[export.body]
"CSSPixelLength" = """
  static StyleCSSPixelLength FromPixels(CSSCoord aCoord) { return {aCoord}; }
  static StyleCSSPixelLength Zero() { return FromPixels(0.0f); }

  inline nscoord ToAppUnits() const;
  inline bool IsZero() const;
  CSSCoord ToCSSPixels() const { return _0; }
  inline void ScaleBy(float);
  inline StyleCSSPixelLength ScaledBy(float) const;
"""

"CalcLengthPercentage" = """
  inline CSSCoord ResolveToCSSPixels(CSSCoord aBasis) const;
  template<typename Rounder>
  inline nscoord Resolve(nscoord aBasis, Rounder) const;
"""

"GenericCalcNode" = """
  void ScaleLengthsBy(float);
"""

"LengthPercentageUnion" = """
  using Self = StyleLengthPercentageUnion;

  // TODO(emilio): cbindgen should be able to generate these in the body of the
  // union, but it seems it's only implemented for structs, not unions.
  static const uint8_t TAG_CALC = StyleLengthPercentageUnion_TAG_CALC;
  static const uint8_t TAG_LENGTH = StyleLengthPercentageUnion_TAG_LENGTH;
  static const uint8_t TAG_PERCENTAGE = StyleLengthPercentageUnion_TAG_PERCENTAGE;
  static const uint8_t TAG_MASK = StyleLengthPercentageUnion_TAG_MASK;

 private:
  uint8_t Tag() const {
    return tag.tag & TAG_MASK;
  }

 public:
  // We need to do all this manually because cbingen can't reason about unions.
  inline StyleLengthPercentageUnion();
  inline StyleLengthPercentageUnion(const Self&);
  inline ~StyleLengthPercentageUnion();
  inline Self& operator=(const Self&);

  inline bool operator==(const Self& aOther) const;
  inline bool operator!=(const Self& aOther) const;

  inline bool IsLength() const;
  inline bool IsPercentage() const;
  inline bool IsCalc() const;

  inline const StyleLength& AsLength() const;
  inline StyleLength& AsLength();

  inline const StylePercentage& AsPercentage() const;
  inline StylePercentage& AsPercentage();

  inline const StyleCalcLengthPercentage& AsCalc() const;
  inline StyleCalcLengthPercentage& AsCalc();

  static inline Self Zero();
  static inline Self FromAppUnits(nscoord);
  static inline Self FromPixels(CSSCoord);
  static inline Self FromPercentage(float);

  inline void ScaleLengthsBy(float);
  inline bool HasPercent() const;
  inline bool ConvertsToLength() const;
  inline nscoord ToLength() const;
  inline CSSCoord ToLengthInCSSPixels() const;
  inline bool ConvertsToPercentage() const;
  inline bool HasLengthAndPercentage() const;
  inline float ToPercentage() const;
  inline bool IsDefinitelyZero() const;
  inline CSSCoord ResolveToCSSPixels(CSSCoord aPercentageBasisInCSSPixels) const;
  template<typename T> inline CSSCoord ResolveToCSSPixelsWith(T aPercentageGetter) const;
  template<typename T, typename Rounder>
  inline nscoord Resolve(T aPercentageGetter, Rounder) const;
  template<typename Rounder>
  inline nscoord Resolve(nscoord aPercentageBasis, Rounder) const;
  template<typename T> inline nscoord Resolve(T aPercentageGetter) const;
  inline nscoord Resolve(nscoord aPercentageBasis) const;
"""

"GenericLengthPercentageOrAuto" = """
  inline bool ConvertsToLength() const;
  inline nscoord ToLength() const;
  inline bool ConvertsToPercentage() const;
  inline float ToPercentage() const;
  inline bool HasPercent() const;
  inline bool HasLengthAndPercentage() const;

  // Just some convenient aliases for LengthOrAuto, to avoid confusing naming.
  inline bool IsLength() const;
  inline const StyleLength& AsLength() const;

  static inline StyleGenericLengthPercentageOrAuto Zero();
"""

"GenericSize" = """
  inline bool ConvertsToLength() const;
  inline nscoord ToLength() const;
  inline bool ConvertsToPercentage() const;
  inline float ToPercentage() const;
  inline bool HasPercent() const;
  inline bool HasLengthAndPercentage() const;
  inline bool BehavesLikeInitialValueOnBlockAxis() const;
"""

"GenericFlexBasis" = """
  inline bool IsAuto() const;
"""

"GenericMaxSize" = """
  inline bool ConvertsToLength() const;
  inline nscoord ToLength() const;
  inline bool ConvertsToPercentage() const;
  inline float ToPercentage() const;
  inline bool HasPercent() const;
  inline bool HasLengthAndPercentage() const;
  inline bool BehavesLikeInitialValueOnBlockAxis() const;
"""

"GenericPosition" = """
  inline bool HasPercent() const;
  inline bool DependsOnPositioningAreaSize() const;
  static inline StyleGenericPosition FromPercentage(float);
"""

"GenericBackgroundSize" = """
  bool IsInitialValue() const;
"""

"Rect" = """
  template<typename Predicate> inline bool All(Predicate) const;
  template<typename Predicate> inline bool Any(Predicate) const;

  // Defined in WritingModes.h
  inline const T& Get(mozilla::Side) const;
  inline const T& Get(WritingMode, LogicalSide) const;
  inline const T& GetIStart(WritingMode) const;
  inline const T& GetBStart(WritingMode) const;
  inline const T& Start(LogicalAxis, WritingMode) const;
  inline const T& GetIEnd(WritingMode) const;
  inline const T& GetBEnd(WritingMode) const;
  inline const T& End(LogicalAxis, WritingMode) const;

  inline T& Get(mozilla::Side);
  inline T& Get(WritingMode, LogicalSide);
  inline T& GetIStart(WritingMode);
  inline T& GetBStart(WritingMode);
  inline T& GetIEnd(WritingMode);
  inline T& GetBEnd(WritingMode);

  static StyleRect WithAllSides(const T& aSide) {
    return {aSide, aSide, aSide, aSide};
  }
"""

"GenericBorderRadius" = """
  inline const StyleLengthPercentage& Get(HalfCorner) const;
"""

"RestyleHint" = """
  static inline StyleRestyleHint RestyleSubtree();
  static inline StyleRestyleHint RecascadeSubtree();
  static inline StyleRestyleHint ForAnimations();
  // Returns true if this change hint is guaranteed to at least recascade all
  // elements in the subtree of the element it is applied to.
  inline bool DefinitelyRecascadesAllSubtree() const;
"""

"TextTransform" = """
  static inline StyleTextTransform None();
  inline bool IsNone() const;
"""

"TextUnderlinePosition" = """
  inline bool IsAuto() const;
  inline bool IsFromFont() const;
  inline bool IsUnder() const;
  inline bool IsLeft() const;
  inline bool IsRight() const;
"""

# TODO(emilio): Add hooks to cbindgen to be able to generate [[nodiscard]]
# on the functions.
"Owned" = """
  UniquePtr<GeckoType> Consume() {
    UniquePtr<GeckoType> ret(ptr);
    ptr = nullptr;
    return ret;
  }
"""

"OwnedOrNull" = """
  UniquePtr<GeckoType> Consume() {
    UniquePtr<GeckoType> ret(ptr);
    ptr = nullptr;
    return ret;
  }
"""

"Strong" = """
  already_AddRefed<GeckoType> Consume() {
    already_AddRefed<GeckoType> ret(const_cast<GeckoType*>(ptr));
    ptr = nullptr;
    return ret;
  }
"""

"GenericColor" = """
  static inline StyleGenericColor FromColor(nscolor);

  static inline StyleGenericColor Transparent();
  static inline StyleGenericColor Black();
  static inline StyleGenericColor White();

  bool MaybeTransparent() const;

  /**
   * Compute the final color, taking into account the foreground color.
   **/
  StyleAbsoluteColor ResolveColor(const StyleAbsoluteColor&) const;

  /**
   * Compute the final color, taking into account the foreground color from the
   * frame's ComputedStyle.
   */
  nscolor CalcColor(const nsIFrame*) const;
  /**
   * Compute the final color, taking into account the foreground color from the
   * style.
   */
  nscolor CalcColor(const ComputedStyle&) const;
  /**
   * Compute the final color, making the argument the foreground color.
   */
  nscolor CalcColor(nscolor) const;
  nscolor CalcColor(const StyleAbsoluteColor&) const;
"""

"AbsoluteColor" = """
  /**
   * Create a new AbsoluteColor in the sRGB color space in legacy color syntax.
   */
  static inline StyleAbsoluteColor SrgbLegacy(float red, float green, float blue, float alpha);

  static inline StyleAbsoluteColor FromColor(nscolor);

  /**
   * Convert this color into the given color space.
   */
  StyleAbsoluteColor ToColorSpace(StyleColorSpace aColorSpace) const;

  /**
   * Convert this color to an nscolor. The color will be converted to sRGB first
   * if required.
   */
  nscolor ToColor() const;
"""

"OwnedSlice" = """
  constexpr StyleOwnedSlice() :
    ptr((T*)alignof(T)),
    len(0) {}

  inline void Clear();
  inline void CopyFrom(const StyleOwnedSlice&);
  inline void SwapElements(StyleOwnedSlice&);

  StyleOwnedSlice& operator=(const StyleOwnedSlice&);
  StyleOwnedSlice& operator=(StyleOwnedSlice&&);

  inline StyleOwnedSlice(const StyleOwnedSlice&);
  inline StyleOwnedSlice(StyleOwnedSlice&&);
  inline explicit StyleOwnedSlice(Vector<T>&&);

  inline ~StyleOwnedSlice();

  Span<const T> AsSpan() const {
    return {ptr, len};
  }

  size_t Length() const {
    return len;
  }

  bool IsEmpty() const { return Length() == 0; }

  bool operator==(const StyleOwnedSlice& other) const {
    return AsSpan() == other.AsSpan();
  }

  bool operator!=(const StyleOwnedSlice& other) const {
    return !(*this == other);
  }
"""

"ArcInner" = """
  // Increase the reference count.
  inline void IncrementRef();
  // Release the reference count, and return whether the result must be freed or not.
  [[nodiscard]] inline bool DecrementRef();
"""

"HeaderSlice" = """
  StyleHeaderSlice() = delete;
  StyleHeaderSlice(const StyleHeaderSlice&) = delete;

  inline ~StyleHeaderSlice();
  inline bool operator==(const StyleHeaderSlice& other) const;
  inline bool operator!=(const StyleHeaderSlice& other) const;

  inline Span<const T> AsSpan() const;
  inline size_t Length() const { return len; }
  inline bool IsEmpty() const { return len == 0; }
"""

"ArcSlice" = """
  inline StyleArcSlice();
  inline explicit StyleArcSlice(const StyleForgottenArcSlicePtr<T>& aPtr);
  inline Span<const T> AsSpan() const;
  inline size_t Length() const;
  inline bool IsEmpty() const;
"""

"Arc" = """
  StyleArc() = delete;
  inline StyleArc(const StyleArc& Other);
 private:
  inline void Release();
 public:
  explicit StyleArc(decltype(p) aP) : p(aP) {
    MOZ_DIAGNOSTIC_ASSERT(p, "Arc shouldn't be null");
  }
  inline ~StyleArc();

  inline StyleArc& operator=(const StyleArc&);
  inline StyleArc& operator=(StyleArc&&);

  const T* operator->() const {
    MOZ_DIAGNOSTIC_ASSERT(p, "Arc shouldn't be null");
    return &p->data;
  }
  const T& operator*() const {
    MOZ_DIAGNOSTIC_ASSERT(p, "Arc shouldn't be null");
    return p->data;
  }
  bool operator==(const StyleArc& other) const {
    return p == other.p || *(*this) == *other;
  }
  bool operator!=(const StyleArc& other) const {
    return !(*this == other);
  }
"""

"CustomIdent" = """
  inline nsAtom* AsAtom() const;
"""

"Atom" = """
  StyleAtom(size_t) = delete;
  StyleAtom() = delete;

  inline bool IsStatic() const;
  inline nsAtom* AsAtom() const;

 private:
  inline void AddRef();
  inline void Release();

 public:
  inline explicit StyleAtom(already_AddRefed<nsAtom>);
  inline explicit StyleAtom(nsStaticAtom*);
  inline StyleAtom(const StyleAtom& aOther);
  inline StyleAtom& operator=(const StyleAtom&);
  inline ~StyleAtom();
"""

"OwnedStr" = """
  inline nsDependentCSubstring AsString() const;
"""

"GenericTransformOrigin" = """
  inline bool HasPercent() const;
"""

"GenericTransform" = """
  inline Span<const T> Operations() const;
  inline bool IsNone() const;
  bool HasPercent() const;
"""

"Angle" = """
  inline static StyleAngle Zero();
  inline float ToDegrees() const;
  inline double ToRadians() const;
  StyleAngle operator+(const StyleAngle& aAngle) const {
    return StyleAngle{_0 + aAngle._0};
  }
  StyleAngle operator-(const StyleAngle& aAngle) const {
    return StyleAngle{_0 - aAngle._0};
  }
"""

"CoordinatePair" = """
  inline gfx::Point ToGfxPoint(const CSSSize* aBasis = nullptr) const;
  gfx::Point ToGfxPoint(const CSSSize& aBasis) const {
    return ToGfxPoint(&aBasis);
  };
"""

"TextOverflow" = """
  StyleTextOverflow()
    : first(StyleTextOverflowSide::Clip()),
      second(StyleTextOverflowSide::Clip()),
      sides_are_logical(true) {}
"""

"GenericTextIndent" = """
  StyleGenericTextIndent()
    : length(StyleLengthPercentage::Zero()),
      hanging(false),
      each_line(false) {}
"""

"UrlExtraData" = """
  StyleUrlExtraData() = delete;

  // Could be implemented if wanted.
  StyleUrlExtraData(const StyleUrlExtraData&) = delete;
  StyleUrlExtraData& operator=(const StyleUrlExtraData&) = delete;

  inline bool IsShared() const;

  inline ~StyleUrlExtraData();
  inline const URLExtraData& get() const;
"""

"CssUrlData" = """
  // Implemented in nsStyleStruct.cpp
  bool operator==(const StyleCssUrlData& other) const;
  bool operator!=(const StyleCssUrlData& other) const {
    return !(*this == other);
  }
"""

"LoadData" = """
  ~StyleLoadData();
"""

"CssUrl" = """
  inline nsDependentCSubstring SpecifiedSerialization() const;
  inline const URLExtraData& ExtraData() const;
  inline StyleLoadData& LoadData() const;
  inline nsIURI* GetURI() const;
"""

"ComputedUrl" = """
  // Forwarded from CssUrl.
  inline nsDependentCSubstring SpecifiedSerialization() const;
  inline const URLExtraData& ExtraData() const;
  inline nsIURI* GetURI() const;
  inline StyleLoadData& LoadData() const;

  inline bool IsLocalRef() const;
  inline bool HasRef() const;
  inline StyleCorsMode CorsMode() const;
  already_AddRefed<nsIURI> ResolveLocalRef(nsIURI* aBase) const;
  already_AddRefed<nsIURI> ResolveLocalRef(const nsIContent* aContent) const;

  // Only relevant for images.
  inline bool IsImageResolved() const;
  inline imgRequestProxy* GetImage() const;
  void ResolveImage(dom::Document&, const StyleComputedUrl* aOldImage);
"""

"GenericGradient" = """
  inline bool Repeating() const;
  bool IsOpaque() const;

  // Return the color interpolation method of the gradient.
  inline const StyleColorInterpolationMethod& ColorInterpolationMethod() const;
"""

"GenericGridLine" = """
  // Returns the `auto` value.
  inline StyleGenericGridLine();
  inline bool IsAuto() const;
  // The line name, or nsGkAtoms::_empty if not present.
  inline nsAtom* LineName() const;
"""

"GenericTrackBreadth" = """
  inline bool HasPercent() const;
"""

"GenericTrackSize" = """
  // Implemented in nsGridContainerFrame.cpp
  inline const StyleGenericTrackBreadth<L>& GetMin() const;
  inline const StyleGenericTrackBreadth<L>& GetMax() const;
"""

"GenericGridTemplateComponent" = """
  inline Maybe<size_t> RepeatAutoIndex() const;
  inline const StyleGenericTrackRepeat<L, I>* GetRepeatAutoValue() const;
  inline bool HasRepeatAuto() const;
  inline Span<const StyleOwnedSlice<StyleCustomIdent>> LineNameLists(bool aIsSubgrid) const;
  inline Span<const StyleGenericTrackListValue<L, I>> TrackListValues() const;
"""

"GenericClipRect" = """
  // Get the layout rect, replacing auto right / bottom values for aAutoSize.
  inline nsRect ToLayoutRect(nscoord aAutoSize = NS_MAXSIZE) const;
"""

"TimingFunction" = """
 public:
  bool IsLinearKeyword() const { return IsKeyword() && AsKeyword() == StyleTimingKeyword::Linear; }
  static StyleTimingFunction LinearKeyword() { return Keyword(StyleTimingKeyword::Linear); }

  inline double At(double, bool aBeforeFlag) const;
  inline void AppendToString(nsACString&) const;

  inline static double GetPortion(const Maybe<StyleTimingFunction>&, double, bool aBeforeFlag);
"""

"GenericImage" = """
 public:
  // Returns the intrinsic resolution of the image.
  //
  // The resolution is in dppx, and should be used to impact the intrinsic
  // size of the image.
  ImageResolution GetResolution(const ComputedStyle&) const;

  // If this is an image-set(), the final image we've selected, otherwise it
  // returns *this.
  const StyleGenericImage& FinalImage() const;

  // Whether this image may have an image request associated with it.
  bool IsImageRequestType() const;

  // Gets the image request URL.
  const StyleComputedImageUrl* GetImageRequestURLValue() const;

  // Gets the image data of this image if it has any image request.
  imgRequestProxy* GetImageRequest() const;

  // Returns true if this image is fully loaded, and its size is calculated.
  // Always returns true if there's no image request involved and this image
  // is not `none`.
  bool IsComplete() const;

  // Returns true if this image has an available size and hasn't errored.
  // Always returns true if there's no image request involved and this image
  // is not `none`.
  bool IsSizeAvailable() const;

  // Returns true if the item is definitely opaque --- i.e., paints every
  // pixel within its bounds opaquely, and the bounds contains at least a pixel.
  bool IsOpaque() const;

  // Resolves the underlying image request if any.
  void ResolveImage(dom::Document&, const StyleGenericImage* aOld);

  // Returns whether this image has been resolved.
  bool IsResolved() const;
"""

"Ratio" = """
  inline AspectRatio ToLayoutRatio(UseBoxSizing aUseBoxSizing) const;
"""

"GenericAspectRatio" = """
  bool HasRatio() const { return ratio.IsRatio(); }
  bool HasFiniteRatio() const { return static_cast<bool>(ToLayoutRatio()); }
  bool BehavesAsAuto() const { return auto_ || !HasFiniteRatio(); }
  inline AspectRatio ToLayoutRatio() const;

  static StyleGenericAspectRatio Auto() {
    return {true, StylePreferredRatio<N>::None()};
  }
"""

"FontFamilyList" = """
  static StyleFontFamilyList WithOneUnquotedFamily(const nsACString&);
  // Constructs a font family list with a list of names.
  static StyleFontFamilyList WithNames(nsTArray<StyleSingleFontFamily>&&);
"""

"SingleFontFamily" = """
  static StyleSingleFontFamily Parse(const nsACString& aName);
  void AppendToString(nsACString& aFamily, bool aIncludeQuotes = true) const;
  bool IsNamedFamily(const nsAString&) const;
"""

"TimelineOrKeyframesName" = """
 public:
  inline nsAtom* AsAtom() const;
"""

"FontWeight" = """
 SERVO_FIXED_POINT_HELPERS(StyleFontWeight, uint16_t, StyleFONT_WEIGHT_FRACTION_BITS);
 bool IsNormal() const { return *this == NORMAL; }

 inline bool IsBold() const;
"""

"FontStyle" = """
 SERVO_FIXED_POINT_HELPERS(StyleFontStyle, int16_t, StyleFONT_STYLE_FRACTION_BITS);
 bool IsNormal() const { return *this == NORMAL; }
 inline bool IsItalic() const;
 inline bool IsOblique() const;
 inline float ObliqueAngle() const;  // Only for use when IsOblique() is true
 inline float SlantAngle() const;  // Returns angle for any font-style, including
                                   // normal/italic as well as explicit oblique
"""

"FontStretch" = """
 SERVO_FIXED_POINT_HELPERS(StyleFontStretch, uint16_t, StyleFONT_STRETCH_FRACTION_BITS);
 bool IsNormal() const { return *this == NORMAL; }
"""

"Zoom" = """
 SERVO_FIXED_POINT_HELPERS(StyleZoom, uint16_t, StyleZOOM_FRACTION_BITS);
 inline float Zoom(float) const;
 inline float Unzoom(float) const;
 inline nscoord ZoomCoord(nscoord) const;
 inline nscoord UnzoomCoord(nscoord) const;
 inline nsSize Zoom(const nsSize&) const;
 inline nsSize Unzoom(const nsSize&) const;
 inline nsPoint Zoom(const nsPoint&) const;
 inline nsPoint Unzoom(const nsPoint&) const;
 inline nsRect Zoom(const nsRect&) const;
 inline nsRect Unzoom(const nsRect&) const;
"""

"AnimationName" = """
 public:
  StyleAnimationName() : _0(nsGkAtoms::_empty) {}
"""

"GenericViewTimelineInset" = """
 public:
  inline StyleGenericViewTimelineInset();
"""

"Time" = """
 float ToSeconds() const { return seconds; }
 float ToMilliseconds() const { return seconds * 1000.0f; }
"""

"FontFaceSourceTechFlags" = """
  inline static StyleFontFaceSourceTechFlags Empty() {
    return StyleFontFaceSourceTechFlags{0};
  }
"""

"FontPalette" = """
  inline static StyleFontPalette Normal() {
    return StyleFontPalette{StyleAtom(nsGkAtoms::normal->ToAddRefed())};
  }
"""

"GenericOffsetPath" = """
  // Return true if the <offset-path> is ray().
  bool IsRay() const {
    return IsOffsetPath() && AsOffsetPath().path->IsRay();
  }

  const StyleRayFunction& AsRay() const {
    return AsOffsetPath().path->AsRay();
  }

  // Return true if the <offset-path> is url().
  bool IsUrl() const {
    return IsOffsetPath() && AsOffsetPath().path->IsUrl();
  }

  const StyleComputedUrl& AsUrl() const {
    return AsOffsetPath().path->AsUrl();
  }

  // Return true if the <basic-shape> is path().
  bool IsPath() const {
    if (!IsOffsetPath()) {
      return false;
    }
    const auto& path = AsOffsetPath().path;
    if (!path->IsShape()) {
      return false;
    }
    const auto& shape = path->AsShape();
    return shape.IsPathOrShape() && shape.AsPathOrShape().IsPath();
  }

  const StyleSVGPathData& AsSVGPathData() const {
    return AsOffsetPath().path->AsShape().AsPathOrShape().AsPath().path;
  }

  // Return true if this is "<basic-shape> || <coord-box>".
  bool IsBasicShapeOrCoordBox() const {
    return IsCoordBox() || (IsOffsetPath() && AsOffsetPath().path->IsShape());
  }
"""

"GenericShapeCommand" = """
  bool IsCubicType() const { return IsCubicCurve() || IsSmoothCubic(); }
  bool IsQuadraticType() const { return IsQuadCurve() || IsSmoothQuad(); }
"""

"GenericContainIntrinsicSize" = """
  bool HasAuto() const { return IsAutoLength() || IsAutoNone(); }
"""

"Display" = """
  inline StyleDisplayOutside Outside() const;
  inline StyleDisplayInside Inside() const;
  inline bool IsListItem() const;
  inline bool IsInlineFlow() const;
  inline bool IsInlineInside() const;
  inline bool IsInlineOutside() const;
  inline bool IsBlockOutside() const;
  inline bool IsRuby() const;
  inline bool IsInternalRuby() const;
  inline bool IsInternalTable() const;
  inline bool IsInternalTableExceptCell() const;
"""

"TransitionProperty" = """
  bool IsAll() const {
    return IsNonCustom() &&
           nsCSSPropertyID(AsNonCustom()._0) == eCSSProperty_all;
  }
"""