style: Implement parsing for baseline-source

Differential Revision: https://phabricator.services.mozilla.com/D173884
This commit is contained in:
David Shin 2023-05-17 12:56:53 +00:00 committed by Martin Robinson
parent 571136562d
commit 7a2b444a60
6 changed files with 64 additions and 10 deletions

View file

@ -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",

View file

@ -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(

View file

@ -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.

View file

@ -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,
};

View file

@ -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,

View file

@ -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,
};