mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
Move TransformStyle out of Mako files
This commit is contained in:
parent
579cef6a69
commit
1f8777bb0b
9 changed files with 63 additions and 13 deletions
|
@ -62,6 +62,7 @@ use values::computed::{NonNegativeLength, ToComputedValue, Percentage};
|
||||||
use values::computed::font::{FontSize, SingleFontFamily};
|
use values::computed::font::{FontSize, SingleFontFamily};
|
||||||
use values::computed::effects::{BoxShadow, Filter, SimpleShadow};
|
use values::computed::effects::{BoxShadow, Filter, SimpleShadow};
|
||||||
use values::computed::outline::OutlineStyle;
|
use values::computed::outline::OutlineStyle;
|
||||||
|
use values::generics::transform::TransformStyle;
|
||||||
use computed_values::border_style;
|
use computed_values::border_style;
|
||||||
|
|
||||||
pub mod style_structs {
|
pub mod style_structs {
|
||||||
|
@ -3345,6 +3346,25 @@ fn static_assert() {
|
||||||
self.copy_transition_property_from(other)
|
self.copy_transition_property_from(other)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hand-written because the Mako helpers transform `Preserve3d` into `PRESERVE3D`.
|
||||||
|
pub fn set_transform_style(&mut self, v: TransformStyle) {
|
||||||
|
self.gecko.mTransformStyle = match v {
|
||||||
|
TransformStyle::Flat => structs::NS_STYLE_TRANSFORM_STYLE_FLAT as u8,
|
||||||
|
TransformStyle::Preserve3d => structs::NS_STYLE_TRANSFORM_STYLE_PRESERVE_3D as u8,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hand-written because the Mako helpers transform `Preserve3d` into `PRESERVE3D`.
|
||||||
|
pub fn clone_transform_style(&self) -> TransformStyle {
|
||||||
|
match self.gecko.mTransformStyle as u32 {
|
||||||
|
structs::NS_STYLE_TRANSFORM_STYLE_FLAT => TransformStyle::Flat,
|
||||||
|
structs::NS_STYLE_TRANSFORM_STYLE_PRESERVE_3D => TransformStyle::Preserve3d,
|
||||||
|
_ => panic!("illegal transform style"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
${impl_simple_copy('transform_style', 'mTransformStyle')}
|
||||||
|
|
||||||
${impl_transition_count('property', 'Property')}
|
${impl_transition_count('property', 'Property')}
|
||||||
|
|
||||||
pub fn animations_equals(&self, other: &Self) -> bool {
|
pub fn animations_equals(&self, other: &Self) -> bool {
|
||||||
|
|
|
@ -526,14 +526,16 @@ ${helpers.single_keyword("transform-box",
|
||||||
gecko_inexhaustive="True",
|
gecko_inexhaustive="True",
|
||||||
animation_value_type="discrete")}
|
animation_value_type="discrete")}
|
||||||
|
|
||||||
// `auto` keyword is not supported in gecko yet.
|
${helpers.predefined_type(
|
||||||
${helpers.single_keyword("transform-style",
|
"transform-style",
|
||||||
"auto flat preserve-3d" if product == "servo" else
|
"TransformStyle",
|
||||||
"flat preserve-3d",
|
"computed::TransformStyle::" + ("Auto" if product == "servo" else "Flat"),
|
||||||
spec="https://drafts.csswg.org/css-transforms/#transform-style-property",
|
spec="https://drafts.csswg.org/css-transforms-2/#transform-style-property",
|
||||||
|
needs_context=False,
|
||||||
extra_prefixes="moz webkit",
|
extra_prefixes="moz webkit",
|
||||||
flags="CREATES_STACKING_CONTEXT FIXPOS_CB",
|
flags="CREATES_STACKING_CONTEXT FIXPOS_CB",
|
||||||
animation_value_type="discrete")}
|
animation_value_type="discrete",
|
||||||
|
)}
|
||||||
|
|
||||||
${helpers.predefined_type("transform-origin",
|
${helpers.predefined_type("transform-origin",
|
||||||
"TransformOrigin",
|
"TransformOrigin",
|
||||||
|
|
|
@ -73,7 +73,8 @@ pub use self::svg::MozContextProperties;
|
||||||
pub use self::table::XSpan;
|
pub use self::table::XSpan;
|
||||||
pub use self::text::{InitialLetter, LetterSpacing, LineHeight, TextAlign, TextOverflow, WordSpacing};
|
pub use self::text::{InitialLetter, LetterSpacing, LineHeight, TextAlign, TextOverflow, WordSpacing};
|
||||||
pub use self::time::Time;
|
pub use self::time::Time;
|
||||||
pub use self::transform::{TimingFunction, Transform, TransformOperation, TransformOrigin, Rotate, Translate, Scale};
|
pub use self::transform::{Rotate, Scale, TimingFunction, Transform, TransformOperation};
|
||||||
|
pub use self::transform::{TransformOrigin, TransformStyle, Translate};
|
||||||
pub use self::ui::MozForceBrokenImageIcon;
|
pub use self::ui::MozForceBrokenImageIcon;
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
|
|
@ -18,6 +18,8 @@ use values::generics::transform::TimingFunction as GenericTimingFunction;
|
||||||
use values::generics::transform::TransformOrigin as GenericTransformOrigin;
|
use values::generics::transform::TransformOrigin as GenericTransformOrigin;
|
||||||
use values::generics::transform::Translate as GenericTranslate;
|
use values::generics::transform::Translate as GenericTranslate;
|
||||||
|
|
||||||
|
pub use values::generics::transform::TransformStyle;
|
||||||
|
|
||||||
/// A single operation in a computed CSS `transform`
|
/// A single operation in a computed CSS `transform`
|
||||||
pub type TransformOperation = GenericTransformOperation<
|
pub type TransformOperation = GenericTransformOperation<
|
||||||
Angle,
|
Angle,
|
||||||
|
|
|
@ -714,3 +714,13 @@ pub enum Translate<LengthOrPercentage, Length> {
|
||||||
/// '<length-percentage> <length-percentage> <length>'
|
/// '<length-percentage> <length-percentage> <length>'
|
||||||
Translate3D(LengthOrPercentage, LengthOrPercentage, Length),
|
Translate3D(LengthOrPercentage, LengthOrPercentage, Length),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(missing_docs)]
|
||||||
|
#[derive(Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)]
|
||||||
|
pub enum TransformStyle {
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
Auto,
|
||||||
|
Flat,
|
||||||
|
#[css(keyword = "preserve-3d")]
|
||||||
|
Preserve3d,
|
||||||
|
}
|
||||||
|
|
|
@ -69,7 +69,8 @@ pub use self::table::XSpan;
|
||||||
pub use self::text::{InitialLetter, LetterSpacing, LineHeight, TextDecorationLine};
|
pub use self::text::{InitialLetter, LetterSpacing, LineHeight, TextDecorationLine};
|
||||||
pub use self::text::{TextAlign, TextAlignKeyword, TextOverflow, WordSpacing};
|
pub use self::text::{TextAlign, TextAlignKeyword, TextOverflow, WordSpacing};
|
||||||
pub use self::time::Time;
|
pub use self::time::Time;
|
||||||
pub use self::transform::{TimingFunction, Transform, TransformOrigin, Rotate, Translate, Scale};
|
pub use self::transform::{Rotate, Scale, TimingFunction, Transform};
|
||||||
|
pub use self::transform::{TransformOrigin, TransformStyle, Translate};
|
||||||
pub use self::ui::MozForceBrokenImageIcon;
|
pub use self::ui::MozForceBrokenImageIcon;
|
||||||
pub use super::generics::grid::GridTemplateComponent as GenericGridTemplateComponent;
|
pub use super::generics::grid::GridTemplateComponent as GenericGridTemplateComponent;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@ use values::specified::{self, Angle, Number, Length, Integer};
|
||||||
use values::specified::{LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrNumber};
|
use values::specified::{LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrNumber};
|
||||||
use values::specified::position::{Side, X, Y};
|
use values::specified::position::{Side, X, Y};
|
||||||
|
|
||||||
|
pub use values::generics::transform::TransformStyle;
|
||||||
|
|
||||||
/// A single operation in a specified CSS `transform`
|
/// A single operation in a specified CSS `transform`
|
||||||
pub type TransformOperation = GenericTransformOperation<
|
pub type TransformOperation = GenericTransformOperation<
|
||||||
Angle,
|
Angle,
|
||||||
|
|
|
@ -21,7 +21,9 @@ pub fn derive(input: DeriveInput) -> Tokens {
|
||||||
);
|
);
|
||||||
|
|
||||||
let variant_attrs = cg::parse_variant_attrs::<CssVariantAttrs>(variant);
|
let variant_attrs = cg::parse_variant_attrs::<CssVariantAttrs>(variant);
|
||||||
let identifier = cg::to_css_identifier(variant.ident.as_ref());
|
let identifier = cg::to_css_identifier(
|
||||||
|
&variant_attrs.keyword.as_ref().unwrap_or(&variant.ident).as_ref(),
|
||||||
|
);
|
||||||
let ident = &variant.ident;
|
let ident = &variant.ident;
|
||||||
|
|
||||||
match_body = quote! {
|
match_body = quote! {
|
||||||
|
|
|
@ -23,10 +23,19 @@ pub fn derive(input: DeriveInput) -> Tokens {
|
||||||
|
|
||||||
if variant_attrs.dimension {
|
if variant_attrs.dimension {
|
||||||
assert_eq!(bindings.len(), 1);
|
assert_eq!(bindings.len(), 1);
|
||||||
assert!(variant_attrs.function.is_none(), "That makes no sense");
|
assert!(
|
||||||
|
variant_attrs.function.is_none() && variant_attrs.keyword.is_none(),
|
||||||
|
"That makes no sense"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut expr = if !bindings.is_empty() {
|
let mut expr = if let Some(keyword) = variant_attrs.keyword {
|
||||||
|
assert!(bindings.is_empty());
|
||||||
|
let keyword = keyword.to_string();
|
||||||
|
quote! {
|
||||||
|
::std::fmt::Write::write_str(dest, #keyword)
|
||||||
|
}
|
||||||
|
} else if !bindings.is_empty() {
|
||||||
let mut expr = quote! {};
|
let mut expr = quote! {};
|
||||||
if variant_attrs.iterable {
|
if variant_attrs.iterable {
|
||||||
assert_eq!(bindings.len(), 1);
|
assert_eq!(bindings.len(), 1);
|
||||||
|
@ -128,6 +137,7 @@ pub struct CssVariantAttrs {
|
||||||
pub iterable: bool,
|
pub iterable: bool,
|
||||||
pub comma: bool,
|
pub comma: bool,
|
||||||
pub dimension: bool,
|
pub dimension: bool,
|
||||||
|
pub keyword: Option<Ident>,
|
||||||
pub aliases: Option<String>,
|
pub aliases: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue