diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index ceaa7cd6e6c..db632be4dd2 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -1822,7 +1822,7 @@ impl FragmentDisplayListBuilding for Fragment { Some(ref operations) => operations, }; - let transform_origin = &self.style.get_effects().transform_origin; + let transform_origin = &self.style.get_box().transform_origin; let transform_origin_x = model::specified(transform_origin.horizontal, stacking_relative_border_box.size .width).to_f32_px(); diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 367352c32f8..f7eca191c59 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -1622,6 +1622,131 @@ ${helpers.predefined_type("perspective", } +// https://drafts.csswg.org/css-transforms/#backface-visibility-property +${helpers.single_keyword("backface-visibility", + "visible hidden", + animatable=False)} + +// https://drafts.csswg.org/css-transforms/#transform-box +${helpers.single_keyword("transform-box", + "border-box fill-box view-box", + products="gecko", + animatable=False)} + +// `auto` keyword is not supported in gecko yet. +// https://drafts.csswg.org/css-transforms/#transform-style-property +${helpers.single_keyword("transform-style", + "auto flat preserve-3d", + animatable=False)} + +// https://drafts.csswg.org/css-transforms/#transform-origin-property +<%helpers:longhand name="transform-origin" products="servo" animatable="True"> + use app_units::Au; + use std::fmt; + use style_traits::ToCss; + use values::HasViewportPercentage; + use values::specified::{Length, LengthOrPercentage, Percentage}; + + pub mod computed_value { + use properties::animated_properties::Interpolate; + use values::computed::{Length, LengthOrPercentage}; + + #[derive(Clone, Copy, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + pub struct T { + pub horizontal: LengthOrPercentage, + pub vertical: LengthOrPercentage, + pub depth: Length, + } + + impl Interpolate for T { + fn interpolate(&self, other: &Self, time: f64) -> Result { + Ok(T { + horizontal: try!(self.horizontal.interpolate(&other.horizontal, time)), + vertical: try!(self.vertical.interpolate(&other.vertical, time)), + depth: try!(self.depth.interpolate(&other.depth, time)), + }) + } + } + } + + impl HasViewportPercentage for SpecifiedValue { + fn has_viewport_percentage(&self) -> bool { + self.horizontal.has_viewport_percentage() || + self.vertical.has_viewport_percentage() || + self.depth.has_viewport_percentage() + } + } + + #[derive(Clone, Copy, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + pub struct SpecifiedValue { + horizontal: LengthOrPercentage, + vertical: LengthOrPercentage, + depth: Length, + } + + impl ToCss for computed_value::T { + fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + try!(self.horizontal.to_css(dest)); + try!(dest.write_str(" ")); + try!(self.vertical.to_css(dest)); + try!(dest.write_str(" ")); + self.depth.to_css(dest) + } + } + + impl ToCss for SpecifiedValue { + fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + try!(self.horizontal.to_css(dest)); + try!(dest.write_str(" ")); + try!(self.vertical.to_css(dest)); + try!(dest.write_str(" ")); + self.depth.to_css(dest) + } + } + + #[inline] + pub fn get_initial_value() -> computed_value::T { + computed_value::T { + horizontal: computed::LengthOrPercentage::Percentage(0.5), + vertical: computed::LengthOrPercentage::Percentage(0.5), + depth: Au(0), + } + } + + pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { + let result = try!(super::parse_origin(context, input)); + Ok(SpecifiedValue { + horizontal: result.horizontal.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))), + vertical: result.vertical.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))), + depth: result.depth.unwrap_or(Length::Absolute(Au(0))), + }) + } + + impl ToComputedValue for SpecifiedValue { + type ComputedValue = computed_value::T; + + #[inline] + fn to_computed_value(&self, context: &Context) -> computed_value::T { + computed_value::T { + horizontal: self.horizontal.to_computed_value(context), + vertical: self.vertical.to_computed_value(context), + depth: self.depth.to_computed_value(context), + } + } + + #[inline] + fn from_computed_value(computed: &computed_value::T) -> Self { + SpecifiedValue { + horizontal: ToComputedValue::from_computed_value(&computed.horizontal), + vertical: ToComputedValue::from_computed_value(&computed.vertical), + depth: ToComputedValue::from_computed_value(&computed.depth), + } + } + } + + // Non-standard ${helpers.single_keyword("-moz-appearance", """none button button-arrow-down button-arrow-next button-arrow-previous button-arrow-up diff --git a/components/style/properties/longhand/effects.mako.rs b/components/style/properties/longhand/effects.mako.rs index a97ea898685..eff56c05a60 100644 --- a/components/style/properties/longhand/effects.mako.rs +++ b/components/style/properties/longhand/effects.mako.rs @@ -690,126 +690,6 @@ pub fn parse_origin(context: &ParserContext, input: &mut Parser) -> Result - use app_units::Au; - use std::fmt; - use style_traits::ToCss; - use values::HasViewportPercentage; - use values::specified::{Length, LengthOrPercentage, Percentage}; - - pub mod computed_value { - use properties::animated_properties::Interpolate; - use values::computed::{Length, LengthOrPercentage}; - - #[derive(Clone, Copy, Debug, PartialEq)] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - pub struct T { - pub horizontal: LengthOrPercentage, - pub vertical: LengthOrPercentage, - pub depth: Length, - } - - impl Interpolate for T { - fn interpolate(&self, other: &Self, time: f64) -> Result { - Ok(T { - horizontal: try!(self.horizontal.interpolate(&other.horizontal, time)), - vertical: try!(self.vertical.interpolate(&other.vertical, time)), - depth: try!(self.depth.interpolate(&other.depth, time)), - }) - } - } - } - - impl HasViewportPercentage for SpecifiedValue { - fn has_viewport_percentage(&self) -> bool { - self.horizontal.has_viewport_percentage() || - self.vertical.has_viewport_percentage() || - self.depth.has_viewport_percentage() - } - } - - #[derive(Clone, Copy, Debug, PartialEq)] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - pub struct SpecifiedValue { - horizontal: LengthOrPercentage, - vertical: LengthOrPercentage, - depth: Length, - } - - impl ToCss for computed_value::T { - fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - try!(self.horizontal.to_css(dest)); - try!(dest.write_str(" ")); - try!(self.vertical.to_css(dest)); - try!(dest.write_str(" ")); - self.depth.to_css(dest) - } - } - - impl ToCss for SpecifiedValue { - fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - try!(self.horizontal.to_css(dest)); - try!(dest.write_str(" ")); - try!(self.vertical.to_css(dest)); - try!(dest.write_str(" ")); - self.depth.to_css(dest) - } - } - - #[inline] - pub fn get_initial_value() -> computed_value::T { - computed_value::T { - horizontal: computed::LengthOrPercentage::Percentage(0.5), - vertical: computed::LengthOrPercentage::Percentage(0.5), - depth: Au(0), - } - } - - pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { - let result = try!(super::parse_origin(context, input)); - Ok(SpecifiedValue { - horizontal: result.horizontal.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))), - vertical: result.vertical.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))), - depth: result.depth.unwrap_or(Length::Absolute(Au(0))), - }) - } - - impl ToComputedValue for SpecifiedValue { - type ComputedValue = computed_value::T; - - #[inline] - fn to_computed_value(&self, context: &Context) -> computed_value::T { - computed_value::T { - horizontal: self.horizontal.to_computed_value(context), - vertical: self.vertical.to_computed_value(context), - depth: self.depth.to_computed_value(context), - } - } - - #[inline] - fn from_computed_value(computed: &computed_value::T) -> Self { - SpecifiedValue { - horizontal: ToComputedValue::from_computed_value(&computed.horizontal), - vertical: ToComputedValue::from_computed_value(&computed.vertical), - depth: ToComputedValue::from_computed_value(&computed.depth), - } - } - } - - ${helpers.single_keyword("mix-blend-mode", """normal multiply screen overlay darken lighten color-dodge color-burn hard-light soft-light difference exclusion hue diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 4b1169e8f06..7adbb9697a5 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1336,7 +1336,7 @@ impl ComputedValues { return transform_style::T::flat; } - if effects.transform_style == transform_style::T::auto { + if box_.transform_style == transform_style::T::auto { if box_.transform.0.is_some() { return transform_style::T::flat; } @@ -1346,7 +1346,7 @@ impl ComputedValues { } // Return the computed value if not overridden by the above exceptions - effects.transform_style + box_.transform_style } pub fn transform_requires_layer(&self) -> bool { diff --git a/components/style/servo/restyle_damage.rs b/components/style/servo/restyle_damage.rs index 09592b68f2c..e56bcd5a27c 100644 --- a/components/style/servo/restyle_damage.rs +++ b/components/style/servo/restyle_damage.rs @@ -227,7 +227,7 @@ fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> Servo get_position.top, get_position.left, get_position.right, get_position.bottom, get_effects.opacity, - get_box.transform, get_effects.transform_style, get_effects.transform_origin, + get_box.transform, get_box.transform_style, get_box.transform_origin, get_box.perspective, get_box.perspective_origin ]) || add_if_not_equal!(old, new, damage, [REPAINT], [