1use crate::derives::*;
8use crate::parser::{Parse, ParserContext};
9use crate::values::generics::ui as generics;
10use crate::values::specified::Number;
11use crate::values::specified::color::Color;
12use crate::values::specified::image::Image;
13use cssparser::Parser;
14use std::fmt::{self, Write};
15use style_traits::{
16 CssWriter, KeywordsCollectFn, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss,
17};
18
19pub type Cursor = generics::GenericCursor<CursorImage>;
21
22pub type CursorImage = generics::GenericCursorImage<Image, Number>;
24
25impl Parse for Cursor {
26 fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ParseError> {
28 let mut images = vec![];
29 loop {
30 match input.try_parse(|input| CursorImage::parse(context, input)) {
31 Ok(image) => images.push(image),
32 Err(_) => break,
33 }
34 input.expect_comma()?;
35 }
36 Ok(Self {
37 images: images.into(),
38 keyword: CursorKind::parse(input)?,
39 })
40 }
41}
42
43impl Parse for CursorImage {
44 fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ParseError> {
45 use crate::Zero;
46
47 let image = Image::parse_only_url(context, input)?;
48 let mut has_hotspot = false;
49 let mut hotspot_x = Number::zero();
50 let mut hotspot_y = Number::zero();
51
52 if let Ok(x) = input.try_parse(|input| Number::parse(context, input)) {
53 has_hotspot = true;
54 hotspot_x = x;
55 hotspot_y = Number::parse(context, input)?;
56 }
57
58 Ok(Self {
59 image,
60 has_hotspot,
61 hotspot_x,
62 hotspot_y,
63 })
64 }
65}
66
67impl SpecifiedValueInfo for CursorImage {
70 fn collect_completion_keywords(f: KeywordsCollectFn) {
71 f(&["url", "image-set"]);
72 }
73}
74#[derive(
76 Clone,
77 Copy,
78 Debug,
79 MallocSizeOf,
80 PartialEq,
81 SpecifiedValueInfo,
82 ToComputedValue,
83 ToResolvedValue,
84 ToShmem,
85 ToTyped,
86)]
87#[repr(transparent)]
88#[typed(todo_derive_fields)]
89pub struct BoolInteger(pub bool);
90
91impl BoolInteger {
92 #[inline]
94 pub fn zero() -> Self {
95 Self(false)
96 }
97}
98
99impl Parse for BoolInteger {
100 fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ParseError> {
101 match input.expect_integer()? {
103 0 => Ok(Self(false)),
104 1 => Ok(Self(true)),
105 _ => Err(ParseError::custom(StyleParseErrorKind::UnspecifiedError)),
106 }
107 }
108}
109
110impl ToCss for BoolInteger {
111 fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
112 where
113 W: Write,
114 {
115 dest.write_str(if self.0 { "1" } else { "0" })
116 }
117}
118
119pub type ScrollbarColor = generics::ScrollbarColor<Color>;
121
122impl Parse for ScrollbarColor {
123 fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ParseError> {
124 if input.try_parse(|i| i.expect_ident_matching("auto")).is_ok() {
125 return Ok(generics::ScrollbarColor::Auto);
126 }
127 Ok(generics::ScrollbarColor::Colors {
128 thumb: Color::parse(context, input)?,
129 track: Color::parse(context, input)?,
130 })
131 }
132}
133
134#[allow(missing_docs)]
138#[derive(
139 Clone,
140 Copy,
141 Debug,
142 Eq,
143 MallocSizeOf,
144 Parse,
145 PartialEq,
146 SpecifiedValueInfo,
147 ToComputedValue,
148 ToCss,
149 ToResolvedValue,
150 ToShmem,
151 ToTyped,
152)]
153#[repr(u8)]
154pub enum UserSelect {
155 Auto,
156 Text,
157 #[parse(aliases = "-moz-none")]
158 None,
159 #[cfg(feature = "servo")]
160 Contain,
161 All,
163}
164
165#[allow(missing_docs)]
169#[derive(
170 Clone,
171 Copy,
172 Debug,
173 Eq,
174 FromPrimitive,
175 MallocSizeOf,
176 Parse,
177 PartialEq,
178 SpecifiedValueInfo,
179 ToComputedValue,
180 ToCss,
181 ToResolvedValue,
182 ToShmem,
183 ToTyped,
184)]
185#[repr(u8)]
186pub enum CursorKind {
187 None,
188 Default,
189 Pointer,
190 ContextMenu,
191 Help,
192 Progress,
193 Wait,
194 Cell,
195 Crosshair,
196 Text,
197 VerticalText,
198 Alias,
199 Copy,
200 Move,
201 NoDrop,
202 NotAllowed,
203 #[parse(aliases = "-moz-grab")]
204 Grab,
205 #[parse(aliases = "-moz-grabbing")]
206 Grabbing,
207 EResize,
208 NResize,
209 NeResize,
210 NwResize,
211 SResize,
212 SeResize,
213 SwResize,
214 WResize,
215 EwResize,
216 NsResize,
217 NeswResize,
218 NwseResize,
219 ColResize,
220 RowResize,
221 AllScroll,
222 #[parse(aliases = "-moz-zoom-in")]
223 ZoomIn,
224 #[parse(aliases = "-moz-zoom-out")]
225 ZoomOut,
226 Auto,
227}
228
229#[derive(
231 Clone,
232 Copy,
233 Debug,
234 Eq,
235 FromPrimitive,
236 MallocSizeOf,
237 Parse,
238 PartialEq,
239 SpecifiedValueInfo,
240 ToComputedValue,
241 ToCss,
242 ToResolvedValue,
243 ToShmem,
244 ToTyped,
245)]
246#[repr(u8)]
247pub enum MozTheme {
248 Auto,
250 NonNative,
252}
253
254#[allow(missing_docs)]
257#[derive(
258 Clone,
259 Copy,
260 Debug,
261 Eq,
262 FromPrimitive,
263 MallocSizeOf,
264 Parse,
265 PartialEq,
266 SpecifiedValueInfo,
267 ToComputedValue,
268 ToCss,
269 ToResolvedValue,
270 ToShmem,
271 ToTyped,
272)]
273#[repr(u8)]
274pub enum PointerEvents {
275 Auto,
276 None,
277 #[cfg(feature = "gecko")]
278 Visiblepainted,
279 #[cfg(feature = "gecko")]
280 Visiblefill,
281 #[cfg(feature = "gecko")]
282 Visiblestroke,
283 #[cfg(feature = "gecko")]
284 Visible,
285 #[cfg(feature = "gecko")]
286 Painted,
287 #[cfg(feature = "gecko")]
288 Fill,
289 #[cfg(feature = "gecko")]
290 Stroke,
291 #[cfg(feature = "gecko")]
292 All,
293}
294
295#[allow(missing_docs)]
298#[derive(
299 Clone,
300 Copy,
301 Debug,
302 Eq,
303 FromPrimitive,
304 MallocSizeOf,
305 Parse,
306 PartialEq,
307 SpecifiedValueInfo,
308 ToComputedValue,
309 ToCss,
310 ToResolvedValue,
311 ToShmem,
312 ToTyped,
313)]
314#[repr(u8)]
315pub enum Inert {
316 None,
317 Inert,
318}
319
320#[allow(missing_docs)]
323#[derive(
324 Clone,
325 Copy,
326 Debug,
327 Eq,
328 FromPrimitive,
329 MallocSizeOf,
330 Parse,
331 PartialEq,
332 SpecifiedValueInfo,
333 ToComputedValue,
334 ToCss,
335 ToResolvedValue,
336 ToShmem,
337 ToTyped,
338)]
339#[repr(u8)]
340pub enum UserFocus {
341 Normal,
342 None,
343 Ignore,
344}
345
346#[allow(missing_docs)]
348#[derive(
349 Clone,
350 Copy,
351 Debug,
352 Deserialize,
353 Eq,
354 FromPrimitive,
355 Hash,
356 MallocSizeOf,
357 Parse,
358 PartialEq,
359 Serialize,
360 SpecifiedValueInfo,
361 ToComputedValue,
362 ToCss,
363 ToResolvedValue,
364 ToShmem,
365 ToTyped,
366)]
367#[repr(u8)]
368pub enum ImeMode {
369 Auto,
370 Normal,
371 Active,
372 Disabled,
373 Inactive,
374}
375
376#[allow(missing_docs)]
378#[derive(
379 Clone,
380 Copy,
381 Debug,
382 Deserialize,
383 Eq,
384 FromPrimitive,
385 Hash,
386 MallocSizeOf,
387 Parse,
388 PartialEq,
389 Serialize,
390 SpecifiedValueInfo,
391 ToComputedValue,
392 ToCss,
393 ToResolvedValue,
394 ToShmem,
395 ToTyped,
396)]
397#[repr(u8)]
398pub enum ScrollbarWidth {
399 Auto,
400 Thin,
401 None,
402}
403
404#[allow(missing_docs)]
406#[derive(
407 Clone,
408 Copy,
409 Debug,
410 Deserialize,
411 Eq,
412 FromPrimitive,
413 Hash,
414 MallocSizeOf,
415 Parse,
416 PartialEq,
417 Serialize,
418 SpecifiedValueInfo,
419 ToComputedValue,
420 ToCss,
421 ToResolvedValue,
422 ToShmem,
423 ToTyped,
424)]
425#[repr(u8)]
426pub enum WindowDragging {
427 Default,
428 Drag,
429 NoDrag,
430}
431
432#[allow(missing_docs)]
434#[derive(
435 Clone,
436 Copy,
437 Debug,
438 Deserialize,
439 Eq,
440 FromPrimitive,
441 Hash,
442 MallocSizeOf,
443 Parse,
444 PartialEq,
445 Serialize,
446 SpecifiedValueInfo,
447 ToComputedValue,
448 ToCss,
449 ToResolvedValue,
450 ToShmem,
451 ToTyped,
452)]
453#[repr(u8)]
454pub enum WindowShadow {
455 Auto,
456 None,
457}
458
459#[allow(missing_docs)]
461#[derive(
462 Clone,
463 Copy,
464 Debug,
465 Deserialize,
466 Eq,
467 FromPrimitive,
468 Hash,
469 MallocSizeOf,
470 Parse,
471 PartialEq,
472 Serialize,
473 SpecifiedValueInfo,
474 ToComputedValue,
475 ToCss,
476 ToResolvedValue,
477 ToShmem,
478 ToTyped,
479)]
480#[repr(u8)]
481pub enum FieldSizing {
482 Fixed,
483 Content,
484}