Copy as Markdown

Other Tools

/* 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
#ifndef mozilla_ServoStyleConsts_h
#define mozilla_ServoStyleConsts_h
/* Generated with cbindgen:0.26.0 */
/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen. See RunCbindgen.py
* To modify this file, edit servo/ports/geckolib/cbindgen.toml and build Firefox.
*/
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
#include "mozilla/ServoStyleConstsForwards.h"
#include "mozilla/ServoStyleSet.h"
// Work-around silly windows.h define.
#pragma push_macro("STRICT")
#undef STRICT
#pragma push_macro("TRANSPARENT")
#undef TRANSPARENT
namespace mozilla {
#if defined(CBINDGEN_IS_GECKO)
/// The minimum stack size for a thread in the styling pool, in kilobytes.
constexpr static const uintptr_t StyleSTYLE_THREAD_STACK_SIZE_KB = 256;
#endif
#if defined(CBINDGEN_IS_SERVO)
/// The minimum stack size for a thread in the styling pool, in kilobytes.
/// Servo requires a bigger stack in debug builds.
constexpr static const uintptr_t StyleSTYLE_THREAD_STACK_SIZE_KB = 512;
#endif
/// The stack margin. If we get this deep in the stack, we will skip recursive
/// optimizations to ensure that there is sufficient room for non-recursive work.
///
/// We allocate large safety margins because certain OS calls can use very large
/// amounts of stack space [1]. Reserving a larger-than-necessary stack costs us
/// address space, but if we keep our safety margin big, we will generally avoid
/// committing those extra pages, and only use them in edge cases that would
/// otherwise cause crashes.
///
/// When measured with 128KB stacks and 40KB margin, we could support 53
/// levels of recursion before the limiter kicks in, on x86_64-Linux [2]. When
/// we doubled the stack size, we added it all to the safety margin, so we should
/// be able to get the same amount of recursion.
///
/// [2] See Gecko bug 1376883 for more discussion on the measurements.
constexpr static const uintptr_t StyleSTACK_SAFETY_MARGIN_KB = 168;
/// The amount of nodes that the style sharing candidate cache should hold at
/// most.
///
/// The cache size was chosen by measuring style sharing and resulting
/// performance on a few pages; sizes up to about 32 were giving good sharing
/// improvements (e.g. 3x fewer styles having to be resolved than at size 8) and
/// slight performance improvements. Sizes larger than 32 haven't really been
/// tested.
constexpr static const uintptr_t StyleSHARING_CACHE_SIZE = 32;
/// We use an unsigned 10.6 fixed-point value (range 0.0 - 1023.984375).
constexpr static const uint16_t StyleZOOM_FRACTION_BITS = 6;
/// font-weight: range 1..1000, fractional values permitted; keywords
/// 'normal', 'bold' aliased to 400, 700 respectively.
///
/// We use an unsigned 10.6 fixed-point value (range 0.0 - 1023.984375)
constexpr static const uint16_t StyleFONT_WEIGHT_FRACTION_BITS = 6;
/// - Use a signed 8.8 fixed-point value (representable range -128.0..128)
///
/// Values of <angle> below -90 or above 90 not permitted, so we use out of
/// range values to represent normal | oblique
constexpr static const uint16_t StyleFONT_STYLE_FRACTION_BITS = 8;
/// font-stretch is a percentage relative to normal.
///
/// We use an unsigned 10.6 fixed-point value (range 0.0 - 1023.984375)
///
/// We arbitrarily limit here to 1000%. (If that becomes a problem, we could
/// reduce the number of fractional bits and increase the limit.)
constexpr static const uint16_t StyleFONT_STRETCH_FRACTION_BITS = 6;
constexpr static const uint8_t StyleLengthPercentageUnion_TAG_CALC = 0;
constexpr static const uint8_t StyleLengthPercentageUnion_TAG_LENGTH = 1;
constexpr static const uint8_t StyleLengthPercentageUnion_TAG_PERCENTAGE = 2;
constexpr static const uint8_t StyleLengthPercentageUnion_TAG_MASK = 3;
/// These are the limits that we choose to clamp grid line numbers to.
/// line_num is clamped to this range at parse time.
constexpr static const int32_t StyleMIN_GRID_LINE = -10000;
/// See above.
constexpr static const int32_t StyleMAX_GRID_LINE = 10000;
/// The minimum font-weight value per:
///
constexpr static const float StyleMIN_FONT_WEIGHT = 1.;
/// The maximum font-weight value per:
///
constexpr static const float StyleMAX_FONT_WEIGHT = 1000.;
///
/// Values less than -90deg or values greater than 90deg are
/// invalid and are treated as parse errors.
///
/// The maximum angle value that `font-style: oblique` should compute to.
constexpr static const float StyleFONT_STYLE_OBLIQUE_MAX_ANGLE_DEGREES = 90.;
/// The minimum angle value that `font-style: oblique` should compute to.
constexpr static const float StyleFONT_STYLE_OBLIQUE_MIN_ANGLE_DEGREES = -90.;
/// The default font size.
constexpr static const float StyleFONT_MEDIUM_PX = 16.0;
/// The default line height.
constexpr static const float StyleFONT_MEDIUM_LINE_HEIGHT_PX = (StyleFONT_MEDIUM_PX * 1.2);
/// Number of non-normal components
constexpr static const uint8_t StylePAINT_ORDER_COUNT = 3;
/// Number of bits for each component
constexpr static const uint8_t StylePAINT_ORDER_SHIFT = 2;
/// Mask with above bits set
constexpr static const uint8_t StylePAINT_ORDER_MASK = 3;
#if defined(CBINDGEN_IS_SERVO)
/// The number of eager pseudo-elements. Keep this in sync with cascade_type.
constexpr static const uintptr_t StyleEAGER_PSEUDO_COUNT = 3;
#endif
/// Whether @import rules are allowed.
enum class StyleAllowImportRules : uint8_t {
/// @import rules will be parsed.
Yes,
/// @import rules will not be parsed.
No,
};
/// Whether to allow negative lengths or not.
enum class StyleAllowedNumericType : uint8_t {
/// Allow all kind of numeric values.
All,
/// Allow only non-negative numeric values.
NonNegative,
/// Allow only numeric values greater or equal to 1.0.
AtLeastOne,
/// Allow only numeric values from 0 to 1.0.
ZeroToOne,
};
/// Keyword values for the anchor positioning function.
enum class StyleAnchorSideKeyword : uint8_t {
/// Inside relative (i.e. Same side) to the inset property it's used in.
Inside,
/// Same as above, but outside (i.e. Opposite side).
Outside,
/// Top of the anchor element.
Top,
/// Left of the anchor element.
Left,
/// Right of the anchor element.
Right,
/// Bottom of the anchor element.
Bottom,
/// Refers to the start side of the anchor element for the same axis of the inset
/// property it's used in, resolved against the positioned element's containing
/// block's writing mode.
Start,
/// Same as above, but for the end side.
End,
/// Same as `start`, resolved against the positioned element's writing mode.
SelfStart,
/// Same as above, but for the end side.
SelfEnd,
/// Halfway between `start` and `end` sides.
Center,
};
/// Keyword values for the anchor size function.
enum class StyleAnchorSizeKeyword : uint8_t {
/// Magic value for nothing.
None,
/// Width of the anchor element.
Width,
/// Height of the anchor element.
Height,
/// Block size of the anchor element.
Block,
/// Inline size of the anchor element.
Inline,
/// Same as `Block`, resolved against the positioned element's writing mode.
SelfBlock,
/// Same as `Inline`, resolved against the positioned element's writing mode.
SelfInline,
};
enum class StyleAnimationComposition : uint8_t {
Replace,
Add,
Accumulate,
};
enum class StyleAnimationDirection : uint8_t {
Normal,
Reverse,
Alternate,
AlternateReverse,
};
enum class StyleAnimationFillMode : uint8_t {
None,
Forwards,
Backwards,
Both,
};
enum class StyleAnimationPlayState : uint8_t {
Running,
Paused,
};
/// The value for the `appearance` property.
///
enum class StyleAppearance : uint8_t {
/// No appearance at all.
None,
/// Default appearance for the element.
///
/// This value doesn't make sense for -moz-default-appearance, but we don't bother to guard
/// against parsing it.
Auto,
/// A searchfield.
Searchfield,
/// A multi-line text field, e.g. HTML <textarea>.
Textarea,
/// A checkbox element.
Checkbox,
/// A radio element within a radio group.
Radio,
/// A dropdown list.
Menulist,
/// List boxes.
Listbox,
/// A horizontal meter bar.
Meter,
/// A horizontal progress bar.
ProgressBar,
/// A typical dialog button.
Button,
/// A single-line text field, e.g. HTML <input type=text>.
Textfield,
/// The dropdown button(s) that open up a dropdown list.
MenulistButton,
/// Various arrows that go in buttons
ButtonArrowDown,
ButtonArrowNext,
ButtonArrowPrevious,
ButtonArrowUp,
/// A dual toolbar button (e.g., a Back button with a dropdown)
Dualbutton,
/// Menu Popup background.
Menupopup,
/// The meter bar's meter indicator.
Meterchunk,
/// The "arrowed" part of the dropdown button that open up a dropdown list.
MozMenulistArrowButton,
/// For HTML's <input type=number>
NumberInput,
/// For HTML's <input type=password>
PasswordInput,
/// The progress bar's progress indicator
Progresschunk,
/// nsRangeFrame and its subparts
Range,
RangeThumb,
/// The scrollbar slider
ScrollbarHorizontal,
ScrollbarVertical,
/// A scrollbar button (up/down/left/right).
/// Keep these in order (some code casts these values to `int` in order to
/// compare them against each other).
ScrollbarbuttonUp,
ScrollbarbuttonDown,
ScrollbarbuttonLeft,
ScrollbarbuttonRight,
/// The scrollbar thumb.
ScrollbarthumbHorizontal,
ScrollbarthumbVertical,
/// The scroll corner
Scrollcorner,
/// A separator. Can be horizontal or vertical.
Separator,
/// A spin control (up/down control for time/date pickers).
Spinner,
/// The up button of a spin control.
SpinnerUpbutton,
/// The down button of a spin control.
SpinnerDownbutton,
/// The textfield of a spin control
SpinnerTextfield,
/// A splitter. Can be horizontal or vertical.
Splitter,
/// A status bar in a main application window.
Statusbar,
/// A single tab in a tab widget.
Tab,
/// A single pane (inside the tabpanels container).
Tabpanel,
/// The tab panels container.
Tabpanels,
/// The tabs scroll arrows (left/right).
TabScrollArrowBack,
TabScrollArrowForward,
/// A single toolbar button (with no associated dropdown).
Toolbarbutton,
/// The dropdown portion of a toolbar button
ToolbarbuttonDropdown,
/// A tooltip.
Tooltip,
/// Sidebar appearance.
MozSidebar,
/// Mac help button.
MozMacHelpButton,
/// An appearance value for the root, so that we can get tinting and unified toolbar looks
/// (which require a transparent gecko background) without really using the whole transparency
/// set-up which otherwise loses window borders, see bug 1870481.
MozMacWindow,
/// Windows themed window frame elements.
MozWindowButtonBox,
MozWindowButtonClose,
MozWindowButtonMaximize,
MozWindowButtonMinimize,
MozWindowButtonRestore,
MozWindowTitlebar,
MozWindowTitlebarMaximized,
MozWindowDecorations,
MozMacDisclosureButtonClosed,
MozMacDisclosureButtonOpen,
/// A themed focus outline (for outline:auto).
///
/// This isn't exposed to CSS at all, just here for convenience.
FocusOutline,
/// A dummy variant that should be last to let the GTK widget do hackery.
Count,
};
/// This indicates that the larger or smaller, respectively, of the two possible arcs must be
/// chosen.
enum class StyleArcSize : uint8_t {
/// Choose the small one. The default value. (This also represents 0 in the svg path.)
Small = 0,
/// Choose the large one. (This also represents 1 in the svg path.)
Large = 1,
};
/// This indicates that the arc that is traced around the ellipse clockwise or counter-clockwise
/// from the center.
enum class StyleArcSweep : uint8_t {
/// Counter-clockwise. The default value. (This also represents 0 in the svg path.)
Ccw = 0,
/// Clockwise. (This also represents 1 in the svg path.)
Cw = 1,
};
/// A specified value for the `baseline-source` property.
enum class StyleBaselineSource : uint8_t {
/// `Last` for `inline-block`, `First` otherwise.
Auto,
/// Use first baseline for alignment.
First,
/// Use last baseline for alignment.
Last,
};
/// Before flag, defined as per https://drafts.csswg.org/css-easing/#before-flag
/// This flag is never user-specified.
enum class StyleEasingBeforeFlag : uint8_t {
Unset,
Set,
};
/// A single border-image-repeat keyword.
enum class StyleBorderImageRepeatKeyword : uint8_t {
Stretch,
Repeat,
Round,
Space,
};
/// A specified value for a single side of a `border-style` property.
///
/// The order here corresponds to the integer values from the border conflict
/// resolution rules in CSS 2.1 § 17.6.2.1. Higher values override lower values.
enum class StyleBorderStyle : uint8_t {
Hidden,
None,
Inset,
Groove,
Outset,
Ridge,
Dotted,
Dashed,
Solid,
Double,
};
/// A kind of break between two boxes.
///
enum class StyleBreakBetween : uint8_t {
Always,
Auto,
Page,
Avoid,
Left,
Right,
};
/// A kind of break within a box.
///
enum class StyleBreakWithin : uint8_t {
Auto,
Avoid,
AvoidPage,
AvoidColumn,
};
/// This indicates the command is absolute or relative.
enum class StyleByTo : uint8_t {
/// This indicates that the <coordinate-pair>s are relative to the command’s starting point.
By,
/// This relative to the top-left corner of the reference box.
To,
};
/// Specified values for the `caption-side` property.
///
/// Note that despite having "physical" names, these are actually interpreted
/// according to the table's writing-mode: Top and Bottom are treated as
/// block-start and -end respectively.
///
enum class StyleCaptionSide : uint8_t {
Top,
Bottom,
};
/// Represents a channel keyword inside a color.
enum class StyleChannelKeyword : uint8_t {
/// alpha
Alpha,
/// a
A,
/// b, blackness, blue
B,
/// chroma
C,
/// green
G,
/// hue
H,
/// lightness
L,
/// red
R,
/// saturation
S,
/// whiteness
W,
/// x
X,
/// y
Y,
/// z
Z,
};
enum class StyleClear : uint8_t {
None,
Left,
Right,
Both,
InlineStart,
InlineEnd,
};
#if defined(CBINDGEN_IS_GECKO)
/// Values for the color-gamut media feature.
/// This implements PartialOrd so that lower values will correctly match
/// higher capabilities.
enum class StyleColorGamut : uint8_t {
#if defined(CBINDGEN_IS_GECKO)
/// The sRGB gamut.
Srgb,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// The gamut specified by the Display P3 Color Space.
P3,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// The gamut specified by the ITU-R Recommendation BT.2020 Color Space.
Rec2020,
#endif
};
#endif
/// A color space representation in the CSS specification.
///
enum class StyleColorSpace : uint8_t {
/// A color specified in the sRGB color space with either the rgb/rgba(..)
/// functions or the newer color(srgb ..) function. If the color(..)
/// function is used, the AS_COLOR_FUNCTION flag will be set. Examples:
/// "color(srgb 0.691 0.139 0.259)", "rgb(176, 35, 66)"
Srgb = 0,
/// A color specified in the Hsl notation in the sRGB color space, e.g.
/// "hsl(289.18 93.136% 65.531%)"
Hsl,
/// A color specified in the Hwb notation in the sRGB color space, e.g.
/// "hwb(740deg 20% 30%)"
Hwb,
/// A color specified in the Lab color format, e.g.
/// "lab(29.2345% 39.3825 20.0664)".
Lab,
/// A color specified in the Lch color format, e.g.
/// "lch(29.2345% 44.2 27)".
Lch,
/// A color specified in the Oklab color format, e.g.
/// "oklab(40.101% 0.1147 0.0453)".
Oklab,
/// A color specified in the Oklch color format, e.g.
/// "oklch(40.101% 0.12332 21.555)".
Oklch,
/// A color specified with the color(..) function and the "srgb-linear"
/// color space, e.g. "color(srgb-linear 0.435 0.017 0.055)".
SrgbLinear,
/// A color specified with the color(..) function and the "display-p3"
/// color space, e.g. "color(display-p3 0.84 0.19 0.72)".
DisplayP3,
/// A color specified with the color(..) function and the "a98-rgb" color
/// space, e.g. "color(a98-rgb 0.44091 0.49971 0.37408)".
A98Rgb,
/// A color specified with the color(..) function and the "prophoto-rgb"
/// color space, e.g. "color(prophoto-rgb 0.36589 0.41717 0.31333)".
ProphotoRgb,
/// A color specified with the color(..) function and the "rec2020" color
/// space, e.g. "color(rec2020 0.42210 0.47580 0.35605)".
Rec2020,
/// A color specified with the color(..) function and the "xyz-d50" color
/// space, e.g. "color(xyz-d50 0.2005 0.14089 0.4472)".
XyzD50,
/// A color specified with the color(..) function and the "xyz-d65" or "xyz"
/// color space, e.g. "color(xyz-d65 0.21661 0.14602 0.59452)".
/// specifies that `xyz` is an alias for the `xyz-d65` color space.
XyzD65,
};
enum class StyleContainerType : uint8_t {
/// The `normal` variant.
Normal,
/// The `inline-size` variant.
InlineSize,
/// The `size` variant.
Size,
};
enum class StyleContentVisibility : uint8_t {
/// `auto` variant, the element turns on layout containment, style containment, and paint
/// containment. In addition, if the element is not relevant to the user (such as by being
/// offscreen) it also skips its content
Auto,
/// `hidden` variant, the element skips its content
Hidden,
/// 'visible' variant, no effect
Visible,
};
/// The <coord-box> value, which defines the box that the <offset-path> sizes into.
///
/// <coord-box> = content-box | padding-box | border-box | fill-box | stroke-box | view-box
enum class StyleCoordBox : uint8_t {
ContentBox,
PaddingBox,
BorderBox,
FillBox,
StrokeBox,
ViewBox,
};
/// The CORS mode used for a CSS load.
enum class StyleCorsMode : uint8_t {
/// No CORS mode, so cross-origin loads can be done.
None,
/// Anonymous CORS request.
Anonymous,
};
enum class StyleCounterSystem : uint8_t {
Cyclic = 0,
Numeric,
Alphabetic,
Symbolic,
Additive,
Fixed,
Extends,
};
enum class StyleCssRuleType : uint8_t {
Style = 1,
Import = 3,
Media = 4,
FontFace = 5,
Page = 6,
Keyframes = 7,
Keyframe = 8,
Margin = 9,
Namespace = 10,
CounterStyle = 11,
Supports = 12,
Document = 13,
FontFeatureValues = 14,
LayerBlock = 16,
LayerStatement = 17,
Container = 18,
FontPaletteValues = 19,
Property = 20,
Scope = 21,
StartingStyle = 22,
PositionTry = 23,
NestedDeclarations = 24,
};
/// The keywords allowed in the Cursor property.
///
enum class StyleCursorKind : uint8_t {
None,
Default,
Pointer,
ContextMenu,
Help,
Progress,
Wait,
Cell,
Crosshair,
Text,
VerticalText,
Alias,
Copy,
Move,
NoDrop,
NotAllowed,
Grab,
Grabbing,
EResize,
NResize,
NeResize,
NwResize,
SResize,
SeResize,
SwResize,
WResize,
EwResize,
NsResize,
NeswResize,
NwseResize,
ColResize,
RowResize,
AllScroll,
ZoomIn,
ZoomOut,
Auto,
};
enum class StyleDisplayInside : uint8_t {
None = 0,
Contents,
Flow,
FlowRoot,
Flex,
Grid,
Table,
TableRowGroup,
TableColumn,
TableColumnGroup,
TableHeaderGroup,
TableFooterGroup,
TableRow,
TableCell,
#if defined(CBINDGEN_IS_GECKO)
Ruby,
#endif
#if defined(CBINDGEN_IS_GECKO)
RubyBase,
#endif
#if defined(CBINDGEN_IS_GECKO)
RubyBaseContainer,
#endif
#if defined(CBINDGEN_IS_GECKO)
RubyText,
#endif
#if defined(CBINDGEN_IS_GECKO)
RubyTextContainer,
#endif
#if defined(CBINDGEN_IS_GECKO)
WebkitBox,
#endif
};
#if defined(CBINDGEN_IS_GECKO)
/// Values for the display-mode media feature.
enum class StyleDisplayMode : uint8_t {
#if defined(CBINDGEN_IS_GECKO)
Browser = 0,
#endif
#if defined(CBINDGEN_IS_GECKO)
MinimalUi,
#endif
#if defined(CBINDGEN_IS_GECKO)
Standalone,
#endif
#if defined(CBINDGEN_IS_GECKO)
Fullscreen,
#endif
};
#endif
/// Defines an element’s display type, which consists of
/// the two basic qualities of how an element generates boxes
enum class StyleDisplayOutside : uint8_t {
None = 0,
Inline,
Block,
TableCaption,
InternalTable,
#if defined(CBINDGEN_IS_GECKO)
InternalRuby,
#endif
};
#if defined(CBINDGEN_IS_GECKO)
/// Values for the dynamic-range and video-dynamic-range media features.
/// This implements PartialOrd so that lower values will correctly match
/// higher capabilities.
enum class StyleDynamicRange : uint8_t {
#if defined(CBINDGEN_IS_GECKO)
Standard,
#endif
#if defined(CBINDGEN_IS_GECKO)
High,
#endif
};
#endif
enum class StyleFillRule : uint8_t {
Nonzero,
Evenodd,
};
enum class StyleFloat : uint8_t {
Left,
Right,
None,
InlineStart,
InlineEnd,
};
/// A font-display value for a @font-face rule.
/// The font-display descriptor determines how a font face is displayed based
/// on whether and when it is downloaded and ready to use.
enum class StyleFontDisplay : uint8_t {
Auto,
Block,
Swap,
Fallback,
Optional,
};
/// Keywords for the font-face src descriptor's format() function.
/// ('None' and 'Unknown' are for internal use in gfx, not exposed to CSS.)
enum class StyleFontFaceSourceFormatKeyword : uint8_t {
None,
Collection,
EmbeddedOpentype,
Opentype,
Svg,
Truetype,
Woff,
Woff2,
Unknown,
};
/// Font family names must either be given quoted as strings,
/// or unquoted as a sequence of one or more identifiers.
enum class StyleFontFamilyNameSyntax : uint8_t {
/// The family name was specified in a quoted form, e.g. "Font Name"
/// or 'Font Name'.
Quoted,
/// The family name was specified in an unquoted form as a sequence of
/// identifiers.
Identifiers,
};
/// CSS font keywords
enum class StyleFontSizeKeyword : uint8_t {
XXSmall,
XSmall,
Small,
Medium,
Large,
XLarge,
XXLarge,
XXXLarge,
#if defined(CBINDGEN_IS_GECKO)
/// Indicate whether to apply font-size: math is specified so that extra
/// scaling due to math-depth changes is applied during the cascade.
Math,
#endif
None,
};
/// A value for any of the font-synthesis-{weight,style,small-caps} properties.
enum class StyleFontSynthesis : uint8_t {
/// This attribute may be synthesized if not supported by a face.
Auto,
/// Do not attempt to synthesis this style attribute.
None,
};
enum class StyleForcedColorAdjust : uint8_t {
/// Adjust colors if needed.
Auto,
/// Respect specified colors.
None,
};
/// Possible values for the forced-colors media query.
enum class StyleForcedColors : uint8_t {
/// Page colors are not being forced.
None,
/// Page colors would be forced in content.
Requested,
/// Page colors are being forced.
Active,
};
/// A generic font-family name.
///
/// The order here is important, if you change it make sure that
/// `gfxPlatformFontList.h`s ranged array and `gfxFontFamilyList`'s
/// sSingleGenerics are updated as well.
///
/// NOTE(emilio): Should be u8, but it's a u32 because of ABI issues between GCC
enum class StyleGenericFontFamily : uint32_t {
/// No generic family specified, only for internal usage.
///
/// NOTE(emilio): Gecko code relies on this variant being zero.
None = 0,
Serif,
SansSerif,
Monospace,
Cursive,
Fantasy,
SystemUi,
#if defined(CBINDGEN_IS_GECKO)
/// An internal value for emoji font selection.
MozEmoji,
#endif
};
/// Whether we used the modern notation or the compatibility `-webkit`, `-moz` prefixes.
enum class StyleGradientCompatMode : uint8_t {
/// Modern syntax.
Modern,
/// `-webkit` prefix.
WebKit,
/// `-moz` prefix
Moz,
};
#if defined(CBINDGEN_IS_GECKO)
/// Allows front-end CSS to discern gtk theme via media queries.
enum class StyleGtkThemeFamily : uint8_t {
#if defined(CBINDGEN_IS_GECKO)
/// Unknown theme family.
Unknown = 0,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// Adwaita, the default GTK theme.
Adwaita,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// Breeze, the default KDE theme.
Breeze,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// Yaru, the default Ubuntu theme.
Yaru,
#endif
};
#endif
/// A keyword for the X direction.
enum class StyleHorizontalPositionKeyword : uint8_t {
Left,
Right,
};
/// A hue-interpolation-method as defined in [1].
///
};
enum class StyleImageRendering : uint8_t {
Auto,
#if defined(CBINDGEN_IS_GECKO)
Smooth,
#endif
CrispEdges,
Pixelated,
#if defined(CBINDGEN_IS_GECKO)
Optimizespeed,
#endif
#if defined(CBINDGEN_IS_GECKO)
Optimizequality,
#endif
};
/// Internal property to represent the inert attribute state:
enum class StyleInert : uint8_t {
None,
Inert,
};
enum class StyleIsOrdinalInRange : uint8_t {
Auto,
InRange,
NotInRange,
NoOrdinalSpecified,
};
/// Values for the `line-break` property.
enum class StyleLineBreak : uint8_t {
Auto,
Loose,
Normal,
Strict,
Anywhere,
};
/// Masonry auto-placement algorithm item sorting option.
enum class StyleMasonryItemOrder : uint8_t {
/// Place all items with a definite placement before auto-placed items.
DefiniteFirst,
/// Place items in `order-modified document order`.
Ordered,
};
/// Masonry auto-placement algorithm packing.
enum class StyleMasonryPlacement : uint8_t {
/// Place the item in the track(s) with the smallest extent so far.
Pack,
/// Place the item after the last item, from start to end.
Next,
};
/// Whether we're a `min` or `max` function.
enum class StyleMinMaxOp : uint8_t {
/// `min()`
Min,
/// `max()`
Max,
};
/// Whether we're a `mod` or `rem` function.
enum class StyleModRemOp : uint8_t {
/// `mod()`
Mod,
/// `rem()`
Rem,
};
/// Values for the `-moz-control-character-visibility` CSS property.
enum class StyleMozControlCharacterVisibility : uint8_t {
Hidden,
Visible,
};
/// The keywords allowed in the -moz-theme property.
enum class StyleMozTheme : uint8_t {
/// Choose the default (maybe native) rendering.
Auto,
/// Choose the non-native rendering.
NonNative,
};
/// Each style rule has an origin, which determines where it enters the cascade.
///
};
/// The value for the `overflow-x` / `overflow-y` properties.
enum class StyleOverflow : uint8_t {
Visible,
Hidden,
Scroll,
Auto,
#if defined(CBINDGEN_IS_GECKO)
Clip,
#endif
};
enum class StyleOverflowAnchor : uint8_t {
Auto,
None,
};
enum class StyleOverflowClipBox : uint8_t {
PaddingBox,
ContentBox,
};
/// Values for the `overflow-wrap` property.
enum class StyleOverflowWrap : uint8_t {
Normal,
BreakWord,
Anywhere,
};
enum class StyleOverscrollBehavior : uint8_t {
Auto,
Contain,
None,
};
/// Page orientation names.
///
enum class StylePageOrientation : uint8_t {
/// upright
Upright,
/// rotate-left (counter-clockwise)
RotateLeft,
/// rotate-right (clockwise)
RotateRight,
};
/// Paper orientation
///
enum class StylePageSizeOrientation : uint8_t {
/// Portrait orientation
Portrait,
/// Landscape orientation
Landscape,
};
/// The specified value for a single CSS paint-order property.
enum class StylePaintOrder : uint8_t {
/// `normal` variant
Normal = 0,
/// `fill` variant
Fill = 1,
/// `stroke` variant
Stroke = 2,
/// `markers` variant
Markers = 3,
};
#if defined(CBINDGEN_IS_GECKO)
/// Allows front-end CSS to discern platform via media queries.
enum class StylePlatform : uint8_t {
#if defined(CBINDGEN_IS_GECKO)
/// Matches any Android version.
Android,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// For our purposes here, "linux" is just "gtk" (so unix-but-not-mac).
/// There's no need for our front-end code to differentiate between those
/// platforms and they already use the "linux" string elsewhere (e.g.,
/// toolkit/themes/linux).
Linux,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// Matches any iOS version.
Ios,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// Matches any macOS version.
Macos,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// Matches any Windows version.
Windows,
#endif
};
#endif
/// The pointer-events property
enum class StylePointerEvents : uint8_t {
Auto,
None,
#if defined(CBINDGEN_IS_GECKO)
Visiblepainted,
#endif
#if defined(CBINDGEN_IS_GECKO)
Visiblefill,
#endif
#if defined(CBINDGEN_IS_GECKO)
Visiblestroke,
#endif
#if defined(CBINDGEN_IS_GECKO)
Visible,
#endif
#if defined(CBINDGEN_IS_GECKO)
Painted,
#endif
#if defined(CBINDGEN_IS_GECKO)
Fill,
#endif
#if defined(CBINDGEN_IS_GECKO)
Stroke,
#endif
#if defined(CBINDGEN_IS_GECKO)
All,
#endif
};
/// Possible values for the `position-area` preperty's keywords.
enum class StylePositionAreaKeyword : uint8_t {
None,
Center,
SpanAll,
Left,
Right,
SpanLeft,
SpanRight,
XStart,
XEnd,
SpanXStart,
SpanXEnd,
XSelfStart,
XSelfEnd,
SpanXSelfStart,
SpanXSelfEnd,
Top,
Bottom,
SpanTop,
SpanBottom,
YStart,
YEnd,
SpanYStart,
SpanYEnd,
YSelfStart,
YSelfEnd,
SpanYSelfStart,
SpanYSelfEnd,
BlockStart,
BlockEnd,
SpanBlockStart,
SpanBlockEnd,
InlineStart,
InlineEnd,
SpanInlineStart,
SpanInlineEnd,
SelfBlockStart,
SelfBlockEnd,
SpanSelfBlockStart,
SpanSelfBlockEnd,
SelfInlineStart,
SelfInlineEnd,
SpanSelfInlineStart,
SpanSelfInlineEnd,
Start,
End,
SpanStart,
SpanEnd,
SelfStart,
SelfEnd,
SpanSelfStart,
SpanSelfEnd,
};
/// How to swap values for the automatically-generated position tactic.
enum class StylePositionTryFallbacksTryTacticKeyword : uint8_t {
/// Magic value for no change.
None,
/// Swap the values in the block axis.
FlipBlock,
/// Swap the values in the inline axis.
FlipInline,
/// Swap the values in the start properties.
FlipStart,
};
enum class StylePositionTryOrder : uint8_t {
/// `normal`
Normal,
/// `most-width`
MostWidth,
/// `most-height`
MostHeight,
/// `most-block-size`
MostBlockSize,
/// `most-inline-size`
MostInlineSize,
};
#if defined(CBINDGEN_IS_GECKO)
/// Values for the prefers-color-scheme media feature.
enum class StylePrefersColorScheme : uint8_t {
#if defined(CBINDGEN_IS_GECKO)
Light,
#endif
#if defined(CBINDGEN_IS_GECKO)
Dark,
#endif
};
#endif
#if defined(CBINDGEN_IS_GECKO)
/// Possible values for prefers-contrast media query.
enum class StylePrefersContrast : uint8_t {
#if defined(CBINDGEN_IS_GECKO)
/// More contrast is preferred.
More,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// Low contrast is preferred.
Less,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// Custom (not more, not less).
Custom,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// The default value if neither high or low contrast is enabled.
NoPreference,
#endif
};
#endif
enum class StylePrintColorAdjust : uint8_t {
/// Ignore backgrounds and darken text.
Economy,
/// Respect specified colors.
Exact,
};
/// The <size> in ray() function.
///
enum class StyleRaySize : uint8_t {
ClosestSide,
ClosestCorner,
FarthestSide,
FarthestCorner,
Sides,
};
enum class StyleRegisterCustomPropertyResult : uint8_t {
SuccessfullyRegistered,
InvalidName,
AlreadyRegistered,
InvalidSyntax,
NoInitialValue,
InvalidInitialValue,
InitialValueNotComputationallyIndependent,
};
/// Which edge side should the invalidation run for?
enum class StyleRelativeSelectorNthEdgeInvalidateFor : uint8_t {
First,
Last,
};
/// A computed value for the `resize` property.
enum class StyleResize : uint8_t {
None,
Both,
Horizontal,
Vertical,
};
/// The strategy used in `round()`
enum class StyleRoundingStrategy : uint8_t {
/// `round(nearest, a, b)`
/// round a to the nearest multiple of b
Nearest,
/// `round(up, a, b)`
/// round a up to the nearest multiple of b
Up,
/// `round(down, a, b)`
/// round a down to the nearest multiple of b
Down,
/// `round(to-zero, a, b)`
/// round a to the nearest multiple of b that is towards zero
ToZero,
};
/// Values for `ruby-position` property
enum class StyleRubyPosition : uint8_t {
AlternateOver,
AlternateUnder,
Over,
Under,
};
/// The kind of change that happened for a given rule.
enum class StyleRuleChangeKind : uint32_t {
/// Some change in the rule which we don't know about, and could have made
/// the rule change in any way.
Generic = 0,
/// The rule was inserted.
Insertion,
/// The rule was removed.
Removal,
/// A change in the declarations of a style rule.
StyleRuleDeclarations,
};
/// The kind of sanitization to use when parsing a stylesheet.
enum class StyleSanitizationKind : uint8_t {
/// Perform no sanitization.
None,
/// Allow only @font-face, style rules, and @namespace.
Standard,
/// Allow everything but conditional rules.
NoConditionalRules,
};
#if defined(CBINDGEN_IS_GECKO)
/// Values for the scripting media feature.
enum class StyleScripting : uint8_t {
#if defined(CBINDGEN_IS_GECKO)
/// Scripting is not supported or not enabled
None,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// Scripting is supported and enabled, but only for initial page load
/// We will never match this value as it is intended for non-browser user agents,
/// but it is part of the spec so we should still parse it.
InitialOnly,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// Scripting is supported and enabled
Enabled,
#endif
};
#endif
/// A value for the <Axis> used in scroll(), or a value for {scroll|view}-timeline-axis.
///
enum class StyleScrollAxis : uint8_t {
/// The block axis of the scroll container. (Default.)
Block = 0,
/// The inline axis of the scroll container.
Inline = 1,
/// The horizontal axis of the scroll container.
X = 2,
/// The vertical axis of the scroll container.
Y = 3,
};
/// Specified value of scroll-snap-align keyword value.
enum class StyleScrollSnapAlignKeyword : uint8_t {
None,
Start,
End,
Center,
};
enum class StyleScrollSnapAxis : uint8_t {
X,
Y,
Block,
Inline,
Both,
};
enum class StyleScrollSnapStop : uint8_t {
Normal,
Always,
};
enum class StyleScrollSnapStrictness : uint8_t {
None,
Mandatory,
Proximity,
};
/// A value for the <Scroller> used in scroll().
///
enum class StyleScroller : uint8_t {
/// The nearest ancestor scroll container. (Default.)
Nearest,
/// The document viewport as the scroll container.
Root,
/// Specifies to use the element’s own principal box as the scroll container.
SelfElement,
};
/// Any warning a selector may generate.
/// TODO(dshin): Bug 1860634 - Merge with never matching host selector warning, which is part of the rule parser.
enum class StyleSelectorWarningKind : uint8_t {
/// Relative Selector with not enough constraint, either outside or inside the selector. e.g. `*:has(.a)`, `.a:has(*)`.
/// May cause expensive invalidations for every element inserted and/or removed.
UnconstraintedRelativeSelector,
};
enum class StyleShapeBox : uint8_t {
MarginBox,
BorderBox,
PaddingBox,
ContentBox,
};
enum class StyleShapeExtent : uint8_t {
ClosestSide,
FarthestSide,
ClosestCorner,
FarthestCorner,
Contain,
Cover,
};
enum class StyleStepPosition : uint8_t {
JumpStart,
JumpEnd,
JumpNone,
JumpBoth,
Start,
End,
};
enum class StyleSymbolsType : uint8_t {
Cyclic,
Numeric,
Alphabetic,
Symbolic,
Fixed,
};
#if defined(CBINDGEN_IS_GECKO)
/// System colors. A bunch of these are ad-hoc, others come from Windows:
///
///
/// Others are HTML/CSS specific. Spec is:
///
enum class StyleSystemColor : uint8_t {
Activeborder,
/// Background in the (active) titlebar.
Activecaption,
Appworkspace,
Background,
Buttonface,
Buttonhighlight,
Buttonshadow,
Buttontext,
Buttonborder,
/// Text color in the (active) titlebar.
Captiontext,
Field,
/// Used for disabled field backgrounds.
MozDisabledfield,
Fieldtext,
Mark,
Marktext,
/// Combobox widgets
MozComboboxtext,
MozCombobox,
Graytext,
Highlight,
Highlighttext,
Inactiveborder,
/// Background in the (inactive) titlebar.
Inactivecaption,
/// Text color in the (inactive) titlebar.
Inactivecaptiontext,
Infobackground,
Infotext,
Menu,
Menutext,
Scrollbar,
Threeddarkshadow,
Threedface,
Threedhighlight,
Threedlightshadow,
Threedshadow,
Window,
Windowframe,
Windowtext,
Canvastext,
Canvas,
MozDialog,
MozDialogtext,
/// Used for selected but not focused cell backgrounds.
MozCellhighlight,
/// Used for selected but not focused cell text.
MozCellhighlighttext,
/// Used for selected and focused html cell backgrounds.
Selecteditem,
/// Used for selected and focused html cell text.
Selecteditemtext,
/// Used to button text background when hovered.
MozButtonhoverface,
/// Used to button text color when hovered.
MozButtonhovertext,
/// Used for menu item backgrounds when hovered.
MozMenuhover,
/// Used for menu item backgrounds when hovered and disabled.
MozMenuhoverdisabled,
/// Used for menu item text when hovered.
MozMenuhovertext,
/// Used for menubar item text when hovered.
MozMenubarhovertext,
/// On platforms where these colors are the same as -moz-field, use
/// -moz-fieldtext as foreground color
MozEventreerow,
MozOddtreerow,
/// Used for button text when pressed.
MozButtonactivetext,
/// Used for button background when pressed.
MozButtonactiveface,
/// Used for button background when disabled.
MozButtondisabledface,
/// Colors used for the header bar (sorta like the tab bar / menubar).
MozHeaderbar,
MozHeaderbartext,
MozHeaderbarinactive,
MozHeaderbarinactivetext,
/// Foreground color of default buttons.
MozMacDefaultbuttontext,
/// Ring color around text fields and lists.
MozMacFocusring,
/// Text color of disabled text on toolbars.
MozMacDisabledtoolbartext,
/// The background of a sidebar.
MozSidebar,
/// The foreground color of a sidebar.
MozSidebartext,
/// The border color of a sidebar.
MozSidebarborder,
/// Theme accent color.
Accentcolor,
/// Foreground for the accent color.
Accentcolortext,
/// The background-color for :autofill-ed inputs.
MozAutofillBackground,
/// Hyperlink color extracted from the system, not affected by the browser.anchor_color user
/// pref.
///
/// There is no OS-specified safe background color for this text, but it is used regularly
/// within Windows and the Gnome DE on Dialog and Window colors.
MozNativehyperlinktext,
/// As above, but visited link color.
MozNativevisitedhyperlinktext,
Linktext,
Activetext,
Visitedtext,
/// Color of tree column headers
MozColheader,
MozColheadertext,
MozColheaderhover,
MozColheaderhovertext,
MozColheaderactive,
MozColheaderactivetext,
TextSelectDisabledBackground,
TextSelectAttentionBackground,
TextSelectAttentionForeground,
TextHighlightBackground,
TextHighlightForeground,
TargetTextBackground,
TargetTextForeground,
IMERawInputBackground,
IMERawInputForeground,
IMERawInputUnderline,
IMESelectedRawTextBackground,
IMESelectedRawTextForeground,
IMESelectedRawTextUnderline,
IMEConvertedTextBackground,
IMEConvertedTextForeground,
IMEConvertedTextUnderline,
IMESelectedConvertedTextBackground,
IMESelectedConvertedTextForeground,
IMESelectedConvertedTextUnderline,
SpellCheckerUnderline,
ThemedScrollbar,
ThemedScrollbarInactive,
ThemedScrollbarThumb,
ThemedScrollbarThumbHover,
ThemedScrollbarThumbActive,
ThemedScrollbarThumbInactive,
End,
};
#endif
#if defined(CBINDGEN_IS_GECKO)
/// System fonts.
enum class StyleSystemFont : uint8_t {
Caption,
Icon,
Menu,
MessageBox,
SmallCaption,
StatusBar,
/// Internal system font, used by the `<menupopup>`s on macOS.
MozPullDownMenu,
/// Internal system font, used for `<button>` elements.
MozButton,
/// Internal font, used by `<select>` elements.
MozList,
/// Internal font, used by `<input>` elements.
MozField,
End,
};
#endif
/// Specified value of text-align keyword value.
enum class StyleTextAlignKeyword : uint8_t {
Start,
Left,
Right,
Center,
Justify,
End,
MozCenter,
MozLeft,
MozRight,
};
/// Specified and computed value of text-align-last.
enum class StyleTextAlignLast : uint8_t {
Auto,
Start,
End,
Left,
Right,
Center,
Justify,
};
/// Implements text-decoration-skip-ink which takes the keywords auto | none | all
///
enum class StyleTextDecorationSkipInk : uint8_t {
Auto,
None,
All,
};
/// Fill mode for the text-emphasis-style property
enum class StyleTextEmphasisFillMode : uint8_t {
/// `filled`
Filled,
/// `open`
Open,
};
/// Shape keyword for the text-emphasis-style property
enum class StyleTextEmphasisShapeKeyword : uint8_t {
/// `dot`
Dot,
/// `circle`
Circle,
/// `double-circle`
DoubleCircle,
/// `triangle`
Triangle,
/// `sesame`
Sesame,
};
/// Values for the `text-justify` CSS property.
enum class StyleTextJustify : uint8_t {
Auto,
None,
InterWord,
InterCharacter,
};
enum class StyleTimingKeyword : uint8_t {
Linear,
Ease,
EaseIn,
EaseOut,
EaseInOut,
};
/// The specified value of `transform-box`.
enum class StyleTransformBox : uint8_t {
ContentBox,
BorderBox,
FillBox,
StrokeBox,
ViewBox,
};
enum class StyleTransformStyle : uint8_t {
Flat,
Preserve3d,
};
/// A specified value for <transition-behavior-value>.
///
enum class StyleTransitionBehavior : uint8_t {
/// Transitions will not be started for discrete properties, only for interpolable properties.
Normal,
/// Transitions will be started for discrete properties as well as interpolable properties.
AllowDiscrete,
};
/// Internal -moz-user-focus property.
enum class StyleUserFocus : uint8_t {
Normal,
None,
Ignore,
};
/// Non-standard user-input property.
enum class StyleUserInput : uint8_t {
Auto,
None,
};
/// The specified value for the `user-select` property.
///
enum class StyleUserSelect : uint8_t {
Auto,
Text,
None,
/// Force selection of all children.
All,
};
enum class StyleVerticalAlignKeyword : uint8_t {
Baseline,
Sub,
Super,
Top,
TextTop,
Middle,
Bottom,
TextBottom,
#if defined(CBINDGEN_IS_GECKO)
MozMiddleWithBaseline,
#endif
};
/// A keyword for the Y direction.
enum class StyleVerticalPositionKeyword : uint8_t {
Top,
Bottom,
};
/// Values for the `word-break` property.
enum class StyleWordBreak : uint8_t {
Normal,
BreakAll,
KeepAll,
#if defined(CBINDGEN_IS_GECKO)
/// The break-word value, needed for compat.
///
/// Specifying `word-break: break-word` makes `overflow-wrap` behave as
/// `anywhere`, and `word-break` behave like `normal`.
BreakWord,
#endif
};
/// How to do font-size scaling.
enum class StyleXTextScale : uint8_t {
/// Both min-font-size and text zoom are enabled.
All,
/// Text-only zoom is enabled, but min-font-size is not honored.
ZoomOnly,
/// Neither of them is enabled.
None,
};
#if defined(CBINDGEN_IS_GECKO)
/// Gecko-FFI-safe Arc (T is an ArcInner).
///
/// This can be null.
///
/// Leaks on drop. Please don't drop this.
template<typename GeckoType>
struct StyleStrong {
const GeckoType *ptr;
bool operator==(const StyleStrong& other) const {
return ptr == other.ptr;
}
bool operator!=(const StyleStrong& other) const {
return ptr != other.ptr;
}
already_AddRefed<GeckoType> Consume() {
already_AddRefed<GeckoType> ret(const_cast<GeckoType*>(ptr));
ptr = nullptr;
return ret;
}
};
#endif
/// A CSS float value.
using StyleCSSFloat = float;
/// A `<number>` value.
using StyleNumber = StyleCSSFloat;
/// A value of the `Scale` property
///
template<typename Number>
struct StyleGenericScale {
enum class Tag : uint8_t {
/// 'none'
None,
/// '<number>{1,3}'
Scale,
};
struct StyleScale_Body {
Number _0;
Number _1;
Number _2;
bool operator==(const StyleScale_Body& other) const {
return _0 == other._0 &&
_1 == other._1 &&
_2 == other._2;
}
bool operator!=(const StyleScale_Body& other) const {
return _0 != other._0 ||
_1 != other._1 ||
_2 != other._2;
}
};
Tag tag;
union {
StyleScale_Body scale;
};
static StyleGenericScale None() {
StyleGenericScale result;
result.tag = Tag::None;
return result;
}
bool IsNone() const {
return tag == Tag::None;
}
static StyleGenericScale Scale(const Number &_0,
const Number &_1,
const Number &_2) {
StyleGenericScale result;
::new (&result.scale._0) (Number)(_0);
::new (&result.scale._1) (Number)(_1);
::new (&result.scale._2) (Number)(_2);
result.tag = Tag::Scale;
return result;
}
bool IsScale() const {
return tag == Tag::Scale;
}
const StyleScale_Body& AsScale() const {
MOZ_DIAGNOSTIC_ASSERT(IsScale());
return scale;
}
bool operator==(const StyleGenericScale& other) const {
if (tag != other.tag) {
return false;
}
switch (tag) {
case Tag::Scale: return scale == other.scale;
default: break;
}
return true;
}
bool operator!=(const StyleGenericScale& other) const {
return !(*this == other);
}
private:
StyleGenericScale() {
}
public:
~StyleGenericScale() {
switch (tag) {
case Tag::Scale: scale.~StyleScale_Body(); break;
default: break;
}
}
StyleGenericScale(const StyleGenericScale& other)
: tag(other.tag) {
switch (tag) {
case Tag::Scale: ::new (&scale) (StyleScale_Body)(other.scale); break;
default: break;
}
}
StyleGenericScale& operator=(const StyleGenericScale& other) {
if (this != &other) {
this->~StyleGenericScale();
new (this) StyleGenericScale(other);
}
return *this;
}
};
/// A computed CSS `scale`
using StyleScale = StyleGenericScale<StyleNumber>;
/// The computed `<length>` value.
struct StyleCSSPixelLength {
StyleCSSFloat _0;
bool operator==(const StyleCSSPixelLength& other) const {
return _0 == other._0;
}
bool operator!=(const StyleCSSPixelLength& other) const {
return _0 != other._0;
}
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;
};
/// An alias of computed `<length>` value.
using StyleLength = StyleCSSPixelLength;
struct StyleLengthVariant {
uint8_t tag;
StyleLength length;
bool operator==(const StyleLengthVariant& other) const {
return tag == other.tag &&
length == other.length;
}
bool operator!=(const StyleLengthVariant& other) const {
return tag != other.tag ||
length != other.length;
}
};
/// A computed percentage.
struct StylePercentage {
StyleCSSFloat _0;
bool operator==(const StylePercentage& other) const {
return _0 == other._0;
}
bool operator!=(const StylePercentage& other) const {
return _0 != other._0;
}
};
struct StylePercentageVariant {
uint8_t tag;
StylePercentage percentage;
bool operator==(const StylePercentageVariant& other) const {
return tag == other.tag &&
percentage == other.percentage;
}
bool operator!=(const StylePercentageVariant& other) const {
return tag != other.tag ||
percentage != other.percentage;
}
};
#if defined(SERVO_32_BITS)
struct StyleCalcVariant {
uint8_t tag;
void *ptr;
bool operator==(const StyleCalcVariant& other) const {
return tag == other.tag &&
ptr == other.ptr;
}
bool operator!=(const StyleCalcVariant& other) const {
return tag != other.tag ||
ptr != other.ptr;
}
};
#endif
#if defined(HAVE_64BIT_BUILD)
struct StyleCalcVariant {
uintptr_t ptr;
bool operator==(const StyleCalcVariant& other) const {
return ptr == other.ptr;
}
bool operator!=(const StyleCalcVariant& other) const {
return ptr != other.ptr;
}
};
#endif
struct StyleTagVariant {
uint8_t tag;
bool operator==(const StyleTagVariant& other) const {
return tag == other.tag;
}
bool operator!=(const StyleTagVariant& other) const {
return tag != other.tag;
}
};
union StyleLengthPercentageUnion {
StyleLengthVariant length;
StylePercentageVariant percentage;
StyleCalcVariant calc;
StyleTagVariant tag;
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;
};
/// A `<length-percentage>` value. This can be either a `<length>`, a
/// `<percentage>`, or a combination of both via `calc()`.
///
///
///
/// The tag is stored in the lower two bits.
///
/// We need to use a struct instead of the union directly because unions with
/// Drop implementations are unstable, looks like.
///
/// Also we need the union and the variants to be `pub` (even though the member
/// is private) so that cbindgen generates it. They're not part of the public
/// API otherwise.
using StyleLengthPercentage = StyleLengthPercentageUnion;
/// A value of the `translate` property
///
///
/// If a 2d translation is specified, the property must serialize with only one
/// or two values (per usual, if the second value is 0px, the default, it must
/// be omitted when serializing; however if 0% is the second value, it is included).
///
/// If a 3d translation is specified and the value can be expressed as 2d, we treat as 2d and
/// serialize accoringly. Otherwise, we serialize all three values.
///
template<typename LengthPercentage, typename Length>
struct StyleGenericTranslate {
enum class Tag : uint8_t {
/// 'none'
None,
/// <length-percentage> [ <length-percentage> <length>? ]?
Translate,
};
struct StyleTranslate_Body {
LengthPercentage _0;
LengthPercentage _1;
Length _2;
bool operator==(const StyleTranslate_Body&