tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

cbindgen.toml (34912B)


      1 header = """/* 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 
     11 #ifndef mozilla_ServoStyleConsts_h
     12 #define mozilla_ServoStyleConsts_h
     13 """
     14 trailer = """
     15 #pragma pop_macro("STRICT")
     16 #pragma pop_macro("TRANSPARENT")
     17 
     18 #endif // mozilla_ServoStyleConsts_h
     19 
     20 #pragma GCC diagnostic pop
     21 #include "mozilla/ServoStyleConstsInlines.h"
     22 """
     23 autogen_warning = """/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen. See RunCbindgen.py
     24 * To modify this file, edit servo/ports/geckolib/cbindgen.toml and build Firefox.
     25 */
     26 """
     27 include_version = true
     28 braces = "SameLine"
     29 line_length = 80
     30 tab_width = 2
     31 language = "C++"
     32 namespaces = ["mozilla"]
     33 includes = ["mozilla/ServoStyleConstsForwards.h", "mozilla/ServoStyleSet.h"]
     34 after_includes = """
     35 // Work-around silly windows.h define.
     36 #pragma push_macro("STRICT")
     37 #undef STRICT
     38 #pragma push_macro("TRANSPARENT")
     39 #undef TRANSPARENT
     40 """
     41 
     42 [parse]
     43 parse_deps = true
     44 extra_bindings = ["style"]
     45 include = ["style", "app_units", "cssparser", "style_traits", "servo_arc"]
     46 
     47 [struct]
     48 associated_constants_in_body = true
     49 derive_eq = true
     50 derive_neq = true
     51 
     52 [defines]
     53 # These will actually never be defined, but is handy to avoid cbindgen
     54 # generating Servo-only types.
     55 "feature = servo" = "CBINDGEN_IS_SERVO"
     56 "feature = servo-layout-2013" = "CBINDGEN_IS_SERVO"
     57 "feature = servo-layout-2020" = "CBINDGEN_IS_SERVO"
     58 "feature = track_alloc_size" = "CBINDGEN_IS_SERVO"
     59 # These will always be defined.
     60 "feature = gecko" = "CBINDGEN_IS_GECKO"
     61 "feature = cbindgen" = "CBINDGEN_IS_GECKO"
     62 # These depend on the build.
     63 "target_pointer_width = 32" = "SERVO_32_BITS"
     64 "target_pointer_width = 64" = "HAVE_64BIT_BUILD"
     65 "unix" = "XP_UNIX"
     66 "windows" = "XP_WIN"
     67 
     68 [macro_expansion]
     69 bitflags = true
     70 
     71 [enum]
     72 derive_helper_methods = true
     73 derive_const_casts = true
     74 derive_tagged_enum_destructor = true
     75 derive_tagged_enum_copy_constructor = true
     76 derive_tagged_enum_copy_assignment = true
     77 private_default_tagged_enum_constructor = true
     78 cast_assert_name = "MOZ_DIAGNOSTIC_ASSERT"
     79 
     80 [export]
     81 prefix = "Style"
     82 exclude = [
     83  "NS_LogCtor",
     84  "NS_LogDtor",
     85  "SelectorList",
     86  "AuthorStyles",
     87  "LockedStyleRule",
     88  "LockedImportRule",
     89  "LockedFontFaceRule",
     90  "LockedCounterStyleRule",
     91  "LockedKeyframesRule",
     92  "LockedPageRule",
     93  "LockedPositionTryRule",
     94  "LockedNestedDeclarationsRule",
     95 ]
     96 include = [
     97  "AnchorName",
     98  "AnchorScope",
     99  "AnimationName",
    100  "AnimationTimeline",
    101  "AnimationIterationCount",
    102  "AnimationDirection",
    103  "AnimationFillMode",
    104  "AnimationPlayState",
    105  "AnimationComposition",
    106  "AnimationDuration",
    107  "Appearance",
    108  "Au",
    109  "BreakBetween",
    110  "BreakWithin",
    111  "BorderSideWidth",
    112  "BorderStyle",
    113  "BorderSpacing",
    114  "BoolInteger",
    115  "OutlineStyle",
    116  "CaptionSide",
    117  "ColorGamut",
    118  "FontSizeAdjust",
    119  "FontPalette",
    120  "FontLanguageOverride",
    121  "FontVariantEastAsian",
    122  "FontVariantLigatures",
    123  "FontVariantNumeric",
    124  "ComputedMozPrefFeatureValue",
    125  "ComputedFontStretchRange",
    126  "ComputedFontStyleDescriptor",
    127  "ComputedFontWeightRange",
    128  "ComputedTimingFunction",
    129  "ComputedValueFlags",
    130  "CursorKind",
    131  "Display",
    132  "DisplayOutside",
    133  "DisplayInside",
    134  "DisplayMode",
    135  "Platform",
    136  "PositionAnchor",
    137  "PositionArea",
    138  "PositionAreaAxis",
    139  "PositionAreaTrack",
    140  "PositionAreaKeyword",
    141  "PositionTryFallbacks",
    142  "PositionTryOrder",
    143  "PositionVisibility",
    144  "GtkThemeFamily",
    145  "PrefersColorScheme",
    146  "PrefersContrast",
    147  "DynamicRange",
    148  "Scripting",
    149  "FillRule",
    150  "FontDisplay",
    151  "FontFaceSourceListComponent",
    152  "FontFaceSourceTechFlags",
    153  "FontLanguageOverride",
    154  "FontSynthesis",
    155  "FontSynthesisStyle",
    156  "GenericFontFamily",
    157  "FontFamily",
    158  "FontFamilyNameSyntax",
    159  "MozTheme",
    160  "OverflowWrap",
    161  "OffsetPath",
    162  "OffsetPathFunction",
    163  "OffsetPosition",
    164  "OffsetRotate",
    165  "RayFunction",
    166  "UnicodeRange",
    167  "UserFocus",
    168  "UserSelect",
    169  "PointerEvents",
    170  "Inert",
    171  "Float",
    172  "Clear",
    173  "OverscrollBehavior",
    174  "ScrollSnapAlign",
    175  "ScrollSnapAxis",
    176  "ScrollSnapStop",
    177  "ScrollSnapStrictness",
    178  "ScrollSnapType",
    179  "TimelineName",
    180  "TransitionBehavior",
    181  "ViewTimelineInset",
    182  "OverflowAnchor",
    183  "OverflowClipMargin",
    184  "Resize",
    185  "Overflow",
    186  "LengthPercentage",
    187  "LetterSpacing",
    188  "NonLocalUriDependency",
    189  "NonNegativeLengthPercentage",
    190  "LengthPercentageOrAuto",
    191  "LineHeight",
    192  "NonNegativeLengthPercentageOrAuto",
    193  "NonNegativeLengthPercentageOrNormal",
    194  "LengthOrAuto",
    195  "NonNegativeLengthOrAuto",
    196  "TextDecorationSkipInk",
    197  "TextDecorationLength",
    198  "TextDecorationInset",
    199  "Time",
    200  "Rect",
    201  "InitialLetter",
    202  "IntersectionObserverMargin",
    203  "Size",
    204  "MaxSize",
    205  "FlexBasis",
    206  "Position",
    207  "PositionOrAuto",
    208  "BackgroundSize",
    209  "BaselineSource",
    210  "BorderImageSlice",
    211  "BorderImageRepeat",
    212  "BorderImageRepeatKeyword",
    213  "BorderSpacing",
    214  "BorderRadius",
    215  "ColorScheme",
    216  "ColumnCount",
    217  "CssRuleRef",
    218  "NonNegativeLengthOrNumberRect",
    219  "Perspective",
    220  "ZIndex",
    221  "TransformBox",
    222  "TransformOrigin",
    223  "LineBreak",
    224  "LineClamp",
    225  "WordBreak",
    226  "Contain",
    227  "ContainerType",
    228  "ContainerName",
    229  "ContentVisibility",
    230  "ContainIntrinsicSize",
    231  "Origin",
    232  "RestyleHint",
    233  "TouchAction",
    234  "WillChange",
    235  "TextDecorationLine",
    236  "MasonryAutoFlow",
    237  "MasonryPlacement",
    238  "MasonryItemOrder",
    239  "TextUnderlinePosition",
    240  "TextTransform",
    241  "TextJustify",
    242  "TextOverflow",
    243  "TextIndent",
    244  "MozControlCharacterVisibility",
    245  "RubyPosition",
    246  "Owned",
    247  "OwnedOrNull",
    248  "Strong",
    249  "ScrollbarColor",
    250  "CaretColor",
    251  "Color",
    252  "ColorOrAuto",
    253  "SystemColor",
    254  "SystemColorScheme",
    255  "SystemFont",
    256  "GradientItem",
    257  "VerticalAlign",
    258  "BasicShape",
    259  "InsetRect",
    260  "ShapeRadius",
    261  "ShapeCommand",
    262  "ArcSlice",
    263  "ForgottenArcSlicePtr",
    264  "HeaderWithLength",
    265  "MozContextProperties",
    266  "Quotes",
    267  "BoxShadow",
    268  "SimpleShadow",
    269  "Transform",
    270  "Rotate",
    271  "Scale",
    272  "Translate",
    273  "BorderImageWidth",
    274  "ComputedUrl",
    275  "UrlOrNone",
    276  "Filter",
    277  "Gradient",
    278  "GridTemplateAreas",
    279  "GridLine",
    280  "TrackSize",
    281  "TrackBreadth",
    282  "ImplicitGridTracks",
    283  "SVGPaint",
    284  "SVGPaintKind",
    285  "GridTemplateComponent",
    286  "TextEmphasisStyle",
    287  "TextEmphasisPosition",
    288  "FontVariantAlternates",
    289  "PaintOrder",
    290  "SVGPaintOrder",
    291  "ClipRectOrAuto",
    292  "CounterReset",
    293  "CounterSet",
    294  "CounterIncrement",
    295  "WritingMode",
    296  "WritingModeProperty",
    297  "Content",
    298  "ContentItem",
    299  "ContentDistribution",
    300  "SelfAlignment",
    301  "ItemPlacement",
    302  "ComputedJustifyItems",
    303  "AlignContent",
    304  "JustifyContent",
    305  "TransformStyle",
    306  "Image",
    307  "ClipPath",
    308  "ShapeOutside",
    309  "GridAutoFlow",
    310  "Cursor",
    311  "SVGStrokeDashArray",
    312  "SVGLength",
    313  "SVGOpacity",
    314  "SVGWidth",
    315  "TextAlign",
    316  "TextAlignLast",
    317  "TextAutospace",
    318  "FontSizeKeyword",
    319  "AspectRatio",
    320  "DefaultFontSizes",
    321  "RuleChangeKind",
    322  "PageName",
    323  "PageOrientation",
    324  "PageSize",
    325  "DProperty",
    326  "ImageRendering",
    327  "PrintColorAdjust",
    328  "ForcedColorAdjust",
    329  "ForcedColors",
    330  "ScrollbarGutter",
    331  "ScrollDirection",
    332  "HyphenateCharacter",
    333  "HyphenateLimitChars",
    334  "NumberOrAuto",
    335  "ComputedLinearStop",
    336  "PiecewiseLinearFunction",
    337  "BeforeFlag",
    338  "VectorEffect",
    339  "XTextScale",
    340  "Zoom",
    341  "TransitionProperty",
    342  "ViewTransitionClass",
    343  "ViewTransitionName",
    344  "Inset",
    345  "AnchorFunction",
    346  "AnchorSide",
    347  "AnchorSizeFunction",
    348  "Margin",
    349  "PositionProperty",
    350  "PhysicalAxis",
    351  "PhysicalSide",
    352  "QueryFontMetricsFlags",
    353  "AllowAnchorPosResolutionInCalcPercentage",
    354 ]
    355 item_types = [
    356  "enums",
    357  "structs",
    358  "unions",
    359  "typedefs",
    360  "functions",
    361  "constants",
    362 ]
    363 renaming_overrides_prefixing = true
    364 
    365 # Prevent some renaming for Gecko types that cbindgen doesn't otherwise understand.
    366 [export.rename]
    367 "nscolor" = "nscolor"
    368 "nsAtom" = "nsAtom"
    369 "nsIURI" = "nsIURI"
    370 "imgRequestProxy" = "imgRequestProxy"
    371 "nsCompatibility" = "nsCompatibility"
    372 "nsSimpleContentList" = "nsSimpleContentList"
    373 "nsACString" = "nsACString"
    374 "nsAString" = "nsAString"
    375 "nsCString" = "nsCString"
    376 "nsString" = "nsString"
    377 "CopyableTArray" = "CopyableTArray"
    378 "nsTArray" = "nsTArray"
    379 "nsPresContext" = "nsPresContext"
    380 "ComputedTiming" = "ComputedTiming"
    381 "CountedUnknownProperty" = "CountedUnknownProperty"
    382 "RefPtr" = "RefPtr"
    383 "NonCustomCSSPropertyId" = "NonCustomCSSPropertyId"
    384 "nsCSSPropertyIDSet" = "nsCSSPropertyIDSet"
    385 "CSSPropertyId" = "CSSPropertyId"
    386 "nsCSSValueSharedList" = "nsCSSValueSharedList"
    387 "AnimationPropertySegment" = "AnimationPropertySegment"
    388 "RawServoAnimationValueTable" = "RawServoAnimationValueTable"
    389 "nsCSSUnit" = "nsCSSUnit"
    390 "InheritTarget" = "InheritTarget"
    391 "PseudoStyleType" = "PseudoStyleType"
    392 "DeclarationBlockMutationClosure" = "DeclarationBlockMutationClosure"
    393 "AtomArray" = "AtomArray"
    394 "UpdateAnimationsTasks" = "UpdateAnimationsTasks"
    395 "StyleRuleInclusion" = "StyleRuleInclusion"
    396 "nsFontFaceRuleContainer" = "nsFontFaceRuleContainer"
    397 "MediumFeaturesChangedResult" = "MediumFeaturesChangedResult"
    398 "FontSizePrefs" = "FontSizePrefs"
    399 "nsCSSFontDesc" = "nsCSSFontDesc"
    400 "nsresult" = "nsresult"
    401 "gfxFontFeature" = "gfxFontFeature"
    402 "gfxFontFeatureValueSet" = "gfxFontFeatureValueSet"
    403 "GeckoFontMetrics" = "GeckoFontMetrics"
    404 "SeenPtrs" = "SeenPtrs"
    405 "gfxFontVariation" = "gfxFontVariation"
    406 "URLExtraData" = "URLExtraData"
    407 "Keyframe" = "Keyframe"
    408 "nsChangeHint" = "nsChangeHint"
    409 "ServoElementSnapshotTable" = "ServoElementSnapshotTable"
    410 "ComputedKeyframeValues" = "ComputedKeyframeValues"
    411 "OriginFlags" = "OriginFlags"
    412 "ServoTraversalFlags" = "ServoTraversalFlags"
    413 "ServoStyleSetSizes" = "ServoStyleSetSizes"
    414 "BeforeFlag" = "StyleEasingBeforeFlag"
    415 "FontPaletteValueSet" = "gfx::FontPaletteValueSet"
    416 "PaletteValues" = "gfx::FontPaletteValueSet::PaletteValues"
    417 "ThinVec" = "CopyableTArray"
    418 "RawPthread" = "pthread_t"
    419 "RawHandle" = "void*"
    420 "PseudoStyleRequest" = "PseudoStyleRequest"
    421 "AnchorPosResolutionParams" = "AnchorPosResolutionParams"
    422 "AnchorPosOffsetResolutionParams" = "AnchorPosOffsetResolutionParams"
    423 
    424 [export.body]
    425 "CSSPixelLength" = """
    426  static StyleCSSPixelLength FromPixels(CSSCoord aCoord) { return {aCoord}; }
    427  static StyleCSSPixelLength Zero() { return FromPixels(0.0f); }
    428 
    429  inline nscoord ToAppUnits() const;
    430  inline bool IsZero() const;
    431  CSSCoord ToCSSPixels() const { return _0; }
    432  inline void ScaleBy(float);
    433  inline StyleCSSPixelLength ScaledBy(float) const;
    434 """
    435 
    436 "CalcLengthPercentage" = """
    437  inline CSSCoord ResolveToCSSPixels(CSSCoord aBasis) const;
    438  template<typename Rounder>
    439  inline nscoord Resolve(nscoord aBasis, Rounder) const;
    440 """
    441 
    442 "GenericCalcNode" = """
    443  void ScaleLengthsBy(float);
    444 """
    445 
    446 "LengthPercentageUnion" = """
    447  using Self = StyleLengthPercentageUnion;
    448 
    449  // TODO(emilio): cbindgen should be able to generate these in the body of the
    450  // union, but it seems it's only implemented for structs, not unions.
    451  static const uint8_t TAG_CALC = StyleLengthPercentageUnion_TAG_CALC;
    452  static const uint8_t TAG_LENGTH = StyleLengthPercentageUnion_TAG_LENGTH;
    453  static const uint8_t TAG_PERCENTAGE = StyleLengthPercentageUnion_TAG_PERCENTAGE;
    454  static const uint8_t TAG_MASK = StyleLengthPercentageUnion_TAG_MASK;
    455 
    456 private:
    457  uint8_t Tag() const {
    458    return tag.tag & TAG_MASK;
    459  }
    460 
    461 public:
    462  // We need to do all this manually because cbingen can't reason about unions.
    463  inline StyleLengthPercentageUnion();
    464  inline StyleLengthPercentageUnion(const Self&);
    465  inline ~StyleLengthPercentageUnion();
    466  inline Self& operator=(const Self&);
    467 
    468  inline bool operator==(const Self& aOther) const;
    469  inline bool operator!=(const Self& aOther) const;
    470 
    471  inline bool IsLength() const;
    472  inline bool IsPercentage() const;
    473  inline bool IsCalc() const;
    474 
    475  inline const StyleLength& AsLength() const;
    476  inline StyleLength& AsLength();
    477 
    478  inline const StylePercentage& AsPercentage() const;
    479  inline StylePercentage& AsPercentage();
    480 
    481  inline const StyleCalcLengthPercentage& AsCalc() const;
    482  inline StyleCalcLengthPercentage& AsCalc();
    483 
    484  static inline Self Zero();
    485  static inline Self FromAppUnits(nscoord);
    486  static inline Self FromPixels(CSSCoord);
    487  static inline Self FromPercentage(float);
    488 
    489  inline void ScaleLengthsBy(float);
    490  inline bool HasPercent() const;
    491  inline bool ConvertsToLength() const;
    492  inline nscoord ToLength() const;
    493  inline CSSCoord ToLengthInCSSPixels() const;
    494  inline bool ConvertsToPercentage() const;
    495  inline bool HasLengthAndPercentage() const;
    496  inline float ToPercentage() const;
    497  inline bool IsDefinitelyZero() const;
    498  inline CSSCoord ResolveToCSSPixels(CSSCoord aPercentageBasisInCSSPixels) const;
    499  template<typename T> inline CSSCoord ResolveToCSSPixelsWith(T aPercentageGetter) const;
    500  template<typename T, typename Rounder>
    501  inline nscoord Resolve(T aPercentageGetter, Rounder) const;
    502  template<typename Rounder>
    503  inline nscoord Resolve(nscoord aPercentageBasis, Rounder) const;
    504  template<typename T> inline nscoord Resolve(T aPercentageGetter) const;
    505  inline nscoord Resolve(nscoord aPercentageBasis) const;
    506 """
    507 
    508 "GenericLengthPercentageOrAuto" = """
    509  inline bool ConvertsToLength() const;
    510  inline nscoord ToLength() const;
    511  inline bool ConvertsToPercentage() const;
    512  inline float ToPercentage() const;
    513  inline bool HasPercent() const;
    514  inline bool HasLengthAndPercentage() const;
    515 
    516  // Just some convenient aliases for LengthOrAuto, to avoid confusing naming.
    517  inline bool IsLength() const;
    518  inline const StyleLength& AsLength() const;
    519 
    520  static inline StyleGenericLengthPercentageOrAuto Zero();
    521 """
    522 
    523 "GenericSize" = """
    524  inline bool ConvertsToLength() const;
    525  inline nscoord ToLength() const;
    526  inline bool ConvertsToPercentage() const;
    527  inline float ToPercentage() const;
    528  inline bool HasPercent() const;
    529  inline bool HasLengthAndPercentage() const;
    530  inline bool BehavesLikeStretchOnInlineAxis() const;
    531  inline bool BehavesLikeStretchOnBlockAxis() const;
    532  inline bool BehavesLikeInitialValueOnBlockAxis() const;
    533  inline bool BehavesLikeInitialValue(LogicalAxis) const;
    534  inline bool HasAnchorPositioningFunction() const;
    535  inline explicit StyleGenericSize(const LengthPercent &);
    536 """
    537 
    538 "GenericFlexBasis" = """
    539  inline bool IsAuto() const;
    540 """
    541 
    542 "GenericMaxSize" = """
    543  inline bool ConvertsToLength() const;
    544  inline nscoord ToLength() const;
    545  inline bool ConvertsToPercentage() const;
    546  inline float ToPercentage() const;
    547  inline bool HasPercent() const;
    548  inline bool HasLengthAndPercentage() const;
    549  inline bool BehavesLikeStretchOnInlineAxis() const;
    550  inline bool BehavesLikeStretchOnBlockAxis() const;
    551  inline bool BehavesLikeInitialValueOnBlockAxis() const;
    552  inline bool BehavesLikeInitialValue(LogicalAxis) const;
    553  inline bool HasAnchorPositioningFunction() const;
    554  inline explicit StyleGenericMaxSize(const LengthPercent &);
    555 """
    556 
    557 "GenericPosition" = """
    558  inline bool HasPercent() const;
    559  inline bool DependsOnPositioningAreaSize() const;
    560  static inline StyleGenericPosition FromPercentage(float);
    561  inline gfx::Point ToGfxPoint(const CSSSize* aBasis = nullptr) const;
    562  gfx::Point ToGfxPoint(const CSSSize& aBasis) const {
    563    return ToGfxPoint(&aBasis);
    564  };
    565 """
    566 
    567 "GenericBackgroundSize" = """
    568  bool IsInitialValue() const;
    569 """
    570 
    571 "Rect" = """
    572  template<typename Predicate> inline bool All(Predicate) const;
    573  template<typename Predicate> inline bool Any(Predicate) const;
    574 
    575  // Defined in WritingModes.h
    576  inline const T& Get(mozilla::Side) const;
    577  inline const T& Get(LogicalSide, WritingMode) const;
    578  inline const T& GetIStart(WritingMode) const;
    579  inline const T& GetBStart(WritingMode) const;
    580  inline const T& Start(LogicalAxis, WritingMode) const;
    581  inline const T& GetIEnd(WritingMode) const;
    582  inline const T& GetBEnd(WritingMode) const;
    583  inline const T& End(LogicalAxis, WritingMode) const;
    584 
    585  inline T& Get(mozilla::Side);
    586  inline T& Get(LogicalSide, WritingMode);
    587  inline T& GetIStart(WritingMode);
    588  inline T& GetBStart(WritingMode);
    589  inline T& GetIEnd(WritingMode);
    590  inline T& GetBEnd(WritingMode);
    591 
    592  static StyleRect WithAllSides(const T& aSide) {
    593    return {aSide, aSide, aSide, aSide};
    594  }
    595 """
    596 
    597 "GenericBorderRadius" = """
    598  inline const StyleLengthPercentage& Get(HalfCorner) const;
    599 """
    600 
    601 "RestyleHint" = """
    602  static inline StyleRestyleHint RestyleSubtree();
    603  static inline StyleRestyleHint RecascadeSubtree();
    604  static inline StyleRestyleHint ForAnimations();
    605  // Returns true if this change hint is guaranteed to at least recascade all
    606  // elements in the subtree of the element it is applied to.
    607  inline bool DefinitelyRecascadesAllSubtree() const;
    608 """
    609 
    610 "TextTransform" = """
    611  bool IsNone() const { return *this == NONE; }
    612 """
    613 
    614 "TextUnderlinePosition" = """
    615  inline bool IsAuto() const;
    616  inline bool IsFromFont() const;
    617  inline bool IsUnder() const;
    618  inline bool IsLeft() const;
    619  inline bool IsRight() const;
    620 """
    621 
    622 "VectorEffect" = """
    623  bool HasNonScalingStroke() const { return bool(*this & StyleVectorEffect::NON_SCALING_STROKE); }
    624 """
    625 
    626 # TODO(emilio): Add hooks to cbindgen to be able to generate [[nodiscard]]
    627 # on the functions.
    628 "Owned" = """
    629  UniquePtr<GeckoType> Consume() {
    630    UniquePtr<GeckoType> ret(ptr);
    631    ptr = nullptr;
    632    return ret;
    633  }
    634 """
    635 
    636 "OwnedOrNull" = """
    637  UniquePtr<GeckoType> Consume() {
    638    UniquePtr<GeckoType> ret(ptr);
    639    ptr = nullptr;
    640    return ret;
    641  }
    642 """
    643 
    644 "Strong" = """
    645  already_AddRefed<GeckoType> Consume() {
    646    already_AddRefed<GeckoType> ret(const_cast<GeckoType*>(ptr));
    647    ptr = nullptr;
    648    return ret;
    649  }
    650 """
    651 
    652 "GenericColor" = """
    653  static inline StyleGenericColor FromColor(nscolor);
    654 
    655  static inline StyleGenericColor Transparent();
    656  static inline StyleGenericColor Black();
    657  static inline StyleGenericColor White();
    658 
    659  bool MaybeTransparent() const;
    660 
    661  /**
    662   * Compute the final color, taking into account the foreground color.
    663   **/
    664  StyleAbsoluteColor ResolveColor(const StyleAbsoluteColor&) const;
    665 
    666  /**
    667   * Compute the final color, taking into account the foreground color from the
    668   * frame's ComputedStyle.
    669   */
    670  nscolor CalcColor(const nsIFrame*) const;
    671  /**
    672   * Compute the final color, taking into account the foreground color from the
    673   * style.
    674   */
    675  nscolor CalcColor(const ComputedStyle&) const;
    676  /**
    677   * Compute the final color, making the argument the foreground color.
    678   */
    679  nscolor CalcColor(nscolor) const;
    680  nscolor CalcColor(const StyleAbsoluteColor&) const;
    681 """
    682 
    683 "AbsoluteColor" = """
    684  /**
    685   * Create a new AbsoluteColor in the sRGB color space in legacy color syntax.
    686   */
    687  static inline StyleAbsoluteColor SrgbLegacy(float red, float green, float blue, float alpha);
    688 
    689  static inline StyleAbsoluteColor FromColor(nscolor);
    690 
    691  /**
    692   * Convert this color into the given color space.
    693   */
    694  StyleAbsoluteColor ToColorSpace(StyleColorSpace aColorSpace) const;
    695 
    696  /**
    697   * Convert this color to an nscolor. The color will be converted to sRGB first
    698   * if required.
    699   */
    700  nscolor ToColor() const;
    701 """
    702 
    703 "OwnedSlice" = """
    704  constexpr StyleOwnedSlice() :
    705    ptr((T*)alignof(T)),
    706    len(0) {}
    707 
    708  inline void Clear();
    709  inline void CopyFrom(const StyleOwnedSlice&);
    710  inline void SwapElements(StyleOwnedSlice&);
    711 
    712  StyleOwnedSlice& operator=(const StyleOwnedSlice&);
    713  StyleOwnedSlice& operator=(StyleOwnedSlice&&);
    714 
    715  inline StyleOwnedSlice(const StyleOwnedSlice&);
    716  inline StyleOwnedSlice(StyleOwnedSlice&&);
    717  inline explicit StyleOwnedSlice(Vector<T>&&);
    718 
    719  inline ~StyleOwnedSlice();
    720 
    721  Span<const T> AsSpan() const {
    722    return {ptr, len};
    723  }
    724 
    725  size_t Length() const {
    726    return len;
    727  }
    728 
    729  bool IsEmpty() const { return Length() == 0; }
    730 
    731  bool operator==(const StyleOwnedSlice& other) const {
    732    return AsSpan() == other.AsSpan();
    733  }
    734 
    735  bool operator!=(const StyleOwnedSlice& other) const {
    736    return !(*this == other);
    737  }
    738 """
    739 
    740 "ArcInner" = """
    741  // Increase the reference count.
    742  inline void IncrementRef();
    743  // Release the reference count, and return whether the result must be freed or not.
    744  [[nodiscard]] inline bool DecrementRef();
    745 """
    746 
    747 "HeaderSlice" = """
    748  StyleHeaderSlice() = delete;
    749  StyleHeaderSlice(const StyleHeaderSlice&) = delete;
    750 
    751  inline ~StyleHeaderSlice();
    752  inline bool operator==(const StyleHeaderSlice& other) const;
    753  inline bool operator!=(const StyleHeaderSlice& other) const;
    754 
    755  inline Span<const T> AsSpan() const;
    756  inline size_t Length() const { return len; }
    757  inline bool IsEmpty() const { return len == 0; }
    758 """
    759 
    760 "ArcSlice" = """
    761  inline StyleArcSlice();
    762  inline explicit StyleArcSlice(const StyleForgottenArcSlicePtr<T>& aPtr);
    763  inline Span<const T> AsSpan() const;
    764  inline size_t Length() const;
    765  inline bool IsEmpty() const;
    766 """
    767 
    768 "Arc" = """
    769  StyleArc() = delete;
    770  inline StyleArc(const StyleArc& Other);
    771 private:
    772  inline void Release();
    773 public:
    774  explicit StyleArc(decltype(p) aP) : p(aP) {
    775    MOZ_DIAGNOSTIC_ASSERT(p, "Arc shouldn't be null");
    776  }
    777  inline ~StyleArc();
    778 
    779  inline StyleArc& operator=(const StyleArc&);
    780  inline StyleArc& operator=(StyleArc&&);
    781 
    782  const T* operator->() const {
    783    MOZ_DIAGNOSTIC_ASSERT(p, "Arc shouldn't be null");
    784    return &p->data;
    785  }
    786  const T& operator*() const {
    787    MOZ_DIAGNOSTIC_ASSERT(p, "Arc shouldn't be null");
    788    return p->data;
    789  }
    790  bool operator==(const StyleArc& other) const {
    791    return p == other.p || *(*this) == *other;
    792  }
    793  bool operator!=(const StyleArc& other) const {
    794    return !(*this == other);
    795  }
    796 """
    797 
    798 "CustomIdent" = """
    799  inline nsAtom* AsAtom() const;
    800 """
    801 
    802 "GenericHyphenateLimitChars" = """
    803  static StyleGenericHyphenateLimitChars Auto() {
    804    return StyleGenericHyphenateLimitChars{
    805      StyleNumberOrAuto<Integer>::Auto(),
    806      StyleNumberOrAuto<Integer>::Auto(),
    807      StyleNumberOrAuto<Integer>::Auto(),
    808    };
    809  };
    810 """
    811 
    812 "Atom" = """
    813  StyleAtom(size_t) = delete;
    814  StyleAtom() = delete;
    815 
    816  inline bool IsStatic() const;
    817  inline nsAtom* AsAtom() const;
    818 
    819 private:
    820  inline void AddRef();
    821  inline void Release();
    822 
    823 public:
    824  inline explicit StyleAtom(already_AddRefed<nsAtom>);
    825  inline explicit StyleAtom(nsStaticAtom*);
    826  inline StyleAtom(const StyleAtom& aOther);
    827  inline StyleAtom& operator=(const StyleAtom&);
    828  inline ~StyleAtom();
    829 """
    830 
    831 "OwnedStr" = """
    832  inline nsDependentCSubstring AsString() const;
    833 """
    834 
    835 "GenericTransformOrigin" = """
    836  inline bool HasPercent() const;
    837 """
    838 
    839 "GenericTransform" = """
    840  inline Span<const T> Operations() const;
    841  inline bool IsNone() const;
    842  bool HasPercent() const;
    843 """
    844 
    845 "Angle" = """
    846  inline static StyleAngle Zero();
    847  inline float ToDegrees() const;
    848  inline double ToRadians() const;
    849  StyleAngle operator+(const StyleAngle& aAngle) const {
    850    return StyleAngle{_0 + aAngle._0};
    851  }
    852  StyleAngle operator-(const StyleAngle& aAngle) const {
    853    return StyleAngle{_0 - aAngle._0};
    854  }
    855 """
    856 
    857 "CoordinatePair" = """
    858  inline gfx::Point ToGfxPoint(const CSSSize* aBasis = nullptr) const;
    859  gfx::Point ToGfxPoint(const CSSSize& aBasis) const {
    860    return ToGfxPoint(&aBasis);
    861  };
    862 """
    863 
    864 "CommandEndPoint" = """
    865  inline gfx::Point ToGfxPoint(const CSSSize* aBasis = nullptr) const;
    866  gfx::Point ToGfxPoint(const CSSSize& aBasis) const {
    867    return ToGfxPoint(&aBasis);
    868  };
    869 """
    870 
    871 "AxisEndPoint" = """
    872  inline gfx::Coord ToGfxCoord(const float* aBasis = nullptr) const;
    873  gfx::Coord ToGfxCoord(const float& aBasis) const {
    874    return ToGfxCoord(&aBasis);
    875  };
    876 """
    877 
    878 "ControlPoint" = """
    879  inline gfx::Point ToGfxPoint(
    880    const gfx::Point aStatePos, const gfx::Point aEndPoint,
    881    const CSSSize* aBasis = nullptr) const;
    882  gfx::Point ToGfxPoint(
    883    const gfx::Point aStatePos, const gfx::Point aEndPoint,
    884    const CSSSize& aBasis) const {
    885    return ToGfxPoint(aStatePos, aEndPoint, &aBasis);
    886  }
    887 """
    888 
    889 "ArcRadii" = """
    890  inline gfx::Point ToGfxPoint(const CSSSize* aBasis = nullptr) const;
    891  gfx::Point ToGfxPoint(const CSSSize& aBasis) const {
    892    return ToGfxPoint(&aBasis);
    893  };
    894 """
    895 
    896 "TextOverflow" = """
    897  StyleTextOverflow()
    898    : first(StyleTextOverflowSide::Clip()),
    899      second(StyleTextOverflowSide::Clip()),
    900      sides_are_logical(true) {}
    901 """
    902 
    903 "GenericTextIndent" = """
    904  StyleGenericTextIndent()
    905    : length(StyleLengthPercentage::Zero()),
    906      hanging(false),
    907      each_line(false) {}
    908 """
    909 
    910 "UrlExtraData" = """
    911  StyleUrlExtraData() = delete;
    912 
    913  // Could be implemented if wanted.
    914  StyleUrlExtraData(const StyleUrlExtraData&) = delete;
    915  StyleUrlExtraData& operator=(const StyleUrlExtraData&) = delete;
    916 
    917  inline bool IsShared() const;
    918 
    919  inline ~StyleUrlExtraData();
    920  inline const URLExtraData& get() const;
    921 """
    922 
    923 "CssUrlData" = """
    924  // Implemented in nsStyleStruct.cpp
    925  bool operator==(const StyleCssUrlData& other) const;
    926  bool operator!=(const StyleCssUrlData& other) const {
    927    return !(*this == other);
    928  }
    929 """
    930 
    931 "LoadData" = """
    932  ~StyleLoadData();
    933 """
    934 
    935 "CssUrl" = """
    936  inline nsDependentCSubstring SpecifiedSerialization() const;
    937  inline const URLExtraData& ExtraData() const;
    938  inline const StyleLoadData& LoadData() const;
    939  inline StyleLoadData& MutLoadData() const;
    940  inline nsIURI* GetURI() const;
    941 """
    942 
    943 "ComputedUrl" = """
    944  // Forwarded from CssUrl.
    945  inline nsDependentCSubstring SpecifiedSerialization() const;
    946  inline const URLExtraData& ExtraData() const;
    947  inline nsIURI* GetURI() const;
    948  inline const StyleLoadData& LoadData() const;
    949  inline StyleLoadData& MutLoadData() const;
    950 
    951  inline bool IsLocalRef() const;
    952  inline bool HasRef() const;
    953  inline StyleCorsMode CorsMode() const;
    954 
    955  // Only relevant for images.
    956  inline bool IsImageResolved() const;
    957  inline imgRequestProxy* GetImage() const;
    958  void ResolveImage(dom::Document&, const StyleComputedUrl* aOldImage);
    959 """
    960 
    961 "GenericGradient" = """
    962  inline bool Repeating() const;
    963  bool IsOpaque() const;
    964 
    965  // Return the color interpolation method of the gradient.
    966  inline const StyleColorInterpolationMethod& ColorInterpolationMethod() const;
    967 """
    968 
    969 "GenericGridLine" = """
    970  // Returns the `auto` value.
    971  inline StyleGenericGridLine();
    972  inline bool IsAuto() const;
    973  // The line name, or nsGkAtoms::_empty if not present.
    974  inline nsAtom* LineName() const;
    975 """
    976 
    977 "GenericTrackBreadth" = """
    978  inline bool HasPercent() const;
    979 """
    980 
    981 "GenericTrackSize" = """
    982  // Implemented in nsGridContainerFrame.cpp
    983  inline const StyleGenericTrackBreadth<L>& GetMin() const;
    984  inline const StyleGenericTrackBreadth<L>& GetMax() const;
    985 """
    986 
    987 "GenericGridTemplateComponent" = """
    988  inline Maybe<size_t> RepeatAutoIndex() const;
    989  inline const StyleGenericTrackRepeat<L, I>* GetRepeatAutoValue() const;
    990  inline bool HasRepeatAuto() const;
    991  inline Span<const StyleOwnedSlice<StyleCustomIdent>> LineNameLists(bool aIsSubgrid) const;
    992  inline Span<const StyleGenericTrackListValue<L, I>> TrackListValues() const;
    993 """
    994 
    995 "GenericClipRect" = """
    996  // Get the layout rect, replacing auto right / bottom values for aAutoSize.
    997  inline nsRect ToLayoutRect(nscoord aAutoSize = NS_MAXSIZE) const;
    998 """
    999 
   1000 "TimingFunction" = """
   1001 public:
   1002  bool IsLinearKeyword() const { return IsKeyword() && AsKeyword() == StyleTimingKeyword::Linear; }
   1003  static StyleTimingFunction LinearKeyword() { return Keyword(StyleTimingKeyword::Linear); }
   1004 
   1005  inline double At(double, bool aBeforeFlag) const;
   1006  inline void AppendToString(nsACString&) const;
   1007 
   1008  inline static double GetPortion(const Maybe<StyleTimingFunction>&, double, bool aBeforeFlag);
   1009 """
   1010 
   1011 "GenericImage" = """
   1012 public:
   1013  // Returns the intrinsic resolution of the image.
   1014  //
   1015  // The resolution is in dppx, and should be used to impact the intrinsic
   1016  // size of the image.
   1017  //
   1018  // @param aStyleForZoom a style, if CSS zoom should be considered as well.
   1019  ImageResolution GetResolution(const ComputedStyle* aStyleForZoom) const;
   1020 
   1021  // If this is an image-set(), the final image we've selected, otherwise it
   1022  // returns *this.
   1023  const StyleGenericImage& FinalImage() const;
   1024 
   1025  // Whether this image may have an image request associated with it.
   1026  bool IsImageRequestType() const;
   1027 
   1028  // Gets the image request URL.
   1029  const StyleComputedUrl* GetImageRequestURLValue() const;
   1030 
   1031  // Gets the image data of this image if it has any image request.
   1032  imgRequestProxy* GetImageRequest() const;
   1033 
   1034  // Returns true if this image is fully loaded, and its size is calculated.
   1035  // Always returns true if there's no image request involved and this image
   1036  // is not `none`.
   1037  bool IsComplete() const;
   1038 
   1039  // Returns true if this image has an available size and hasn't errored.
   1040  // Always returns true if there's no image request involved and this image
   1041  // is not `none`.
   1042  bool IsSizeAvailable() const;
   1043 
   1044  // Returns true if the item is definitely opaque --- i.e., paints every
   1045  // pixel within its bounds opaquely, and the bounds contains at least a pixel.
   1046  bool IsOpaque() const;
   1047 
   1048  // Resolves the underlying image request if any.
   1049  void ResolveImage(dom::Document&, const StyleGenericImage* aOld);
   1050 
   1051  // Returns whether this image has been resolved.
   1052  bool IsResolved() const;
   1053 """
   1054 
   1055 "Ratio" = """
   1056  inline AspectRatio ToLayoutRatio(UseBoxSizing aUseBoxSizing) const;
   1057 """
   1058 
   1059 "GenericAspectRatio" = """
   1060  bool HasRatio() const { return ratio.IsRatio(); }
   1061  bool HasFiniteRatio() const { return static_cast<bool>(ToLayoutRatio()); }
   1062  bool BehavesAsAuto() const { return auto_ || !HasFiniteRatio(); }
   1063  inline AspectRatio ToLayoutRatio() const;
   1064 
   1065  static StyleGenericAspectRatio Auto() {
   1066    return {true, StylePreferredRatio<N>::None()};
   1067  }
   1068 """
   1069 
   1070 "FontFamilyList" = """
   1071  static StyleFontFamilyList WithOneUnquotedFamily(const nsACString&);
   1072  // Constructs a font family list with a list of names.
   1073  static StyleFontFamilyList WithNames(nsTArray<StyleSingleFontFamily>&&);
   1074 """
   1075 
   1076 "SingleFontFamily" = """
   1077  static StyleSingleFontFamily Parse(const nsACString& aName);
   1078  void AppendToString(nsACString& aFamily, bool aIncludeQuotes = true) const;
   1079  bool IsNamedFamily(const nsAString&) const;
   1080 """
   1081 
   1082 "FontWeight" = """
   1083 SERVO_FIXED_POINT_HELPERS(StyleFontWeight, uint16_t, StyleFONT_WEIGHT_FRACTION_BITS);
   1084 bool IsNormal() const { return *this == NORMAL; }
   1085 
   1086 inline bool IsBold() const;
   1087 inline bool PreferBold() const;
   1088 """
   1089 
   1090 "FontStyle" = """
   1091 SERVO_FIXED_POINT_HELPERS(StyleFontStyle, int16_t, StyleFONT_STYLE_FRACTION_BITS);
   1092 bool IsNormal() const { return *this == NORMAL; }
   1093 inline bool IsItalic() const;
   1094 inline float ObliqueAngle() const;  // Not for use when IsItalic() is true
   1095 inline float SlantAngle() const;  // Returns angle for any font-style, including
   1096                                   // normal/italic as well as explicit oblique
   1097 """
   1098 
   1099 "FontStretch" = """
   1100 SERVO_FIXED_POINT_HELPERS(StyleFontStretch, uint16_t, StyleFONT_STRETCH_FRACTION_BITS);
   1101 bool IsNormal() const { return *this == NORMAL; }
   1102 """
   1103 
   1104 "Zoom" = """
   1105 float ToFloat() const { return _0; }
   1106 inline float Zoom(float) const;
   1107 inline float Unzoom(float) const;
   1108 inline nscoord ZoomCoord(nscoord) const;
   1109 inline nscoord UnzoomCoord(nscoord) const;
   1110 inline nsSize Zoom(const nsSize&) const;
   1111 inline nsSize Unzoom(const nsSize&) const;
   1112 inline nsPoint Zoom(const nsPoint&) const;
   1113 inline nsPoint Unzoom(const nsPoint&) const;
   1114 inline nsRect Zoom(const nsRect&) const;
   1115 inline nsRect Unzoom(const nsRect&) const;
   1116 """
   1117 
   1118 "AnimationName" = """
   1119 public:
   1120  StyleAnimationName() : _0(nsGkAtoms::_empty) {}
   1121 """
   1122 
   1123 "TimelineName" = """
   1124 public:
   1125  StyleTimelineName() : _0(nsGkAtoms::_empty) {}
   1126  nsAtom* AsAtom() const { return _0.AsAtom(); }
   1127 """
   1128 
   1129 "GenericViewTimelineInset" = """
   1130 public:
   1131  inline StyleGenericViewTimelineInset();
   1132 """
   1133 
   1134 "Time" = """
   1135 float ToSeconds() const { return seconds; }
   1136 float ToMilliseconds() const { return seconds * 1000.0f; }
   1137 """
   1138 
   1139 "ComputedFontStyleDescriptor" = """
   1140  inline static StyleComputedFontStyleDescriptor Normal() {
   1141    return StyleComputedFontStyleDescriptor::Oblique(0, 0);
   1142  }
   1143 """
   1144 
   1145 "FontFaceSourceTechFlags" = """
   1146  inline static StyleFontFaceSourceTechFlags Empty() {
   1147    return StyleFontFaceSourceTechFlags{0};
   1148  }
   1149 """
   1150 
   1151 "FontPalette" = """
   1152  inline static StyleFontPalette Normal() {
   1153    return StyleFontPalette{StyleAtom(nsGkAtoms::normal->ToAddRefed())};
   1154  }
   1155 """
   1156 
   1157 "GenericOffsetPath" = """
   1158  // Return true if the <offset-path> is ray().
   1159  bool IsRay() const {
   1160    return IsOffsetPath() && AsOffsetPath().path->IsRay();
   1161  }
   1162 
   1163  const StyleRayFunction& AsRay() const {
   1164    return AsOffsetPath().path->AsRay();
   1165  }
   1166 
   1167  // Return true if the <offset-path> is url().
   1168  bool IsUrl() const {
   1169    return IsOffsetPath() && AsOffsetPath().path->IsUrl();
   1170  }
   1171 
   1172  const StyleComputedUrl& AsUrl() const {
   1173    return AsOffsetPath().path->AsUrl();
   1174  }
   1175 
   1176  // Return true if the <basic-shape> is path().
   1177  bool IsPath() const {
   1178    if (!IsOffsetPath()) {
   1179      return false;
   1180    }
   1181    const auto& path = AsOffsetPath().path;
   1182    if (!path->IsShape()) {
   1183      return false;
   1184    }
   1185    const auto& shape = path->AsShape();
   1186    return shape.IsPathOrShape() && shape.AsPathOrShape().IsPath();
   1187  }
   1188 
   1189  const StyleSVGPathData& AsSVGPathData() const {
   1190    return AsOffsetPath().path->AsShape().AsPathOrShape().AsPath().path;
   1191  }
   1192 
   1193  // Return true if this is "<basic-shape> || <coord-box>".
   1194  bool IsBasicShapeOrCoordBox() const {
   1195    return IsCoordBox() || (IsOffsetPath() && AsOffsetPath().path->IsShape());
   1196  }
   1197 """
   1198 
   1199 "GenericShapeCommand" = """
   1200  bool IsCubicType() const { return IsCubicCurve() || IsSmoothCubic(); }
   1201  bool IsQuadraticType() const { return IsQuadCurve() || IsSmoothQuad(); }
   1202 """
   1203 
   1204 "GenericContainIntrinsicSize" = """
   1205  bool HasAuto() const { return IsAutoLength() || IsAutoNone(); }
   1206 """
   1207 
   1208 "Display" = """
   1209  inline StyleDisplayOutside Outside() const;
   1210  inline StyleDisplayInside Inside() const;
   1211  inline bool IsListItem() const;
   1212  inline bool IsInlineFlow() const;
   1213  inline bool IsInlineInside() const;
   1214  inline bool IsInlineOutside() const;
   1215  inline bool IsBlockOutside() const;
   1216  inline bool IsRuby() const;
   1217  inline bool IsInternalRuby() const;
   1218  inline bool IsInternalTable() const;
   1219  inline bool IsInternalTableExceptCell() const;
   1220 """
   1221 
   1222 "TransitionProperty" = """
   1223  bool IsAll() const {
   1224    return IsNonCustom() &&
   1225           NonCustomCSSPropertyId(AsNonCustom()._0) == eCSSProperty_all;
   1226  }
   1227 """
   1228 
   1229 "GenericInset" = """
   1230  inline bool HasPercent() const;
   1231  inline bool ConvertsToLength() const;
   1232  inline bool HasLengthAndPercentage() const;
   1233  inline bool HasAnchorPositioningFunction() const;
   1234  inline nscoord ToLength() const;
   1235  inline bool ConvertsToPercentage() const;
   1236  inline float ToPercentage() const;
   1237  inline explicit StyleGenericInset(const LP &);
   1238 """
   1239 
   1240 "GenericMargin" = """
   1241  inline bool HasPercent() const;
   1242  inline bool ConvertsToLength() const;
   1243  inline bool HasLengthAndPercentage() const;
   1244  inline nscoord ToLength() const;
   1245  inline bool ConvertsToPercentage() const;
   1246  inline float ToPercentage() const;
   1247  inline bool HasAnchorPositioningFunction() const;
   1248  inline explicit StyleGenericMargin(const LP &);
   1249 """
   1250 
   1251 "PositionArea" = """
   1252  inline bool IsNone() const;
   1253  constexpr StylePositionArea()
   1254    : first(StylePositionAreaKeyword::None),
   1255      second(StylePositionAreaKeyword::None)
   1256  {}
   1257 """