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