From 5fe702fa2be5a2e0ca0008b41fb8ff0967335f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 7 Feb 2021 12:33:45 +0000 Subject: [PATCH] style: Move caption-side outside of mako. Make it an enum class, etc. Differential Revision: https://phabricator.services.mozilla.com/D103978 --- components/style/properties/data.py | 1 + .../longhands/inherited_table.mako.rs | 10 ++--- components/style/values/computed/mod.rs | 1 + components/style/values/computed/table.rs | 7 +++ components/style/values/specified/mod.rs | 1 + components/style/values/specified/table.rs | 45 +++++++++++++++++++ 6 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 components/style/values/computed/table.rs create mode 100644 components/style/values/specified/table.rs diff --git a/components/style/properties/data.py b/components/style/properties/data.py index 77444f971d7..2dccca68790 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -399,6 +399,7 @@ class Longhand(object): "BackgroundRepeat", "BorderImageRepeat", "BorderStyle", + "table::CaptionSide", "Clear", "ColumnCount", "Contain", diff --git a/components/style/properties/longhands/inherited_table.mako.rs b/components/style/properties/longhands/inherited_table.mako.rs index 488fe5d2659..5630d1070ea 100644 --- a/components/style/properties/longhands/inherited_table.mako.rs +++ b/components/style/properties/longhands/inherited_table.mako.rs @@ -26,12 +26,12 @@ ${helpers.single_keyword( servo_restyle_damage="rebuild_and_reflow", )} -${helpers.single_keyword( +${helpers.predefined_type( "caption-side", - "top bottom", + "table::CaptionSide", + "computed::table::CaptionSide::Top", + needs_context=False, engines="gecko servo-2013", - extra_gecko_values="right left top-outside bottom-outside", - needs_conversion="True", animation_value_type="discrete", spec="https://drafts.csswg.org/css-tables/#propdef-caption-side", servo_restyle_damage="rebuild_and_reflow", @@ -46,5 +46,5 @@ ${helpers.predefined_type( animation_value_type="BorderSpacing", boxed=True, spec="https://drafts.csswg.org/css-tables/#propdef-border-spacing", - servo_restyle_damage = "reflow", + servo_restyle_damage="reflow", )} diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index f5266b1cc4b..9ac147c8279 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -125,6 +125,7 @@ pub mod position; pub mod rect; pub mod resolution; pub mod svg; +pub mod table; pub mod text; pub mod time; pub mod transform; diff --git a/components/style/values/computed/table.rs b/components/style/values/computed/table.rs new file mode 100644 index 00000000000..47109e20eca --- /dev/null +++ b/components/style/values/computed/table.rs @@ -0,0 +1,7 @@ +/* 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 CSS values related to tables. + +pub use super::specified::table::CaptionSide; diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 76d383a07ee..f5183993f64 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -129,6 +129,7 @@ pub mod resolution; pub mod source_size_list; pub mod svg; pub mod svg_path; +pub mod table; pub mod text; pub mod time; pub mod transform; diff --git a/components/style/values/specified/table.rs b/components/style/values/specified/table.rs new file mode 100644 index 00000000000..cd2bfa96c5d --- /dev/null +++ b/components/style/values/specified/table.rs @@ -0,0 +1,45 @@ +/* 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/. */ + +//! Specified types for CSS values related to tables. + +/// Specified values for the `caption-side` property. +/// +/// Note that despite having "physical" names, these are actually interpreted +/// according to the table's writing-mode: Top and Bottom are treated as +/// block-start and -end respectively, and Left and Right are treated as +/// line-start and -end. +/// +/// https://drafts.csswg.org/css-tables/#propdef-caption-side +#[allow(missing_docs)] +#[derive( + Clone, + Copy, + Debug, + Eq, + FromPrimitive, + MallocSizeOf, + Ord, + Parse, + PartialEq, + PartialOrd, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, +)] +#[repr(u8)] +pub enum CaptionSide { + Top, + Bottom, + #[cfg(feature = "gecko")] + Right, + #[cfg(feature = "gecko")] + Left, + #[cfg(feature = "gecko")] + TopOutside, + #[cfg(feature = "gecko")] + BottomOutside, +}