From cec761e60423a960aed94de57dcc92c1a0c42614 Mon Sep 17 00:00:00 2001 From: Alaska Date: Thu, 23 Nov 2023 15:02:08 +0100 Subject: [PATCH] web/core: Parse "justify-self" property --- crates/web/core/identifiers.json | 6 +++ crates/web/core/properties.json | 7 +++ crates/web/core/src/css/values/alignment.rs | 47 +++++++++++++++++++++ crates/web/core/src/css/values/mod.rs | 2 + 4 files changed, 62 insertions(+) create mode 100644 crates/web/core/src/css/values/alignment.rs diff --git a/crates/web/core/identifiers.json b/crates/web/core/identifiers.json index 0e9f7292..56f5f657 100644 --- a/crates/web/core/identifiers.json +++ b/crates/web/core/identifiers.json @@ -18,6 +18,7 @@ "b", "background-color", "base", + "baseline", "basefont", "before", "beige", @@ -129,6 +130,7 @@ "figcaption", "figure", "firebrick", + "first", "first-letter", "first-line", "fixed", @@ -193,10 +195,12 @@ "inset", "is", "ivory", + "justify-self", "keygen", "khaki", "large", "larger", + "last", "lavender", "lavenderblush", "lawngreen", @@ -271,6 +275,7 @@ "noembed", "noframes", "none", + "normal", "noscript", "object", "ol", @@ -354,6 +359,7 @@ "static", "steelblue", "sticky", + "stretch", "strike", "strong", "style", diff --git a/crates/web/core/properties.json b/crates/web/core/properties.json index 151de5b3..2627fc34 100644 --- a/crates/web/core/properties.json +++ b/crates/web/core/properties.json @@ -98,6 +98,13 @@ "value": "AutoOr>", "initial": "AutoOr::Auto" }, + { + "name": "justify-self", + "specification": "https://drafts.csswg.org/css-align-3/#propdef-justify-self", + "inherited": false, + "value": "AutoOr", + "initial": "AutoOr::Auto" + }, { "name": "left", "specification": "https://drafts.csswg.org/css-position/#propdef-left", diff --git a/crates/web/core/src/css/values/alignment.rs b/crates/web/core/src/css/values/alignment.rs new file mode 100644 index 00000000..5bad9f94 --- /dev/null +++ b/crates/web/core/src/css/values/alignment.rs @@ -0,0 +1,47 @@ +use crate::{ + css::{self, CSSParse}, + static_interned, +}; + +/// +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum JustifySelf { + /// + Normal, + + /// + Stretch, + + /// + FirstBaseline, + + /// + LastBaseline, + // FIXME: There are more values here +} + +impl<'a> CSSParse<'a> for JustifySelf { + fn parse(parser: &mut css::Parser<'a>) -> Result { + let justify_self = match parser.expect_identifier()? { + static_interned!("normal") => Self::Normal, + static_interned!("stretch") => Self::Stretch, + static_interned!("first") => { + parser.skip_whitespace(); + let static_interned!("baseline") = parser.expect_identifier()? else { + return Err(css::ParseError); + }; + Self::FirstBaseline + }, + static_interned!("last") => { + parser.skip_whitespace(); + let static_interned!("baseline") = parser.expect_identifier()? else { + return Err(css::ParseError); + }; + Self::LastBaseline + }, + _ => return Err(css::ParseError), + }; + + Ok(justify_self) + } +} diff --git a/crates/web/core/src/css/values/mod.rs b/crates/web/core/src/css/values/mod.rs index e765818b..9c3367a6 100644 --- a/crates/web/core/src/css/values/mod.rs +++ b/crates/web/core/src/css/values/mod.rs @@ -1,3 +1,4 @@ +mod alignment; mod auto; mod background_color; mod border; @@ -11,6 +12,7 @@ mod number; mod percentage; mod position; +pub use alignment::JustifySelf; pub use auto::AutoOr; pub use background_color::BackgroundColor; pub use border::{Border, LineStyle, LineWidth};