css_ast/values/transforms/
mod.rs

1#![allow(warnings)]
2//! CSS Transforms Module Level 2
3//! https://drafts.csswg.org/css-transforms-2/
4
5mod impls;
6use impls::*;
7
8/// Represents the style value for `transform` as defined in [css-transforms-2](https://drafts.csswg.org/css-transforms-2/#transform).
9///
10/// The transform CSS property and its 2D transform functions allow rotating, scaling, skewing, and translating an element. Arbitrary 2D transforms are also possible using a transformation matrix.
11///
12/// The grammar is defined as:
13///
14/// ```text,ignore
15/// none | <transform-list>
16/// ```
17///
18// https://drafts.csswg.org/css-transforms-2/#transform
19#[syntax(" none | <transform-list> ")]
20#[derive(Parse, Peek, ToSpan, ToCursors, StyleValue, Visitable, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
21#[style_value(
22	initial = "none",
23	applies_to = "transformable elements",
24	inherited = "no",
25	percentages = "refer to the size of reference box",
26	canonical_order = "per grammar",
27	animation_type = "transform list, see interpolation rules"
28)]
29#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
30#[cfg_attr(feature = "css_feature_data", derive(ToCSSFeature), css_feature("css.properties.transform"))]
31#[visit]
32pub struct TransformStyleValue<'a>;
33
34// /// Represents the style value for `transform-origin` as defined in [css-transforms-2](https://drafts.csswg.org/css-transforms-2/#transform-origin).
35// ///
36// /// The transform CSS property and its 2D transform functions allow rotating, scaling, skewing, and translating an element. Arbitrary 2D transforms are also possible using a transformation matrix.
37// ///
38// /// The grammar is defined as:
39// ///
40// /// ```text,ignore
41// /// [ left | center | right | top | bottom | <length-percentage> ] |   [ left | center | right | <length-percentage> ]  [ top | center | bottom | <length-percentage> ] <length>? |  [ [ center | left | right ] && [ center | top | bottom ] ] <length>?
42// /// ```
43// ///
44// // https://drafts.csswg.org/css-transforms-2/#transform-origin
45// #[syntax(
46// 	" [ left | center | right | top | bottom | <length-percentage> ] |   [ left | center | right | <length-percentage> ]  [ top | center | bottom | <length-percentage> ] <length>? |  [ [ center | left | right ] && [ center | top | bottom ] ] <length>? "
47// )]
48// #[derive(Parse, Peek, ToSpan, ToCursors, StyleValue, Visitable, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
49// #[style_value(
50// 	initial = "50% 50%",
51//   applies_to = "transformable elements",
52// 	inherited = "no",
53// 	percentages = "refer to the size of reference box",
54// 	canonical_order = "per grammar",
55// 	animation_type = "by computed value",
56// )]
57// #[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
58// #[cfg_attr(feature = "css_feature_data", derive(ToCSSFeature), css_feature("css.properties.transform-origin"))]
59// #[visit]
60// pub enum TransformOriginStyleValue {}
61
62/// Represents the style value for `transform-box` as defined in [css-transforms-2](https://drafts.csswg.org/css-transforms-2/#transform-box).
63///
64/// The transform-box CSS property sets the position and dimensions of the reference box relative to which an element's transformations are calculated.
65///
66/// The grammar is defined as:
67///
68/// ```text,ignore
69/// content-box | border-box | fill-box | stroke-box | view-box
70/// ```
71///
72// https://drafts.csswg.org/css-transforms-2/#transform-box
73#[syntax(" content-box | border-box | fill-box | stroke-box | view-box ")]
74#[derive(Parse, Peek, ToSpan, ToCursors, StyleValue, Visitable, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
75#[style_value(
76	initial = "view-box",
77	applies_to = "transformable elements",
78	inherited = "no",
79	percentages = "n/a",
80	canonical_order = "per grammar",
81	animation_type = "discrete"
82)]
83#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
84#[cfg_attr(feature = "css_feature_data", derive(ToCSSFeature), css_feature("css.properties.transform-box"))]
85#[visit]
86pub enum TransformBoxStyleValue {}
87
88// /// Represents the style value for `translate` as defined in [css-transforms-2](https://drafts.csswg.org/css-transforms-2/#translate).
89// ///
90// /// The translate, rotate, and scale CSS properties apply single transformations independently, as opposed to applying multiple transformations with the transform CSS property.
91// ///
92// /// The grammar is defined as:
93// ///
94// /// ```text,ignore
95// /// none | <length-percentage> [ <length-percentage> <length>? ]?
96// /// ```
97// ///
98// // https://drafts.csswg.org/css-transforms-2/#translate
99// #[syntax(" none | <length-percentage> [ <length-percentage> <length>? ]? ")]
100// #[derive(Parse, Peek, ToSpan, ToCursors, StyleValue, Visitable, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
101// #[style_value(
102// 	initial = "none",
103//   applies_to = "transformable elements",
104// 	inherited = "no",
105// 	percentages = "relative to the width of the reference box (for the first value) or the height (for the second value)",
106// 	canonical_order = "per grammar",
107// 	animation_type = "by computed value, but see below for none",
108// )]
109// #[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
110// #[cfg_attr(feature = "css_feature_data", derive(ToCSSFeature), css_feature("css.properties.translate"))]
111// #[visit]
112// pub struct TranslateStyleValue;
113
114// /// Represents the style value for `rotate` as defined in [css-transforms-2](https://drafts.csswg.org/css-transforms-2/#rotate).
115// ///
116// /// The translate, rotate, and scale CSS properties apply single transformations independently, as opposed to applying multiple transformations with the transform CSS property.
117// ///
118// /// The grammar is defined as:
119// ///
120// /// ```text,ignore
121// /// none | <angle> | [ x | y | z | <number>{3} ] && <angle>
122// /// ```
123// ///
124// // https://drafts.csswg.org/css-transforms-2/#rotate
125// #[syntax(" none | <angle> | [ x | y | z | <number>{3} ] && <angle> ")]
126// #[derive(Parse, Peek, ToSpan, ToCursors, StyleValue, Visitable, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
127// #[style_value(
128// 	initial = "none",
129//   applies_to = "transformable elements",
130// 	inherited = "no",
131// 	percentages = "n/a",
132// 	canonical_order = "per grammar",
133// 	animation_type = "as slerp, but see below for none",
134// )]
135// #[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
136// #[cfg_attr(feature = "css_feature_data", derive(ToCSSFeature), css_feature("css.properties.rotate"))]
137// #[visit]
138// pub enum RotateStyleValue {}
139
140/// Represents the style value for `scale` as defined in [css-transforms-2](https://drafts.csswg.org/css-transforms-2/#scale).
141///
142/// The translate, rotate, and scale CSS properties apply single transformations independently, as opposed to applying multiple transformations with the transform CSS property.
143///
144/// The grammar is defined as:
145///
146/// ```text,ignore
147/// none | [ <number> | <percentage> ]{1,3}
148/// ```
149///
150// https://drafts.csswg.org/css-transforms-2/#scale
151#[syntax(" none | [ <number> | <percentage> ]{1,3} ")]
152#[derive(Parse, Peek, ToSpan, ToCursors, StyleValue, Visitable, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
153#[style_value(
154	initial = "none",
155	applies_to = "transformable elements",
156	inherited = "no",
157	percentages = "n/a",
158	canonical_order = "per grammar",
159	animation_type = "by computed value, but see below for none"
160)]
161#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
162#[cfg_attr(feature = "css_feature_data", derive(ToCSSFeature), css_feature("css.properties.scale"))]
163#[visit]
164pub struct ScaleStyleValue;
165
166/// Represents the style value for `transform-style` as defined in [css-transforms-2](https://drafts.csswg.org/css-transforms-2/#transform-style).
167///
168/// The transform CSS property and its 3D transform functions allow rotations and other transforms in three dimensions, including perspective transforms.
169///
170/// The grammar is defined as:
171///
172/// ```text,ignore
173/// flat | preserve-3d
174/// ```
175///
176// https://drafts.csswg.org/css-transforms-2/#transform-style
177#[syntax(" flat | preserve-3d ")]
178#[derive(Parse, Peek, ToSpan, ToCursors, StyleValue, Visitable, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
179#[style_value(
180	initial = "flat",
181	applies_to = "transformable elements",
182	inherited = "no",
183	percentages = "n/a",
184	canonical_order = "per grammar",
185	animation_type = "discrete"
186)]
187#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
188#[cfg_attr(feature = "css_feature_data", derive(ToCSSFeature), css_feature("css.properties.transform-style"))]
189#[visit]
190pub enum TransformStyleStyleValue {}
191
192/// Represents the style value for `perspective` as defined in [css-transforms-2](https://drafts.csswg.org/css-transforms-2/#perspective).
193///
194/// The transform CSS property and its 3D transform functions allow rotations and other transforms in three dimensions, including perspective transforms.
195///
196/// The grammar is defined as:
197///
198/// ```text,ignore
199/// none | <length [0,∞]>
200/// ```
201///
202// https://drafts.csswg.org/css-transforms-2/#perspective
203#[syntax(" none | <length [0,∞]> ")]
204#[derive(Parse, Peek, ToSpan, ToCursors, StyleValue, Visitable, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
205#[style_value(
206	initial = "none",
207	applies_to = "transformable elements",
208	inherited = "no",
209	percentages = "n/a",
210	canonical_order = "per grammar",
211	animation_type = "by computed value"
212)]
213#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
214#[cfg_attr(feature = "css_feature_data", derive(ToCSSFeature), css_feature("css.properties.perspective"))]
215#[visit]
216pub struct PerspectiveStyleValue;
217
218/// Represents the style value for `perspective-origin` as defined in [css-transforms-2](https://drafts.csswg.org/css-transforms-2/#perspective-origin).
219///
220/// The transform CSS property and its 3D transform functions allow rotations and other transforms in three dimensions, including perspective transforms.
221///
222/// The grammar is defined as:
223///
224/// ```text,ignore
225/// <position>
226/// ```
227///
228// https://drafts.csswg.org/css-transforms-2/#perspective-origin
229#[syntax(" <position> ")]
230#[derive(Parse, Peek, ToSpan, ToCursors, StyleValue, Visitable, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
231#[style_value(
232	initial = "50% 50%",
233	applies_to = "transformable elements",
234	inherited = "no",
235	percentages = "refer to the size of the reference box",
236	canonical_order = "per grammar",
237	animation_type = "by computed value"
238)]
239#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
240#[cfg_attr(feature = "css_feature_data", derive(ToCSSFeature), css_feature("css.properties.perspective-origin"))]
241#[visit]
242pub struct PerspectiveOriginStyleValue;
243
244/// Represents the style value for `backface-visibility` as defined in [css-transforms-2](https://drafts.csswg.org/css-transforms-2/#backface-visibility).
245///
246/// The transform CSS property and its 3D transform functions allow rotations and other transforms in three dimensions, including perspective transforms.
247///
248/// The grammar is defined as:
249///
250/// ```text,ignore
251/// visible | hidden
252/// ```
253///
254// https://drafts.csswg.org/css-transforms-2/#backface-visibility
255#[syntax(" visible | hidden ")]
256#[derive(Parse, Peek, ToSpan, ToCursors, StyleValue, Visitable, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
257#[style_value(
258	initial = "visible",
259	applies_to = "transformable elements",
260	inherited = "no",
261	percentages = "n/a",
262	canonical_order = "per grammar",
263	animation_type = "discrete"
264)]
265#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
266#[cfg_attr(feature = "css_feature_data", derive(ToCSSFeature), css_feature("css.properties.backface-visibility"))]
267#[visit]
268pub enum BackfaceVisibilityStyleValue {}