servo/ports/geckolib/cbindgen.toml
author Emilio Cobos Álvarez <emilio@crisal.io>
Thu, 04 Apr 2019 22:06:03 +0000
changeset 468101 1ea4b3582033d4d9777590af85c7299f68861ffd
parent 468053 ddcd214baefac1efcec62fa50d163677de01869b
child 468107 dd4d744643a31e8817f15b07fe610bc0fbe0b671
permissions -rw-r--r--
Bug 760345 - Remove the last usage of lossy currentcolor. r=heycam We don't have lossy currentcolor in the style system anymore, except for a single property -moz-font-smoothing-background-color. I could've converted it into a proper StyleColor and thread down all the necessary information to the font metrics code. But it doesn't really seem worth it given it's not exposed to the web, so I just did the simplest thing, which is making currentcolor compute to transparent to that specific property. This patch also removes the stores_complex_colors_lossily code and related, since now we always can cache computed colors. Differential Revision: https://phabricator.services.mozilla.com/D26187

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"""
trailer = "#pragma GCC diagnostic pop"
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"]

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

[struct]
derive_eq = true
derive_neq = true

[macro_expansion]
bitflags = true

[enum]
derive_helper_methods = true
derive_const_casts = true
cast_assert_name = "MOZ_ASSERT"

[export]
prefix = "Style"
include = [
  "Appearance",
  "BreakBetween",
  "BreakWithin",
  "BorderStyle",
  "OutlineStyle",
  "ComputedFontStretchRange",
  "ComputedFontStyleDescriptor",
  "ComputedFontWeightRange",
  "ComputedTimingFunction",
  "CursorKind",
  "Display",
  "DisplayMode",
  "PrefersColorScheme",
  "ExtremumLength",
  "FillRule",
  "FontDisplay",
  "FontFaceSourceListComponent",
  "FontLanguageOverride",
  "GenericFontFamily",
  "FontFamilyNameSyntax",
  "OverflowWrap",
  "TimingFunction",
  "PathCommand",
  "UnicodeRange",
  "UserSelect",
  "Float",
  "OverscrollBehavior",
  "ScrollSnapAlign",
  "ScrollSnapType",
  "OverflowAnchor",
  "OverflowClipBox",
  "Resize",
  "Overflow",
  "LengthPercentage",
  "LetterSpacing",
  "NonNegativeLengthPercentage",
  "LengthPercentageOrAuto",
  "LineHeight",
  "NonNegativeLengthPercentageOrAuto",
  "LengthOrAuto",
  "NonNegativeLengthOrAuto",
  "Rect",
  "IntersectionObserverRootMargin",
  "Size",
  "MaxSize",
  "FlexBasis",
  "Position",
  "BackgroundSize",
  "BorderImageSlice",
  "BorderSpacing",
  "BorderRadius",
  "NonNegativeLengthOrNumberRect",
  "Perspective",
  "ZIndex",
  "TransformOrigin",
  "WordBreak",
  "Contain",
  "RestyleHint",
  "TouchAction",
  "WillChangeBits",
  "TextDecorationLine",
  "MozListReversed",
  "Owned",
  "OwnedOrNull",
  "Strong",
  "ScrollbarColor",
  "Color",
  "ColorOrAuto",
]
item_types = ["enums", "structs", "typedefs", "functions"]
renaming_overrides_prefixing = true

# Prevent some renaming for Gecko types that cbindgen doesn't otherwise understand.
[export.rename]
"nscolor" = "nscolor"
"nsAtom" = "nsAtom"
"nsCompatibility" = "nsCompatibility"
"SharedFontList" = "SharedFontList"
"nsSimpleContentList" = "nsSimpleContentList"
"nsACString" = "nsACString"
"nsAString" = "nsAString"
"nsString" = "nsString"
"nsTArray" = "nsTArray"
"nsPresContext" = "nsPresContext"
"ComputedTiming" = "ComputedTiming"
"RefPtr" = "RefPtr"
"nsCSSPropertyID" = "nsCSSPropertyID"
"nsCSSPropertyIDSet" = "nsCSSPropertyIDSet"
"nsCSSValueSharedList" = "nsCSSValueSharedList"
"AnimationPropertySegment" = "AnimationPropertySegment"
"RawServoAnimationValueMap" = "RawServoAnimationValueMap"
"RawServoAnimationValueTable" = "RawServoAnimationValueTable"
"nsCSSUnit" = "nsCSSUnit"
"ParsingMode" = "ParsingMode"
"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"
"SeenPtrs" = "SeenPtrs"
"gfxFontVariation" = "gfxFontVariation"
"URLExtraData" = "URLExtraData"
"Keyframe" = "Keyframe"
"nsChangeHint" = "nsChangeHint"
"ServoElementSnapshotTable" = "ServoElementSnapshotTable"
"nsTimingFunction" = "nsTimingFunction"
"Keyframe" = "Keyframe"
"ComputedKeyframeValues" = "ComputedKeyframeValues"
"OriginFlags" = "OriginFlags"
"ServoTraversalFlags" = "ServoTraversalFlags"
"ServoStyleSetSizes" = "ServoStyleSetSizes"

[export.body]
"CSSPixelLength" = """
  inline nscoord ToAppUnits() const;
  inline bool IsZero() const;
"""

"LengthPercentage" = """
  // Defined in nsStyleCoord.h
  static constexpr inline StyleLengthPercentage Zero();
  static inline StyleLengthPercentage FromAppUnits(nscoord);
  static inline StyleLengthPercentage FromPixels(CSSCoord);
  static inline StyleLengthPercentage FromPercentage(float);
  inline CSSCoord LengthInCSSPixels() const;
  inline float Percentage() const;
  inline bool HasPercent() const;
  inline bool ConvertsToLength() const;
  inline nscoord ToLength() 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 U>
  inline nscoord Resolve(T aPercentageGetter, U aPercentRoundingFunction) const;
  template<typename T>
  inline nscoord Resolve(nscoord aPercentageBasis, T aPercentRoundingFunction) 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;
"""

"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 DependsOnPositioningAreaSize() const;
  static inline StyleGenericPosition FromPercentage(float);
"""

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

"Rect" = """
  // Defined in nsStyleCoord.h
  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(mozilla::WritingMode, mozilla::LogicalSide) const;
  inline const T& GetIStart(mozilla::WritingMode) const;
  inline const T& GetBStart(mozilla::WritingMode) const;
  inline const T& GetIEnd(mozilla::WritingMode) const;
  inline const T& GetBEnd(mozilla::WritingMode) const;
"""

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

"RestyleHint" = """
  static inline StyleRestyleHint RestyleSubtree();
  static inline StyleRestyleHint RecascadeSubtree();
  static inline StyleRestyleHint ForAnimations();
"""

# TODO(emilio): Add hooks to cbindgen to be able to generate MOZ_MUST_USE_TYPE
# or MOZ_MUST_USE 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 Black();
  static inline StyleGenericColor White();
  static inline StyleGenericColor Transparent();
  bool MaybeTransparent() 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 StyleRGBA&) const;
"""

"RGBA" = """
  static inline StyleRGBA Transparent();
  static inline StyleRGBA FromColor(nscolor);

  inline nscolor ToColor() const;
"""