LibWeb: Add mode flag to CSSStyleValue::to_string()

This will be used to differentiate between serialization for resolved
style (i.e window.getComputedStyle()) and serialization for all other
purposes.
This commit is contained in:
Andreas Kling 2024-12-07 00:59:49 +01:00 committed by Sam Atkins
commit e85c3c97fb
Notes: github-actions[bot] 2024-12-07 08:32:08 +00:00
112 changed files with 217 additions and 208 deletions

View file

@ -33,7 +33,11 @@ public:
auto font_weight = font_style_value.longhand(CSS::PropertyID::FontWeight);
auto font_size = font_style_value.longhand(CSS::PropertyID::FontSize);
auto font_family = font_style_value.longhand(CSS::PropertyID::FontFamily);
return ByteString::formatted("{} {} {} {}", font_style->to_string(), font_weight->to_string(), font_size->to_string(), font_family->to_string());
return ByteString::formatted("{} {} {} {}",
font_style->to_string(CSS::CSSStyleValue::SerializationMode::Normal),
font_weight->to_string(CSS::CSSStyleValue::SerializationMode::Normal),
font_size->to_string(CSS::CSSStyleValue::SerializationMode::Normal),
font_family->to_string(CSS::CSSStyleValue::SerializationMode::Normal));
}
void set_font(StringView font)

View file

@ -1142,7 +1142,7 @@ void HTMLInputElement::computed_css_values_changed()
auto const& accent_color_property = computed_css_values()->property(CSS::PropertyID::AccentColor);
if (accent_color_property.has_color())
accent_color = accent_color_property.to_string();
accent_color = accent_color_property.to_string(CSS::CSSStyleValue::SerializationMode::Normal);
if (m_slider_progress_element)
MUST(m_slider_progress_element->style_for_bindings()->set_property(CSS::PropertyID::BackgroundColor, accent_color));

View file

@ -137,7 +137,7 @@ void HTMLProgressElement::computed_css_values_changed()
auto const& accent_color_property = computed_css_values()->property(CSS::PropertyID::AccentColor);
if (accent_color_property.has_color())
accent_color = accent_color_property.to_string();
accent_color = accent_color_property.to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal);
if (m_progress_value_element)
MUST(m_progress_value_element->style_for_bindings()->set_property(CSS::PropertyID::BackgroundColor, accent_color));