From acbc9add0f1100e8c8a5f85fcf69116eb181b374 Mon Sep 17 00:00:00 2001 From: Shark Date: Wed, 18 Sep 2024 22:22:50 +0200 Subject: [PATCH] fix wong parsing of commas --- crates/gosub_css3/src/parser/value.rs | 2 +- crates/gosub_css3/src/stylesheet.rs | 3 +++ crates/gosub_render_backend/src/layout.rs | 4 ++++ crates/gosub_styling/src/render_tree.rs | 12 ++++++++---- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/crates/gosub_css3/src/parser/value.rs b/crates/gosub_css3/src/parser/value.rs index d7697b3c0..7bf4a000c 100644 --- a/crates/gosub_css3/src/parser/value.rs +++ b/crates/gosub_css3/src/parser/value.rs @@ -48,7 +48,7 @@ impl Css3<'_> { Ok(Some(node)) } TokenType::Comma => { - let node = Node::new(NodeType::Operator(",".into()), t.location); + let node = Node::new(NodeType::Comma, t.location); Ok(Some(node)) } TokenType::LBracket => Err(Error::new( diff --git a/crates/gosub_css3/src/stylesheet.rs b/crates/gosub_css3/src/stylesheet.rs index 7dfa5d494..dcdfdfca9 100644 --- a/crates/gosub_css3/src/stylesheet.rs +++ b/crates/gosub_css3/src/stylesheet.rs @@ -390,6 +390,9 @@ impl CssValue { } Ok(CssValue::Function(name, list)) } + + crate::node::NodeType::Comma => Ok(CssValue::Comma), + _ => Err(anyhow!(format!( "Cannot convert node to CssValue: {:?}", node diff --git a/crates/gosub_render_backend/src/layout.rs b/crates/gosub_render_backend/src/layout.rs index 974de083f..6f5b27316 100644 --- a/crates/gosub_render_backend/src/layout.rs +++ b/crates/gosub_render_backend/src/layout.rs @@ -157,6 +157,8 @@ pub trait CssProperty: Debug + Sized { fn as_list(&self) -> Option>; fn is_none(&self) -> bool; + + fn is_comma(&self) -> bool; } pub trait CssValue: Sized { @@ -170,6 +172,8 @@ pub trait CssValue: Sized { fn as_list(&self) -> Option>; fn is_none(&self) -> bool; + + fn is_comma(&self) -> bool; } pub trait TextLayout { diff --git a/crates/gosub_styling/src/render_tree.rs b/crates/gosub_styling/src/render_tree.rs index d54d1a22b..257ec3a86 100644 --- a/crates/gosub_styling/src/render_tree.rs +++ b/crates/gosub_styling/src/render_tree.rs @@ -324,10 +324,6 @@ impl RenderTree { // create property for the given values let property_name = declaration.property.clone(); - if &property_name == "font-variation-settings" { - println!("Font variation settings: {:?}", &value); - } - // Check if the declaration matches the definition and return the "expanded" order let res = definition.matches_and_shorthands(match_value, &mut fix_list); if !res { @@ -882,6 +878,10 @@ impl gosub_render_backend::layout::CssProperty for CssProperty { fn is_none(&self) -> bool { matches!(self.actual, CssValue::None) } + + fn is_comma(&self) -> bool { + matches!(self.actual, CssValue::Comma) + } } impl gosub_render_backend::layout::CssValue for Value { @@ -940,6 +940,10 @@ impl gosub_render_backend::layout::CssValue for Value { fn is_none(&self) -> bool { matches!(self.0, CssValue::None) } + + fn is_comma(&self) -> bool { + matches!(self.0, CssValue::Comma) + } } impl From for Value {