Skip to main content

css_ast/values/
o.rs

1//! Opera-prefixed CSS property value types.
2//!
3//! Non-standard aliases for standardised properties, kept for compatibility
4//! with legacy stylesheets targeting Opera Presto.
5
6use super::prelude::*;
7
8/// `-o-object-fit` — alias for `object-fit`.
9#[syntax(" fill | none | [ contain | cover ] || scale-down ")]
10#[derive(
11	Parse, Peek, ToSpan, ToCursors, DeclarationMetadata, SemanticEq, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
12)]
13#[declaration_metadata(
14    initial = "fill",
15    applies_to = Elements,
16    animation_type = Discrete,
17    property_group = Images,
18    computed_value_type = AsSpecified,
19    canonical_order = "per grammar",
20)]
21#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
22#[cfg_attr(feature = "visitable", derive(Visitable), visit)]
23#[derive(csskit_derives::NodeWithMetadata)]
24pub enum OObjectFitStyleValue {}
25
26/// `-o-box-sizing` — alias for `box-sizing`.
27#[syntax(" content-box | border-box ")]
28#[derive(
29	Parse, Peek, ToSpan, ToCursors, DeclarationMetadata, SemanticEq, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
30)]
31#[declaration_metadata(
32    initial = "content-box",
33    applies_to = Elements,
34    animation_type = Discrete,
35    property_group = Sizing,
36    computed_value_type = AsSpecified,
37    canonical_order = "per grammar",
38)]
39#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
40#[cfg_attr(feature = "visitable", derive(Visitable), visit)]
41#[derive(csskit_derives::NodeWithMetadata)]
42pub enum OBoxSizingStyleValue {}
43
44#[cfg(test)]
45mod tests {
46	use super::*;
47	use crate::CssAtomSet;
48	use css_parse::{assert_parse, assert_parse_error};
49
50	#[test]
51	fn test_o_object_fit_parses() {
52		assert_parse!(CssAtomSet::ATOMS, OObjectFitStyleValue, "fill");
53		assert_parse!(CssAtomSet::ATOMS, OObjectFitStyleValue, "none");
54		assert_parse!(CssAtomSet::ATOMS, OObjectFitStyleValue, "contain");
55		assert_parse!(CssAtomSet::ATOMS, OObjectFitStyleValue, "cover");
56		assert_parse!(CssAtomSet::ATOMS, OObjectFitStyleValue, "scale-down");
57	}
58
59	#[test]
60	fn test_o_object_fit_errors() {
61		assert_parse_error!(CssAtomSet::ATOMS, OObjectFitStyleValue, "invalid");
62	}
63
64	#[test]
65	fn test_o_box_sizing_parses() {
66		assert_parse!(CssAtomSet::ATOMS, OBoxSizingStyleValue, "content-box");
67		assert_parse!(CssAtomSet::ATOMS, OBoxSizingStyleValue, "border-box");
68	}
69
70	#[test]
71	fn test_o_box_sizing_errors() {
72		assert_parse_error!(CssAtomSet::ATOMS, OBoxSizingStyleValue, "invalid");
73	}
74}