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 {}
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;
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 {}
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 {}
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 {}
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 {}
135
136#[cfg(test)]
137mod tests {
138	use super::*;
139	use crate::CssAtomSet;
140	use css_parse::{assert_parse, assert_parse_error};
141
142	#[test]
143	fn test_moz_column_gap_parses() {
144		assert_parse!(CssAtomSet::ATOMS, MozColumnGapStyleValue, "normal");
145		assert_parse!(CssAtomSet::ATOMS, MozColumnGapStyleValue, "1rem");
146		assert_parse!(CssAtomSet::ATOMS, MozColumnGapStyleValue, "0");
147	}
148
149	#[test]
150	fn test_moz_column_gap_errors() {
151		assert_parse_error!(CssAtomSet::ATOMS, MozColumnGapStyleValue, "invalid");
152	}
153
154	#[test]
155	fn test_moz_column_count_parses() {
156		assert_parse!(CssAtomSet::ATOMS, MozColumnCountStyleValue, "auto");
157		assert_parse!(CssAtomSet::ATOMS, MozColumnCountStyleValue, "3");
158	}
159
160	#[test]
161	fn test_moz_column_count_errors() {
162		assert_parse_error!(CssAtomSet::ATOMS, MozColumnCountStyleValue, "0");
163	}
164
165	#[test]
166	fn test_moz_user_select_parses() {
167		assert_parse!(CssAtomSet::ATOMS, MozUserSelectStyleValue, "none");
168		assert_parse!(CssAtomSet::ATOMS, MozUserSelectStyleValue, "auto");
169		assert_parse!(CssAtomSet::ATOMS, MozUserSelectStyleValue, "all");
170	}
171
172	#[test]
173	fn test_moz_user_select_errors() {
174		assert_parse_error!(CssAtomSet::ATOMS, MozUserSelectStyleValue, "invalid");
175	}
176
177	#[test]
178	fn test_moz_appearance_parses() {
179		assert_parse!(CssAtomSet::ATOMS, MozAppearanceStyleValue, "none");
180		assert_parse!(CssAtomSet::ATOMS, MozAppearanceStyleValue, "auto");
181	}
182
183	#[test]
184	fn test_moz_appearance_errors() {
185		assert_parse_error!(CssAtomSet::ATOMS, MozAppearanceStyleValue, "invalid");
186	}
187
188	#[test]
189	fn test_moz_osx_font_smoothing_parses() {
190		assert_parse!(CssAtomSet::ATOMS, MozOsxFontSmoothingStyleValue, "auto");
191		assert_parse!(CssAtomSet::ATOMS, MozOsxFontSmoothingStyleValue, "grayscale");
192	}
193
194	#[test]
195	fn test_moz_osx_font_smoothing_errors() {
196		assert_parse_error!(CssAtomSet::ATOMS, MozOsxFontSmoothingStyleValue, "antialiased");
197	}
198
199	#[test]
200	fn test_moz_transition_parses() {
201		assert_parse!(CssAtomSet::ATOMS, MozTransitionStyleValue, "none");
202		assert_parse!(CssAtomSet::ATOMS, MozTransitionStyleValue, "all 0.3s ease");
203	}
204
205	#[test]
206	fn test_moz_transition_errors() {
207		assert_parse_error!(CssAtomSet::ATOMS, MozTransitionStyleValue, "invalid!!!!");
208	}
209
210	#[test]
211	fn test_moz_box_sizing_parses() {
212		assert_parse!(CssAtomSet::ATOMS, MozBoxSizingStyleValue, "content-box");
213		assert_parse!(CssAtomSet::ATOMS, MozBoxSizingStyleValue, "border-box");
214	}
215
216	#[test]
217	fn test_moz_box_sizing_errors() {
218		assert_parse_error!(CssAtomSet::ATOMS, MozBoxSizingStyleValue, "invalid");
219	}
220}