diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index be11ba66edd..ceaa7cd6e6c 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -1567,9 +1567,9 @@ impl FragmentDisplayListBuilding for Fragment { let overflow = base_flow.overflow.paint.translate(&-border_box_offset); let transform = self.transform_matrix(&border_box); - let perspective = match self.style().get_effects().perspective { + let perspective = match self.style().get_box().perspective { Either::First(length) => { - let perspective_origin = self.style().get_effects().perspective_origin; + let perspective_origin = self.style().get_box().perspective_origin; let perspective_origin = Point2D::new(model::specified(perspective_origin.horizontal, border_box.size.width).to_f32_px(), diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index e5d86e78ed5..35ed91cf6eb 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -2370,7 +2370,7 @@ impl Fragment { // TODO(mrobinson): Determine if this is necessary, since blocks with // transformations already create stacking contexts. - if let Either::First(ref _length) = self.style().get_effects().perspective { + if let Either::First(ref _length) = self.style().get_box().perspective { return true } diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index a47b7d590a2..44988f466a5 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -1526,6 +1526,102 @@ ${helpers.single_keyword("resize", products="gecko", animatable=False)} + +// https://drafts.csswg.org/css-transforms/#perspective +${helpers.predefined_type("perspective", + "LengthOrNone", + "Either::Second(None_)", + products="servo", + animatable=True)} + +// FIXME: This prop should be animatable +// https://drafts.csswg.org/css-transforms/#perspective-origin-property +<%helpers:longhand name="perspective-origin" products="servo" animatable="False"> + use std::fmt; + use style_traits::ToCss; + use values::HasViewportPercentage; + use values::specified::{LengthOrPercentage, Percentage}; + + pub mod computed_value { + use values::computed::LengthOrPercentage; + + #[derive(Clone, Copy, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + pub struct T { + pub horizontal: LengthOrPercentage, + pub vertical: LengthOrPercentage, + } + } + + 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(" ")); + self.vertical.to_css(dest) + } + } + + impl HasViewportPercentage for SpecifiedValue { + fn has_viewport_percentage(&self) -> bool { + self.horizontal.has_viewport_percentage() || self.vertical.has_viewport_percentage() + } + } + + #[derive(Clone, Copy, Debug, PartialEq)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + pub struct SpecifiedValue { + horizontal: LengthOrPercentage, + vertical: LengthOrPercentage, + } + + 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(" ")); + self.vertical.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), + } + } + + pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { + let result = try!(super::parse_origin(context, input)); + match result.depth { + Some(_) => Err(()), + None => Ok(SpecifiedValue { + horizontal: result.horizontal.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))), + vertical: result.vertical.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))), + }) + } + } + + 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), + } + } + + #[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), + } + } + } + + // 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 718c447e6c8..a97ea898685 100644 --- a/components/style/properties/longhand/effects.mako.rs +++ b/components/style/properties/longhand/effects.mako.rs @@ -810,99 +810,6 @@ ${helpers.single_keyword("transform-style", } -${helpers.predefined_type("perspective", - "LengthOrNone", - "Either::Second(None_)", - products="servo", - animatable=True)} - -// FIXME: This prop should be animatable -<%helpers:longhand name="perspective-origin" products="servo" animatable="False"> - use std::fmt; - use style_traits::ToCss; - use values::HasViewportPercentage; - use values::specified::{LengthOrPercentage, Percentage}; - - pub mod computed_value { - use values::computed::LengthOrPercentage; - - #[derive(Clone, Copy, Debug, PartialEq)] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - pub struct T { - pub horizontal: LengthOrPercentage, - pub vertical: LengthOrPercentage, - } - } - - 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(" ")); - self.vertical.to_css(dest) - } - } - - impl HasViewportPercentage for SpecifiedValue { - fn has_viewport_percentage(&self) -> bool { - self.horizontal.has_viewport_percentage() || self.vertical.has_viewport_percentage() - } - } - - #[derive(Clone, Copy, Debug, PartialEq)] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - pub struct SpecifiedValue { - horizontal: LengthOrPercentage, - vertical: LengthOrPercentage, - } - - 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(" ")); - self.vertical.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), - } - } - - pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { - let result = try!(super::parse_origin(context, input)); - match result.depth { - Some(_) => Err(()), - None => Ok(SpecifiedValue { - horizontal: result.horizontal.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))), - vertical: result.vertical.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))), - }) - } - } - - 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), - } - } - - #[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), - } - } - } - - ${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 4929208a7b9..4b1169e8f06 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1340,7 +1340,7 @@ impl ComputedValues { if box_.transform.0.is_some() { return transform_style::T::flat; } - if let Either::First(ref _length) = effects.perspective { + if let Either::First(ref _length) = box_.perspective { return transform_style::T::flat; } } diff --git a/components/style/servo/restyle_damage.rs b/components/style/servo/restyle_damage.rs index fb17071321a..09592b68f2c 100644 --- a/components/style/servo/restyle_damage.rs +++ b/components/style/servo/restyle_damage.rs @@ -228,7 +228,7 @@ fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> Servo get_position.right, get_position.bottom, get_effects.opacity, get_box.transform, get_effects.transform_style, get_effects.transform_origin, - get_effects.perspective, get_effects.perspective_origin + get_box.perspective, get_box.perspective_origin ]) || add_if_not_equal!(old, new, damage, [REPAINT], [ get_color.color, get_background.background_color,