diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index 2be09150edc..9f6613102a3 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -866,23 +866,13 @@ impl PropertyDeclarationBlock { }; // Substeps 7 and 8 - // We need to check the shorthand whether it's an alias property or not. - // If it's an alias property, it should be serialized like its longhand. - if shorthand.flags().contains(PropertyFlags::SHORTHAND_ALIAS_PROPERTY) { - append_serialization::>, _>( - dest, - &property, - value, - importance, - &mut is_first_serialization)?; - } else { - append_serialization::>, _>( - dest, - &shorthand, - value, - importance, - &mut is_first_serialization)?; - } + append_serialization::>, _>( + dest, + &shorthand, + value, + importance, + &mut is_first_serialization, + )?; for current_longhand in ¤t_longhands { // Substep 9 diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index e06b724afaa..32ae4fe6d3d 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -968,10 +968,7 @@ def set_gecko_property(ffi_name, expr): <% transform_functions = [ ("Matrix3D", "matrix3d", ["number"] * 16), - ("PrefixedMatrix3D", "matrix3d", ["number"] * 12 + ["lopon"] * 2 - + ["lon"] + ["number"]), ("Matrix", "matrix", ["number"] * 6), - ("PrefixedMatrix", "matrix", ["number"] * 4 + ["lopon"] * 2), ("Translate", "translate", ["lop", "optional_lop"]), ("Translate3D", "translate3d", ["lop", "lop", "length"]), ("TranslateX", "translatex", ["lop"]), @@ -1027,8 +1024,6 @@ transform_functions = [ # need to cast it to f32. "integer_to_percentage" : "bindings::Gecko_CSSValue_SetPercentage(%s, %s as f32)", "lop" : "%s.set_lop(%s)", - "lopon" : "set_lopon(%s, %s)", - "lon" : "set_lon(%s, %s)", "angle" : "%s.set_angle(%s)", "number" : "bindings::Gecko_CSSValue_SetNumber(%s, %s)", # Note: We use nsCSSValueSharedList here, instead of nsCSSValueList_heap @@ -1106,16 +1101,7 @@ transform_functions = [ field_names = ["from_list", "to_list", "count"] %> - <% - - guard = "" - if name == "Matrix3D" or name == "Matrix": - guard = "if !needs_prefix " - elif name == "PrefixedMatrix3D" or name == "PrefixedMatrix": - guard = "if needs_prefix " - - %> - structs::nsCSSKeyword::eCSSKeyword_${keyword} ${guard}=> { + structs::nsCSSKeyword::eCSSKeyword_${keyword} => { ::values::generics::transform::TransformOperation::${name}${pre_symbols} % for index, item in enumerate(items): % if keyword == "matrix3d": @@ -1149,7 +1135,6 @@ fn set_single_transform_function( servo_value: &values::computed::TransformOperation, gecko_value: &mut structs::nsCSSValue /* output */ ) { - use values::computed::{Length, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrNumber}; use values::computed::TransformOperation; use values::generics::transform::{Matrix, Matrix3D}; @@ -1159,22 +1144,6 @@ fn set_single_transform_function( value }; - unsafe fn set_lopon(css: &mut structs::nsCSSValue, lopon: LengthOrPercentageOrNumber) { - let lop = match lopon { - Either::First(number) => LengthOrPercentage::Length(Length::new(number)), - Either::Second(lop) => lop, - }; - css.set_lop(lop); - } - - unsafe fn set_lon(css: &mut structs::nsCSSValue, lopon: LengthOrNumber) { - let length = match lopon { - Either::Second(number) => Length::new(number), - Either::First(l) => l, - }; - bindings::Gecko_CSSValue_SetPixelLength(css, length.px()) - } - unsafe { match *servo_value { % for servo, gecko, format in transform_functions: @@ -1228,19 +1197,6 @@ fn clone_single_transform_function( bindings::Gecko_CSSValue_GetKeyword(bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, 0)) }; - let needs_prefix = if transform_function == structs::nsCSSKeyword::eCSSKeyword_matrix3d { - unsafe { - bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, 13).mUnit - != structs::nsCSSUnit::eCSSUnit_Number || - bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, 14).mUnit - != structs::nsCSSUnit::eCSSUnit_Number || - bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, 15).mUnit - != structs::nsCSSUnit::eCSSUnit_Number - } - } else { - false - }; - unsafe { match transform_function { % for servo, gecko, format in transform_functions: diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 9713cc83bfa..6bc9bf8e621 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -395,7 +395,7 @@ ${helpers.predefined_type( ${helpers.predefined_type("transform", "Transform", "generics::transform::Transform::none()", - extra_prefixes="webkit", + extra_prefixes="webkit moz", animation_value_type="ComputedValue", gecko_ffi_name="mSpecifiedTransform", flags="CREATES_STACKING_CONTEXT FIXPOS_CB", diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index e74cad34361..523bfc4de31 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -793,14 +793,12 @@ bitflags! { /// This property has values that can establish a containing block for /// absolutely positioned elements. const ABSPOS_CB = 1 << 2; - /// This shorthand property is an alias of another property. - const SHORTHAND_ALIAS_PROPERTY = 1 << 3; /// This longhand property applies to ::first-letter. - const APPLIES_TO_FIRST_LETTER = 1 << 4; + const APPLIES_TO_FIRST_LETTER = 1 << 3; /// This longhand property applies to ::first-line. - const APPLIES_TO_FIRST_LINE = 1 << 5; + const APPLIES_TO_FIRST_LINE = 1 << 4; /// This longhand property applies to ::placeholder. - const APPLIES_TO_PLACEHOLDER = 1 << 6; + const APPLIES_TO_PLACEHOLDER = 1 << 5; } } @@ -1687,17 +1685,10 @@ impl ToCss for VariableDeclaration { { // https://drafts.csswg.org/css-variables/#variables-in-shorthands match self.value.from_shorthand { - // Normally, we shouldn't be printing variables here if they came from - // shorthands. But we should allow properties that came from shorthand - // aliases. That also matches with the Gecko behavior. - // FIXME(emilio): This is just a hack for `-moz-transform`. - Some(shorthand) if shorthand.flags().contains(PropertyFlags::SHORTHAND_ALIAS_PROPERTY) => { - dest.write_str(&*self.value.css)? - } None => { dest.write_str(&*self.value.css)? } - _ => {}, + Some(..) => {}, } Ok(()) } @@ -1768,20 +1759,11 @@ impl PropertyDeclaration { fn with_variables_from_shorthand(&self, shorthand: ShorthandId) -> Option< &str> { match *self { PropertyDeclaration::WithVariables(ref declaration) => { - if let Some(s) = declaration.value.from_shorthand { - if s == shorthand { - Some(&*declaration.value.css) - } else { None } - } else { - // Normally, longhand property that doesn't come from a shorthand - // should return None here. But we return Some to longhands if they - // came from a shorthand alias. Because for example, we should be able to - // get -moz-transform's value from transform. - if shorthand.flags().contains(PropertyFlags::SHORTHAND_ALIAS_PROPERTY) { - return Some(&*declaration.value.css); - } - None + let s = declaration.value.from_shorthand?; + if s != shorthand { + return None; } + Some(&*declaration.value.css) }, _ => None, } diff --git a/components/style/properties/shorthand/box.mako.rs b/components/style/properties/shorthand/box.mako.rs index 137599078ad..e9c87dca6aa 100644 --- a/components/style/properties/shorthand/box.mako.rs +++ b/components/style/properties/shorthand/box.mako.rs @@ -392,7 +392,7 @@ macro_rules! try_parse_one { spec="https://wicg.github.io/overscroll-behavior/#overscroll-behavior-properties"> pub fn parse_value<'i, 't>( _: &ParserContext, - input: &mut Parser<'i, 't> + input: &mut Parser<'i, 't>, ) -> Result> { use values::specified::OverscrollBehavior; let behavior_x = OverscrollBehavior::parse(input)?; @@ -416,18 +416,3 @@ macro_rules! try_parse_one { } } - -<%helpers:shorthand name="-moz-transform" products="gecko" - sub_properties="transform" - gecko_pref="layout.css.prefixes.transforms" - flags="SHORTHAND_ALIAS_PROPERTY" - derive_serialize="True" - spec="Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/transform"> - pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) - -> Result> { - use values::specified::transform::Transform; - Ok(expanded! { - transform: Transform::parse_prefixed(context, input)?, - }) - } - diff --git a/components/style/values/computed/transform.rs b/components/style/values/computed/transform.rs index bcf90f3966c..a320224d4e0 100644 --- a/components/style/values/computed/transform.rs +++ b/components/style/values/computed/transform.rs @@ -6,10 +6,9 @@ use euclid::{Transform3D, Vector3D}; use num_traits::Zero; -use super::{CSSFloat, Either}; +use super::CSSFloat; use values::animated::ToAnimatedZero; use values::computed::{Angle, Integer, Length, LengthOrPercentage, Number, Percentage}; -use values::computed::{LengthOrNumber, LengthOrPercentageOrNumber}; use values::generics::transform::{self, Matrix as GenericMatrix, Matrix3D as GenericMatrix3D}; use values::generics::transform::{Transform as GenericTransform, TransformOperation as GenericTransformOperation}; use values::generics::transform::Rotate as GenericRotate; @@ -26,9 +25,7 @@ pub type TransformOperation = GenericTransformOperation< Number, Length, Integer, - LengthOrNumber, LengthOrPercentage, - LengthOrPercentageOrNumber, >; /// A computed CSS `transform` pub type Transform = GenericTransform; @@ -56,12 +53,8 @@ impl TransformOrigin { /// computed value of matrix3d() pub type Matrix3D = GenericMatrix3D; -/// computed value of matrix3d() in -moz-transform -pub type PrefixedMatrix3D = GenericMatrix3D; /// computed value of matrix() pub type Matrix = GenericMatrix; -/// computed value of matrix() in -moz-transform -pub type PrefixedMatrix = GenericMatrix; // we rustfmt_skip here because we want the matrices to look like // matrices instead of being split across lines @@ -95,21 +88,6 @@ impl Matrix3D { } } -#[cfg_attr(rustfmt, rustfmt_skip)] -impl PrefixedMatrix3D { - #[inline] - /// Get an identity matrix - pub fn identity() -> Self { - Self { - m11: 1.0, m12: 0.0, m13: 0.0, m14: 0.0, - m21: 0.0, m22: 1.0, m23: 0.0, m24: 0.0, - m31: 0.0, m32: 0.0, m33: 1.0, m34: 0.0, - m41: Either::First(0.), m42: Either::First(0.), - m43: Either::First(Length::new(0.)), m44: 1.0 - } - } -} - #[cfg_attr(rustfmt, rustfmt_skip)] impl Matrix { #[inline] @@ -136,20 +114,6 @@ impl From for Matrix3D { } } -#[cfg_attr(rustfmt, rustfmt_skip)] -impl PrefixedMatrix { - #[inline] - /// Get an identity matrix - pub fn identity() -> Self { - Self { - a: 1., c: 0., /* 0 0 */ - b: 0., d: 1., /* 0 0 */ - /* 0 0 1 0 */ - e: Either::First(0.), f: Either::First(0.), /* 0 1 */ - } - } -} - #[cfg_attr(rustfmt, rustfmt_skip)] impl From> for Matrix3D { #[inline] @@ -213,17 +177,7 @@ impl ToAnimatedZero for TransformOperation { fn to_animated_zero(&self) -> Result { match *self { GenericTransformOperation::Matrix3D(..) => Ok(GenericTransformOperation::Matrix3D(Matrix3D::identity())), - GenericTransformOperation::PrefixedMatrix3D(..) => { - Ok(GenericTransformOperation::PrefixedMatrix3D( - PrefixedMatrix3D::identity(), - )) - }, GenericTransformOperation::Matrix(..) => Ok(GenericTransformOperation::Matrix(Matrix::identity())), - GenericTransformOperation::PrefixedMatrix(..) => { - Ok(GenericTransformOperation::PrefixedMatrix( - PrefixedMatrix::identity(), - )) - }, GenericTransformOperation::Skew(sx, sy) => { Ok(GenericTransformOperation::Skew( sx.to_animated_zero()?, diff --git a/components/style/values/generics/transform.rs b/components/style/values/generics/transform.rs index caa71d15102..504198ab89c 100644 --- a/components/style/values/generics/transform.rs +++ b/components/style/values/generics/transform.rs @@ -19,24 +19,24 @@ use values::specified::length::LengthOrPercentage as SpecifiedLengthOrPercentage #[allow(missing_docs)] #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] #[css(comma, function)] -pub struct Matrix { +pub struct Matrix { pub a: T, pub b: T, pub c: T, pub d: T, - pub e: U, - pub f: U, + pub e: T, + pub f: T, } #[allow(missing_docs)] #[cfg_attr(rustfmt, rustfmt_skip)] #[css(comma, function = "matrix3d")] #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] -pub struct Matrix3D { +pub struct Matrix3D { pub m11: T, pub m12: T, pub m13: T, pub m14: T, pub m21: T, pub m22: T, pub m23: T, pub m24: T, pub m31: T, pub m32: T, pub m33: T, pub m34: T, - pub m41: U, pub m42: U, pub m43: V, pub m44: T, + pub m41: T, pub m42: T, pub m43: T, pub m44: T, } #[cfg_attr(rustfmt, rustfmt_skip)] @@ -200,17 +200,11 @@ impl TimingKeyword { #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] /// A single operation in the list of a `transform` value -pub enum TransformOperation { +pub enum TransformOperation { /// Represents a 2D 2x3 matrix. Matrix(Matrix), - /// Represents a 3D 4x4 matrix with percentage and length values. - /// For `moz-transform`. - PrefixedMatrix(Matrix), /// Represents a 3D 4x4 matrix. Matrix3D(Matrix3D), - /// Represents a 3D 4x4 matrix with percentage and length values. - /// For `moz-transform`. - PrefixedMatrix3D(Matrix3D), /// A 2D skew. /// /// If the second angle is not provided it is assumed zero. @@ -300,9 +294,7 @@ pub enum TransformOperation, >, #[compute(ignore_bound)] @@ -313,9 +305,7 @@ pub enum TransformOperation, >, #[compute(clone)] @@ -333,9 +323,7 @@ pub enum TransformOperation, >, #[compute(ignore_bound)] @@ -346,9 +334,7 @@ pub enum TransformOperation, >, count: Integer, @@ -360,8 +346,8 @@ pub enum TransformOperation(pub Vec); -impl - TransformOperation { +impl + TransformOperation { /// Check if it is any translate function pub fn is_translate(&self) -> bool { use self::TransformOperation::*; @@ -450,8 +436,8 @@ pub trait ToMatrix { fn to_3d_matrix(&self, reference_box: Option<&Rect>) -> Result, ()>; } -impl ToMatrix - for TransformOperation +impl ToMatrix + for TransformOperation where Angle: Copy + AsRef, Number: Copy + Into + Into, @@ -464,8 +450,7 @@ where match *self { Translate3D(..) | TranslateZ(..) | Rotate3D(..) | RotateX(..) | RotateY(..) | RotateZ(..) | - Scale3D(..) | ScaleZ(..) | - Perspective(..) | Matrix3D(..) | PrefixedMatrix3D(..) => true, + Scale3D(..) | ScaleZ(..) | Perspective(..) | Matrix3D(..) => true, _ => false, } } @@ -553,10 +538,6 @@ where }, Matrix3D(m) => m.into(), Matrix(m) => m.into(), - PrefixedMatrix3D(_) | PrefixedMatrix(_) => { - unreachable!("-moz-transform` is not implemented in Servo yet, and DOMMatrix \ - doesn't support this") - }, InterpolateMatrix { .. } | AccumulateMatrix { .. } => { // TODO: Convert InterpolateMatrix/AccumulateMatrix into a valid Transform3D by // the reference box and do interpolation on these two Transform3D matrices. diff --git a/components/style/values/specified/transform.rs b/components/style/values/specified/transform.rs index e2965cfefc5..e13e3f231ef 100644 --- a/components/style/values/specified/transform.rs +++ b/components/style/values/specified/transform.rs @@ -18,8 +18,7 @@ use values::generics::transform::Rotate as GenericRotate; use values::generics::transform::Scale as GenericScale; use values::generics::transform::TransformOperation as GenericTransformOperation; use values::generics::transform::Translate as GenericTranslate; -use values::specified::{self, Angle, Number, Length, Integer}; -use values::specified::{LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrNumber}; +use values::specified::{self, Angle, Number, Length, Integer, LengthOrPercentage}; use values::specified::position::{Side, X, Y}; pub use values::generics::transform::TransformStyle; @@ -30,9 +29,7 @@ pub type TransformOperation = GenericTransformOperation< Number, Length, Integer, - LengthOrNumber, LengthOrPercentage, - LengthOrPercentageOrNumber, >; /// A specified CSS `transform` @@ -49,7 +46,6 @@ impl Transform { fn parse_internal<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, - prefixed: bool, ) -> Result> { use style_traits::{Separator, Space}; @@ -75,19 +71,11 @@ impl Transform { input.expect_comma()?; let d = Number::parse(context, input)?; input.expect_comma()?; - if !prefixed { - // Standard matrix parsing. - let e = Number::parse(context, input)?; - input.expect_comma()?; - let f = Number::parse(context, input)?; - Ok(GenericTransformOperation::Matrix(Matrix { a, b, c, d, e, f })) - } else { - // Non-standard prefixed matrix parsing for -moz-transform. - let e = LengthOrPercentageOrNumber::parse(context, input)?; - input.expect_comma()?; - let f = LengthOrPercentageOrNumber::parse(context, input)?; - Ok(GenericTransformOperation::PrefixedMatrix(Matrix { a, b, c, d, e, f })) - } + // Standard matrix parsing. + let e = Number::parse(context, input)?; + input.expect_comma()?; + let f = Number::parse(context, input)?; + Ok(GenericTransformOperation::Matrix(Matrix { a, b, c, d, e, f })) }, "matrix3d" => { let m11 = Number::parse(context, input)?; @@ -114,37 +102,20 @@ impl Transform { input.expect_comma()?; let m34 = Number::parse(context, input)?; input.expect_comma()?; - if !prefixed { - // Standard matrix3d parsing. - let m41 = Number::parse(context, input)?; - input.expect_comma()?; - let m42 = Number::parse(context, input)?; - input.expect_comma()?; - let m43 = Number::parse(context, input)?; - input.expect_comma()?; - let m44 = Number::parse(context, input)?; - Ok(GenericTransformOperation::Matrix3D(Matrix3D { - m11, m12, m13, m14, - m21, m22, m23, m24, - m31, m32, m33, m34, - m41, m42, m43, m44, - })) - } else { - // Non-standard prefixed matrix parsing for -moz-transform. - let m41 = LengthOrPercentageOrNumber::parse(context, input)?; - input.expect_comma()?; - let m42 = LengthOrPercentageOrNumber::parse(context, input)?; - input.expect_comma()?; - let m43 = LengthOrNumber::parse(context, input)?; - input.expect_comma()?; - let m44 = Number::parse(context, input)?; - Ok(GenericTransformOperation::PrefixedMatrix3D(Matrix3D { - m11, m12, m13, m14, - m21, m22, m23, m24, - m31, m32, m33, m34, - m41, m42, m43, m44, - })) - } + // Standard matrix3d parsing. + let m41 = Number::parse(context, input)?; + input.expect_comma()?; + let m42 = Number::parse(context, input)?; + input.expect_comma()?; + let m43 = Number::parse(context, input)?; + input.expect_comma()?; + let m44 = Number::parse(context, input)?; + Ok(GenericTransformOperation::Matrix3D(Matrix3D { + m11, m12, m13, m14, + m21, m22, m23, m24, + m31, m32, m33, m34, + m41, m42, m43, m44, + })) }, "translate" => { let sx = specified::LengthOrPercentage::parse(context, input)?; @@ -259,16 +230,6 @@ impl Transform { }) })?)) } - - /// Parses `-moz-transform` property. This prefixed property also accepts LengthOrPercentage - /// in the nondiagonal homogeneous components of matrix and matrix3d. - #[inline] - pub fn parse_prefixed<'i, 't>( - context: &ParserContext, - input: &mut Parser<'i, 't>, - ) -> Result> { - Transform::parse_internal(context, input, true) - } } impl Parse for Transform { @@ -276,7 +237,7 @@ impl Parse for Transform { context: &ParserContext, input: &mut Parser<'i, 't> ) -> Result> { - Transform::parse_internal(context, input, false) + Transform::parse_internal(context, input) } }