1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* constants used in the style struct data provided by ComputedStyle */
#ifndef nsStyleConsts_h___
#define nsStyleConsts_h___
#include <inttypes.h>
#include "X11UndefineNone.h"
#include "gfxFontConstants.h"
#include "mozilla/ServoStyleConsts.h"
// XXX fold this into ComputedStyle and group by nsStyleXXX struct
namespace mozilla {
static constexpr uint16_t STYLE_DISPLAY_LIST_ITEM_BIT = 0x8000;
static constexpr uint8_t STYLE_DISPLAY_OUTSIDE_BITS = 7;
static constexpr uint8_t STYLE_DISPLAY_INSIDE_BITS = 8;
// The `display` longhand.
uint16_t constexpr StyleDisplayFrom(StyleDisplayOutside aOuter,
StyleDisplayInside aInner) {
return uint16_t(uint16_t(aOuter) << STYLE_DISPLAY_INSIDE_BITS) |
uint16_t(aInner);
}
enum class StyleDisplay : uint16_t {
// These MUST be in sync with the Rust enum values in
// servo/components/style/values/specified/box.rs
/// https://drafts.csswg.org/css-display/#the-display-properties
None = StyleDisplayFrom(StyleDisplayOutside::None, StyleDisplayInside::None),
Contents =
StyleDisplayFrom(StyleDisplayOutside::None, StyleDisplayInside::Contents),
Inline =
StyleDisplayFrom(StyleDisplayOutside::Inline, StyleDisplayInside::Flow),
Block =
StyleDisplayFrom(StyleDisplayOutside::Block, StyleDisplayInside::Flow),
FlowRoot = StyleDisplayFrom(StyleDisplayOutside::Block,
StyleDisplayInside::FlowRoot),
Flex = StyleDisplayFrom(StyleDisplayOutside::Block, StyleDisplayInside::Flex),
Grid = StyleDisplayFrom(StyleDisplayOutside::Block, StyleDisplayInside::Grid),
Table =
StyleDisplayFrom(StyleDisplayOutside::Block, StyleDisplayInside::Table),
InlineTable =
StyleDisplayFrom(StyleDisplayOutside::Inline, StyleDisplayInside::Table),
TableCaption = StyleDisplayFrom(StyleDisplayOutside::TableCaption,
StyleDisplayInside::Flow),
Ruby =
StyleDisplayFrom(StyleDisplayOutside::Inline, StyleDisplayInside::Ruby),
WebkitBox = StyleDisplayFrom(StyleDisplayOutside::Block,
StyleDisplayInside::WebkitBox),
WebkitInlineBox = StyleDisplayFrom(StyleDisplayOutside::Inline,
StyleDisplayInside::WebkitBox),
ListItem = Block | STYLE_DISPLAY_LIST_ITEM_BIT,
/// Internal table boxes.
TableRowGroup = StyleDisplayFrom(StyleDisplayOutside::InternalTable,
StyleDisplayInside::TableRowGroup),
TableHeaderGroup = StyleDisplayFrom(StyleDisplayOutside::InternalTable,
StyleDisplayInside::TableHeaderGroup),
TableFooterGroup = StyleDisplayFrom(StyleDisplayOutside::InternalTable,
StyleDisplayInside::TableFooterGroup),
TableColumn = StyleDisplayFrom(StyleDisplayOutside::InternalTable,
StyleDisplayInside::TableColumn),
TableColumnGroup = StyleDisplayFrom(StyleDisplayOutside::InternalTable,
StyleDisplayInside::TableColumnGroup),
TableRow = StyleDisplayFrom(StyleDisplayOutside::InternalTable,
StyleDisplayInside::TableRow),
TableCell = StyleDisplayFrom(StyleDisplayOutside::InternalTable,
StyleDisplayInside::TableCell),
/// Internal ruby boxes.
RubyBase = StyleDisplayFrom(StyleDisplayOutside::InternalRuby,
StyleDisplayInside::RubyBase),
RubyBaseContainer = StyleDisplayFrom(StyleDisplayOutside::InternalRuby,
StyleDisplayInside::RubyBaseContainer),
RubyText = StyleDisplayFrom(StyleDisplayOutside::InternalRuby,
StyleDisplayInside::RubyText),
RubyTextContainer = StyleDisplayFrom(StyleDisplayOutside::InternalRuby,
StyleDisplayInside::RubyTextContainer),
/// XUL boxes.
MozBox =
StyleDisplayFrom(StyleDisplayOutside::Block, StyleDisplayInside::MozBox),
MozInlineBox =
StyleDisplayFrom(StyleDisplayOutside::Inline, StyleDisplayInside::MozBox),
};
// The order of the StyleDisplay values isn't meaningful.
bool operator<(const StyleDisplay&, const StyleDisplay&) = delete;
bool operator<=(const StyleDisplay&, const StyleDisplay&) = delete;
bool operator>(const StyleDisplay&, const StyleDisplay&) = delete;
bool operator>=(const StyleDisplay&, const StyleDisplay&) = delete;
// Basic shapes
enum class StyleBasicShapeType : uint8_t {
Polygon,
Circle,
Ellipse,
Inset,
};
// box-align
enum class StyleBoxAlign : uint8_t {
Stretch,
Start,
Center,
Baseline,
End,
};
// box-decoration-break
enum class StyleBoxDecorationBreak : uint8_t {
Slice,
Clone,
};
// box-direction
enum class StyleBoxDirection : uint8_t {
Normal,
Reverse,
};
// box-orient
enum class StyleBoxOrient : uint8_t {
Horizontal,
Vertical,
};
// box-pack
enum class StyleBoxPack : uint8_t {
Start,
Center,
End,
Justify,
};
// box-sizing
enum class StyleBoxSizing : uint8_t { Content, Border };
// box-shadow
enum class StyleBoxShadowType : uint8_t {
Inset,
};
enum class StyleColumnFill : uint8_t {
Balance,
Auto,
};
enum class StyleColumnSpan : uint8_t {
None,
All,
};
// Define geometry box for clip-path's reference-box, background-clip,
// background-origin, mask-clip, mask-origin, shape-box and transform-box.
enum class StyleGeometryBox : uint8_t {
ContentBox, // Used by everything, except transform-box.
PaddingBox, // Used by everything, except transform-box.
BorderBox,
MarginBox, // XXX Bug 1260094 comment 9.
// Although margin-box is required by mask-origin and mask-clip,
// we do not implement that due to lack of support in other
// browsers. clip-path reference-box only.
FillBox, // Used by everything, except shape-box.
StrokeBox, // mask-clip, mask-origin and clip-path reference-box only.
ViewBox, // Used by everything, except shape-box.
NoClip, // mask-clip only.
Text, // background-clip only.
NoBox, // Depending on which kind of element this style value applied on,
// the default value of a reference-box can be different.
// For an HTML element, the default value of reference-box is
// border-box; for an SVG element, the default value is fill-box.
// Since we can not determine the default value at parsing time,
// set it as NoBox so that we make a decision later.
// clip-path reference-box only.
MozAlmostPadding = 127 // A magic value that we use for our "pretend that
// background-clip is 'padding' when we have a solid
// border" optimization. This isn't actually equal
// to StyleGeometryBox::Padding because using that
// causes antialiasing seams between the background
// and border.
// background-clip only.
};
// float-edge
enum class StyleFloatEdge : uint8_t {
ContentBox,
MarginBox,
};
// Hyphens
enum class StyleHyphens : uint8_t {
None,
Manual,
Auto,
};
// image-orientation
enum class StyleImageOrientation : uint8_t {
None,
FromImage,
};
// scrollbar-width
enum class StyleScrollbarWidth : uint8_t {
Auto,
Thin,
None,
};
// Shape source type
enum class StyleShapeSourceType : uint8_t {
None,
Image, // shape-outside / clip-path only, and clip-path only uses it for
// <url>s
Shape,
Box,
Path, // SVG path function
};
// user-focus
enum class StyleUserFocus : uint8_t {
None,
Ignore,
Normal,
SelectAll,
SelectBefore,
SelectAfter,
SelectSame,
SelectMenu,
};
// user-input
enum class StyleUserInput : uint8_t {
None,
Auto,
};
// user-modify
enum class StyleUserModify : uint8_t {
ReadOnly,
ReadWrite,
WriteOnly,
};
// -moz-inert
enum class StyleInert : uint8_t {
None,
Inert,
};
// -moz-window-dragging
enum class StyleWindowDragging : uint8_t {
Default,
Drag,
NoDrag,
};
// orient
enum class StyleOrient : uint8_t {
Inline,
Block,
Horizontal,
Vertical,
};
// See AnimationEffect.webidl
// and mozilla/dom/AnimationEffectBinding.h
namespace dom {
enum class PlaybackDirection : uint8_t;
enum class FillMode : uint8_t;
} // namespace dom
// Animation play state
enum class StyleAnimationPlayState : uint8_t { Running, Paused };
// See nsStyleImageLayers
enum class StyleImageLayerAttachment : uint8_t { Scroll, Fixed, Local };
// See nsStyleImageLayers
enum class StyleImageLayerRepeat : uint8_t {
NoRepeat = 0x00,
RepeatX,
RepeatY,
Repeat,
Space,
Round
};
// Mask mode
enum class StyleMaskMode : uint8_t { Alpha = 0, Luminance, MatchSource };
// See nsStyleTable
enum class StyleBorderCollapse : uint8_t { Collapse, Separate };
// border-image-repeat
enum class StyleBorderImageRepeat : uint8_t { Stretch, Repeat, Round, Space };
// See nsStyleVisibility
enum class StyleDirection : uint8_t { Ltr, Rtl };
// See nsStyleVisibility
// NOTE: WritingModes.h depends on the particular values used here.
// Single-bit flag, used in combination with VerticalLR and RL to specify
// the corresponding Sideways* modes.
// (To avoid ambiguity, this bit must be high enough such that no other
// values here accidentally use it in their binary representation.)
static constexpr uint8_t kWritingModeSidewaysMask = 4;
enum class StyleWritingModeProperty : uint8_t {
HorizontalTb = 0,
VerticalRl = 1,
// HorizontalBT = 2, // hypothetical
VerticalLr = 3,
SidewaysRl = VerticalRl | kWritingModeSidewaysMask,
SidewaysLr = VerticalLr | kWritingModeSidewaysMask,
};
// See nsStylePosition
enum class StyleFlexDirection : uint8_t {
Row,
RowReverse,
Column,
ColumnReverse,
};
// See nsStylePosition
enum class StyleFlexWrap : uint8_t {
Nowrap,
Wrap,
WrapReverse,
};
// CSS Grid <track-breadth> keywords
enum class StyleGridTrackBreadth : uint8_t {
MaxContent = 1,
MinContent = 2,
};
// defaults per MathML spec
static constexpr float kMathMLDefaultScriptSizeMultiplier{0.71f};
static constexpr float kMathMLDefaultScriptMinSizePt{8.f};
// See nsStyleFont
enum class StyleMathVariant : uint8_t {
None = 0,
Normal = 1,
Bold = 2,
Italic = 3,
BoldItalic = 4,
Script = 5,
BoldScript = 6,
Fraktur = 7,
DoubleStruck = 8,
BoldFraktur = 9,
SansSerif = 10,
BoldSansSerif = 11,
SansSerifItalic = 12,
SansSerifBoldItalic = 13,
Monospace = 14,
Initial = 15,
Tailed = 16,
Looped = 17,
Stretched = 18,
};
// See nsStyleFont::mMathStyle
enum class StyleMathStyle : uint8_t { Compact = 0, Normal = 1 };
// See nsStyleDisplay.mPosition
enum class StylePositionProperty : uint8_t {
Static,
Relative,
Absolute,
Fixed,
Sticky,
};
enum class FrameBorderProperty : uint8_t { Yes, No, One, Zero };
enum class ScrollingAttribute : uint8_t {
Yes,
No,
On,
Off,
Scroll,
Noscroll,
Auto
};
// See nsStyleList
enum class ListStyle : uint8_t {
Custom = 255, // for @counter-style
None = 0,
Decimal,
Disc,
Circle,
Square,
DisclosureClosed,
DisclosureOpen,
Hebrew,
JapaneseInformal,
JapaneseFormal,
KoreanHangulFormal,
KoreanHanjaInformal,
KoreanHanjaFormal,
SimpChineseInformal,
SimpChineseFormal,
TradChineseInformal,
TradChineseFormal,
EthiopicNumeric,
// These styles are handled as custom styles defined in counterstyles.css.
// They are preserved here only for html attribute map.
LowerRoman = 100,
UpperRoman,
LowerAlpha,
UpperAlpha
};
// See nsStyleList
enum class StyleListStylePosition : uint8_t { Inside, Outside };
// See nsStyleVisibility
enum class StylePointerEvents : uint8_t {
None,
Visiblepainted,
Visiblefill,
Visiblestroke,
Visible,
Painted,
Fill,
Stroke,
All,
Auto,
};
enum class StyleIsolation : uint8_t {
Auto,
Isolate,
};
// See nsStylePosition.mObjectFit
enum class StyleObjectFit : uint8_t {
Fill,
Contain,
Cover,
None,
ScaleDown,
};
// See nsStyleText
enum class StyleTextDecorationStyle : uint8_t {
None, // not in CSS spec, mapped to -moz-none
Dotted,
Dashed,
Solid,
Double,
Wavy,
Sentinel = Wavy
};
// See nsStyleDisplay
enum class StyleTopLayer : uint8_t {
None,
Top,
};
// See nsStyleVisibility
enum class StyleVisibility : uint8_t {
Hidden,
Visible,
Collapse,
};
// See nsStyleText
enum class StyleWhiteSpace : uint8_t {
Normal = 0,
Pre,
Nowrap,
PreWrap,
PreLine,
PreSpace,
BreakSpaces,
};
// ruby-align, see nsStyleText
enum class StyleRubyAlign : uint8_t {
Start,
Center,
SpaceBetween,
SpaceAround,
};
// See nsStyleText
enum class StyleTextSizeAdjust : uint8_t {
None,
Auto,
};
// See nsStyleVisibility
enum class StyleTextOrientation : uint8_t {
Mixed,
Upright,
Sideways,
};
// Whether to emulate -moz-box with flex. See nsStyleVisibility
enum class StyleMozBoxLayout : uint8_t {
Legacy,
Flex,
};
// See nsStyleText
enum class StyleTextCombineUpright : uint8_t {
None,
All,
};
// See nsStyleText
enum class StyleUnicodeBidi : uint8_t {
Normal,
Embed,
Isolate,
BidiOverride,
IsolateOverride,
Plaintext
};
enum class StyleTableLayout : uint8_t {
Auto,
Fixed,
};
enum class StyleEmptyCells : uint8_t {
Hide,
Show,
};
// See nsStyleUIReset
enum class StyleImeMode : uint8_t {
Auto,
Normal,
Active,
Disabled,
Inactive,
};
// See nsStyleSVG
/*
* -moz-window-shadow
* Also used in widget code
*/
enum class StyleWindowShadow : uint8_t {
None,
Default,
// These can't be specified in CSS, they get computed from the "default"
// value.
Menu,
Tooltip,
};
// dominant-baseline
enum class StyleDominantBaseline : uint8_t {
Auto,
Ideographic,
Alphabetic,
Hanging,
Mathematical,
Central,
Middle,
TextAfterEdge,
TextBeforeEdge,
};
// mask-type
enum class StyleMaskType : uint8_t {
Luminance,
Alpha,
};
// shape-rendering
enum class StyleShapeRendering : uint8_t {
Auto,
Optimizespeed,
Crispedges,
Geometricprecision,
};
// stroke-linecap
enum class StyleStrokeLinecap : uint8_t {
Butt,
Round,
Square,
};
// stroke-linejoin
enum class StyleStrokeLinejoin : uint8_t {
Miter,
Round,
Bevel,
};
// text-anchor
enum class StyleTextAnchor : uint8_t {
Start,
Middle,
End,
};
// text-rendering
enum class StyleTextRendering : uint8_t {
Auto,
Optimizespeed,
Optimizelegibility,
Geometricprecision,
};
// color-interpolation and color-interpolation-filters
enum class StyleColorInterpolation : uint8_t {
Auto = 0,
Srgb = 1,
Linearrgb = 2,
};
// vector-effect
enum class StyleVectorEffect : uint8_t { None = 0, NonScalingStroke = 1 };
// 3d Transforms - Backface visibility
enum class StyleBackfaceVisibility : uint8_t { Hidden = 0, Visible = 1 };
// blending
enum class StyleBlend : uint8_t {
Normal = 0,
Multiply,
Screen,
Overlay,
Darken,
Lighten,
ColorDodge,
ColorBurn,
HardLight,
SoftLight,
Difference,
Exclusion,
Hue,
Saturation,
Color,
Luminosity,
PlusLighter,
};
// composite
enum class StyleMaskComposite : uint8_t {
Add = 0,
Subtract,
Intersect,
Exclude
};
// scroll-behavior
enum class StyleScrollBehavior : uint8_t {
Auto,
Smooth,
};
} // namespace mozilla
#endif /* nsStyleConsts_h___ */
|