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
// Work-around silly windows.h define.
#pragma push_macro("STRICT")
#undef STRICT
#ifndef mozilla_ServoStyleConsts_h
#define mozilla_ServoStyleConsts_h
/* Generated with cbindgen:0.14.3 */
/* 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 <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <new>
#include "mozilla/ServoStyleConstsForwards.h"
#include "mozilla/ServoStyleSet.h"
namespace mozilla {
/// The default angle for `font-style: oblique`.
///
/// NOTE(emilio): As of right now this diverges from the spec, which specifies
/// 20, because it's not updated yet to account for the resolution in:
///
static const float StyleDEFAULT_FONT_STYLE_OBLIQUE_ANGLE_DEGREES = 14.;
#if defined(CBINDGEN_IS_SERVO)
/// The number of eager pseudo-elements. Keep this in sync with cascade_type.
static const uintptr_t StyleEAGER_PSEUDO_COUNT = 3;
#endif
/// The default font size.
static const float StyleFONT_MEDIUM_PX = 16.0;
///
/// 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.
static const float StyleFONT_STYLE_OBLIQUE_MAX_ANGLE_DEGREES = 90.;
/// The minimum angle value that `font-style: oblique` should compute to.
static const float StyleFONT_STYLE_OBLIQUE_MIN_ANGLE_DEGREES = -90.;
/// The maximum font-weight value per:
///
static const float StyleMAX_FONT_WEIGHT = 1000.;
/// See above.
static const int32_t StyleMAX_GRID_LINE = 10000;
/// The minimum font-weight value per:
///
static const float StyleMIN_FONT_WEIGHT = 1.;
/// These are the limits that we choose to clamp grid line numbers to.
/// line_num is clamped to this range at parse time.
static const int32_t StyleMIN_GRID_LINE = -10000;
/// Number of non-normal components
static const uint8_t StylePAINT_ORDER_COUNT = 3;
/// Mask with above bits set
static const uint8_t StylePAINT_ORDER_MASK = 3;
/// Number of bits for each component
static const uint8_t StylePAINT_ORDER_SHIFT = 2;
/// 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.
static const uintptr_t StyleSHARING_CACHE_SIZE = 32;
/// 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.
///
static const uintptr_t StyleSTACK_SAFETY_MARGIN_KB = 168;
/// The minimum stack size for a thread in the styling pool, in kilobytes.
static const uintptr_t StyleSTYLE_THREAD_STACK_SIZE_KB = 256;
static const uint8_t StyleLengthPercentageUnion_TAG_CALC = 0;
static const uint8_t StyleLengthPercentageUnion_TAG_LENGTH = 1;
static const uint8_t StyleLengthPercentageUnion_TAG_MASK = 3;
static const uint8_t StyleLengthPercentageUnion_TAG_PERCENTAGE = 2;
/// The maximum number of child nodes that we will process as a single unit.
///
/// Larger values will increase style sharing cache hits and general DOM
/// locality at the expense of decreased opportunities for parallelism. There
/// are some measurements in
/// and 13 that investigate some slightly different values for the work unit
/// size. If the size is significantly increased, make sure to adjust the
/// condition for kicking off a new work unit in top_down_dom, because
/// otherwise we're likely to end up doing too much work serially. For
/// example, the condition there could become some fraction of WORK_UNIT_MAX
/// instead of WORK_UNIT_MAX.
static const uintptr_t StyleWORK_UNIT_MAX = 16;
/// 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,
};
/// 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,
/// The focus outline box inside of a button.
ButtonFocus,
/// A dual toolbar button (e.g., a Back button with a dropdown)
Dualbutton,
/// A groupbox.
Groupbox,
/// Menu Bar background
Menubar,
/// <menu> and <menuitem> appearances
Menuitem,
Checkmenuitem,
Radiomenuitem,
/// For text on non-iconic menuitems only
Menuitemtext,
/// The text part of a dropdown list, to left of button.
MenulistText,
/// Menu Popup background.
Menupopup,
/// menu checkbox/radio appearances
Menucheckbox,
Menuradio,
Menuseparator,
Menuarrow,
/// An image in the menu gutter, like in bookmarks or history.
Menuimage,
/// 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,
/// The progress bar's progress indicator
Progresschunk,
/// A generic container that always repaints on state changes. This is a
/// hack to make XUL checkboxes and radio buttons work.
CheckboxContainer,
RadioContainer,
/// The label part of a checkbox or radio button, used for painting a focus
/// outline.
CheckboxLabel,
RadioLabel,
/// nsRangeFrame and its subparts
Range,
RangeThumb,
/// The resizer background area in a status bar for the resizer widget in
/// the corner of a window.
Resizerpanel,
/// The resizer itself.
Resizer,
/// A scrollbar.
Scrollbar,
/// A small scrollbar.
ScrollbarSmall,
/// 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 scrollbar track.
ScrollbartrackHorizontal,
ScrollbartrackVertical,
/// 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 pane of a status bar.
Statusbarpanel,
/// 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 toolbar in an application window.
Toolbar,
/// A single toolbar button (with no associated dropdown).
Toolbarbutton,
/// The dropdown portion of a toolbar button
ToolbarbuttonDropdown,
/// The gripper for a toolbar.
Toolbargripper,
/// The toolbox that contains the toolbars.
Toolbox,
/// A tooltip.
Tooltip,
/// A listbox or tree widget header
Treeheader,
/// An individual header cell
Treeheadercell,
/// The sort arrow for a header.
Treeheadersortarrow,
/// A tree item.
Treeitem,
/// A tree widget branch line
Treeline,
/// A tree widget twisty.
Treetwisty,
/// Open tree widget twisty.
Treetwistyopen,
/// A tree widget.
Treeview,
/// Window and dialog backgrounds.
Window,
Dialog,
/// Vista Rebars.
MozWinCommunicationsToolbox,
MozWinMediaToolbox,
MozWinBrowsertabbarToolbox,
/// Vista glass.
MozWinGlass,
MozWinBorderlessGlass,
/// -moz-apperance style used in setting proper glass margins.
MozWinExcludeGlass,
/// Titlebar elements on the Mac.
MozMacFullscreenButton,
/// Mac help button.
MozMacHelpButton,
/// Windows themed window frame elements.
MozWindowButtonBox,
MozWindowButtonBoxMaximized,
MozWindowButtonClose,
MozWindowButtonMaximize,
MozWindowButtonMinimize,
MozWindowButtonRestore,
MozWindowFrameBottom,
MozWindowFrameLeft,
MozWindowFrameRight,
MozWindowTitlebar,
MozWindowTitlebarMaximized,
MozGtkInfoBar,
MozMacActiveSourceListSelection,
MozMacDisclosureButtonClosed,
MozMacDisclosureButtonOpen,
MozMacSourceList,
MozMacSourceListSelection,
MozMacVibrancyDark,
MozMacVibrancyLight,
MozMacVibrantTitlebarDark,
MozMacVibrantTitlebarLight,
/// A non-disappearing scrollbar.
ScrollbarNonDisappearing,
/// 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,
};
/// 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,
};
#if defined(CBINDGEN_IS_GECKO)
/// Represents the parts of prefers-contrast that explicitly deal with
/// contrast. Used in combination with information about rather or not
/// forced colors are active this allows for evaluation of the
/// prefers-contrast media query.
enum class StyleContrastPref : uint8_t {
#if defined(CBINDGEN_IS_GECKO)
/// More contrast is prefered. Corresponds to an accessibility theme
/// being enabled or firefox forcing high contrast colors.
More,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// Low contrast is prefered.
Less,
#endif
#if defined(CBINDGEN_IS_GECKO)
/// The default value if neither high or low contrast is enabled.
NoPreference,
#endif
};
#endif
/// 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,
};
/// 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,
#if (defined(CBINDGEN_IS_SERVO) || defined(CBINDGEN_IS_GECKO))
Contents,
#endif
Flow,
FlowRoot,
Flex,
#if defined(CBINDGEN_IS_GECKO)
Grid,
#endif
#if (defined(CBINDGEN_IS_SERVO) || defined(CBINDGEN_IS_GECKO))
Table,
#endif
#if (defined(CBINDGEN_IS_SERVO) || defined(CBINDGEN_IS_GECKO))
TableRowGroup,
#endif
#if (defined(CBINDGEN_IS_SERVO) || defined(CBINDGEN_IS_GECKO))
TableColumn,
#endif
#if (defined(CBINDGEN_IS_SERVO) || defined(CBINDGEN_IS_GECKO))
TableColumnGroup,
#endif
#if (defined(CBINDGEN_IS_SERVO) || defined(CBINDGEN_IS_GECKO))
TableHeaderGroup,
#endif
#if (defined(CBINDGEN_IS_SERVO) || defined(CBINDGEN_IS_GECKO))
TableFooterGroup,
#endif
#if (defined(CBINDGEN_IS_SERVO) || defined(CBINDGEN_IS_GECKO))
TableRow,
#endif
#if (defined(CBINDGEN_IS_SERVO) || defined(CBINDGEN_IS_GECKO))
TableCell,
#endif
#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)
MozBox,
#endif
#if defined(CBINDGEN_IS_GECKO)
MozGrid,
#endif
#if defined(CBINDGEN_IS_GECKO)
MozGridGroup,
#endif
#if defined(CBINDGEN_IS_GECKO)
MozGridLine,
#endif
#if defined(CBINDGEN_IS_GECKO)
MozStack,
#endif
#if defined(CBINDGEN_IS_GECKO)
MozDeck,
#endif
#if defined(CBINDGEN_IS_GECKO)
MozPopup,
#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,
#if (defined(CBINDGEN_IS_SERVO) || defined(CBINDGEN_IS_GECKO))
TableCaption,
#endif
#if (defined(CBINDGEN_IS_SERVO) || defined(CBINDGEN_IS_GECKO))
InternalTable,
#endif
#if defined(CBINDGEN_IS_GECKO)
InternalRuby,
#endif
#if defined(CBINDGEN_IS_GECKO)
XUL,
#endif
};
/// A type for possible values for min- and max- flavors of width, height,
/// block-size, and inline-size.
enum class StyleExtremumLength : uint8_t {
MaxContent,
MinContent,
MozFitContent,
MozAvailable,
};
enum class StyleFillRule : uint8_t {
Nonzero,
Evenodd,
};
/// A computed value for the `float` property.
enum class StyleFloat : uint8_t {
Left,
Right,
None,
};
/// 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,
};
/// 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,
None,
};
/// 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.
enum class StyleGenericFontFamily : uint8_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,
#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,
};
/// A keyword for the X direction.
enum class StyleHorizontalPositionKeyword : uint8_t {
Left,
Right,
};
/// The path command absolute type.
enum class StyleIsAbsolute : uint8_t {
Yes,
No,
};
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,
};
/// Whether we're a `min` or `max` function.
enum class StyleMinMaxOp : uint8_t {
/// `min()`
Min,
/// `max()`
Max,
};
/// Specified and computed `-moz-list-reversed` property (for UA sheets only).
enum class StyleMozListReversed : uint8_t {
/// the initial value
False,
/// exclusively used for <ol reversed> in our html.css UA sheet
True,
};
/// 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,
};
/// 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)
/// 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
#if defined(CBINDGEN_IS_GECKO)
NoPreference,
#endif
};
#endif
/// The <size> in ray() function.
///
enum class StyleRaySize : uint8_t {
ClosestSide,
ClosestCorner,
FarthestSide,
FarthestCorner,
Sides,
};
/// A computed value for the `resize` property.
enum class StyleResize : uint8_t {
None,
Both,
Horizontal,
Vertical,
};
/// The kind of change that happened for a given rule.
enum class StyleRuleChangeKind : uint32_t {
/// The rule was inserted.
Insertion,
/// The rule was removed.
Removal,
/// Some change in the rule which we don't know about, and could have made
/// the rule change in any way.
Generic,
/// 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,
};
/// 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 StyleScrollSnapStrictness : uint8_t {
None,
Mandatory,
Proximity,
};
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.
enum class StyleSystemColor : uint8_t {
WindowBackground,
WindowForeground,
WidgetBackground,
WidgetForeground,
WidgetSelectBackground,
WidgetSelectForeground,
Widget3DHighlight,
Widget3DShadow,
TextBackground,
TextForeground,
TextSelectBackground,
TextSelectForeground,
TextSelectForegroundCustom,
TextSelectBackgroundDisabled,
TextSelectBackgroundAttention,
TextHighlightBackground,
TextHighlightForeground,
IMERawInputBackground,
IMERawInputForeground,
IMERawInputUnderline,
IMESelectedRawTextBackground,
IMESelectedRawTextForeground,
IMESelectedRawTextUnderline,
IMEConvertedTextBackground,
IMEConvertedTextForeground,
IMEConvertedTextUnderline,
IMESelectedConvertedTextBackground,
IMESelectedConvertedTextForeground,
IMESelectedConvertedTextUnderline,
SpellCheckerUnderline,
Activeborder,
Activecaption,
Appworkspace,
Background,
Buttonface,
Buttonhighlight,
Buttonshadow,
Buttontext,
Captiontext,
Field,
Fieldtext,
Graytext,
Highlight,
Highlighttext,
Inactiveborder,
Inactivecaption,
Inactivecaptiontext,
Infobackground,
Infotext,
Menu,
Menutext,
Scrollbar,
Threeddarkshadow,
Threedface,
Threedhighlight,
Threedlightshadow,
Threedshadow,
Window,
Windowframe,
Windowtext,
MozButtondefault,
Canvastext,
Canvas,
MozDialog,
MozDialogtext,
/// Used to highlight valid regions to drop something onto.
MozDragtargetzone,
/// Used for selected but not focused cell backgrounds.
MozCellhighlight,
/// Used for selected but not focused cell text.
MozCellhighlighttext,
/// Used for selected but not focused html cell backgrounds.
MozHtmlCellhighlight,
/// Used for selected but not focused html cell text.
MozHtmlCellhighlighttext,
/// 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 text when hovered.
MozMenuhovertext,
/// Used for menubar item text.
MozMenubartext,
/// 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.
MozGtkButtonactivetext,
/// Used for button text when pressed.
MozMacButtonactivetext,
/// Background color of chrome toolbars in active windows.
MozMacChromeActive,
/// Background color of chrome toolbars in inactive windows.
MozMacChromeInactive,
/// Foreground color of default buttons.
MozMacDefaultbuttontext,
/// Ring color around text fields and lists.
MozMacFocusring,
/// Color used when mouse is over a menu item.
MozMacMenuselect,
/// Color used to do shadows on menu items.
MozMacMenushadow,
/// Color used to display text for disabled menu items.
MozMacMenutextdisable,
/// Color used to display text while mouse is over a menu item.
MozMacMenutextselect,
/// Text color of disabled text on toolbars.
MozMacDisabledtoolbartext,
/// Inactive light hightlight
MozMacSecondaryhighlight,
/// Font smoothing background colors needed by the Mac OS X theme, based on
/// -moz-appearance names.
MozMacVibrancyLight,
MozMacVibrancyDark,
MozMacVibrantTitlebarLight,
MozMacVibrantTitlebarDark,
MozMacMenupopup,
MozMacMenuitem,
MozMacActiveMenuitem,
MozMacSourceList,
MozMacSourceListSelection,
MozMacActiveSourceListSelection,
MozMacTooltip,
/// Accent color for title bar.
MozWinAccentcolor,
/// Color from drawing text over the accent color.
MozWinAccentcolortext,
/// Media rebar text.
MozWinMediatext,
/// Communications rebar text.
MozWinCommunicationstext,
/// 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,
Linktext,
Activetext,
Visitedtext,
/// Combobox widgets
MozComboboxtext,
MozCombobox,
MozGtkInfoBarText,
/// Color of tree column headers
MozColheadertext,
MozColheaderhovertext,
End,
};
#endif
/// Specified value of text-align keyword value.
enum class StyleTextAlignKeyword : uint8_t {
Start,
Left,
Right,
Center,
#if (defined(CBINDGEN_IS_GECKO) || defined(CBINDGEN_IS_SERVO))
Justify,
#endif
#if defined(CBINDGEN_IS_GECKO)
Char,
#endif
End,
#if defined(CBINDGEN_IS_GECKO)
MozCenter,
#endif
#if defined(CBINDGEN_IS_GECKO)
MozLeft,
#endif
#if defined(CBINDGEN_IS_GECKO)
MozRight,
#endif
#if defined(CBINDGEN_IS_SERVO)
ServoCenter,
#endif
#if defined(CBINDGEN_IS_SERVO)
ServoLeft,
#endif
#if defined(CBINDGEN_IS_SERVO)
ServoRight,
#endif
};
/// 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,
};
/// Specified keyword values for case transforms in the text-transform property. (These are exclusive.)
enum class StyleTextTransformCase {
/// No case transform.
None,
/// All uppercase.
Uppercase,
/// All lowercase.
Lowercase,
/// Capitalize each word.
Capitalize,
};
enum class StyleTimingKeyword : uint8_t {
Linear,
Ease,
EaseIn,
EaseOut,
EaseInOut,
};
enum class StyleTransformStyle : uint8_t {
Flat,
Preserve3d,
};
/// 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
};
#if defined(CBINDGEN_IS_GECKO)
/// Gecko-FFI-safe owned pointer.
///
/// Cannot be null, and leaks on drop, so needs to be converted into a rust-side
/// `Box` before.
template<typename GeckoType>
struct StyleOwned {
GeckoType *ptr;
bool operator==(const StyleOwned& other) const {
return ptr == other.ptr;
}
bool operator!=(const StyleOwned& other) const {
return ptr != other.ptr;
}
UniquePtr<GeckoType> Consume() {
UniquePtr<GeckoType> ret(ptr);
ptr = nullptr;
return ret;
}
};
#endif
#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;
/// 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;
}
};
/// The leaves of a `<length-percentage>` calc expression.
union StyleCalcLengthPercentageLeaf {
enum class Tag : uint8_t {
Length,
Percentage,
};
struct Length_Body {
Tag tag;
StyleLength _0;
bool operator==(const Length_Body& other) const {
return _0 == other._0;
}
bool operator!=(const Length_Body& other) const {
return _0 != other._0;
}
};
struct Percentage_Body {
Tag tag;
StylePercentage _0;
bool operator==(const Percentage_Body& other) const {
return _0 == other._0;
}
bool operator!=(const Percentage_Body& other) const {
return _0 != other._0;
}
};
struct {
Tag tag;
};
Length_Body length;
Percentage_Body percentage;
static StyleCalcLengthPercentageLeaf Length(const StyleLength &a0) {
StyleCalcLengthPercentageLeaf result;
::new (&result.length._0) (StyleLength)(a0);
result.tag = Tag::Length;
return result;
}
bool IsLength() const {
return tag == Tag::Length;
}
const StyleLength& AsLength() const {
MOZ_ASSERT(IsLength());
return length._0;
}
static StyleCalcLengthPercentageLeaf Percentage(const StylePercentage &a0) {
StyleCalcLengthPercentageLeaf result;
::new (&result.percentage._0) (StylePercentage)(a0);
result.tag = Tag::Percentage;
return result;
}
bool IsPercentage() const {
return tag == Tag::Percentage;
}
const StylePercentage& AsPercentage() const {
MOZ_ASSERT(IsPercentage());
return percentage._0;
}
bool operator==(const StyleCalcLengthPercentageLeaf& other) const {
if (tag != other.tag) {
return false;
}
switch (tag) {
case Tag::Length: return length == other.length;
case Tag::Percentage: return percentage == other.percentage;
}
return true;
}
bool operator!=(const StyleCalcLengthPercentageLeaf& other) const {
return !(*this == other);
}
private:
StyleCalcLengthPercentageLeaf() {
}
public:
~StyleCalcLengthPercentageLeaf() {
switch (tag) {
case Tag::Length: length.~Length_Body(); break;
case Tag::Percentage: percentage.~Percentage_Body(); break;
}
}
StyleCalcLengthPercentageLeaf(const StyleCalcLengthPercentageLeaf& other)
: tag(other.tag) {
switch (tag) {
case Tag::Length: ::new (&length) (Length_Body)(other.length); break;
case Tag::Percentage: ::new (&percentage) (Percentage_Body)(other.percentage); break;
}
}
StyleCalcLengthPercentageLeaf& operator=(const StyleCalcLengthPercentageLeaf& other) {
if (this != &other) {
this->~StyleCalcLengthPercentageLeaf();
new (this) StyleCalcLengthPercentageLeaf(other);
}
return *this;
}
};
/// A struct that basically replaces a `Box<[T]>`, but which cbindgen can
/// understand.
///
/// We could rely on the struct layout of `Box<[T]>` per:
///
///
/// But handling fat pointers with cbindgen both in structs and argument
/// positions more generally is a bit tricky.
///
template<typename T>
struct StyleOwnedSlice {
T *ptr;
uintptr_t len;
StyleOwnedSlice() :
ptr((T*)alignof(T)),
len(0) {}
inline void Clear();
inline void CopyFrom(const StyleOwnedSlice&);
inline void SwapElements(StyleOwnedSlice&);
StyleOwnedSlice& operator=(const StyleOwnedSlice&);
StyleOwnedSlice& operator=(StyleOwnedSlice&&);
inline StyleOwnedSlice(const StyleOwnedSlice&);
inline StyleOwnedSlice(StyleOwnedSlice&&);
inline explicit StyleOwnedSlice(Vector<T>&&);
inline ~StyleOwnedSlice();
Span<const T> AsSpan() const {
return {ptr, len};
}
size_t Length() const {
return len;
}
bool IsEmpty() const { return Length() == 0; }
bool operator==(const StyleOwnedSlice& other) const {
return AsSpan() == other.AsSpan();
}
bool operator!=(const StyleOwnedSlice& other) const {
return !(*this == other);
}
};
/// A generic node in a calc expression.
///
/// FIXME: This would be much more elegant if we used `Self` in the types below,
/// but we can't because of https://github.com/serde-rs/serde/issues/1565.
///
/// FIXME: The following annotations are to workaround an LLVM inlining bug, see
///
template<typename L>
union StyleGenericCalcNode {
enum class Tag : uint8_t {
/// A leaf node.
Leaf,
/// A sum node, representing `a + b + c` where a, b, and c are the
/// arguments.
Sum,
/// A `min` or `max` function.
MinMax,
/// A `clamp()` function.
Clamp,
};
struct Leaf_Body {
Tag tag;
L _0;
bool operator==(const Leaf_Body& other) const {
return _0 == other._0;
}
bool operator!=(const Leaf_Body& other) const {
return _0 != other._0;
}
};
struct Sum_Body {
Tag tag;
StyleOwnedSlice<StyleGenericCalcNode<L>> _0;
bool operator==(const Sum_Body& other) const {
return _0 == other._0;
}
bool operator!=(const Sum_Body& other) const {
return _0 != other._0;
}
};
struct MinMax_Body {
Tag tag;
StyleOwnedSlice<StyleGenericCalcNode<L>> _0;
StyleMinMaxOp _1;
bool operator==(const MinMax_Body& other) const {
return _0 == other._0 &&
_1 == other._1;
}
bool operator!=(const MinMax_Body& other) const {
return _0 != other._0 ||
_1 != other._1;
}
};
struct Clamp_Body {
Tag tag;
/// The minimum value.
StyleBox<StyleGenericCalcNode<L>> min;
/// The central value.
StyleBox<StyleGenericCalcNode<L>> center;
/// The maximum value.
StyleBox<StyleGenericCalcNode<L>> max;
bool operator==(const Clamp_Body& other) const {
return min == other.min &&
center == other.center &&
max == other.max;
}
bool operator!=(const Clamp_Body& other) const {
return min != other.min ||
center != other.center ||
max != other.max;
}
};
struct {
Tag tag;
};
Leaf_Body leaf;
Sum_Body sum;
MinMax_Body min_max;
Clamp_Body clamp;
static StyleGenericCalcNode Leaf(const L &a0) {
StyleGenericCalcNode result;
::new (&result.leaf._0) (L)(a0);
result.tag = Tag::Leaf;
return result;
}
bool IsLeaf() const {
return tag == Tag::Leaf;
}
const L& AsLeaf() const {
MOZ_ASSERT(IsLeaf());
return leaf._0;
}
static StyleGenericCalcNode Sum(const StyleOwnedSlice<StyleGenericCalcNode<L>> &a0) {
StyleGenericCalcNode result;
::new (&result.sum._0) (StyleOwnedSlice<StyleGenericCalcNode<L>>)(a0);
result.tag = Tag::Sum;
return result;
}
bool IsSum() const {
return tag == Tag::Sum;
}
const StyleOwnedSlice<StyleGenericCalcNode<L>>& AsSum() const {
MOZ_ASSERT(IsSum());
return sum._0;
}
static StyleGenericCalcNode MinMax(const StyleOwnedSlice<StyleGenericCalcNode<L>> &a0,
const StyleMinMaxOp &a1) {
StyleGenericCalcNode result;
::new (&result.min_max._0) (StyleOwnedSlice<StyleGenericCalcNode<L>>)(a0);
::new (&result.min_max._1) (StyleMinMaxOp)(a1);
result.tag = Tag::MinMax;
return result;
}
bool IsMinMax() const {
return tag == Tag::MinMax;
}
const MinMax_Body& AsMinMax() const {
MOZ_ASSERT(IsMinMax());
return min_max;
}
static StyleGenericCalcNode Clamp(const StyleBox<StyleGenericCalcNode<L>> &aMin,
const StyleBox<StyleGenericCalcNode<L>> &aCenter,
const StyleBox<StyleGenericCalcNode<L>> &aMax) {
StyleGenericCalcNode result;
::new (&result.clamp.min) (StyleBox<StyleGenericCalcNode<L>>)(aMin);
::new (&result.clamp.center) (StyleBox<StyleGenericCalcNode<L>>)(aCenter);
::new (&result.clamp.max) (StyleBox<StyleGenericCalcNode<L>>)(aMax);
result.tag = Tag::Clamp;
return result;
}
bool IsClamp() const {
return tag == Tag::Clamp;
}
const Clamp_Body& AsClamp() const {
MOZ_ASSERT(IsClamp());
return clamp;
}
MOZ_NEVER_INLINE bool operator==(const StyleGenericCalcNode& other) const {
if (tag != other.tag) {
return false;
}
switch (tag) {
case Tag::Leaf: return leaf == other.leaf;
case Tag::Sum: return sum == other.sum;
case Tag::MinMax: return min_max == other.min_max;
case Tag::Clamp: return clamp == other.clamp;
}
return true;
}
bool operator!=(const StyleGenericCalcNode& other) const {
return !(*this == other);
}
private:
StyleGenericCalcNode() {
}
public:
MOZ_NEVER_INLINE ~StyleGenericCalcNode() {
switch (tag) {
case Tag::Leaf: leaf.~Leaf_Body(); break;
case Tag::Sum: sum.~Sum_Body(); break;
case Tag::MinMax: min_max.~MinMax_Body(); break;
case Tag::Clamp: clamp.~Clamp_Body(); break;
}
}
MOZ_NEVER_INLINE StyleGenericCalcNode(const StyleGenericCalcNode& other)
: tag(other.tag) {
switch (tag) {
case Tag::Leaf: ::new (&leaf) (Leaf_Body)(other.leaf); break;
case Tag::Sum: ::new (&sum) (Sum_Body)(other.sum); break;
case Tag::MinMax: ::new (&min_max) (MinMax_Body)(other.min_max); break;
case Tag::Clamp: ::new (&clamp) (Clamp_Body)(other.clamp); break;
}
}
StyleGenericCalcNode& operator=(const StyleGenericCalcNode& other) {
if (this != &other) {
this->~StyleGenericCalcNode();
new (this) StyleGenericCalcNode(other);
}
return *this;
}
private:
template <typename ResultT, typename PercentageConverter>
ResultT ResolveInternal(ResultT aPercentageBasis,
PercentageConverter aPercentageConverter) const;
public:
CSSCoord ResolveToCSSPixels(CSSCoord aPercentageBasis) const;
using CoordPercentageRounder = nscoord(*)(float);
nscoord Resolve(nscoord aBasis, CoordPercentageRounder) const;
void ScaleLengthsBy(float);
};
/// The computed version of a calc() node for `<length-percentage>` values.
using StyleCalcNode = StyleGenericCalcNode<StyleCalcLengthPercentageLeaf>;
/// The representation of a calc() function with mixed lengths and percentages.
struct StyleCalcLengthPercentage {
StyleAllowedNumericType clamping_mode;
StyleCalcNode node;
bool operator==(const StyleCalcLengthPercentage& other) const {
return clamping_mode == other.clamping_mode &&
node == other.node;
}
bool operator!=(const StyleCalcLengthPercentage& other) const {
return clamping_mode != other.clamping_mode ||
node != other.node;
}
};
#if defined(SERVO_32_BITS)
struct StyleCalcVariant {
uint8_t tag;
StyleCalcLengthPercentage *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 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;
};
/// 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;
/// The computed value of a CSS horizontal position.
using StyleHorizontalPosition = StyleLengthPercentage;
/// The computed value of a CSS vertical position.
using StyleVerticalPosition = StyleLengthPercentage;
/// A generic type for representing a CSS [position](https://drafts.csswg.org/css-values/#position).
template<typename H, typename V>
struct StyleGenericPosition {
/// The horizontal component of position.
H horizontal;
/// The vertical component of position.
V vertical;
bool operator==(const StyleGenericPosition& other) const {
return horizontal == other.horizontal &&
vertical == other.vertical;
}
bool operator!=(const StyleGenericPosition& other) const {
return horizontal != other.horizontal ||
vertical != other.vertical;
}
inline bool HasPercent() const;
inline bool DependsOnPositioningAreaSize() const;
static inline StyleGenericPosition FromPercentage(float);
};
/// The computed value of a CSS `<position>`
using StylePosition = StyleGenericPosition<StyleHorizontalPosition, StyleVerticalPosition>;
/// A generic type for representing an `Auto | <position>`.
/// This is used by <offset-anchor> for now.
template<typename Pos>
struct StyleGenericPositionOrAuto {
enum class Tag : uint8_t {
/// The <position> value.
Position,
/// The keyword `auto`.
Auto,
};
struct StylePosition_Body {
Pos _0;
bool operator==(const StylePosition_Body& other) const {
return _0 == other._0;
}
bool operator!=(const StylePosition_Body& other) const {
return _0 != other._0;
}
};
Tag tag;
union {
StylePosition_Body position;
};
static StyleGenericPositionOrAuto Position(const Pos &a0) {
StyleGenericPositionOrAuto result;
::new (&result.position._0) (Pos)(a0);
result.tag = Tag::Position;
return result;
}
bool IsPosition() const {
return tag == Tag::Position;
}
const Pos& AsPosition() const {
MOZ_ASSERT(IsPosition());
return position._0;
}
static StyleGenericPositionOrAuto Auto() {
StyleGenericPositionOrAuto result;
result.tag = Tag::Auto;
return result;
}
bool IsAuto() const {
return tag == Tag::Auto;
}
bool operator==(const StyleGenericPositionOrAuto& other) const {
if (tag != other.tag) {
return false;
}
switch (tag) {
case Tag::Position: return position == other.position;
default: break;
}
return true;
}
bool operator!=(const StyleGenericPositionOrAuto& other) const {
return !(*this == other);
}
~StyleGenericPositionOrAuto() {
switch (tag) {
case Tag::Position: position.~StylePosition_Body(); break;
default: break;
}
}
StyleGenericPositionOrAuto(const StyleGenericPositionOrAuto& other)
: tag(other.tag) {
switch (tag) {
case Tag::Position: ::new (&position) (StylePosition_Body)(other.position); break;
default: break;
}
}
StyleGenericPositionOrAuto& operator=(const StyleGenericPositionOrAuto& other) {
if (this != &other) {
this->~StyleGenericPositionOrAuto();
new (this) StyleGenericPositionOrAuto(other);
}
return *this;
}
public:
// The implementation of IPC LayersMessages needs this to be public.
StyleGenericPositionOrAuto(): tag(Tag::Auto) {}
};
/// The computed value of an `auto | <position>`
using StylePositionOrAuto = StyleGenericPositionOrAuto<StylePosition>;
/// A computed angle in degrees.
struct StyleAngle {
StyleCSSFloat _0;
bool operator==(const StyleAngle& other) const {
return _0 == other._0;
}
bool operator!=(const StyleAngle& other) const {
return _0 != other._0;
}
inline static StyleAngle Zero();
inline float ToDegrees() const;
inline double ToRadians() const;
StyleAngle operator+(const StyleAngle& aAngle) const {
return StyleAngle{_0 + aAngle._0};
}
StyleAngle operator-(const StyleAngle& aAngle) const {
return StyleAngle{_0 - aAngle._0};
}
};
/// The path coord type.
struct StyleCoordPair {
StyleCSSFloat _0;
StyleCSSFloat _1;
bool operator==(const StyleCoordPair& other) const {
return _0 == other._0 &&
_1 == other._1;
}
bool operator!=(const StyleCoordPair& other) const {
return _0 != other._0 ||
_1 != other._1;
}
explicit StyleCoordPair(const gfx::Point& aPoint): _0(aPoint.x), _1(aPoint.y) {}
};
/// The EllipticalArc flag type.
struct StyleArcFlag {
bool _0;
bool operator==(const StyleArcFlag& other) const {
return _0 == other._0;
}
bool operator!=(const StyleArcFlag& other) const {
return _0 != other._0;
}
};
/// The SVG path command.
/// The fields of these commands are self-explanatory, so we skip the documents.
/// Note: the index of the control points, e.g. control1, control2, are mapping to the control
/// points of the Bézier curve in the spec.
///
struct StylePathCommand {
enum class Tag : uint8_t {
/// The unknown type.
Unknown,
/// The "moveto" command.
MoveTo,
/// The "lineto" command.
LineTo,
/// The horizontal "lineto" command.
HorizontalLineTo,
/// The vertical "lineto" command.
VerticalLineTo,
/// The cubic Bézier curve command.
CurveTo,
/// The smooth curve command.
SmoothCurveTo,
/// The quadratic Bézier curve command.
QuadBezierCurveTo,
/// The smooth quadratic Bézier curve command.
SmoothQuadBezierCurveTo,
/// The elliptical arc curve command.
EllipticalArc,
/// The "closepath" command.
ClosePath,
};
struct StyleMoveTo_Body {
StyleCoordPair point;
StyleIsAbsolute absolute;
bool operator==(const StyleMoveTo_Body& other) const {
return point == other.point &&
absolute == other.absolute;
}
bool operator!=(const StyleMoveTo_Body& other) const {
return point != other.point ||
absolute != other.absolute;
}
};
struct StyleLineTo_Body {
StyleCoordPair point;
StyleIsAbsolute absolute;
bool operator==(const StyleLineTo_Body& other) const {
return point == other.point &&
absolute == other.absolute;
}
bool operator!=(const StyleLineTo_Body& other) const {
return point != other.point ||
absolute != other.absolute;
}
};
struct StyleHorizontalLineTo_Body {
StyleCSSFloat x;
StyleIsAbsolute absolute;
bool operator==(const StyleHorizontalLineTo_Body& other) const {
return x == other.x &&
absolute == other.absolute;
}
bool operator!=(const StyleHorizontalLineTo_Body& other) const {
return x != other.x ||
absolute != other.absolute;
}
};
struct StyleVerticalLineTo_Body {
StyleCSSFloat y;
StyleIsAbsolute absolute;
bool operator==(const StyleVerticalLineTo_Body& other) const {
return y == other.y &&
absolute == other.absolute;
}
bool operator!=(const StyleVerticalLineTo_Body& other) const {
return y != other.y ||
absolute != other.absolute;
}
};
struct StyleCurveTo_Body {
StyleCoordPair control1;
StyleCoordPair control2;
StyleCoordPair point;
StyleIsAbsolute absolute;
bool operator==(const StyleCurveTo_Body& other) const {
return control1 == other.control1 &&
control2 == other.control2 &&
point == other.point &&
absolute == other.absolute;
}
bool operator!=(const StyleCurveTo_Body& other) const {
return control1 != other.control1 ||
control2 != other.control2 ||
point != other.point ||
absolute != other.absolute;
}
};
struct StyleSmoothCurveTo_Body {
StyleCoordPair control2;
StyleCoordPair point;
StyleIsAbsolute absolute;
bool operator==(const StyleSmoothCurveTo_Body& other) const {
return control2 == other.control2 &&
point == other.point &&
absolute == other.absolute;
}
bool operator!=(const StyleSmoothCurveTo_Body& other) const {
return control2 != other.control2 ||
point != other.point ||
absolute != other.absolute;
}
};
struct StyleQuadBezierCurveTo_Body {
StyleCoordPair control1;
StyleCoordPair point;
StyleIsAbsolute absolute;
bool operator==(const StyleQuadBezierCurveTo_Body& other) const {
return control1 == other.control1 &&
point == other.point &&
absolute == other.absolute;
}
bool operator!=(const StyleQuadBezierCurveTo_Body& other) const {
return control1 != other.control1 ||
point != other.point ||
absolute != other.absolute;
}
};
struct StyleSmoothQuadBezierCurveTo_Body {
StyleCoordPair point;
StyleIsAbsolute absolute;
bool operator==(const StyleSmoothQuadBezierCurveTo_Body& other) const {
return point == other.point &&
absolute == other.absolute;
}
bool operator!=(const StyleSmoothQuadBezierCurveTo_Body& other) const {
return point != other.point ||
absolute != other.absolute;
}
};
struct StyleEllipticalArc_Body {
StyleCSSFloat rx;
StyleCSSFloat ry;
StyleCSSFloat angle;
StyleArcFlag large_arc_flag;
StyleArcFlag sweep_flag;
StyleCoordPair point;
StyleIsAbsolute absolute;
bool operator==(const StyleEllipticalArc_Body& other) const {
return rx == other.rx &&
ry == other.ry &&
angle == other.angle &&
large_arc_flag == other.large_arc_flag &&
sweep_flag == other.sweep_flag &&
point == other.point &&
absolute == other.absolute;
}
bool operator!=(const StyleEllipticalArc_Body& other) const {
return rx != other.rx ||
ry != other.ry ||
angle != other.angle ||
large_arc_flag != other.large_arc_flag ||
sweep_flag != other.sweep_flag ||
point != other.point ||
absolute != other.absolute;
}
};
Tag tag;
union {
StyleMoveTo_Body move_to;
StyleLineTo_Body line_to;
StyleHorizontalLineTo_Body horizontal_line_to;
StyleVerticalLineTo_Body vertical_line_to;
StyleCurveTo_Body curve_to;
StyleSmoothCurveTo_Body smooth_curve_to;
StyleQuadBezierCurveTo_Body quad_bezier_curve_to;
StyleSmoothQuadBezierCurveTo_Body smooth_quad_bezier_curve_to;
StyleEllipticalArc_Body elliptical_arc;
};
static StylePathCommand Unknown() {
StylePathCommand result;
result.tag = Tag::Unknown;
return result;
}
bool IsUnknown() const {
return tag == Tag::Unknown;
}
static StylePathCommand MoveTo(const StyleCoordPair &aPoint,
const StyleIsAbsolute &aAbsolute) {
StylePathCommand result;
::new (&result.move_to.point) (StyleCoordPair)(aPoint);
::new (&result.move_to.absolute) (StyleIsAbsolute)(aAbsolute);
result.tag = Tag::MoveTo;
return result;
}
bool IsMoveTo() const {
return tag == Tag::MoveTo;
}
const StyleMoveTo_Body& AsMoveTo() const {
MOZ_ASSERT(IsMoveTo());
return move_to;
}
static StylePathCommand LineTo(const StyleCoordPair &aPoint,
const StyleIsAbsolute &aAbsolute) {
StylePathCommand result;
::new (&result.line_to.point) (StyleCoordPair)(aPoint);
::new (&result.line_to.absolute) (StyleIsAbsolute)(aAbsolute);
result.tag = Tag::LineTo;
return result;
}
bool IsLineTo() const {
return tag == Tag::LineTo;
}
const StyleLineTo_Body& AsLineTo() const {
MOZ_ASSERT(IsLineTo());
return line_to;
}
static StylePathCommand HorizontalLineTo(const StyleCSSFloat &aX,
const StyleIsAbsolute &aAbsolute) {
StylePathCommand result;
::new (&result.horizontal_line_to.x) (StyleCSSFloat)(aX);
::new (&result.horizontal_line_to.absolute) (StyleIsAbsolute)(aAbsolute);
result.tag = Tag::HorizontalLineTo;
return result;
}
bool IsHorizontalLineTo() const {
return tag == Tag::HorizontalLineTo;
}
const StyleHorizontalLineTo_Body& AsHorizontalLineTo() const {
MOZ_ASSERT(IsHorizontalLineTo());
return horizontal_line_to;
}
static StylePathCommand VerticalLineTo(const StyleCSSFloat &aY,
const StyleIsAbsolute &aAbsolute) {
StylePathCommand result;
::new (&result.vertical_line_to.y) (StyleCSSFloat)(aY);
::new (&result.vertical_line_to.absolute) (StyleIsAbsolute)(aAbsolute);
result.tag = Tag::VerticalLineTo;
return result;
}
bool IsVerticalLineTo() const {
return tag == Tag::VerticalLineTo;
}
const StyleVerticalLineTo_Body& AsVerticalLineTo() const {
MOZ_ASSERT(IsVerticalLineTo());
return vertical_line_to;
}
static StylePathCommand CurveTo(const StyleCoordPair &aControl1,
const StyleCoordPair &aControl2,
const StyleCoordPair &aPoint,
const StyleIsAbsolute &aAbsolute) {
StylePathCommand result;
::new (&result.curve_to.control1) (StyleCoordPair)(aControl1);
::new (&result.curve_to.control2) (StyleCoordPair)(aControl2);
::new (&result.curve_to.point) (StyleCoordPair)(aPoint);
::new (&result.curve_to.absolute) (StyleIsAbsolute)(aAbsolute);
result.tag = Tag::CurveTo;
return result;
}
bool IsCurveTo() const {
return tag == Tag::CurveTo;
}
const StyleCurveTo_Body& AsCurveTo() const {
MOZ_ASSERT(IsCurveTo());
return curve_to;
}
static StylePathCommand SmoothCurveTo(const StyleCoordPair &aControl2,
const StyleCoordPair &aPoint,
const StyleIsAbsolute &aAbsolute) {
StylePathCommand result;
::new (&result.smooth_curve_to.control2) (StyleCoordPair)(aControl2);
::new (&result.smooth_curve_to.point) (StyleCoordPair)(aPoint);
::new (&result.smooth_curve_to.absolute) (StyleIsAbsolute)(aAbsolute);
result.tag = Tag::SmoothCurveTo;
return result;
}
bool IsSmoothCurveTo() const {
return tag == Tag::SmoothCurveTo;
}
const StyleSmoothCurveTo_Body& AsSmoothCurveTo() const {
MOZ_ASSERT(IsSmoothCurveTo());
return smooth_curve_to;
}
static StylePathCommand QuadBezierCurveTo(const StyleCoordPair &aControl1,
const StyleCoordPair &aPoint,
const StyleIsAbsolute &aAbsolute) {
StylePathCommand result;
::new (&result.quad_bezier_curve_to.control1) (StyleCoordPair)(aControl1);
::new (&result.quad_bezier_curve_to.point) (StyleCoordPair)(aPoint);
::new (&result.quad_bezier_curve_to.absolute) (StyleIsAbsolute)(aAbsolute);
result.tag = Tag::QuadBezierCurveTo;
return result;
}
bool IsQuadBezierCurveTo() const {
return tag == Tag::QuadBezierCurveTo;
}
const StyleQuadBezierCurveTo_Body& AsQuadBezierCurveTo() const {
MOZ_ASSERT(IsQuadBezierCurveTo());
return quad_bezier_curve_to;
}
static StylePathCommand SmoothQuadBezierCurveTo(const StyleCoordPair &aPoint,
const StyleIsAbsolute &aAbsolute) {
StylePathCommand result;
::new (&result.smooth_quad_bezier_curve_to.point) (StyleCoordPair)(aPoint);
::new (&result.smooth_quad_bezier_curve_to.absolute) (StyleIsAbsolute)(aAbsolute);
result.tag = Tag::SmoothQuadBezierCurveTo;
return result;
}
bool IsSmoothQuadBezierCurveTo() const {
return tag == Tag::SmoothQuadBezierCurveTo;
}
const StyleSmoothQuadBezierCurveTo_Body& AsSmoothQuadBezierCurveTo() const {
MOZ_ASSERT(IsSmoothQuadBezierCurveTo());
return smooth_quad_bezier_curve_to;
}
static StylePathCommand EllipticalArc(const StyleCSSFloat &aRx,
const StyleCSSFloat &aRy,
const StyleCSSFloat &aAngle,
const StyleArcFlag &aLargeArcFlag,
const StyleArcFlag &aSweepFlag,
const StyleCoordPair &aPoint,
const StyleIsAbsolute &aAbsolute) {
StylePathCommand result;
::new (&result.elliptical_arc.rx) (StyleCSSFloat)(aRx);
::new (&result.elliptical_arc.ry) (StyleCSSFloat)(aRy);
::new (&result.elliptical_arc.angle) (StyleCSSFloat)(aAngle);
::new (&result.elliptical_arc.large_arc_flag) (StyleArcFlag)(aLargeArcFlag);
::new (&result.elliptical_arc.sweep_flag) (StyleArcFlag)(aSweepFlag);
::new (&result.elliptical_arc.point) (StyleCoordPair)(aPoint);
::new (&result.elliptical_arc.absolute) (StyleIsAbsolute)(aAbsolute);
result.tag = Tag::EllipticalArc;
return result;
}
bool IsEllipticalArc() const {
return tag == Tag::EllipticalArc;
}
const StyleEllipticalArc_Body& AsEllipticalArc() const {
MOZ_ASSERT(IsEllipticalArc());
return elliptical_arc;
}
static StylePathCommand ClosePath() {
StylePathCommand result;
result.tag = Tag::ClosePath;
return result;
}
bool IsClosePath() const {
return tag == Tag::ClosePath;
}
bool operator==(const StylePathCommand& other) const {
if (tag != other.tag) {
return false;
}
switch (tag) {
case Tag::MoveTo: return move_to == other.move_to;
case Tag::LineTo: return line_to == other.line_to;
case Tag::HorizontalLineTo: return horizontal_line_to == other.horizontal_line_to;
case Tag::VerticalLineTo: return vertical_line_to == other.vertical_line_to;
case Tag::CurveTo: return curve_to == other.curve_to;
case Tag::SmoothCurveTo: return smooth_curve_to == other.smooth_curve_to;
case Tag::QuadBezierCurveTo: return quad_bezier_curve_to == other.quad_bezier_curve_to;
case Tag::SmoothQuadBezierCurveTo: return smooth_quad_bezier_curve_to == other.smooth_quad_bezier_curve_to;
case Tag::EllipticalArc: return elliptical_arc == other.elliptical_arc;
default: break;
}
return true;
}
bool operator!=(const StylePathCommand& other) const {
return !(*this == other);
}
private:
StylePathCommand() {
}
public:
~StylePathCommand() {
switch (tag) {
case Tag::MoveTo: move_to.~StyleMoveTo_Body(); break;
case Tag::LineTo: line_to.~StyleLineTo_Body(); break;
case Tag::HorizontalLineTo: horizontal_line_to.~StyleHorizontalLineTo_Body(); break;
case Tag::VerticalLineTo: vertical_line_to.~StyleVerticalLineTo_Body(); break;
case Tag::CurveTo: curve_to.~StyleCurveTo_Body(); break;
case Tag::SmoothCurveTo: smooth_curve_to.~StyleSmoothCurveTo_Body(); break;
case Tag::QuadBezierCurveTo: quad_bezier_curve_to.~StyleQuadBezierCurveTo_Body(); break;
case Tag::SmoothQuadBezierCurveTo: smooth_quad_bezier_curve_to.~StyleSmoothQuadBezierCurveTo_Body(); break;
case Tag::EllipticalArc: elliptical_arc.~StyleEllipticalArc_Body(); break;
default: break;
}
}
StylePathCommand(const StylePathCommand& other)
: tag(other.tag) {
switch (tag) {
case Tag::MoveTo: ::new (&move_to) (StyleMoveTo_Body)(other.move_to); break;
case Tag::LineTo: ::new (&line_to) (StyleLineTo_Body)(other.line_to); break;
case Tag::HorizontalLineTo: ::new (&horizontal_line_to) (StyleHorizontalLineTo_Body)(other.horizontal_line_to); break;
case Tag::VerticalLineTo: ::new (&vertical_line_to) (StyleVerticalLineTo_Body)(other.