Skip to content

Commit

Permalink
fix wong parsing of commas
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharktheone committed Sep 19, 2024
1 parent afea121 commit acbc9ad
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/gosub_css3/src/parser/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions crates/gosub_css3/src/stylesheet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions crates/gosub_render_backend/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ pub trait CssProperty: Debug + Sized {
fn as_list(&self) -> Option<Vec<Self::Value>>;

fn is_none(&self) -> bool;

fn is_comma(&self) -> bool;
}

pub trait CssValue: Sized {
Expand All @@ -170,6 +172,8 @@ pub trait CssValue: Sized {
fn as_list(&self) -> Option<Vec<Self>>;

fn is_none(&self) -> bool;

fn is_comma(&self) -> bool;
}

pub trait TextLayout {
Expand Down
12 changes: 8 additions & 4 deletions crates/gosub_styling/src/render_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,6 @@ impl<L: Layouter> RenderTree<L> {
// 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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<CssValue> for Value {
Expand Down

0 comments on commit acbc9ad

Please sign in to comment.