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 Interactivity {
341 Auto,
342 Inert,
343}
344
345#[allow(missing_docs)]
348#[derive(
349 Clone,
350 Copy,
351 Debug,
352 Eq,
353 FromPrimitive,
354 MallocSizeOf,
355 Parse,
356 PartialEq,
357 SpecifiedValueInfo,
358 ToComputedValue,
359 ToCss,
360 ToResolvedValue,
361 ToShmem,
362 ToTyped,
363)]
364#[repr(u8)]
365pub enum UserFocus {
366 Normal,
367 None,
368 Ignore,
369}
370
371#[allow(missing_docs)]
373#[derive(
374 Clone,
375 Copy,
376 Debug,
377 Deserialize,
378 Eq,
379 FromPrimitive,
380 Hash,
381 MallocSizeOf,
382 Parse,
383 PartialEq,
384 Serialize,
385 SpecifiedValueInfo,
386 ToComputedValue,
387 ToCss,
388 ToResolvedValue,
389 ToShmem,
390 ToTyped,
391)]
392#[repr(u8)]
393pub enum ImeMode {
394 Auto,
395 Normal,
396 Active,
397 Disabled,
398 Inactive,
399}
400
401#[allow(missing_docs)]
403#[derive(
404 Clone,
405 Copy,
406 Debug,
407 Deserialize,
408 Eq,
409 FromPrimitive,
410 Hash,
411 MallocSizeOf,
412 Parse,
413 PartialEq,
414 Serialize,
415 SpecifiedValueInfo,
416 ToComputedValue,
417 ToCss,
418 ToResolvedValue,
419 ToShmem,
420 ToTyped,
421)]
422#[repr(u8)]
423pub enum ScrollbarWidth {
424 Auto,
425 Thin,
426 None,
427}
428
429#[allow(missing_docs)]
431#[derive(
432 Clone,
433 Copy,
434 Debug,
435 Deserialize,
436 Eq,
437 FromPrimitive,
438 Hash,
439 MallocSizeOf,
440 Parse,
441 PartialEq,
442 Serialize,
443 SpecifiedValueInfo,
444 ToComputedValue,
445 ToCss,
446 ToResolvedValue,
447 ToShmem,
448 ToTyped,
449)]
450#[repr(u8)]
451pub enum WindowDragging {
452 Default,
453 Drag,
454 NoDrag,
455}
456
457#[allow(missing_docs)]
459#[derive(
460 Clone,
461 Copy,
462 Debug,
463 Deserialize,
464 Eq,
465 FromPrimitive,
466 Hash,
467 MallocSizeOf,
468 Parse,
469 PartialEq,
470 Serialize,
471 SpecifiedValueInfo,
472 ToComputedValue,
473 ToCss,
474 ToResolvedValue,
475 ToShmem,
476 ToTyped,
477)]
478#[repr(u8)]
479pub enum WindowShadow {
480 Auto,
481 None,
482}
483
484#[allow(missing_docs)]
486#[derive(
487 Clone,
488 Copy,
489 Debug,
490 Deserialize,
491 Eq,
492 FromPrimitive,
493 Hash,
494 MallocSizeOf,
495 Parse,
496 PartialEq,
497 Serialize,
498 SpecifiedValueInfo,
499 ToComputedValue,
500 ToCss,
501 ToResolvedValue,
502 ToShmem,
503 ToTyped,
504)]
505#[repr(u8)]
506pub enum FieldSizing {
507 Fixed,
508 Content,
509}