diff options
author | David Shin <dshin@mozilla.com> | 2023-05-17 12:56:53 +0000 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-11-24 08:57:14 +0100 |
commit | 7a2b444a6043bb82f83886b66be85d2255bba44e (patch) | |
tree | 891d2fd29e4b0844dd94f2feb37368b9299c0a30 /components/style | |
parent | 571136562d7bc64a448e3b5da269f438a5d20ed1 (diff) | |
download | servo-7a2b444a6043bb82f83886b66be85d2255bba44e.tar.gz servo-7a2b444a6043bb82f83886b66be85d2255bba44e.zip |
style: Implement parsing for `baseline-source`
Differential Revision: https://phabricator.services.mozilla.com/D173884
Diffstat (limited to 'components/style')
-rw-r--r-- | components/style/properties/data.py | 5 | ||||
-rw-r--r-- | components/style/properties/longhands/box.mako.rs | 10 | ||||
-rw-r--r-- | components/style/values/computed/box.rs | 8 | ||||
-rw-r--r-- | components/style/values/computed/mod.rs | 2 | ||||
-rw-r--r-- | components/style/values/specified/box.rs | 47 | ||||
-rw-r--r-- | components/style/values/specified/mod.rs | 2 |
6 files changed, 64 insertions, 10 deletions
diff --git a/components/style/properties/data.py b/components/style/properties/data.py index 195b773ca8d..03e5b4aa0a6 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -428,6 +428,7 @@ class Longhand(Property): "AlignSelf", "Appearance", "AspectRatio", + "BaselineSource", "BreakBetween", "BreakWithin", "BackgroundRepeat", @@ -785,6 +786,8 @@ class PropertyRestrictions: "-webkit-text-fill-color", "-webkit-text-stroke-color", "vertical-align", + # Will become shorthand of vertical-align (Bug 1830771) + "baseline-source", "line-height", # Kinda like css-backgrounds? "background-blend-mode", @@ -818,6 +821,8 @@ class PropertyRestrictions: "-webkit-text-fill-color", "-webkit-text-stroke-color", "vertical-align", + # Will become shorthand of vertical-align (Bug 1830771) + "baseline-source", "line-height", # Kinda like css-backgrounds? "background-blend-mode", diff --git a/components/style/properties/longhands/box.mako.rs b/components/style/properties/longhands/box.mako.rs index 8f8d88567f9..e09885e80c7 100644 --- a/components/style/properties/longhands/box.mako.rs +++ b/components/style/properties/longhands/box.mako.rs @@ -94,6 +94,16 @@ ${helpers.predefined_type( servo_restyle_damage = "reflow", )} +${helpers.predefined_type( + "baseline-source", + "BaselineSource", + "computed::BaselineSource::Auto", + engines="gecko servo-2013", + animation_value_type="discrete", + spec="https://drafts.csswg.org/css-inline-3/#baseline-source", + servo_restyle_damage = "reflow", +)} + // CSS 2.1, Section 11 - Visual effects ${helpers.single_keyword( diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs index 238bbe8376a..e25cd104894 100644 --- a/components/style/values/computed/box.rs +++ b/components/style/values/computed/box.rs @@ -13,10 +13,10 @@ use crate::values::generics::box_::{ use crate::values::specified::box_ as specified; pub use crate::values::specified::box_::{ - Appearance, BreakBetween, BreakWithin, Clear as SpecifiedClear, Contain, ContainerName, - ContainerType, ContentVisibility, Display, Float as SpecifiedFloat, Overflow, OverflowAnchor, - OverflowClipBox, OverscrollBehavior, ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop, - ScrollSnapStrictness, ScrollSnapType, ScrollbarGutter, TouchAction, WillChange, + Appearance, BaselineSource, BreakBetween, BreakWithin, Clear as SpecifiedClear, Contain, + ContainerName, ContainerType, ContentVisibility, Display, Float as SpecifiedFloat, Overflow, + OverflowAnchor, OverflowClipBox, OverscrollBehavior, ScrollSnapAlign, ScrollSnapAxis, + ScrollSnapStop, ScrollSnapStrictness, ScrollSnapType, ScrollbarGutter, TouchAction, WillChange, }; /// A computed value for the `vertical-align` property. diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 54b33253955..c10ab1160eb 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -57,7 +57,7 @@ pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize, S pub use self::box_::{ ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop, ScrollSnapStrictness, ScrollSnapType, }; -pub use self::box_::{TouchAction, VerticalAlign, WillChange}; +pub use self::box_::{BaselineSource, TouchAction, VerticalAlign, WillChange}; pub use self::color::{ Color, ColorOrAuto, ColorPropertyValue, ColorScheme, ForcedColorAdjust, PrintColorAdjust, }; diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs index a1d18c40b7d..1b932648361 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -8,7 +8,7 @@ use crate::parser::{Parse, ParserContext}; #[cfg(feature = "gecko")] use crate::properties::{LonghandId, PropertyDeclarationId, PropertyId}; use crate::values::generics::box_::{ - GenericLineClamp, GenericPerspective, GenericContainIntrinsicSize, GenericVerticalAlign, + GenericContainIntrinsicSize, GenericLineClamp, GenericPerspective, GenericVerticalAlign, VerticalAlignKeyword, }; use crate::values::specified::length::{LengthPercentage, NonNegativeLength}; @@ -606,6 +606,33 @@ impl Parse for VerticalAlign { } } +/// A specified value for the `baseline-source` property. +/// https://drafts.csswg.org/css-inline-3/#baseline-source +#[derive( + Clone, + Copy, + Debug, + Eq, + Hash, + MallocSizeOf, + Parse, + PartialEq, + SpecifiedValueInfo, + ToCss, + ToShmem, + ToComputedValue, + ToResolvedValue, +)] +#[repr(u8)] +pub enum BaselineSource { + /// `Last` for `inline-block`, `First` otherwise. + Auto, + /// Use first baseline for alignment. + First, + /// Use last baseline for alignment. + Last, +} + /// https://drafts.csswg.org/css-scroll-snap-1/#snap-axis #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] @@ -1176,7 +1203,20 @@ pub enum ContentVisibility { Visible, } -#[derive(Clone, Copy, Debug, PartialEq, Eq, MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToCss, Parse, ToResolvedValue, ToShmem)] +#[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + MallocSizeOf, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + Parse, + ToResolvedValue, + ToShmem, +)] #[repr(u8)] #[allow(missing_docs)] /// https://drafts.csswg.org/css-contain-3/#container-type @@ -1237,8 +1277,7 @@ impl ContainerName { if !for_query && first.eq_ignore_ascii_case("none") { return Ok(Self::none()); } - const DISALLOWED_CONTAINER_NAMES: &'static [&'static str] = - &["none", "not", "or", "and"]; + const DISALLOWED_CONTAINER_NAMES: &'static [&'static str] = &["none", "not", "or", "and"]; idents.push(CustomIdent::from_ident( location, first, diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index ecba583ad17..e42efdbf912 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -44,7 +44,7 @@ pub use self::box_::{Contain, Display}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize, ScrollbarGutter}; pub use self::box_::{ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop}; pub use self::box_::{ScrollSnapStrictness, ScrollSnapType}; -pub use self::box_::{TouchAction, VerticalAlign, WillChange}; +pub use self::box_::{BaselineSource, TouchAction, VerticalAlign, WillChange}; pub use self::color::{ Color, ColorOrAuto, ColorPropertyValue, ColorScheme, ForcedColorAdjust, PrintColorAdjust, }; |