From 8bf0f82ddcb3b9a10796a0714cda5d2e423593f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 21 May 2019 22:51:54 +0000 Subject: [PATCH] style: Remove old CSS scroll snap implementation. This will save us some time from figuring out what's the best thing to do in bug 1552587, so that other patches I have in flight (mainly bug 1552708) can land, since we cannot add a single byte to nsStyleDisplay right now otherwise. The code removed here is well isolated and not that complicated, so it seems to me that should be easy to bring back should we have an emergency (and I commit to doing that while preserving the nsStyleDisplay size limit if we need to :)). Differential Revision: https://phabricator.services.mozilla.com/D32026 --- components/style/gecko/values.rs | 22 -------- components/style/properties/gecko.mako.rs | 53 +------------------ .../style/properties/longhands/box.mako.rs | 35 ------------ components/style/values/computed/gecko.rs | 11 ---- components/style/values/computed/mod.rs | 4 -- components/style/values/generics/gecko.rs | 44 --------------- components/style/values/generics/mod.rs | 2 - components/style/values/specified/gecko.rs | 21 -------- components/style/values/specified/mod.rs | 2 - 9 files changed, 2 insertions(+), 192 deletions(-) delete mode 100644 components/style/values/computed/gecko.rs delete mode 100644 components/style/values/generics/gecko.rs diff --git a/components/style/gecko/values.rs b/components/style/gecko/values.rs index 8f777b9f782..8df85339265 100644 --- a/components/style/gecko/values.rs +++ b/components/style/gecko/values.rs @@ -12,7 +12,6 @@ use crate::gecko_bindings::structs::{nsStyleCoord, CounterStylePtr}; use crate::gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue}; use crate::values::computed::{Angle, Length, LengthPercentage}; use crate::values::computed::{Number, NumberOrPercentage, Percentage}; -use crate::values::generics::gecko::ScrollSnapPoint; use crate::values::generics::grid::{TrackBreadth, TrackKeyword}; use crate::values::generics::length::LengthPercentageOrAuto; use crate::values::generics::{CounterStyleOrNone, NonNegative}; @@ -217,27 +216,6 @@ impl GeckoStyleCoordConvertible for Angle { } } -impl GeckoStyleCoordConvertible for ScrollSnapPoint { - fn to_gecko_style_coord(&self, coord: &mut T) { - match self.repeated() { - None => coord.set_value(CoordDataValue::None), - Some(l) => l.to_gecko_style_coord(coord), - }; - } - - fn from_gecko_style_coord(coord: &T) -> Option { - use crate::gecko_bindings::structs::root::nsStyleUnit; - - Some(match coord.unit() { - nsStyleUnit::eStyleUnit_None => ScrollSnapPoint::None, - _ => ScrollSnapPoint::Repeat( - LengthPercentage::from_gecko_style_coord(coord) - .expect("coord could not convert to LengthPercentage"), - ), - }) - } -} - /// Convert a given RGBA value to `nscolor`. pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 { ((rgba.alpha as u32) << 24) | diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 41fac1bd57a..980abeafa47 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -696,28 +696,6 @@ def set_gecko_property(ffi_name, expr): } -<%def name="impl_style_coord(ident, gecko_ffi_name)"> - #[allow(non_snake_case)] - pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { - v.to_gecko_style_coord(&mut self.gecko.${gecko_ffi_name}); - } - #[allow(non_snake_case)] - pub fn copy_${ident}_from(&mut self, other: &Self) { - self.gecko.${gecko_ffi_name}.copy_from(&other.gecko.${gecko_ffi_name}); - } - #[allow(non_snake_case)] - pub fn reset_${ident}(&mut self, other: &Self) { - self.copy_${ident}_from(other) - } - - #[allow(non_snake_case)] - pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { - use crate::properties::longhands::${ident}::computed_value::T; - T::from_gecko_style_coord(&self.gecko.${gecko_ffi_name}) - .expect("clone for ${ident} failed") - } - - <%def name="copy_sides_style_coord(ident)"> <% gecko_ffi_name = "m" + to_camel_case(ident) %> #[allow(non_snake_case)] @@ -2184,9 +2162,8 @@ fn static_assert() { animation-iteration-count animation-timing-function clear transition-duration transition-delay transition-timing-function transition-property - transform-style scroll-snap-points-x - scroll-snap-points-y scroll-snap-coordinate - -moz-binding shape-outside -webkit-line-clamp""" %> + transform-style -moz-binding shape-outside + -webkit-line-clamp""" %> <%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}"> #[inline] pub fn set_display(&mut self, v: longhands::display::computed_value::T) { @@ -2226,33 +2203,7 @@ fn static_assert() { gecko_inexhaustive=True, ) %> ${impl_keyword('clear', 'mBreakType', clear_keyword)} - - ${impl_style_coord("scroll_snap_points_x", "mScrollSnapPointsX")} - ${impl_style_coord("scroll_snap_points_y", "mScrollSnapPointsY")} - - pub fn set_scroll_snap_coordinate(&mut self, v: I) - where I: IntoIterator, - I::IntoIter: ExactSizeIterator - { - self.gecko.mScrollSnapCoordinate.assign_from_iter_pod(v.into_iter()); - } - - pub fn copy_scroll_snap_coordinate_from(&mut self, other: &Self) { - let iter = other.gecko.mScrollSnapCoordinate.iter().map(|c| *c); - self.gecko.mScrollSnapCoordinate.assign_from_iter_pod(iter); - } - - pub fn reset_scroll_snap_coordinate(&mut self, other: &Self) { - self.copy_scroll_snap_coordinate_from(other) - } - - pub fn clone_scroll_snap_coordinate(&self) -> longhands::scroll_snap_coordinate::computed_value::T { - let vec = self.gecko.mScrollSnapCoordinate.iter().cloned().collect(); - longhands::scroll_snap_coordinate::computed_value::List(vec) - } - ${impl_css_url('_moz_binding', 'mBinding')} - ${impl_transition_time_value('delay', 'Delay')} ${impl_transition_time_value('duration', 'Duration')} ${impl_transition_timing_function()} diff --git a/components/style/properties/longhands/box.mako.rs b/components/style/properties/longhands/box.mako.rs index bddc56da848..d6c3366c4b7 100644 --- a/components/style/properties/longhands/box.mako.rs +++ b/components/style/properties/longhands/box.mako.rs @@ -309,41 +309,6 @@ ${helpers.predefined_type( allowed_in_keyframe_block=False, )} -% for axis in ["x", "y"]: - ${helpers.predefined_type( - "scroll-snap-points-" + axis, - "ScrollSnapPoint", - "computed::ScrollSnapPoint::none()", - animation_value_type="discrete", - gecko_pref="layout.css.scroll-snap.enabled", - products="gecko", - spec="Nonstandard (https://www.w3.org/TR/2015/WD-css-snappoints-1-20150326/#scroll-snap-points)", - )} -% endfor - -${helpers.predefined_type( - "scroll-snap-destination", - "Position", - "computed::Position::zero()", - products="gecko", - gecko_pref="layout.css.scroll-snap.enabled", - boxed=True, - spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)", - animation_value_type="discrete", -)} - -${helpers.predefined_type( - "scroll-snap-coordinate", - "Position", - "computed::Position::zero()", - vector=True, - allow_empty=True, - products="gecko", - gecko_pref="layout.css.scroll-snap.enabled", - spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)", - animation_value_type="discrete", -)} - <% transform_extra_prefixes = "moz:layout.css.prefixes.transforms webkit" %> ${helpers.predefined_type( diff --git a/components/style/values/computed/gecko.rs b/components/style/values/computed/gecko.rs deleted file mode 100644 index cbe0802eab8..00000000000 --- a/components/style/values/computed/gecko.rs +++ /dev/null @@ -1,11 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -//! Computed types for legacy Gecko-only properties. - -use crate::values::computed::length::LengthPercentage; -use crate::values::generics::gecko::ScrollSnapPoint as GenericScrollSnapPoint; - -/// A computed type for scroll snap points. -pub type ScrollSnapPoint = GenericScrollSnapPoint; diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index aa3963db804..b8e3c0eca17 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -56,8 +56,6 @@ pub use self::font::{FontSize, FontSizeAdjust, FontStretch, FontSynthesis}; pub use self::font::{FontVariantAlternates, FontWeight}; pub use self::font::{FontVariantEastAsian, FontVariationSettings}; pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom}; -#[cfg(feature = "gecko")] -pub use self::gecko::ScrollSnapPoint; pub use self::image::{Gradient, GradientItem, Image, ImageLayer, LineDirection, MozImageRect}; pub use self::length::{CSSPixelLength, ExtremumLength, NonNegativeLength}; pub use self::length::{Length, LengthOrNumber, LengthPercentage, NonNegativeLengthOrNumber}; @@ -106,8 +104,6 @@ pub mod easing; pub mod effects; pub mod flex; pub mod font; -#[cfg(feature = "gecko")] -pub mod gecko; pub mod image; pub mod length; pub mod list; diff --git a/components/style/values/generics/gecko.rs b/components/style/values/generics/gecko.rs deleted file mode 100644 index ccff3d2a76d..00000000000 --- a/components/style/values/generics/gecko.rs +++ /dev/null @@ -1,44 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -//! Generic types for legacy Gecko-only properties that should probably be -//! un-shipped at some point in the future. - -/// A generic value for scroll snap points. -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[derive( - Clone, - Copy, - Debug, - PartialEq, - SpecifiedValueInfo, - ToComputedValue, - ToCss, - ToResolvedValue, - ToShmem, -)] -pub enum ScrollSnapPoint { - /// `none` - None, - /// `repeat()` - #[css(function)] - Repeat(LengthPercentage), -} - -impl ScrollSnapPoint { - /// Returns `none`. - #[inline] - pub fn none() -> Self { - ScrollSnapPoint::None - } - - /// Returns the repeat argument, if any. - #[inline] - pub fn repeated(&self) -> Option<&L> { - match *self { - ScrollSnapPoint::None => None, - ScrollSnapPoint::Repeat(ref length) => Some(length), - } - } -} diff --git a/components/style/values/generics/mod.rs b/components/style/values/generics/mod.rs index d735e3bbdef..08ae15a4c2c 100644 --- a/components/style/values/generics/mod.rs +++ b/components/style/values/generics/mod.rs @@ -26,8 +26,6 @@ pub mod easing; pub mod effects; pub mod flex; pub mod font; -#[cfg(feature = "gecko")] -pub mod gecko; pub mod grid; pub mod image; pub mod length; diff --git a/components/style/values/specified/gecko.rs b/components/style/values/specified/gecko.rs index 42ca5e3e2bf..131c2a1a314 100644 --- a/components/style/values/specified/gecko.rs +++ b/components/style/values/specified/gecko.rs @@ -7,33 +7,12 @@ use crate::parser::{Parse, ParserContext}; use crate::values::computed::length::CSSPixelLength; use crate::values::computed::{self, LengthPercentage}; -use crate::values::generics::gecko::ScrollSnapPoint as GenericScrollSnapPoint; use crate::values::generics::rect::Rect; -use crate::values::specified::length::LengthPercentage as SpecifiedLengthPercentage; use cssparser::{Parser, Token}; use std::fmt; use style_traits::values::SequenceWriter; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; -/// A specified type for scroll snap points. -pub type ScrollSnapPoint = GenericScrollSnapPoint; - -impl Parse for ScrollSnapPoint { - fn parse<'i, 't>( - context: &ParserContext, - input: &mut Parser<'i, 't>, - ) -> Result> { - if input.try(|i| i.expect_ident_matching("none")).is_ok() { - return Ok(GenericScrollSnapPoint::None); - } - input.expect_function_matching("repeat")?; - // FIXME(emilio): This won't clamp properly when animating. - let length = input - .parse_nested_block(|i| SpecifiedLengthPercentage::parse_non_negative(context, i))?; - Ok(GenericScrollSnapPoint::Repeat(length)) - } -} - fn parse_pixel_or_percent<'i, 't>( _context: &ParserContext, input: &mut Parser<'i, 't>, diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 7c59f66e318..4cb7305fab8 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -54,8 +54,6 @@ pub use self::font::{FontSize, FontSizeAdjust, FontStretch, FontSynthesis}; pub use self::font::{FontVariantAlternates, FontWeight}; pub use self::font::{FontVariantEastAsian, FontVariationSettings}; pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom}; -#[cfg(feature = "gecko")] -pub use self::gecko::ScrollSnapPoint; pub use self::image::{ColorStop, EndingShape as GradientEndingShape, Gradient}; pub use self::image::{GradientItem, GradientKind, Image, ImageLayer, MozImageRect}; pub use self::length::{AbsoluteLength, CalcLengthPercentage, CharacterWidth};