Skip to main content

css_ast/values/
moz.rs

1//! Mozilla-prefixed CSS property value types.
2//!
3//! Non-standard aliases for standardised properties, kept for compatibility
4//! with legacy stylesheets.
5
6use super::prelude::*;
7
8/// `-moz-column-gap` — alias for `column-gap`.
9#[syntax(" normal | <length-percentage [0,∞]> | <line-width> ")]
10#[derive(
11	Parse, Peek, ToSpan, ToCursors, DeclarationMetadata, SemanticEq, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
12)]
13#[declaration_metadata(
14    initial = "normal",
15    applies_to = Elements,
16    animation_type = ByComputedValue,
17    property_group = Gaps,
18    computed_value_type = Unknown,
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 MozColumnGapStyleValue<'a> {}
25
26/// `-moz-column-count` — alias for `column-count`.
27#[syntax(" auto | <integer [1,∞]> ")]
28#[derive(
29	Parse, Peek, ToSpan, ToCursors, DeclarationMetadata, SemanticEq, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
30)]
31#[declaration_metadata(
32    initial = "auto",
33    applies_to = Elements,
34    animation_type = ByComputedValue,
35    property_group = Multicol,
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 struct MozColumnCountStyleValue<'a>;
43
44/// `-moz-user-select` — alias for `user-select`.
45#[syntax(" auto | text | none | all ")]
46#[derive(
47	Parse, Peek, ToSpan, ToCursors, DeclarationMetadata, SemanticEq, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
48)]
49#[declaration_metadata(
50    initial = "auto",
51    applies_to = Elements,
52    animation_type = Discrete,
53    property_group = Ui,
54    computed_value_type = AsSpecified,
55    canonical_order = "per grammar",
56)]
57#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
58#[cfg_attr(feature = "visitable", derive(Visitable), visit)]
59#[derive(csskit_derives::NodeWithMetadata)]
60pub enum MozUserSelectStyleValue<'a> {}
61
62/// `-moz-appearance` — alias for `appearance`.
63#[syntax(" none | auto | base | base-select | <compat-auto> | <compat-special> ")]
64#[derive(
65	Parse, Peek, ToSpan, ToCursors, DeclarationMetadata, SemanticEq, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
66)]
67#[declaration_metadata(
68    initial = "none",
69    applies_to = Elements,
70    animation_type = Discrete,
71    property_group = Ui,
72    computed_value_type = Unknown,
73    canonical_order = "per grammar",
74)]
75#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
76#[cfg_attr(feature = "visitable", derive(Visitable), visit)]
77#[derive(csskit_derives::NodeWithMetadata)]
78pub enum MozAppearanceStyleValue<'a> {}
79
80/// `-moz-osx-font-smoothing` — non-standard macOS font smoothing.
81///
82/// Equivalent to `-webkit-font-smoothing` on macOS.
83#[syntax(" auto | grayscale ")]
84#[derive(
85	Parse, Peek, ToSpan, ToCursors, DeclarationMetadata, SemanticEq, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
86)]
87#[declaration_metadata(
88    initial = "auto",
89    inherits,
90    applies_to = Elements,
91    animation_type = Discrete,
92    property_group = Fonts,
93    computed_value_type = AsSpecified,
94    canonical_order = "per grammar",
95)]
96#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
97#[cfg_attr(feature = "visitable", derive(Visitable), visit)]
98#[derive(csskit_derives::NodeWithMetadata)]
99pub enum MozOsxFontSmoothingStyleValue<'a> {}
100
101/// `-moz-transition` — alias for `transition`.
102#[syntax(" <single-transition># ")]
103#[derive(
104	Parse, Peek, ToSpan, ToCursors, DeclarationMetadata, SemanticEq, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
105)]
106#[declaration_metadata(
107    initial = "see individual properties",
108    applies_to = Elements,
109    property_group = Transitions,
110    computed_value_type = Unknown,
111    canonical_order = "per grammar",
112)]
113#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
114#[cfg_attr(feature = "visitable", derive(Visitable), visit)]
115#[derive(csskit_derives::NodeWithMetadata)]
116pub struct MozTransitionStyleValue<'a>;
117
118/// `-moz-box-sizing` — alias for `box-sizing`.
119#[syntax(" content-box | border-box ")]
120#[derive(
121	Parse, Peek, ToSpan, ToCursors, DeclarationMetadata, SemanticEq, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
122)]
123#[declaration_metadata(
124    initial = "content-box",
125    applies_to = Elements,
126    animation_type = Discrete,
127    property_group = Sizing,
128    computed_value_type = AsSpecified,
129    canonical_order = "per grammar",
130)]
131#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
132#[cfg_attr(feature = "visitable", derive(Visitable), visit)]
133#[derive(csskit_derives::NodeWithMetadata)]
134pub enum MozBoxSizingStyleValue<'a> {}
135
136/// `-moz-filter` - alias for `filter`.
137#[syntax(" none | <filter-value-list> ")]
138#[derive(
139	Parse, Peek, ToSpan, ToCursors, DeclarationMetadata, SemanticEq, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
140)]
141#[declaration_metadata(
142    initial = "none",
143    applies_to = Elements,
144    animation_type = Unknown,
145    property_group = FilterEffects,
146    computed_value_type = AsSpecified,
147    canonical_order = "per grammar",
148)]
149#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
150#[cfg_attr(feature = "visitable", derive(Visitable), visit)]
151#[derive(csskit_derives::NodeWithMetadata)]
152pub struct MozFilterStyleValue<'a>;
153
154#[cfg(test)]
155mod tests {
156	use super::*;
157	use crate::CssAtomSet;
158	use css_parse::{assert_parse, assert_parse_error, assert_peek_false};
159
160	#[test]
161	fn test_moz_column_gap_parses() {
162		assert_parse!(CssAtomSet::ATOMS, MozColumnGapStyleValue, "normal");
163		assert_parse!(CssAtomSet::ATOMS, MozColumnGapStyleValue, "1rem");
164		assert_parse!(CssAtomSet::ATOMS, MozColumnGapStyleValue, "0");
165	}
166
167	#[test]
168	fn test_moz_column_gap_errors() {
169		assert_peek_false!(CssAtomSet::ATOMS, MozColumnGapStyleValue, "invalid");
170	}
171
172	#[test]
173	fn test_moz_column_count_parses() {
174		assert_parse!(CssAtomSet::ATOMS, MozColumnCountStyleValue, "auto");
175		assert_parse!(CssAtomSet::ATOMS, MozColumnCountStyleValue, "3");
176	}
177
178	#[test]
179	fn test_moz_column_count_errors() {
180		assert_parse_error!(CssAtomSet::ATOMS, MozColumnCountStyleValue, "0");
181	}
182
183	#[test]
184	fn test_moz_user_select_parses() {
185		assert_parse!(CssAtomSet::ATOMS, MozUserSelectStyleValue, "none");
186		assert_parse!(CssAtomSet::ATOMS, MozUserSelectStyleValue, "auto");
187		assert_parse!(CssAtomSet::ATOMS, MozUserSelectStyleValue, "all");
188	}
189
190	#[test]
191	fn test_moz_user_select_errors() {
192		assert_peek_false!(CssAtomSet::ATOMS, MozUserSelectStyleValue, "invalid");
193	}
194
195	#[test]
196	fn test_moz_appearance_parses() {
197		assert_parse!(CssAtomSet::ATOMS, MozAppearanceStyleValue, "none");
198		assert_parse!(CssAtomSet::ATOMS, MozAppearanceStyleValue, "auto");
199	}
200
201	#[test]
202	fn test_moz_appearance_errors() {
203		assert_peek_false!(CssAtomSet::ATOMS, MozAppearanceStyleValue, "invalid");
204	}
205
206	#[test]
207	fn test_moz_osx_font_smoothing_parses() {
208		assert_parse!(CssAtomSet::ATOMS, MozOsxFontSmoothingStyleValue, "auto");
209		assert_parse!(CssAtomSet::ATOMS, MozOsxFontSmoothingStyleValue, "grayscale");
210	}
211
212	#[test]
213	fn test_moz_osx_font_smoothing_errors() {
214		assert_peek_false!(CssAtomSet::ATOMS, MozOsxFontSmoothingStyleValue, "antialiased");
215	}
216
217	#[test]
218	fn test_moz_transition_parses() {
219		assert_parse!(CssAtomSet::ATOMS, MozTransitionStyleValue, "none");
220		assert_parse!(CssAtomSet::ATOMS, MozTransitionStyleValue, "all 0.3s ease");
221	}
222
223	#[test]
224	fn test_moz_transition_errors() {
225		assert_parse_error!(CssAtomSet::ATOMS, MozTransitionStyleValue, "invalid!!!!");
226	}
227
228	#[test]
229	fn test_moz_box_sizing_parses() {
230		assert_parse!(CssAtomSet::ATOMS, MozBoxSizingStyleValue, "content-box");
231		assert_parse!(CssAtomSet::ATOMS, MozBoxSizingStyleValue, "border-box");
232	}
233
234	#[test]
235	fn test_moz_box_sizing_errors() {
236		assert_peek_false!(CssAtomSet::ATOMS, MozBoxSizingStyleValue, "invalid");
237	}
238
239	#[test]
240	fn test_moz_filter_parses() {
241		assert_parse!(CssAtomSet::ATOMS, MozFilterStyleValue, "none");
242		assert_parse!(CssAtomSet::ATOMS, MozFilterStyleValue, "blur(4px)");
243		assert_parse!(CssAtomSet::ATOMS, MozFilterStyleValue, "brightness(0.5) contrast(1.2)");
244	}
245
246	#[test]
247	fn test_moz_filter_errors() {
248		assert_peek_false!(CssAtomSet::ATOMS, MozFilterStyleValue, "invalid");
249	}
250}