Other Tools

1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5
// See the comment in ServoBindings.h about the same.
6
#pragma GCC diagnostic push
7
#ifdef __clang__
8
# pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"
9
#endif
10
// Work-around silly windows.h define.
11
#pragma push_macro("STRICT")
12
#undef STRICT
13
14
15
#ifndef mozilla_ServoStyleConsts_h
16
#define mozilla_ServoStyleConsts_h
17
18
/* Generated with cbindgen:0.12.0 */
19
20
/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.
21
* To generate this file:
22
* 1. Get the latest cbindgen using `cargo install --force cbindgen`
23
* a. Alternatively, you can clone `https://github.com/eqrion/cbindgen` and use a tagged release
24
* 2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate style -o layout/style/ServoStyleConsts.h`
25
*/
26
27
28
#include <cstdarg>
29
#include <cstdint>
30
#include <cstdlib>
31
#include <new>
32
#include "mozilla/ServoStyleConstsForwards.h"
33
34
namespace mozilla {
35
36
static const float StyleDEFAULT_FONT_STYLE_OBLIQUE_ANGLE_DEGREES = 14.;
37
38
#if defined(CBINDGEN_IS_SERVO)
39
static const uintptr_t StyleEAGER_PSEUDO_COUNT = 3;
40
#endif
41
42
static const int32_t StyleFONT_MEDIUM_PX = 16;
43
44
static const float StyleFONT_STYLE_OBLIQUE_MAX_ANGLE_DEGREES = 90.;
45
46
static const float StyleFONT_STYLE_OBLIQUE_MIN_ANGLE_DEGREES = -90.;
47
48
static const float StyleMAX_FONT_WEIGHT = 1000.;
49
50
static const int32_t StyleMAX_GRID_LINE = 10000;
51
52
static const float StyleMIN_FONT_WEIGHT = 1.;
53
54
static const int32_t StyleMIN_GRID_LINE = -10000;
55
56
static const uint8_t StylePAINT_ORDER_COUNT = 3;
57
58
static const uint8_t StylePAINT_ORDER_MASK = 3;
59
60
static const uint8_t StylePAINT_ORDER_SHIFT = 2;
61
62
static const uintptr_t StyleSHARING_CACHE_SIZE = 32;
63
64
static const uintptr_t StyleSTACK_SAFETY_MARGIN_KB = 168;
65
66
static const uintptr_t StyleSTYLE_THREAD_STACK_SIZE_KB = 256;
67
68
static const uint32_t StyleLengthPercentageUnion_TAG_CALC = 0;
69
70
static const uint32_t StyleLengthPercentageUnion_TAG_LENGTH = 1;
71
72
static const uint32_t StyleLengthPercentageUnion_TAG_MASK = 3;
73
74
static const uint32_t StyleLengthPercentageUnion_TAG_PERCENTAGE = 2;
75
76
static const uintptr_t StyleWORK_UNIT_MAX = 16;
77
78
/// Whether to allow negative lengths or not.
79
enum class StyleAllowedNumericType : uint8_t {
80
/// Allow all kind of numeric values.
81
All,
82
/// Allow only non-negative numeric values.
83
NonNegative,
84
/// Allow only numeric values greater or equal to 1.0.
85
AtLeastOne,
86
};
87
88
/// The value for the `appearance` property.
89
///
91
enum class StyleAppearance : uint8_t {
92
/// No appearance at all.
93
None,
94
/// A typical dialog button.
95
Button,
96
/// Various arrows that go in buttons
97
ButtonArrowDown,
98
ButtonArrowNext,
99
ButtonArrowPrevious,
100
ButtonArrowUp,
101
/// A rectangular button that contains complex content
102
/// like images (e.g. HTML <button> elements)
103
ButtonBevel,
104
/// The focus outline box inside of a button.
105
ButtonFocus,
106
/// The caret of a text area
107
Caret,
108
/// A dual toolbar button (e.g., a Back button with a dropdown)
109
Dualbutton,
110
/// A groupbox.
111
Groupbox,
112
/// A inner-spin button.
113
InnerSpinButton,
114
/// List boxes.
115
Listbox,
116
/// A listbox item.
117
Listitem,
118
/// Menu Bar background
119
Menubar,
120
/// <menu> and <menuitem> appearances
121
Menuitem,
122
Checkmenuitem,
123
Radiomenuitem,
124
/// For text on non-iconic menuitems only
125
Menuitemtext,
126
/// A dropdown list.
127
Menulist,
128
/// The dropdown button(s) that open up a dropdown list.
129
MenulistButton,
130
/// The text part of a dropdown list, to left of button.
131
MenulistText,
132
/// An editable textfield with a dropdown list (a combobox).
133
MenulistTextfield,
134
/// Menu Popup background.
135
Menupopup,
136
/// menu checkbox/radio appearances
137
Menucheckbox,
138
Menuradio,
139
Menuseparator,
140
Menuarrow,
141
/// An image in the menu gutter, like in bookmarks or history.
142
Menuimage,
143
/// A horizontal meter bar.
144
Meter,
145
/// The meter bar's meter indicator.
146
Meterchunk,
147
/// The "arrowed" part of the dropdown button that open up a dropdown list.
148
MozMenulistButton,
149
/// For HTML's <input type=number>
150
NumberInput,
151
/// A horizontal progress bar.
152
ProgressBar,
153
/// The progress bar's progress indicator
154
Progresschunk,
155
/// A vertical progress bar.
156
ProgressbarVertical,
157
/// A checkbox element.
158
Checkbox,
159
/// A radio element within a radio group.
160
Radio,
161
/// A generic container that always repaints on state changes. This is a
162
/// hack to make XUL checkboxes and radio buttons work.
163
CheckboxContainer,
164
RadioContainer,
165
/// The label part of a checkbox or radio button, used for painting a focus
166
/// outline.
167
CheckboxLabel,
168
RadioLabel,
169
/// nsRangeFrame and its subparts
170
Range,
171
RangeThumb,
172
/// The resizer background area in a status bar for the resizer widget in
173
/// the corner of a window.
174
Resizerpanel,
175
/// The resizer itself.
176
Resizer,
177
/// A slider.
178
ScaleHorizontal,
179
ScaleVertical,
180
/// A slider's thumb.
181
ScalethumbHorizontal,
182
ScalethumbVertical,
183
/// If the platform supports it, the left/right chunks of the slider thumb.
184
Scalethumbstart,
185
Scalethumbend,
186
/// The ticks for a slider.
187
Scalethumbtick,
188
/// A scrollbar.
189
Scrollbar,
190
/// A small scrollbar.
191
ScrollbarSmall,
192
/// The scrollbar slider
193
ScrollbarHorizontal,
194
ScrollbarVertical,
195
/// A scrollbar button (up/down/left/right).
196
/// Keep these in order (some code casts these values to `int` in order to
197
/// compare them against each other).
198
ScrollbarbuttonUp,
199
ScrollbarbuttonDown,
200
ScrollbarbuttonLeft,
201
ScrollbarbuttonRight,
202
/// The scrollbar thumb.
203
ScrollbarthumbHorizontal,
204
ScrollbarthumbVertical,
205
/// The scrollbar track.
206
ScrollbartrackHorizontal,
207
ScrollbartrackVertical,
208
/// The scroll corner
209
Scrollcorner,
210
/// A searchfield.
211
Searchfield,
212
/// A separator. Can be horizontal or vertical.
213
Separator,
214
/// A spin control (up/down control for time/date pickers).
215
Spinner,
216
/// The up button of a spin control.
217
SpinnerUpbutton,
218
/// The down button of a spin control.
219
SpinnerDownbutton,
220
/// The textfield of a spin control
221
SpinnerTextfield,
222
/// A splitter. Can be horizontal or vertical.
223
Splitter,
224
/// A status bar in a main application window.
225
Statusbar,
226
/// A single pane of a status bar.
227
Statusbarpanel,
228
/// A single tab in a tab widget.
229
Tab,
230
/// A single pane (inside the tabpanels container).
231
Tabpanel,
232
/// The tab panels container.
233
Tabpanels,
234
/// The tabs scroll arrows (left/right).
235
TabScrollArrowBack,
236
TabScrollArrowForward,
237
/// A multi-line text field, e.g. HTML <textarea>.
238
Textarea,
239
/// A single-line text field, e.g. HTML <input type=text>.
240
Textfield,
241
/// A toolbar in an application window.
242
Toolbar,
243
/// A single toolbar button (with no associated dropdown).
244
Toolbarbutton,
245
/// The dropdown portion of a toolbar button
246
ToolbarbuttonDropdown,
247
/// The gripper for a toolbar.
248
Toolbargripper,
249
/// The toolbox that contains the toolbars.
250
Toolbox,
251
/// A tooltip.
252
Tooltip,
253
/// A listbox or tree widget header
254
Treeheader,
255
/// An individual header cell
256
Treeheadercell,
257
/// The sort arrow for a header.
258
Treeheadersortarrow,
259
/// A tree item.
260
Treeitem,
261
/// A tree widget branch line
262
Treeline,
263
/// A tree widget twisty.
264
Treetwisty,
265
/// Open tree widget twisty.
266
Treetwistyopen,
267
/// A tree widget.
268
Treeview,
269
/// Window and dialog backgrounds.
270
Window,
271
Dialog,
272
/// Vista Rebars.
273
MozWinCommunicationsToolbox,
274
MozWinMediaToolbox,
275
MozWinBrowsertabbarToolbox,
276
/// Vista glass.
277
MozWinGlass,
278
MozWinBorderlessGlass,
279
/// -moz-apperance style used in setting proper glass margins.
280
MozWinExcludeGlass,
281
/// Titlebar elements on the Mac.
282
MozMacFullscreenButton,
283
/// Mac help button.
284
MozMacHelpButton,
285
/// Windows themed window frame elements.
286
MozWindowButtonBox,
287
MozWindowButtonBoxMaximized,
288
MozWindowButtonClose,
289
MozWindowButtonMaximize,
290
MozWindowButtonMinimize,
291
MozWindowButtonRestore,
292
MozWindowFrameBottom,
293
MozWindowFrameLeft,
294
MozWindowFrameRight,
295
MozWindowTitlebar,
296
MozWindowTitlebarMaximized,
297
MozGtkInfoBar,
298
MozMacActiveSourceListSelection,
299
MozMacDisclosureButtonClosed,
300
MozMacDisclosureButtonOpen,
301
MozMacSourceList,
302
MozMacSourceListSelection,
303
MozMacVibrancyDark,
304
MozMacVibrancyLight,
305
MozMacVibrantTitlebarDark,
306
MozMacVibrantTitlebarLight,
307
/// A non-disappearing scrollbar.
308
ScrollbarNonDisappearing,
309
/// A themed focus outline (for outline:auto).
310
///
311
/// This isn't exposed to CSS at all, just here for convenience.
312
FocusOutline,
313
/// A dummy variant that should be last to let the GTK widget do hackery.
314
Count,
315
};
316
317
/// A specified value for a single side of a `border-style` property.
318
///
319
/// The order here corresponds to the integer values from the border conflict
320
/// resolution rules in CSS 2.1 § 17.6.2.1. Higher values override lower values.
321
enum class StyleBorderStyle : uint8_t {
322
Hidden,
323
None,
324
Inset,
325
Groove,
326
Outset,
327
Ridge,
328
Dotted,
329
Dashed,
330
Solid,
331
Double,
332
};
333
334
/// A kind of break between two boxes.
335
///
337
enum class StyleBreakBetween : uint8_t {
338
Always,
339
Auto,
340
Page,
341
Avoid,
342
Left,
343
Right,
344
};
345
346
/// A kind of break within a box.
347
///
349
enum class StyleBreakWithin : uint8_t {
350
Auto,
351
Avoid,
352
};
353
354
/// The CORS mode used for a CSS load.
355
enum class StyleCorsMode : uint8_t {
356
/// No CORS mode, so cross-origin loads can be done.
357
None,
358
/// Anonymous CORS request.
359
Anonymous,
360
};
361
362
/// The keywords allowed in the Cursor property.
363
///
365
enum class StyleCursorKind : uint8_t {
366
None,
367
Default,
368
Pointer,
369
ContextMenu,
370
Help,
371
Progress,
372
Wait,
373
Cell,
374
Crosshair,
375
Text,
376
VerticalText,
377
Alias,
378
Copy,
379
Move,
380
NoDrop,
381
NotAllowed,
382
Grab,
383
Grabbing,
384
EResize,
385
NResize,
386
NeResize,
387
NwResize,
388
SResize,
389
SeResize,
390
SwResize,
391
WResize,
392
EwResize,
393
NsResize,
394
NeswResize,
395
NwseResize,
396
ColResize,
397
RowResize,
398
AllScroll,
399
ZoomIn,
400
ZoomOut,
401
Auto,
402
};
403
404
enum class StyleDisplayInside : uint8_t {
405
None = 0,
406
Contents,
407
Flow,
408
FlowRoot,
409
Flex,
410
Grid,
411
Table,
412
TableRowGroup,
413
TableColumn,
414
TableColumnGroup,
415
TableHeaderGroup,
416
TableFooterGroup,
417
TableRow,
418
TableCell,
419
Ruby,
420
RubyBase,
421
RubyBaseContainer,
422
RubyText,
423
RubyTextContainer,
424
WebkitBox,
425
MozBox,
426
MozGrid,
427
MozGridGroup,
428
MozGridLine,
429
MozDeck,
430
MozGroupbox,
431
MozPopup,
432
};
433
434
/// Values for the display-mode media feature.
435
enum class StyleDisplayMode : uint8_t {
436
Browser = 0,
437
MinimalUi,
438
Standalone,
439
Fullscreen,
440
};
441
442
/// Defines an element’s display type, which consists of
443
/// the two basic qualities of how an element generates boxes
445
enum class StyleDisplayOutside : uint8_t {
446
None = 0,
447
Inline,
448
Block,
449
TableCaption,
450
InternalTable,
451
InternalRuby,
452
XUL,
453
};
454
455
/// A type for possible values for min- and max- flavors of width, height,
456
/// block-size, and inline-size.
457
enum class StyleExtremumLength : uint8_t {
458
MaxContent,
459
MinContent,
460
MozFitContent,
461
MozAvailable,
462
};
463
464
enum class StyleFillRule : uint8_t {
465
Nonzero,
466
Evenodd,
467
};
468
469
/// A computed value for the `float` property.
470
enum class StyleFloat : uint8_t {
471
Left,
472
Right,
473
None,
474
};
475
476
/// A font-display value for a @font-face rule.
477
/// The font-display descriptor determines how a font face is displayed based
478
/// on whether and when it is downloaded and ready to use.
479
enum class StyleFontDisplay : uint8_t {
480
Auto,
481
Block,
482
Swap,
483
Fallback,
484
Optional,
485
};
486
487
/// Font family names must either be given quoted as strings,
488
/// or unquoted as a sequence of one or more identifiers.
489
enum class StyleFontFamilyNameSyntax : uint8_t {
490
/// The family name was specified in a quoted form, e.g. "Font Name"
491
/// or 'Font Name'.
492
Quoted,
493
/// The family name was specified in an unquoted form as a sequence of
494
/// identifiers.
495
Identifiers,
496
};
497
498
/// A generic font-family name.
499
///
500
/// The order here is important, if you change it make sure that
501
/// `gfxPlatformFontList.h`s ranged array and `gfxFontFamilyList`'s
502
/// sSingleGenerics are updated as well.
503
enum class StyleGenericFontFamily : uint8_t {
504
/// No generic family specified, only for internal usage.
505
None,
506
Serif,
507
SansSerif,
508
Monospace,
509
Cursive,
510
Fantasy,
511
/// An internal value for emoji font selection.
512
MozEmoji,
513
};
514
515
/// Whether we used the modern notation or the compatibility `-webkit`, `-moz` prefixes.
516
enum class StyleGradientCompatMode : uint8_t {
517
/// Modern syntax.
518
Modern,
519
/// `-webkit` prefix.
520
WebKit,
521
/// `-moz` prefix
522
Moz,
523
};
524
525
/// A keyword for the X direction.
526
enum class StyleHorizontalPositionKeyword : uint8_t {
527
Left,
528
Right,
529
};
530
531
/// The path command absolute type.
532
enum class StyleIsAbsolute : uint8_t {
533
Yes,
534
No,
535
};
536
537
enum class StyleIsOrdinalInRange : uint8_t {
538
Auto,
539
InRange,
540
NotInRange,
541
NoOrdinalSpecified,
542
};
543
544
/// Values for the `line-break` property.
545
enum class StyleLineBreak : uint8_t {
546
Auto,
547
Loose,
548
Normal,
549
Strict,
550
Anywhere,
551
};
552
553
/// Specified and computed `-moz-list-reversed` property (for UA sheets only).
554
enum class StyleMozListReversed : uint8_t {
555
/// the initial value
556
False,
557
/// exclusively used for <ol reversed> in our html.css UA sheet
558
True,
559
};
560
561
/// Each style rule has an origin, which determines where it enters the cascade.
562
///
564
enum class StyleOrigin : uint8_t {
566
UserAgent = 1,
568
User = 2,
570
Author = 4,
571
};
572
573
/// The value for the `overflow-x` / `overflow-y` properties.
574
enum class StyleOverflow : uint8_t {
575
Visible,
576
Hidden,
577
Scroll,
578
Auto,
579
MozHiddenUnscrollable,
580
};
581
582
enum class StyleOverflowAnchor : uint8_t {
583
Auto,
584
None,
585
};
586
587
enum class StyleOverflowClipBox : uint8_t {
588
PaddingBox,
589
ContentBox,
590
};
591
592
/// Values for the `overflow-wrap` property.
593
enum class StyleOverflowWrap : uint8_t {
594
Normal,
595
BreakWord,
596
Anywhere,
597
};
598
599
enum class StyleOverscrollBehavior : uint8_t {
600
Auto,
601
Contain,
602
None,
603
};
604
605
/// The specified value for a single CSS paint-order property.
606
enum class StylePaintOrder : uint8_t {
607
/// `normal` variant
608
Normal = 0,
609
/// `fill` variant
610
Fill = 1,
611
/// `stroke` variant
612
Stroke = 2,
613
/// `markers` variant
614
Markers = 3,
615
};
616
617
/// Values for the prefers-color-scheme media feature.
618
enum class StylePrefersColorScheme : uint8_t {
619
Light,
620
Dark,
621
NoPreference,
622
};
623
624
/// The <size> in ray() function.
625
///
627
enum class StyleRaySize : uint8_t {
628
ClosestSide,
629
ClosestCorner,
630
FarthestSide,
631
FarthestCorner,
632
Sides,
633
};
634
635
/// A computed value for the `resize` property.
636
enum class StyleResize : uint8_t {
637
None,
638
Both,
639
Horizontal,
640
Vertical,
641
};
642
643
/// The kind of sanitization to use when parsing a stylesheet.
644
enum class StyleSanitizationKind : uint8_t {
645
/// Perform no sanitization.
646
None,
647
/// Allow only @font-face, style rules, and @namespace.
648
Standard,
649
/// Allow everything but conditional rules.
650
NoConditionalRules,
651
};
652
653
/// Specified value of scroll-snap-align keyword value.
654
enum class StyleScrollSnapAlignKeyword : uint8_t {
655
None,
656
Start,
657
End,
658
Center,
659
};
660
662
enum class StyleScrollSnapAxis : uint8_t {
663
X,
664
Y,
665
Block,
666
Inline,
667
Both,
668
};
669
671
enum class StyleScrollSnapStrictness : uint8_t {
672
None,
673
Mandatory,
674
Proximity,
675
};
676
678
enum class StyleShapeExtent : uint8_t {
679
ClosestSide,
680
FarthestSide,
681
ClosestCorner,
682
FarthestCorner,
683
Contain,
684
Cover,
685
};
686
687
enum class StyleStepPosition : uint8_t {
688
JumpStart,
689
JumpEnd,
690
JumpNone,
691
JumpBoth,
692
Start,
693
End,
694
};
695
697
enum class StyleSymbolsType : uint8_t {
698
Cyclic,
699
Numeric,
700
Alphabetic,
701
Symbolic,
702
Fixed,
703
};
704
705
/// System colors.
706
enum class StyleSystemColor : uint8_t {
707
WindowBackground,
708
WindowForeground,
709
WidgetBackground,
710
WidgetForeground,
711
WidgetSelectBackground,
712
WidgetSelectForeground,
713
Widget3DHighlight,
714
Widget3DShadow,
715
TextBackground,
716
TextForeground,
717
TextSelectBackground,
718
TextSelectForeground,
719
TextSelectForegroundCustom,
720
TextSelectBackgroundDisabled,
721
TextSelectBackgroundAttention,
722
TextHighlightBackground,
723
TextHighlightForeground,
724
IMERawInputBackground,
725
IMERawInputForeground,
726
IMERawInputUnderline,
727
IMESelectedRawTextBackground,
728
IMESelectedRawTextForeground,
729
IMESelectedRawTextUnderline,
730
IMEConvertedTextBackground,
731
IMEConvertedTextForeground,
732
IMEConvertedTextUnderline,
733
IMESelectedConvertedTextBackground,
734
IMESelectedConvertedTextForeground,
735
IMESelectedConvertedTextUnderline,
736
SpellCheckerUnderline,
737
Activeborder,
738
Activecaption,
739
Appworkspace,
740
Background,
741
Buttonface,
742
Buttonhighlight,
743
Buttonshadow,
744
Buttontext,
745
Captiontext,
746
Field,
747
Fieldtext,
748
Graytext,
749
Highlight,
750
Highlighttext,
751
Inactiveborder,
752
Inactivecaption,
753
Inactivecaptiontext,
754
Infobackground,
755
Infotext,
756
Menu,
757
Menutext,
758
Scrollbar,
759
Threeddarkshadow,
760
Threedface,
761
Threedhighlight,
762
Threedlightshadow,
763
Threedshadow,
764
Window,
765
Windowframe,
766
Windowtext,
767
MozButtondefault,
768
MozDefaultColor,
769
MozDefaultBackgroundColor,
770
MozDialog,
771
MozDialogtext,
772
/// Used to highlight valid regions to drop something onto.
773
MozDragtargetzone,
774
/// Used for selected but not focused cell backgrounds.
775
MozCellhighlight,
776
/// Used for selected but not focused cell text.
777
MozCellhighlighttext,
778
/// Used for selected but not focused html cell backgrounds.
779
MozHtmlCellhighlight,
780
/// Used for selected but not focused html cell text.
781
MozHtmlCellhighlighttext,
782
/// Used to button text background when hovered.
783
MozButtonhoverface,
784
/// Used to button text color when hovered.
785
MozButtonhovertext,
786
/// Used for menu item backgrounds when hovered.
787
MozMenuhover,
788
/// Used for menu item text when hovered.
789
MozMenuhovertext,
790
/// Used for menubar item text.
791
MozMenubartext,
792
/// Used for menubar item text when hovered.
793
MozMenubarhovertext,
794
/// On platforms where these colors are the same as -moz-field, use
795
/// -moz-fieldtext as foreground color
796
MozEventreerow,
797
MozOddtreerow,
798
/// Used for button text when pressed.
799
MozGtkButtonactivetext,
800
/// Used for button text when pressed.
801
MozMacButtonactivetext,
802
/// Background color of chrome toolbars in active windows.
803
MozMacChromeActive,
804
/// Background color of chrome toolbars in inactive windows.
805
MozMacChromeInactive,
806
/// Foreground color of default buttons.
807
MozMacDefaultbuttontext,
808
/// Ring color around text fields and lists.
809
MozMacFocusring,
810
/// Color used when mouse is over a menu item.
811
MozMacMenuselect,
812
/// Color used to do shadows on menu items.
813
MozMacMenushadow,
814
/// Color used to display text for disabled menu items.
815
MozMacMenutextdisable,
816
/// Color used to display text while mouse is over a menu item.
817
MozMacMenutextselect,
818
/// Text color of disabled text on toolbars.
819
MozMacDisabledtoolbartext,
820
/// Inactive light hightlight
821
MozMacSecondaryhighlight,
822
/// Font smoothing background colors needed by the Mac OS X theme, based on
823
/// -moz-appearance names.
824
MozMacVibrancyLight,
825
MozMacVibrancyDark,
826
MozMacVibrantTitlebarLight,
827
MozMacVibrantTitlebarDark,
828
MozMacMenupopup,
829
MozMacMenuitem,
830
MozMacActiveMenuitem,
831
MozMacSourceList,
832
MozMacSourceListSelection,
833
MozMacActiveSourceListSelection,
834
MozMacTooltip,
835
/// Accent color for title bar.
836
MozWinAccentcolor,
837
/// Color from drawing text over the accent color.
838
MozWinAccentcolortext,
839
/// Media rebar text.
840
MozWinMediatext,
841
/// Communications rebar text.
842
MozWinCommunicationstext,
843
/// Hyperlink color extracted from the system, not affected by the
844
/// browser.anchor_color user pref.
845
///
846
/// There is no OS-specified safe background color for this text, but it is
847
/// used regularly within Windows and the Gnome DE on Dialog and Window
848
/// colors.
849
MozNativehyperlinktext,
850
MozHyperlinktext,
851
MozActivehyperlinktext,
852
MozVisitedhyperlinktext,
853
/// Combobox widgets
854
MozComboboxtext,
855
MozCombobox,
856
MozGtkInfoBarText,
857
End,
858
};
859
860
/// Implements text-decoration-skip-ink which takes the keywords auto | none
861
///
863
enum class StyleTextDecorationSkipInk : uint8_t {
864
Auto,
865
None,
866
};
867
868
/// Fill mode for the text-emphasis-style property
869
enum class StyleTextEmphasisFillMode : uint8_t {
870
/// `filled`
871
Filled,
872
/// `open`
873
Open,
874
};
875
876
/// Shape keyword for the text-emphasis-style property
877
enum class StyleTextEmphasisShapeKeyword : uint8_t {
878
/// `dot`
879
Dot,
880
/// `circle`
881
Circle,
882
/// `double-circle`
883
DoubleCircle,
884
/// `triangle`
885
Triangle,
886
/// `sesame`
887
Sesame,
888
};
889
890
/// Specified keyword values for case transforms in the text-transform property. (These are exclusive.)
891
enum class StyleTextTransformCase {
892
/// No case transform.
893
None,
894
/// All uppercase.
895
Uppercase,
896
/// All lowercase.
897
Lowercase,
898
/// Capitalize each word.
899
Capitalize,
900
};
901
902
enum class StyleTimingKeyword : uint8_t {
903
Linear,
904
Ease,
905
EaseIn,
906
EaseOut,
907
EaseInOut,
908
};
909
910
/// The specified value for the `user-select` property.
911
///
913
enum class StyleUserSelect : uint8_t {
914
Auto,
915
Text,
916
None,
917
/// Force selection of all children.
918
All,
919
};
920
921
enum class StyleVerticalAlignKeyword : uint8_t {
922
Baseline,
923
Sub,
924
Super,
925
Top,
926
TextTop,
927
Middle,
928
Bottom,
929
TextBottom,
930
MozMiddleWithBaseline,
931
};
932
933
/// A keyword for the Y direction.
934
enum class StyleVerticalPositionKeyword : uint8_t {
935
Top,
936
Bottom,
937
};
938
939
/// Values for the `word-break` property.
940
enum class StyleWordBreak : uint8_t {
941
Normal,
942
BreakAll,
943
KeepAll,
944
/// The break-word value, needed for compat.
945
///
946
/// Specifying `word-break: break-word` makes `overflow-wrap` behave as
947
/// `anywhere`, and `word-break` behave like `normal`.
948
BreakWord,
949
};
950
951
/// Gecko-FFI-safe owned pointer.
952
///
953
/// Cannot be null, and leaks on drop, so needs to be converted into a rust-side
954
/// `Box` before.
955
template<typename GeckoType>
956
struct StyleOwned {
957
GeckoType *ptr;
958
959
bool operator==(const StyleOwned& other) const {
960
return ptr == other.ptr;
961
}
962
bool operator!=(const StyleOwned& other) const {
963
return ptr != other.ptr;
964
}
965
UniquePtr<GeckoType> Consume() {
966
UniquePtr<GeckoType> ret(ptr);
967
ptr = nullptr;
968
return ret;
969
}
970
};
971
972
/// Gecko-FFI-safe Arc (T is an ArcInner).
973
///
974
/// This can be null.
975
///
976
/// Leaks on drop. Please don't drop this.
977
template<typename GeckoType>
978
struct StyleStrong {
979
const GeckoType *ptr;
980
981
bool operator==(const StyleStrong& other) const {
982
return ptr == other.ptr;
983
}
984
bool operator!=(const StyleStrong& other) const {
985
return ptr != other.ptr;
986
}
987
already_AddRefed<GeckoType> Consume() {
988
already_AddRefed<GeckoType> ret(const_cast<GeckoType*>(ptr));
989
ptr = nullptr;
990
return ret;
991
}
992
};
993
994
/// A CSS float value.
995
using StyleCSSFloat = float;
996
997
/// The computed `<length>` value.
998
struct StyleCSSPixelLength {
999
StyleCSSFloat _0;
1000
1001
bool operator==(const StyleCSSPixelLength& other) const {
1002
return _0 == other._0;
1003
}
1004
bool operator!=(const StyleCSSPixelLength& other) const {
1005
return _0 != other._0;
1006
}
1007
inline nscoord ToAppUnits() const;
1008
inline bool IsZero() const;
1009
float ToCSSPixels() const { return _0; }
1010
inline void ScaleBy(float);
1011
};
1012
1013
/// An alias of computed `<length>` value.
1014
using StyleLength = StyleCSSPixelLength;
1015
1016
struct StyleLengthVariant {
1017
uint32_t tag;
1018
StyleLength length;
1019
1020
bool operator==(const StyleLengthVariant& other) const {
1021
return tag == other.tag &&
1022
length == other.length;
1023
}
1024
bool operator!=(const StyleLengthVariant& other) const {
1025
return tag != other.tag ||
1026
length != other.length;
1027
}
1028
};
1029
1030
/// A computed percentage.
1031
struct StylePercentage {
1032
StyleCSSFloat _0;
1033
1034
bool operator==(const StylePercentage& other) const {
1035
return _0 == other._0;
1036
}
1037
bool operator!=(const StylePercentage& other) const {
1038
return _0 != other._0;
1039
}
1040
};
1041
1042
struct StylePercentageVariant {
1043
uint32_t tag;
1044
StylePercentage percentage;
1045
1046
bool operator==(const StylePercentageVariant& other) const {
1047
return tag == other.tag &&
1048
percentage == other.percentage;
1049
}
1050
bool operator!=(const StylePercentageVariant& other) const {
1051
return tag != other.tag ||
1052
percentage != other.percentage;
1053
}
1054
};
1055
1056
/// The representation of a calc() function.
1057
struct StyleCalcLengthPercentage {
1058
StyleLength length;
1059
StylePercentage percentage;
1060
StyleAllowedNumericType clamping_mode;
1061
/// Whether we specified a percentage or not.
1062
bool has_percentage;
1063
1064
bool operator==(const StyleCalcLengthPercentage& other) const {
1065
return length == other.length &&
1066
percentage == other.percentage &&
1067
clamping_mode == other.clamping_mode &&
1068
has_percentage == other.has_percentage;
1069
}
1070
bool operator!=(const StyleCalcLengthPercentage& other) const {
1071
return length != other.length ||
1072
percentage != other.percentage ||
1073
clamping_mode != other.clamping_mode ||
1074
has_percentage != other.has_percentage;
1075
}
1076
};
1077
1078
#if defined(SERVO_32_BITS)
1079
struct StyleCalcVariant {
1080
uint32_t tag;
1081
StyleCalcLengthPercentage *ptr;
1082
1083
bool operator==(const StyleCalcVariant& other) const {
1084
return tag == other.tag &&
1085
ptr == other.ptr;
1086
}
1087
bool operator!=(const StyleCalcVariant& other) const {
1088
return tag != other.tag ||
1089
ptr != other.ptr;
1090
}
1091
};
1092
#endif
1093
1094
#if defined(HAVE_64BIT_BUILD)
1095
struct StyleCalcVariant {
1096
StyleCalcLengthPercentage *ptr;
1097
1098
bool operator==(const StyleCalcVariant& other) const {
1099
return ptr == other.ptr;
1100
}
1101
bool operator!=(const StyleCalcVariant& other) const {
1102
return ptr != other.ptr;
1103
}
1104
};
1105
#endif
1106
1107
struct StyleTagVariant {
1108
uint32_t tag;
1109
1110
bool operator==(const StyleTagVariant& other) const {
1111
return tag == other.tag;
1112
}
1113
bool operator!=(const StyleTagVariant& other) const {
1114
return tag != other.tag;
1115
}
1116
};
1117
1118
union StyleLengthPercentageUnion {
1119
StyleLengthVariant length;
1120
StylePercentageVariant percentage;
1121
StyleCalcVariant calc;
1122
StyleTagVariant tag;
1123
using Self = StyleLengthPercentageUnion;
1124
1125
// TODO(emilio): cbindgen should be able to generate these in the body of the
1126
// union, but it seems it's only implemented for structs, not unions.
1127
static const uint32_t TAG_CALC = StyleLengthPercentageUnion_TAG_CALC;
1128
static const uint32_t TAG_LENGTH = StyleLengthPercentageUnion_TAG_LENGTH;
1129
static const uint32_t TAG_PERCENTAGE = StyleLengthPercentageUnion_TAG_PERCENTAGE;
1130
static const uint32_t TAG_MASK = StyleLengthPercentageUnion_TAG_MASK;
1131
1132
private:
1133
uint32_t Tag() const {
1134
return tag.tag & TAG_MASK;
1135
}
1136
1137
public:
1138
// We need to do all this manually because cbingen can't reason about unions.
1139
inline StyleLengthPercentageUnion();
1140
inline StyleLengthPercentageUnion(const Self&);
1141
inline ~StyleLengthPercentageUnion();
1142
inline Self& operator=(const Self&);
1143
1144
inline bool operator==(const Self& aOther) const;
1145
inline bool operator!=(const Self& aOther) const;
1146
1147
inline bool IsLength() const;
1148
inline bool IsPercentage() const;
1149
inline bool IsCalc() const;
1150
1151
inline const StyleLength& AsLength() const;
1152
inline StyleLength& AsLength();
1153
1154
inline const StylePercentage& AsPercentage() const;
1155
inline StylePercentage& AsPercentage();
1156
1157
inline const StyleCalcLengthPercentage& AsCalc() const;
1158
inline StyleCalcLengthPercentage& AsCalc();
1159
1160
static inline Self Zero();
1161
static inline Self FromAppUnits(nscoord);
1162
static inline Self FromPixels(CSSCoord);
1163
static inline Self FromPercentage(float);
1164
1165
inline void ScaleLengthsBy(float);
1166
inline CSSCoord LengthInCSSPixels() const;
1167
inline float Percentage() const;
1168
inline bool HasPercent() const;
1169
inline bool ConvertsToLength() const;
1170
inline nscoord ToLength() const;
1171
inline bool ConvertsToPercentage() const;
1172
inline bool HasLengthAndPercentage() const;
1173
inline float ToPercentage() const;
1174
inline bool IsDefinitelyZero() const;
1175
inline CSSCoord ResolveToCSSPixels(CSSCoord aPercentageBasisInCSSPixels) const;
1176
template<typename T> inline CSSCoord ResolveToCSSPixelsWith(T aPercentageGetter) const;
1177
template<typename T, typename U>
1178
inline nscoord Resolve(T aPercentageGetter, U aPercentRoundingFunction) const;
1179
template<typename T>
1180
inline nscoord Resolve(nscoord aPercentageBasis, T aPercentRoundingFunction) const;
1181
template<typename T> inline nscoord Resolve(T aPercentageGetter) const;
1182
inline nscoord Resolve(nscoord aPercentageBasis) const;
1183
};
1184
1185
/// A `<length-percentage>` value. This can be either a `<length>`, a
1186
/// `<percentage>`, or a combination of both via `calc()`.
1187
///
1188
///
1190
///
1191
/// The tag is stored in the lower two bits.
1192
///
1193
/// We need to use a struct instead of the union directly because unions with
1194
/// Drop implementations are unstable, looks like.
1195
///
1196
/// Also we need the union and the variants to be `pub` (even though the member
1197
/// is private) so that cbindgen generates it. They're not part of the public
1198
/// API otherwise.
1199
using StyleLengthPercentage = StyleLengthPercentageUnion;
1200
1201
/// The computed value of a CSS horizontal position.
1202
using StyleHorizontalPosition = StyleLengthPercentage;
1203
1204
/// The computed value of a CSS vertical position.
1205
using StyleVerticalPosition = StyleLengthPercentage;
1206
1207
/// A generic type for representing a CSS [position](https://drafts.csswg.org/css-values/#position).
1208
template<typename H, typename V>
1209
struct StyleGenericPosition {
1210
/// The horizontal component of position.
1211
H horizontal;
1212
/// The vertical component of position.
1213
V vertical;
1214
1215
bool operator==(const StyleGenericPosition& other) const {
1216
return horizontal == other.horizontal &&
1217
vertical == other.vertical;
1218
}
1219
bool operator!=(const StyleGenericPosition& other) const {
1220
return horizontal != other.horizontal ||
1221
vertical != other.vertical;
1222
}
1223
inline bool HasPercent() const;
1224
inline bool DependsOnPositioningAreaSize() const;
1225
static inline StyleGenericPosition FromPercentage(float);
1226
};
1227
1228
/// The computed value of a CSS `<position>`
1229
using StylePosition = StyleGenericPosition<StyleHorizontalPosition, StyleVerticalPosition>;
1230
1231
/// A generic type for representing an `Auto | <position>`.
1232
/// This is used by <offset-anchor> for now.
1234
template<typename Pos>
1235
struct StyleGenericPositionOrAuto {
1236
enum class Tag : uint8_t {
1237
/// The <position> value.
1238
Position,
1239
/// The keyword `auto`.
1240
Auto,
1241
};
1242
1243
struct StylePosition_Body {
1244
Pos _0;
1245
1246
bool operator==(const StylePosition_Body& other) const {
1247
return _0 == other._0;
1248
}
1249
bool operator!=(const StylePosition_Body& other) const {
1250
return _0 != other._0;
1251
}
1252
};
1253
1254
Tag tag;
1255
union {
1256
StylePosition_Body position;
1257
};
1258
1259
static StyleGenericPositionOrAuto Position(const Pos &a0) {
1260
StyleGenericPositionOrAuto result;
1261
::new (&result.position._0) (Pos)(a0);
1262
result.tag = Tag::Position;
1263
return result;
1264
}
1265
1266
static StyleGenericPositionOrAuto Auto() {
1267
StyleGenericPositionOrAuto result;
1268
result.tag = Tag::Auto;
1269
return result;
1270
}
1271
1272
bool IsPosition() const {
1273
return tag == Tag::Position;
1274
}
1275
1276
bool IsAuto() const {
1277
return tag == Tag::Auto;
1278
}
1279
1280
const Pos& AsPosition() const {
1281
MOZ_ASSERT(IsPosition());
1282
return position._0;
1283
}
1284
1285
bool operator==(const StyleGenericPositionOrAuto& other) const {
1286
if (tag != other.tag) {
1287
return false;
1288
}
1289
switch (tag) {
1290
case Tag::Position: return position == other.position;
1291
default: return true;
1292
}
1293
}
1294
1295
bool operator!=(const StyleGenericPositionOrAuto& other) const {
1296
return !(*this == other);
1297
}
1298
1299
private:
1300
StyleGenericPositionOrAuto() {
1301
1302
}
1303
public:
1304
1305
1306
~StyleGenericPositionOrAuto() {
1307
switch (tag) {
1308
case Tag::Position: position.~StylePosition_Body(); break;
1309
default: break;
1310
}
1311
}
1312
1313
StyleGenericPositionOrAuto(const StyleGenericPositionOrAuto& other)
1314
: tag(other.tag) {
1315
switch (tag) {
1316
case Tag::Position: ::new (&position) (StylePosition_Body)(other.position); break;
1317
default: break;
1318
}
1319
}
1320
StyleGenericPositionOrAuto& operator=(const StyleGenericPositionOrAuto& other) {
1321
if (this != &other) {
1322
this->~StyleGenericPositionOrAuto();
1323
new (this) StyleGenericPositionOrAuto(other);
1324
}
1325
return *this;
1326
}
1327
};
1328
1329
/// The computed value of an `auto | <position>`
1330
using StylePositionOrAuto = StyleGenericPositionOrAuto<StylePosition>;
1331
1332
/// A computed angle in degrees.
1333
struct StyleAngle {
1334
StyleCSSFloat _0;
1335
1336
bool operator==(const StyleAngle& other) const {
1337
return _0 == other._0;
1338
}
1339
bool operator!=(const StyleAngle& other) const {
1340
return _0 != other._0;
1341
}
1342
inline static StyleAngle Zero();
1343
inline float ToDegrees() const;
1344
inline double ToRadians() const;
1345
StyleAngle operator+(const StyleAngle& aAngle) const {
1346
return StyleAngle{_0 + aAngle._0};
1347
}
1348
StyleAngle operator-(const StyleAngle& aAngle) const {
1349
return StyleAngle{_0 - aAngle._0};
1350
}
1351
};
1352
1353
/// The path coord type.
1354
struct StyleCoordPair {
1355
StyleCSSFloat _0;
1356
StyleCSSFloat _1;
1357
1358
bool operator==(const StyleCoordPair& other) const {
1359
return _0 == other._0 &&
1360
_1 == other._1;
1361
}
1362
bool operator!=(const StyleCoordPair& other) const {
1363
return _0 != other._0 ||
1364
_1 != other._1;
1365
}
1366
explicit StyleCoordPair(const gfx::Point& aPoint): _0(aPoint.x), _1(aPoint.y) {}
1367
};
1368
1369
/// The EllipticalArc flag type.
1370
struct StyleArcFlag {
1371
bool _0;
1372
1373
bool operator==(const StyleArcFlag& other) const {
1374
return _0 == other._0;
1375
}
1376
bool operator!=(const StyleArcFlag& other) const {
1377
return _0 != other._0;
1378
}
1379
};
1380
1381
/// The SVG path command.
1382
/// The fields of these commands are self-explanatory, so we skip the documents.
1383
/// Note: the index of the control points, e.g. control1, control2, are mapping to the control
1384
/// points of the Bézier curve in the spec.
1385
///
1387
struct StylePathCommand {
1388
enum class Tag : uint8_t {
1389
/// The unknown type.
1391
Unknown,
1392
/// The "moveto" command.
1393
MoveTo,
1394
/// The "lineto" command.
1395
LineTo,
1396
/// The horizontal "lineto" command.
1397
HorizontalLineTo,
1398
/// The vertical "lineto" command.
1399
VerticalLineTo,
1400
/// The cubic Bézier curve command.
1401
CurveTo,
1402
/// The smooth curve command.
1403
SmoothCurveTo,
1404
/// The quadratic Bézier curve command.
1405
QuadBezierCurveTo,
1406
/// The smooth quadratic Bézier curve command.
1407
SmoothQuadBezierCurveTo,
1408
/// The elliptical arc curve command.
1409
EllipticalArc,
1410
/// The "closepath" command.
1411
ClosePath,
1412
};
1413
1414
struct StyleMoveTo_Body {
1415
StyleCoordPair point;
1416
StyleIsAbsolute absolute;
1417
1418
bool operator==(const StyleMoveTo_Body& other) const {
1419
return point == other.point &&
1420
absolute == other.absolute;
1421
}
1422
bool operator!=(const StyleMoveTo_Body& other) const {
1423
return point != other.point ||
1424
absolute != other.absolute;
1425
}
1426
};
1427
1428
struct StyleLineTo_Body {
1429
StyleCoordPair point;
1430
StyleIsAbsolute absolute;
1431
1432
bool operator==(const StyleLineTo_Body& other) const {
1433
return point == other.point &&
1434
absolute == other.absolute;
1435
}
1436
bool operator!=(const StyleLineTo_Body& other) const {
1437
return point != other.point ||
1438
absolute != other.absolute;
1439
}
1440
};
1441
1442
struct StyleHorizontalLineTo_Body {
1443
StyleCSSFloat x;
1444
StyleIsAbsolute absolute;
1445
1446
bool operator==(const StyleHorizontalLineTo_Body& other) const {
1447
return x == other.x &&
1448
absolute == other.absolute;
1449
}
1450
bool operator!=(const StyleHorizontalLineTo_Body& other) const {
1451
return x != other.x ||
1452
absolute != other.absolute;
1453
}
1454
};
1455
1456
struct StyleVerticalLineTo_Body {
1457
StyleCSSFloat y;
1458
StyleIsAbsolute absolute;
1459
1460
bool operator==(const StyleVerticalLineTo_Body& other) const {
1461
return y == other.y &&
1462
absolute == other.absolute;
1463
}
1464
bool operator!=(const StyleVerticalLineTo_Body& other) const {
1465
return y != other.y ||
1466
absolute != other.absolute;
1467
}
1468
};
1469
1470
struct StyleCurveTo_Body {
1471
StyleCoordPair control1;
1472
StyleCoordPair control2;
1473
StyleCoordPair point;
1474
StyleIsAbsolute absolute;
1475
1476
bool operator==(const StyleCurveTo_Body& other) const {
1477
return control1 == other.control1 &&
1478
control2 == other.control2 &&
1479
point == other.point &&
1480
absolute == other.absolute;
1481
}
1482
bool operator!=(const StyleCurveTo_Body& other) const {
1483
return control1 != other.control1 ||
1484
control2 != other.control2 ||
1485
point != other.point ||
1486
absolute != other.absolute;
1487
}
1488
};
1489
1490
struct StyleSmoothCurveTo_Body {
1491
StyleCoordPair control2;
1492
StyleCoordPair point;
1493
StyleIsAbsolute absolute;
1494
1495
bool operator==(const StyleSmoothCurveTo_Body& other) const {
1496
return control2 == other.control2 &&
1497
point == other.point &&
1498
absolute == other.absolute;
1499
}
1500
bool operator!=(const StyleSmoothCurveTo_Body& other) const {
1501
return control2 != other.control2 ||
1502
point != other.point ||
1503
absolute != other.absolute;
1504
}
1505
};
1506
1507
struct StyleQuadBezierCurveTo_Body {
1508
StyleCoordPair control1;
1509
StyleCoordPair point;
1510
StyleIsAbsolute absolute;
1511
1512
bool operator==(const StyleQuadBezierCurveTo_Body& other) const {
1513
return control1 == other.control1 &&
1514
point == other.point &&
1515
absolute == other.absolute;
1516
}
1517
bool operator!=(const StyleQuadBezierCurveTo_Body& other) const {
1518
return control1 != other.control1 ||
1519
point != other.point ||
1520
absolute != other.absolute;
1521
}
1522
};
1523
1524
struct StyleSmoothQuadBezierCurveTo_Body {
1525
StyleCoordPair point;
1526
StyleIsAbsolute absolute;
1527
1528
bool operator==(const StyleSmoothQuadBezierCurveTo_Body& other) const {
1529
return point == other.point &&
1530
absolute == other.absolute;
1531
}
1532
bool operator!=(const StyleSmoothQuadBezierCurveTo_Body& other) const {
1533
return point != other.point ||
1534
absolute != other.absolute;
1535
}
1536
};
1537
1538
struct StyleEllipticalArc_Body {
1539
StyleCSSFloat rx;
1540
StyleCSSFloat ry;
1541
StyleCSSFloat angle;
1542
StyleArcFlag large_arc_flag;
1543
StyleArcFlag sweep_flag;
1544
StyleCoordPair point;
1545
StyleIsAbsolute absolute;
1546
1547
bool operator==(const StyleEllipticalArc_Body& other) const {
1548
return rx == other.rx &&
1549
ry == other.ry &&
1550
angle == other.angle &&
1551
large_arc_flag == other.large_arc_flag &&
1552
sweep_flag == other.sweep_flag &&
1553
point == other.point &&
1554
absolute == other.absolute;
1555
}
1556
bool operator!=(const StyleEllipticalArc_Body& other) const {
1557
return rx != other.rx ||
1558
ry != other.ry ||
1559
angle != other.angle ||
1560
large_arc_flag != other.large_arc_flag ||
1561
sweep_flag != other.sweep_flag ||
1562
point != other.point ||
1563
absolute != other.absolute;
1564
}
1565
};
1566
1567
Tag tag;
1568
union {
1569
StyleMoveTo_Body move_to;
1570
StyleLineTo_Body line_to;
1571
StyleHorizontalLineTo_Body horizontal_line_to;
1572
StyleVerticalLineTo_Body vertical_line_to;
1573
StyleCurveTo_Body curve_to;
1574
StyleSmoothCurveTo_Body smooth_curve_to;
1575
StyleQuadBezierCurveTo_Body quad_bezier_curve_to;
1576
StyleSmoothQuadBezierCurveTo_Body smooth_quad_bezier_curve_to;
1577
StyleEllipticalArc_Body elliptical_arc;
1578
};
1579
1580
static StylePathCommand Unknown() {
1581
StylePathCommand result;
1582
result.tag = Tag::Unknown;
1583
return result;
1584
}
1585
1586
static StylePathCommand MoveTo(const StyleCoordPair &aPoint,
1587
const StyleIsAbsolute &aAbsolute) {
1588
StylePathCommand result;
1589
::new (&result.move_to.point) (StyleCoordPair)(aPoint);
1590
::new (&result.move_to.absolute) (StyleIsAbsolute)(aAbsolute);
1591
result.tag = Tag::MoveTo;
1592
return result;
1593
}
1594
1595
static StylePathCommand LineTo(const StyleCoordPair &aPoint,
1596
const StyleIsAbsolute &aAbsolute) {
1597
StylePathCommand result;
1598
::new (&result.line_to.point) (StyleCoordPair)(aPoint);
1599
::new (&result.line_to.absolute) (StyleIsAbsolute)(aAbsolute);
1600
result.tag = Tag::LineTo;
1601
return result;
1602
}
1603
1604
static StylePathCommand HorizontalLineTo(const StyleCSSFloat &aX,
1605
const StyleIsAbsolute &aAbsolute) {
1606
StylePathCommand result;
1607
::new (&result.horizontal_line_to.x) (StyleCSSFloat)(aX);
1608
::new (&result.horizontal_line_to.absolute) (StyleIsAbsolute)(aAbsolute);
1609
result.tag = Tag::HorizontalLineTo;
1610
return result;
1611
}
1612
1613
static StylePathCommand VerticalLineTo(const StyleCSSFloat &aY,
1614
const StyleIsAbsolute &aAbsolute) {
1615
StylePathCommand result;
1616
::new (&result.vertical_line_to.y) (StyleCSSFloat)(aY);
1617
::new (&result.vertical_line_to.absolute) (StyleIsAbsolute)(aAbsolute);
1618
result.tag = Tag::VerticalLineTo;
1619
return result;
1620
}
1621
1622
static StylePathCommand CurveTo(const StyleCoordPair &aControl1,
1623
const StyleCoordPair &aControl2,
1624
const StyleCoordPair &aPoint,
1625
const StyleIsAbsolute &aAbsolute) {
1626
StylePathCommand result;
1627
::new (&result.curve_to.control1) (StyleCoordPair)(aControl1);
1628
::new (&result.curve_to.control2) (StyleCoordPair)(aControl2);
1629
::new (&result.curve_to.point) (StyleCoordPair)(aPoint);
1630
::new (&result.curve_to.absolute) (StyleIsAbsolute)(aAbsolute);
1631
result.tag = Tag::CurveTo;
1632
return result;
1633
}
1634
1635
static StylePathCommand SmoothCurveTo(const StyleCoordPair &aControl2,
1636
const StyleCoordPair &aPoint,
1637
const StyleIsAbsolute &aAbsolute) {
1638
StylePathCommand result;
1639
::new (&result.smooth_curve_to.control2) (StyleCoordPair)(aControl2);
1640
::new (&result.smooth_curve_to.point) (StyleCoordPair)(aPoint);
1641
::new (&result.smooth_curve_to.absolute) (StyleIsAbsolute)(aAbsolute);
1642
result.tag = Tag::SmoothCurveTo;
1643
return result;
1644
}
1645
1646
static StylePathCommand QuadBezierCurveTo(const StyleCoordPair &aControl1,
1647
const StyleCoordPair &aPoint,
1648
const StyleIsAbsolute &aAbsolute) {
1649
StylePathCommand result;
1650
::new (&result.quad_bezier_curve_to.control1) (StyleCoordPair)(aControl1);
1651
::new (&result.quad_bezier_curve_to.point) (StyleCoordPair)(aPoint);
1652
::new (&result.quad_bezier_curve_to.absolute) (StyleIsAbsolute)(aAbsolute);
1653
result.tag = Tag::QuadBezierCurveTo;
1654
return result;
1655
}
1656
1657
static StylePathCommand SmoothQuadBezierCurveTo(const StyleCoordPair &aPoint,
1658
const StyleIsAbsolute &aAbsolute) {
1659
StylePathCommand result;
1660
::new (&result.smooth_quad_bezier_curve_to.point) (StyleCoordPair)(aPoint);
1661
::new (&result.smooth_quad_bezier_curve_to.absolute) (StyleIsAbsolute)(aAbsolute);
1662
result.tag = Tag::SmoothQuadBezierCurveTo;
1663
return result;
1664
}
1665
1666
static StylePathCommand EllipticalArc(const StyleCSSFloat &aRx,
1667
const StyleCSSFloat &aRy,
1668
const StyleCSSFloat &aAngle,
1669
const StyleArcFlag &aLargeArcFlag,
1670
const StyleArcFlag &aSweepFlag,
1671
const StyleCoordPair &aPoint,
1672
const StyleIsAbsolute &aAbsolute) {
1673
StylePathCommand result;
1674
::new (&result.elliptical_arc.rx) (StyleCSSFloat)(aRx);
1675
::new (&result.elliptical_arc.ry) (StyleCSSFloat)(aRy);
1676
::new (&result.elliptical_arc.angle) (StyleCSSFloat)(aAngle);
1677
::new (&result.elliptical_arc.large_arc_flag) (StyleArcFlag)(aLargeArcFlag);
1678
::new (&result.elliptical_arc.sweep_flag) (StyleArcFlag)(aSweepFlag);
1679
::new (&result.elliptical_arc.point) (StyleCoordPair)(aPoint);
1680
::new (&result.elliptical_arc.absolute) (StyleIsAbsolute)(aAbsolute);
1681
result.tag = Tag::EllipticalArc;
1682
return result;
1683
}
1684
1685
static StylePathCommand ClosePath() {
1686
StylePathCommand result;
1687
result.tag = Tag::ClosePath;
1688
return result;
1689
}
1690
1691
bool IsUnknown() const {
1692
return tag == Tag::Unknown;
1693
}
1694
1695
bool IsMoveTo() const {
1696
return tag == Tag::MoveTo;
1697
}
1698
1699
bool IsLineTo() const {
1700
return tag == Tag::LineTo;
1701
}
1702
1703
bool IsHorizontalLineTo() const {
1704
return tag == Tag::HorizontalLineTo;
1705
}
1706
1707
bool IsVerticalLineTo() const {
1708
return tag == Tag::VerticalLineTo;
1709
}
1710
1711
bool IsCurveTo() const {
1712
return tag == Tag::CurveTo;
1713
}
1714
1715
bool IsSmoothCurveTo() const {
1716
return tag == Tag::SmoothCurveTo;
1717
}
1718
1719
bool IsQuadBezierCurveTo() const {
1720
return tag == Tag::QuadBezierCurveTo;
1721
}
1722
1723
bool IsSmoothQuadBezierCurveTo() const {
1724
return tag == Tag::SmoothQuadBezierCurveTo;
1725
}
1726
1727
bool IsEllipticalArc() const {
1728
return tag == Tag::EllipticalArc;
1729
}
1730
1731
bool IsClosePath() const {
1732
return tag == Tag::ClosePath;
1733
}
1734
1735
const StyleMoveTo_Body& AsMoveTo() const {
1736
MOZ_ASSERT(IsMoveTo());
1737
return move_to;
1738
}
1739
1740
const StyleLineTo_Body& AsLineTo() const {
1741
MOZ_ASSERT(IsLineTo());
1742
return line_to;
1743
}
1744
1745
const StyleHorizontalLineTo_Body& AsHorizontalLineTo() const {
1746
MOZ_ASSERT(IsHorizontalLineTo());
1747
return horizontal_line_to;
1748
}
1749
1750
const StyleVerticalLineTo_Body& AsVerticalLineTo() const {
1751
MOZ_ASSERT(IsVerticalLineTo());
1752
return vertical_line_to;
1753
}
1754
1755
const StyleCurveTo_Body& AsCurveTo() const {
1756
MOZ_ASSERT(IsCurveTo());
1757
return curve_to;
1758
}
1759
1760
const StyleSmoothCurveTo_Body& AsSmoothCurveTo() const {
1761
MOZ_ASSERT(IsSmoothCurveTo());
1762
return smooth_curve_to;
1763
}
1764
1765
const StyleQuadBezierCurveTo_Body& AsQuadBezierCurveTo() const {
1766
MOZ_ASSERT(IsQuadBezierCurveTo());
1767
return quad_bezier_curve_to;
1768
}
1769
1770
const StyleSmoothQuadBezierCurveTo_Body& AsSmoothQuadBezierCurveTo() const {
1771
MOZ_ASSERT(IsSmoothQuadBezierCurveTo());
1772
return smooth_quad_bezier_curve_to;
1773
}
1774
1775
const StyleEllipticalArc_Body& AsEllipticalArc() const {
1776
MOZ_ASSERT(IsEllipticalArc());
1777
return elliptical_arc;
1778
}
1779
1780
bool operator==(const StylePathCommand& other) const {
1781
if (tag != other.tag) {
1782
return false;
1783
}
1784
switch (tag) {
1785
case Tag::MoveTo: return move_to == other.move_to;
1786
case Tag::LineTo: return line_to == other.line_to;
1787
case Tag::HorizontalLineTo: return horizontal_line_to == other.horizontal_line_to;
1788
case Tag::VerticalLineTo: return vertical_line_to == other.vertical_line_to;
1789
case Tag::CurveTo: return curve_to == other.curve_to;
1790
case Tag::SmoothCurveTo: return smooth_curve_to == other.smooth_curve_to;
1791
case Tag::QuadBezierCurveTo: return quad_bezier_curve_to == other.quad_bezier_curve_to;
1792
case Tag::SmoothQuadBezierCurveTo: return smooth_quad_bezier_curve_to == other.smooth_quad_bezier_curve_to;
1793
case Tag::EllipticalArc: return elliptical_arc == other.elliptical_arc;
1794
default: return true;
1795
}
1796
}
1797
1798
bool operator!=(const StylePathCommand& other) const {
1799
return !(*this == other);
1800
}
1801
1802
private:
1803
StylePathCommand() {
1804
1805
}
1806
public:
1807
1808
1809
~StylePathCommand() {
1810
switch (tag) {
1811
case Tag::MoveTo: move_to.~StyleMoveTo_Body(); break;
1812
case Tag::LineTo: line_to.~StyleLineTo_Body(); break;
1813
case Tag::HorizontalLineTo: horizontal_line_to.~StyleHorizontalLineTo_Body(); break;
1814
case Tag::VerticalLineTo: vertical_line_to.~StyleVerticalLineTo_Body(); break;
1815
case Tag::CurveTo: curve_to.~StyleCurveTo_Body(); break;
1816
case Tag::SmoothCurveTo: smooth_curve_to.~StyleSmoothCurveTo_Body(); break;
1817
case Tag::QuadBezierCurveTo: quad_bezier_curve_to.~StyleQuadBezierCurveTo_Body(); break;
1818
case Tag::SmoothQuadBezierCurveTo: smooth_quad_bezier_curve_to.~StyleSmoothQuadBezierCurveTo_Body(); break;
1819
case Tag::EllipticalArc: elliptical_arc.~StyleEllipticalArc_Body(); break;
1820
default: break;
1821
}
1822
}
1823
1824
StylePathCommand(const StylePathCommand& other)
1825
: tag(other.tag) {
1826
switch (tag) {
1827
case Tag::MoveTo: ::new (&move_to) (StyleMoveTo_Body)(other.move_to); break;
1828
case Tag::LineTo: ::new (&line_to) (StyleLineTo_Body)(other.line_to); break;
1829
case Tag::HorizontalLineTo: ::new (&horizontal_line_to) (StyleHorizontalLineTo_Body)(other.horizontal_line_to); break;
1830
case Tag::VerticalLineTo: ::new (&vertical_line_to) (StyleVerticalLineTo_Body)(other.vertical_line_to); break;
1831
case Tag::CurveTo: ::new (&curve_to) (StyleCurveTo_Body)(other.curve_to); break;
1832
case Tag::SmoothCurveTo: ::new (&smooth_curve_to) (StyleSmoothCurveTo_Body)(other.smooth_curve_to); break;
1833
case Tag::QuadBezierCurveTo: ::new (&quad_bezier_curve_to) (StyleQuadBezierCurveTo_Body)(other.quad_bezier_curve_to); break;
1834
case Tag::SmoothQuadBezierCurveTo: ::new (&smooth_quad_bezier_curve_to) (StyleSmoothQuadBezierCurveTo_Body)(other.smooth_quad_bezier_curve_to); break;
1835
case Tag::EllipticalArc: ::new (&elliptical_arc) (StyleEllipticalArc_Body)(other.elliptical_arc); break;
1836
default: break;
1837
}
1838
}
1839
StylePathCommand& operator=(const StylePathCommand& other) {
1840
if (this != &other) {
1841
this->~StylePathCommand();
1842
new (this) StylePathCommand(other);
1843
}
1844
return *this;
1845
}
1846
};
1847
1848
/// Header data with an inline length. Consumers that use HeaderWithLength as the
1849
/// Header type in HeaderSlice can take advantage of ThinArc.
1850
template<typename H>
1851
struct StyleHeaderWithLength {
1852
/// The fixed-sized data.
1853
H header;
1854
/// The slice length.
1855
uintptr_t length;
1856
1857
bool operator==(const StyleHeaderWithLength& other) const {
1858
return header == other.header &&
1859
length == other.length;
1860
}
1861
bool operator!=(const StyleHeaderWithLength& other) const {
1862
return header != other.header ||
1863
length != other.length;
1864
}
1865
};
1866
1867
/// Structure to allow Arc-managing some fixed-sized data and a variably-sized
1868
/// slice in a single allocation.
1869
template<typename H, typename T>
1870
struct StyleHeaderSlice {
1871
/// The fixed-sized data.
1872
H header;
1873
/// The dynamically-sized data.
1874
T slice;
1875
1876
bool operator==(const StyleHeaderSlice& other) const {
1877
return header == other.header &&
1878
slice == other.slice;
1879
}
1880
bool operator!=(const StyleHeaderSlice& other) const {
1881
return header != other.header ||
1882
slice != other.slice;
1883
}
1884
};
1885
1886
template<typename H, typename T>
1887
using StyleHeaderSliceWithLength = StyleHeaderSlice<StyleHeaderWithLength<H>, T>;
1888
1889
/// The object allocated by an Arc<T>
1890
template<typename T>
1891
struct StyleArcInner {
1892
StyleAtomicUsize count;
1893
T data;
1894
1895
bool operator==(const StyleArcInner& other) const {
1896
return count == other.count &&
1897
data == other.data;
1898
}
1899
bool operator!=(const StyleArcInner& other) const {
1900
return count != other.count ||
1901
data != other.data;
1902
}
1903
// Increase the reference count.
1904
inline void IncrementRef();
1905
// Release the reference count, and return whether the result must be freed or not.
1906
MOZ_MUST_USE inline bool DecrementRef();
1907
};
1908
1909
/// A "thin" `Arc` containing dynamically sized data
1910
///
1911
/// This is functionally equivalent to Arc<(H, [T])>
1912
///
1913
/// When you create an `Arc` containing a dynamically sized type
1914
/// like `HeaderSlice<H, [T]>`, the `Arc` is represented on the stack
1915
/// as a "fat pointer", where the length of the slice is stored
1916
/// alongside the `Arc`'s pointer. In some situations you may wish to
1917
/// have a thin pointer instead, perhaps for FFI compatibility
1918
/// or space efficiency.
1919
///
1920
/// Note that we use `[T; 0]` in order to have the right alignment for `T`.
1921
///
1922
/// `ThinArc` solves this by storing the length in the allocation itself,
1923
/// via `HeaderSliceWithLength`.
1924
template<typename H, typename T>
1925
struct StyleThinArc {
1926
StyleArcInner<StyleHeaderSliceWithLength<H, T[0]>> *ptr;
1927
1928
bool operator==(const StyleThinArc& other) const {
1929
return ptr == other.ptr;
1930
}
1931
bool operator!=(const StyleThinArc& other) const {
1932
return ptr != other.ptr;
1933
}
1934
};
1935
1936
/// A wrapper type for a refcounted slice using ThinArc.
1937
///
1938
template<typename T>
1939
struct StyleArcSlice {
1940
StyleThinArc<uint64_t, T> _0;
1941
inline StyleArcSlice();
1942
inline StyleArcSlice(const StyleArcSlice& aOther);
1943
1944
// Should be easily implementable if wanted, but the default implementation would leak.
1945
StyleArcSlice& operator=(const StyleArcSlice&) = delete;
1946
StyleArcSlice& operator=(StyleArcSlice&&) = delete;
1947
1948
inline explicit StyleArcSlice(const StyleForgottenArcSlicePtr<T>& aPtr);
1949
inline ~StyleArcSlice();
1950
inline Span<const T> AsSpan() const;
1951
inline size_t Length() const;
1952
inline bool IsEmpty() const;
1953
inline bool operator==(const StyleArcSlice& other) const;
1954
inline bool operator!=(const StyleArcSlice& other) const;
1955
};
1956
1957
/// The SVG path data.
1958
///
1960
struct StyleSVGPathData {
1961
StyleArcSlice<StylePathCommand> _0;
1962
1963
bool operator==(const StyleSVGPathData& other) const {
1964
return _0 == other._0;
1965
}
1966
bool operator!=(const StyleSVGPathData& other) const {
1967
return _0 != other._0;
1968
}
1969
};
1970
1971
/// The `ray()` function, `ray( [ <angle> && <size> && contain? ] )`
1972
///
1974
template<typename Angle>
1975
struct StyleRayFunction {
1976
/// The bearing angle with `0deg` pointing up and positive angles
1977
/// representing clockwise rotation.
1978
Angle angle;
1979
/// Decide the path length used when `offset-distance` is expressed
1980
/// as a percentage.
1981
StyleRaySize size;
1982
/// Clamp `offset-distance` so that the box is entirely contained
1983
/// within the path.
1984
bool contain;
1985
1986
bool operator==(const StyleRayFunction& other) const {
1987
return angle == other.angle &&
1988
size == other.size &&
1989
contain == other.contain;
1990
}
1991
bool operator!=(const StyleRayFunction& other) const {
1992
return angle != other.angle ||
1993
size != other.size ||
1994
contain != other.contain;
1995
}
1996
};
1997
1998
/// The offset-path value.
1999
///
2001
template<typename Angle>
2002
struct StyleGenericOffsetPath {
2003
enum class Tag : uint8_t {
2004
/// Path value for path(<string>).
2005
Path,
2006
/// ray() function, which defines a path in the polar coordinate system.
2007
Ray,
2008
/// None value.
2009
None,
2010
};
2011
2012
struct StylePath_Body {
2013
StyleSVGPathData _0;
2014
2015
bool operator==(const StylePath_Body& other) const {
2016
return _0 == other._0;
2017
}
2018
bool operator!=(const StylePath_Body& other) const {
2019
return _0 != other._0;
2020
}
2021
};
2022
2023
struct StyleRay_Body {
2024
StyleRayFunction<Angle> _0;
2025
2026
bool operator==(const StyleRay_Body& other) const {
2027
return _0 == other._0;
2028
}
2029
bool operator!=(const StyleRay_Body& other) const {
2030
return _0 != other._0;
2031
}
2032
};
2033
2034
Tag tag;
2035
union {
2036
StylePath_Body path;
2037
StyleRay_Body ray;
2038
};
2039
2040
static StyleGenericOffsetPath Path(const StyleSVGPathData &a0) {
2041
StyleGenericOffsetPath result;
2042
::new (&result.path._0) (StyleSVGPathData)(a0);
2043
result.tag = Tag::Path;
2044
return result;
2045
}
2046
2047
static StyleGenericOffsetPath Ray(const StyleRayFunction<Angle> &a0) {
2048
StyleGenericOffsetPath result;
2049
::new (&result.ray._0) (StyleRayFunction<Angle>)(a0);
2050
result.tag = Tag::Ray;
2051
return result;
2052
}
2053
2054
static StyleGenericOffsetPath None() {
2055
StyleGenericOffsetPath result;
2056
result.tag = Tag::None;
2057
return result;
2058
}
2059
2060
bool IsPath() const {
2061
return tag == Tag::Path;
2062
}
2063
2064
bool IsRay() const {
2065
return tag == Tag::Ray;
2066
}
2067
2068
bool IsNone() const {
2069
return tag == Tag::None;
2070
}
2071
2072
const StyleSVGPathData& AsPath() const {
2073
MOZ_ASSERT(IsPath());
2074
return path._0;
2075
}
2076
2077
const StyleRayFunction<Angle>& AsRay() const {
2078
MOZ_ASSERT(IsRay());
2079
return ray._0;
2080
}
2081
2082
bool operator==(const StyleGenericOffsetPath& other) const {
2083
if (tag != other.tag) {
2084
return false;
2085
}
2086
switch (tag) {
2087
case Tag::Path: return path == other.path;
2088
case Tag::Ray: return ray == other.ray;
2089
default: return true;
2090
}
2091
}
2092
2093
bool operator!=(const StyleGenericOffsetPath& other) const {
2094
return !(*this == other);
2095
}
2096
2097
private:
2098
StyleGenericOffsetPath() {
2099
2100
}
2101
public:
2102
2103
2104
~StyleGenericOffsetPath() {
2105
switch (tag) {
2106
case Tag::Path: path.~StylePath_Body(); break;
2107
case Tag::Ray: ray.~StyleRay_Body(); break;
2108
default: break;
2109
}
2110
}
2111
2112
StyleGenericOffsetPath(const StyleGenericOffsetPath& other)
2113
: tag(other.tag) {
2114
switch (tag) {
2115
case Tag::Path: ::new (&path) (StylePath_Body)(other.path); break;
2116
case Tag::Ray: ::new (&ray) (StyleRay_Body)(other.ray); break;
2117
default: break;
2118
}
2119
}
2120
StyleGenericOffsetPath& operator=(const StyleGenericOffsetPath& other) {
2121
if (this != &other) {
2122
this->~StyleGenericOffsetPath();
2123
new (this) StyleGenericOffsetPath(other);
2124
}
2125
return *this;
2126
}
2127
};
2128
2129
/// The computed value of `offset-path`.
2130
using StyleOffsetPath = StyleGenericOffsetPath<StyleAngle>;
2131
2132
/// A computed offset-rotate.
2133
struct StyleOffsetRotate {
2134
/// If auto is false, this is a fixed angle which indicates a
2135
/// constant clockwise rotation transformation applied to it by this
2136
/// specified rotation angle. Otherwise, the angle will be added to
2137
/// the angle of the direction in layout.
2138
bool auto_;
2139
/// The angle value.
2140
StyleAngle angle;
2141
2142
bool operator==(const StyleOffsetRotate& other) const {
2143
return auto_ == other.auto_ &&
2144
angle == other.angle;
2145
}
2146
bool operator!=(const StyleOffsetRotate& other) const {
2147
return auto_ != other.auto_ ||
2148
angle != other.angle;
2149
}
2150
};
2151
2152
/// A `<number>` value.
2153
using StyleNumber = StyleCSSFloat;
2154
2155
/// A value of the `Rotate` property
2156
///
2158
template<typename Number, typename Angle>
2159
struct StyleGenericRotate {
2160
enum class Tag : uint8_t {
2161
/// 'none'
2162
None,
2163
/// '<angle>'
2164
Rotate,
2165
/// '<number>{3} <angle>'
2166
Rotate3D,
2167
};
2168
2169
struct StyleRotate_Body {
2170
Angle _0;
2171
2172
bool operator==(const StyleRotate_Body& other) const {
2173
return _0 == other._0;
2174
}
2175
bool operator!=(const StyleRotate_Body& other) const {
2176
return _0 != other._0;
2177
}
2178
};
2179
2180
struct StyleRotate3D_Body {
2181
Number _0;
2182
Number _1;
2183
Number _2;
2184
Angle _3;
2185
2186
bool operator==(const StyleRotate3D_Body& other) const {
2187
return _0 == other._0 &&
2188
_1 == other._1 &&
2189
_2 == other._2 &&
2190
_3 == other._3;
2191
}
2192
bool operator!=(const StyleRotate3D_Body& other) const {
2193
return _0 != other._0 ||
2194
_1 != other._1 ||
2195
_2 != other._2 ||
2196
_3 != other._3;
2197
}
2198
};
2199
2200
Tag tag;
2201
union {
2202
StyleRotate_Body rotate;
2203
StyleRotate3D_Body rotate3_d;
2204
};
2205
2206
static StyleGenericRotate None() {
2207
StyleGenericRotate result;
2208
result.tag = Tag::None;
2209
return result;
2210
}
2211
2212
static StyleGenericRotate Rotate(const Angle &a0) {
2213
StyleGenericRotate result;
2214
::new (&result.rotate._0) (Angle)(a0);
2215
result.tag = Tag::Rotate;
2216
return result;
2217
}
2218
2219
static StyleGenericRotate Rotate3D(const Number &a0,
2220
const Number &a1,
2221
const Number &a2,
2222
const Angle &a3) {
2223
StyleGenericRotate result;
2224
::new (&result.rotate3_d._0) (Number)(a0);
2225
::new (&result.rotate3_d._1) (Number)(a1);
2226
::new (&result.rotate3_d._2) (Number)(a2);
2227
::new (&result.rotate3_d._3) (Angle)(a3);
2228
result.tag = Tag::Rotate3D;
2229
return result;
2230
}
2231
2232
bool IsNone() const {
2233
return tag == Tag::None;
2234
}
2235
2236
bool IsRotate() const {
2237
return tag == Tag::Rotate;
2238
}
2239
2240
bool IsRotate3D() const {
2241
return tag == Tag::Rotate3D;
2242
}
2243
2244
const Angle& AsRotate() const {
2245
MOZ_ASSERT(IsRotate());
2246
return rotate._0;
2247
}
2248
2249
const StyleRotate3D_Body& AsRotate3D() const {
2250
MOZ_ASSERT(IsRotate3D());
2251
return rotate3_d;
2252
}
2253
2254
bool operator==(const StyleGenericRotate& other) const {
2255
if (tag != other.tag) {
2256
return false;
2257
}
2258
switch (tag) {
2259
case Tag::Rotate: return rotate == other.rotate;
2260
case Tag::Rotate3D: return rotate3_d == other.rotate3_d;
2261
default: return true;
2262
}
2263
}
2264
2265
bool operator!=(const StyleGenericRotate& other) const {
2266
return !(*this == other);
2267
}
2268
2269
private:
2270
StyleGenericRotate() {
2271
2272
}
2273
public:
2274
2275
2276
~StyleGenericRotate() {
2277
switch (tag) {
2278
case Tag::Rotate: rotate.~StyleRotate_Body(); break;
2279
case Tag::Rotate3D: rotate3_d.~StyleRotate3D_Body(); break;
2280
default: break;
2281
}
2282
}
2283
2284
StyleGenericRotate(const StyleGenericRotate& other)
2285
: tag(other.tag) {
2286
switch (tag) {
2287
case Tag::Rotate: ::new (&rotate) (StyleRotate_Body)(other.rotate); break;
2288
case Tag::Rotate3D: ::new (&rotate3_d) (StyleRotate3D_Body)(other.rotate3_d); break;
2289
default: break;
2290
}
2291
}
2292
StyleGenericRotate& operator=(const StyleGenericRotate& other) {
2293
if (this != &other) {
2294
this->~StyleGenericRotate();
2295
new (this) StyleGenericRotate(other);
2296
}
2297
return *this;
2298
}
2299
};
2300
2301
/// A computed CSS `rotate`
2302
using StyleRotate = StyleGenericRotate<StyleNumber, StyleAngle>;
2303
2304
/// A value of the `Scale` property
2305
///
2307
template<typename Number>
2308
struct StyleGenericScale {
2309
enum class Tag : uint8_t {
2310
/// 'none'
2311
None,
2312
/// '<number>{1,3}'
2313
Scale,
2314
};
2315
2316
struct StyleScale_Body {
2317
Number _0;