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
use crate as css;
use crate::{Parser, PrintErr, Printer};
/// A value for the [overflow](https://www.w3.org/TR/css-overflow-3/#overflow-properties) shorthand property.
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct Overflow {
/// A value for the [overflow](https://www.w3.org/TR/css-overflow-3/#overflow-properties) shorthand property.
pub x: OverflowKeyword,
/// The overflow mode for the y direction.
pub y: OverflowKeyword,
}
impl Overflow {
pub(crate) fn parse(input: &mut Parser) -> css::Result<Overflow> {
let x = OverflowKeyword::parse(input)?;
let y = input.try_parse(OverflowKeyword::parse).unwrap_or(x);
Ok(Overflow { x, y })
}
pub(crate) fn to_css(self, dest: &mut Printer) -> Result<(), PrintErr> {
self.x.to_css(dest)?;
if self.y != self.x {
dest.write_char(b' ')?;
self.y.to_css(dest)?;
}
Ok(())
}
}
/// An [overflow](https://www.w3.org/TR/css-overflow-3/#overflow-properties) keyword
/// as used in the `overflow-x`, `overflow-y`, and `overflow` properties.
// PORT NOTE: css.DefineEnumProperty(@This()) — comptime mixin providing
// eql/hash/parse/to_css/deep_clone from @tagName.
#[derive(Clone, Copy, PartialEq, Eq, Hash, crate::DefineEnumProperty)]
pub enum OverflowKeyword {
/// Overflowing content is visible.
Visible,
/// Overflowing content is hidden. Programmatic scrolling is allowed.
Hidden,
/// Overflowing content is clipped. Programmatic scrolling is not allowed.
Clip,
/// The element is scrollable.
Scroll,
/// Overflowing content scrolls if needed.
Auto,
}
/// A value for the [text-overflow](https://www.w3.org/TR/css-overflow-3/#text-overflow) property.
#[derive(Clone, Copy, PartialEq, Eq, Hash, crate::DefineEnumProperty)]
pub enum TextOverflow {
/// Overflowing text is clipped.
Clip,
/// Overflowing text is truncated with an ellipsis.
Ellipsis,
}
// ported from: src/css/properties/overflow.zig