From aeb5d34394d15e14d71d3e28989e8fb3ba9c35be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Fri, 23 Dec 2016 17:10:54 +0300 Subject: [PATCH 1/4] Move perspective and perspective-origin properties from effects to box. --- components/layout/display_list_builder.rs | 4 +- components/layout/fragment.rs | 2 +- .../style/properties/longhand/box.mako.rs | 96 +++++++++++++++++++ .../style/properties/longhand/effects.mako.rs | 93 ------------------ .../style/properties/properties.mako.rs | 2 +- components/style/servo/restyle_damage.rs | 2 +- 6 files changed, 101 insertions(+), 98 deletions(-) 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, From ed7945e7474523009775ba32f3fe11a84684dda8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Fri, 23 Dec 2016 19:29:50 +0300 Subject: [PATCH 2/4] Add gecko glue for perspective and perspective-origin. --- components/style/gecko/values.rs | 16 +++++++++++++++- components/style/properties/gecko.mako.rs | 12 +++++++++++- components/style/properties/longhand/box.mako.rs | 4 ++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/components/style/gecko/values.rs b/components/style/gecko/values.rs index cf5b90c71fc..409c52726fb 100644 --- a/components/style/gecko/values.rs +++ b/components/style/gecko/values.rs @@ -10,7 +10,7 @@ use gecko_bindings::structs::{NS_RADIUS_CLOSEST_SIDE, NS_RADIUS_FARTHEST_SIDE}; use gecko_bindings::structs::nsStyleCoord; use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue}; use std::cmp::max; -use values::{Auto, Either}; +use values::{Auto, Either, None_}; use values::computed::{Angle, LengthOrPercentageOrNone, Number}; use values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto}; use values::computed::basic_shape::ShapeRadius; @@ -201,6 +201,20 @@ impl GeckoStyleCoordConvertible for Auto { } } +impl GeckoStyleCoordConvertible for None_ { + fn to_gecko_style_coord(&self, coord: &mut T) { + coord.set_value(CoordDataValue::None) + } + + fn from_gecko_style_coord(coord: &T) -> Option { + if let CoordDataValue::None = coord.as_value() { + Some(None_) + } else { + None + } + } +} + pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 { (((rgba.alpha * 255.0).round() as u32) << 24) | (((rgba.blue * 255.0).round() as u32) << 16) | diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index d85aa8b63ab..30a26051c9b 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -505,6 +505,7 @@ impl Debug for ${style_struct.gecko_struct_name} { "LengthOrPercentage": impl_style_coord, "LengthOrPercentageOrAuto": impl_style_coord, "LengthOrPercentageOrNone": impl_style_coord, + "LengthOrNone": impl_style_coord, "Number": impl_simple, "Opacity": impl_simple, "CSSColor": impl_color, @@ -1053,7 +1054,7 @@ fn static_assert() { <% skip_box_longhands= """display overflow-y vertical-align -moz-binding page-break-before page-break-after scroll-snap-points-x scroll-snap-points-y transform - scroll-snap-type-y""" %> + scroll-snap-type-y perspective-origin""" %> <%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}"> // We manually-implement the |display| property until we get general @@ -1325,6 +1326,15 @@ fn static_assert() { ${impl_keyword('scroll_snap_type_y', 'mScrollSnapTypeY', scroll_snap_type_keyword, need_clone=False)} + pub fn set_perspective_origin(&mut self, v: longhands::perspective_origin::computed_value::T) { + self.gecko.mPerspectiveOrigin[0].set(v.horizontal); + self.gecko.mPerspectiveOrigin[1].set(v.vertical); + } + + pub fn copy_perspective_origin_from(&mut self, other: &Self) { + self.gecko.mPerspectiveOrigin[0].copy_from(&other.gecko.mPerspectiveOrigin[0]); + self.gecko.mPerspectiveOrigin[1].copy_from(&other.gecko.mPerspectiveOrigin[1]); + } <%def name="simple_image_array_property(name, shorthand, field_name)"> diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 44988f466a5..367352c32f8 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -1531,12 +1531,12 @@ ${helpers.single_keyword("resize", ${helpers.predefined_type("perspective", "LengthOrNone", "Either::Second(None_)", - products="servo", + gecko_ffi_name="mChildPerspective", 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"> +<%helpers:longhand name="perspective-origin" animatable="False"> use std::fmt; use style_traits::ToCss; use values::HasViewportPercentage; From 2e9d4df223b61bcd5b91968bddb08c9a94ff815e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Fri, 23 Dec 2016 19:53:07 +0300 Subject: [PATCH 3/4] Move transform related properties from effects to box. --- components/layout/display_list_builder.rs | 2 +- .../style/properties/longhand/box.mako.rs | 125 ++++++++++++++++++ .../style/properties/longhand/effects.mako.rs | 120 ----------------- .../style/properties/properties.mako.rs | 4 +- components/style/servo/restyle_damage.rs | 2 +- 5 files changed, 129 insertions(+), 124 deletions(-) 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], [ From d5eba1e7dceb4d0492647468299877edc00ab50b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Fri, 23 Dec 2016 21:21:24 +0300 Subject: [PATCH 4/4] Add gecko glue for transform related properties. --- components/style/properties/gecko.mako.rs | 29 +++++++++++++++++-- .../style/properties/longhand/box.mako.rs | 5 ++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 30a26051c9b..bfe0b6040c4 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -475,8 +475,6 @@ impl Debug for ${style_struct.gecko_struct_name} { # Make a list of types we can't auto-generate. # force_stub = []; - # These are currently being shuffled to a different style struct on the gecko side. - force_stub += ["backface-visibility", "transform-box", "transform-style"] # These live in an nsFont member in Gecko. Should be straightforward to do manually. force_stub += ["font-variant"] # These have unusual representations in gecko. @@ -1054,7 +1052,7 @@ fn static_assert() { <% skip_box_longhands= """display overflow-y vertical-align -moz-binding page-break-before page-break-after scroll-snap-points-x scroll-snap-points-y transform - scroll-snap-type-y perspective-origin""" %> + scroll-snap-type-y perspective-origin transform-origin""" %> <%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}"> // We manually-implement the |display| property until we get general @@ -1335,6 +1333,31 @@ fn static_assert() { self.gecko.mPerspectiveOrigin[0].copy_from(&other.gecko.mPerspectiveOrigin[0]); self.gecko.mPerspectiveOrigin[1].copy_from(&other.gecko.mPerspectiveOrigin[1]); } + + pub fn set_transform_origin(&mut self, v: longhands::transform_origin::computed_value::T) { + self.gecko.mTransformOrigin[0].set(v.horizontal); + self.gecko.mTransformOrigin[1].set(v.vertical); + self.gecko.mTransformOrigin[2].set(v.depth); + } + + pub fn copy_transform_origin_from(&mut self, other: &Self) { + self.gecko.mTransformOrigin[0].copy_from(&other.gecko.mTransformOrigin[0]); + self.gecko.mTransformOrigin[1].copy_from(&other.gecko.mTransformOrigin[1]); + self.gecko.mTransformOrigin[2].copy_from(&other.gecko.mTransformOrigin[2]); + } + + pub fn clone_transform_origin(&self) -> longhands::transform_origin::computed_value::T { + use properties::longhands::transform_origin::computed_value::T; + use values::computed::LengthOrPercentage; + T { + horizontal: LengthOrPercentage::from_gecko_style_coord(&self.gecko.mTransformOrigin[0]) + .expect("clone for LengthOrPercentage failed"), + vertical: LengthOrPercentage::from_gecko_style_coord(&self.gecko.mTransformOrigin[1]) + .expect("clone for LengthOrPercentage failed"), + depth: Au::from_gecko_style_coord(&self.gecko.mTransformOrigin[2]) + .expect("clone for Length failed"), + } + } <%def name="simple_image_array_property(name, shorthand, field_name)"> diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index f7eca191c59..988bc40c77f 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -1636,11 +1636,12 @@ ${helpers.single_keyword("transform-box", // `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", + "auto flat preserve-3d" if product == "servo" else + "flat preserve-3d", animatable=False)} // https://drafts.csswg.org/css-transforms/#transform-origin-property -<%helpers:longhand name="transform-origin" products="servo" animatable="True"> +<%helpers:longhand name="transform-origin" animatable="True"> use app_units::Au; use std::fmt; use style_traits::ToCss;