forked from servo/rust-css
-
Notifications
You must be signed in to change notification settings - Fork 0
/
values.rs
326 lines (274 loc) · 6.44 KB
/
values.rs
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
/* 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/. */
/*!
The representation of CSS property values
Enums are named after the property. Variants have the same name + the
name of the value used in the spec. This leads to some verbose names,
e.g.:
The property 'background-color' and the specified value called '<color>'
in the spec lead to the variant CSSBackgroundColorColor(Color).
At least it's consistent though.
*/
use std::cmp::Eq;
use extra::url::Url;
use units::{Length, AbsoluteSize, RelativeSize};
use units::GenericFontFamily;
use color::Color;
/** A partial CSS value, before inheritance has been resolved */
#[deriving(Eq)]
pub enum CSSValue<T> {
Inherit,
Specified(T),
}
// CSS 2.1, Section 8 - Box model
#[deriving(Eq)]
pub enum CSSMargin {
CSSMarginLength(Length),
CSSMarginPercentage(float),
CSSMarginAuto
}
#[deriving(Eq)]
pub enum CSSPadding {
CSSPaddingLength(Length),
CSSPaddingPercentage(float)
}
#[deriving(Eq)]
pub enum CSSBorderWidth {
CSSBorderWidthThin,
CSSBorderWidthMedium,
CSSBorderWidthThick,
CSSBorderWidthLength(Length)
}
#[deriving(Eq)]
pub enum CSSBorderColor {
CSSBorderColorColor(Color),
CSSBorderColorTransparent
}
#[deriving(Eq, Clone)]
pub enum CSSBorderStyle {
CSSBorderStyleNone,
CSSBorderStyleHidden,
CSSBorderStyleDotted,
CSSBorderStyleDashed,
CSSBorderStyleSolid,
CSSBorderStyleDouble,
CSSBorderStyleGroove,
CSSBorderStyleRidge,
CSSBorderStyleInset,
CSSBorderStyleOutset,
}
// CSS 2.1, Section 9 - Visual formatting model
#[deriving(Eq)]
pub enum CSSDisplay {
CSSDisplayInline,
CSSDisplayBlock,
CSSDisplayListItem,
CSSDisplayInlineBlock,
CSSDisplayTable,
CSSDisplayInlineTable,
CSSDisplayTableRowGroup,
CSSDisplayTableHeaderGroup,
CSSDisplayTableFooterGroup,
CSSDisplayTableRow,
CSSDisplayTableColumnGroup,
CSSDisplayTableColumn,
CSSDisplayTableCell,
CSSDisplayTableCaption,
CSSDisplayNone
}
#[deriving(Eq)]
pub enum CSSPosition {
CSSPositionStatic,
CSSPositionRelative,
CSSPositionAbsolute,
CSSPositionFixed
}
#[deriving(Eq)]
pub enum CSSTop {
CSSTopLength(Length),
CSSTopPercentage,
CSSTopAuto
}
#[deriving(Eq)]
pub enum CSSRight {
CSSRightLength(Length),
CSSRightPercentage(float),
CSSRightAuto
}
#[deriving(Eq)]
pub enum CSSBottom {
CSSBottomLength(Length),
CSSBottomPercentage(float),
CSSBottomAuto
}
#[deriving(Eq)]
pub enum CSSLeft {
CSSLeftLength(Length),
CSSLeftPercentage(float),
CSSLeftAuto
}
#[deriving(Eq)]
pub enum CSSFloat {
CSSFloatLeft,
CSSFloatRight,
CSSFloatNone
}
#[deriving(Eq)]
pub enum CSSClear {
CSSClearLeft,
CSSClearRight,
CSSClearBoth,
CSSClearNone
}
#[deriving(Eq)]
pub enum CSSDirection {
CSSDirectionLtr,
CSSDirectionRtl
}
// CSS 2.1, Section 10 - Visual formatting model details
#[deriving(Eq)]
pub enum CSSWidth {
CSSWidthLength(Length),
CSSWidthPercentage(float),
CSSWidthAuto
}
#[deriving(Eq)]
pub enum CSSHeight {
CSSHeightLength(Length),
CSSHeightPercentage(float),
CSSHeightAuto
}
#[deriving(Eq)]
pub enum CSSLineHeight {
CSSLineHeightNormal,
CSSLineHeightNumber(float),
CSSLineHeightLength(Length),
CSSLineHeightPercentage(float),
}
#[deriving(Eq)]
pub enum CSSVerticalAlign {
CSSVerticalAlignBaseline,
CSSVerticalAlignSub,
CSSVerticalAlignSuper,
CSSVerticalAlignTop,
CSSVerticalAlignTextTop,
CSSVerticalAlignMiddle,
CSSVerticalAlignBottom,
CSSVerticalAlignTextBottom,
CSSVerticalAlignPercentage(float),
CSSVerticalAlignLength(Length),
}
// CSS 2.1, Section 11 - Visual effects
#[deriving(Eq)]
pub enum CSSOverflow {
CSSOverflowVisible,
CSSOverflowHidden,
CSSOverflowScroll,
CSSOverflowAuto
}
#[deriving(Eq)]
pub enum CSSVisibility {
CSSVisibilityVisible,
CSSVisibilityHidden,
CSSVisibilityCollapse
}
// CSS 2.1, Section 12 - Generated content, automatic numbering, and lists
// CSS 2.1, Section 13 - Paged media
// CSS 2.1, Section 14 - Colors and Backgrounds
#[deriving(Eq)]
pub enum CSSColor {
CSSColorColor(Color)
}
#[deriving(Eq)]
pub enum CSSBackgroundColor {
CSSBackgroundColorColor(Color),
CSSBackgroundColorTransparent
}
#[deriving(Eq)]
pub enum CSSBackgroundImage {
CSSBackgroundUri(Url),
CSSBackgroundImageNone
}
#[deriving(Eq)]
pub enum CSSBackgroundRepeat {
CSSBackgroundRepeatRepeat,
CSSBackgroundRepeatRepeatX,
CSSBackgroundRepeatRepeatY,
CSSBackgroundRepeatNoRepeat
}
#[deriving(Eq)]
pub enum CSSBackgroundAttachment {
CSSBackgroundAttachmentScroll,
CSSBackgroundAttachmentFixed
}
#[deriving(Eq)]
pub enum CSSBackgroundPosition {
CSSBackgroundPositionPercentage(float),
CSSBackgroundPositionLength(Length),
CSSBackgroundPositionLeft,
CSSBackgroundPositionCenter,
CSSBackgroundPositionRight,
CSSBackgroundPositionTop,
CSSBackgroundPositionBottom
}
// CSS 2.1, Section 15 - Fonts
#[deriving(Eq)]
pub enum CSSFontFamily {
CSSFontFamilyFamilyName(~str),
CSSFontFamilyGenericFamily(GenericFontFamily)
}
#[deriving(Eq)]
pub enum CSSFontStyle {
CSSFontStyleNormal,
CSSFontStyleItalic,
CSSFontStyleOblique
}
#[deriving(Eq)]
pub enum CSSFontWeight {
CSSFontWeightNormal,
CSSFontWeightBold,
CSSFontWeightBolder,
CSSFontWeightLighter,
CSSFontWeight100,
CSSFontWeight200,
CSSFontWeight300,
CSSFontWeight400,
CSSFontWeight500,
CSSFontWeight600,
CSSFontWeight700,
CSSFontWeight800,
CSSFontWeight900
}
#[deriving(Eq)]
pub enum CSSFontSize {
CSSFontSizeAbsoluteSize(AbsoluteSize),
CSSFontSizeRelativeSize(RelativeSize),
CSSFontSizeLength(Length),
CSSFontSizePercentage(float)
}
// CSS 2.1, Section 16 - Text
#[deriving(Eq)]
pub enum CSSTextAlign {
CSSTextAlignLeft,
CSSTextAlignRight,
CSSTextAlignCenter,
CSSTextAlignJustify
}
#[deriving(Eq, Clone)]
pub enum CSSTextDecoration {
CSSTextDecorationNone,
CSSTextDecorationUnderline,
CSSTextDecorationOverline,
CSSTextDecorationLineThrough,
CSSTextDecorationBlink
}
#[deriving(Eq)]
pub enum CSSTextTransform {
CSSTextTransformCapitalize,
CSSTextTransformUppercase,
CSSTextTransformLowercase,
CSSTextTransformNone
}
// CSS 2.1, Section 17 - Tables
// CSS 2.1, Section 18 - User interface