mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibWeb: Add SVG paint fallback color support to CSS parsing
This commit is contained in:
committed by
Jelle Raaijmakers
parent
f13a26d68e
commit
804287847a
Notes:
github-actions[bot]
2026-02-27 16:16:30 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/804287847ac Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8011 Reviewed-by: https://github.com/gmta ✅
@@ -821,16 +821,24 @@ void NodeWithStyle::apply_style(CSS::ComputedProperties const& computed_style)
|
||||
computed_values.set_x(CSS::LengthPercentage::from_style_value(computed_style.property(CSS::PropertyID::X)));
|
||||
computed_values.set_y(CSS::LengthPercentage::from_style_value(computed_style.property(CSS::PropertyID::Y)));
|
||||
|
||||
auto extract_paint_fallback_color = [&](CSS::URLStyleValue const& url_value) -> Optional<Color> {
|
||||
if (auto const& fallback = url_value.paint_fallback()) {
|
||||
if (fallback->has_color())
|
||||
return fallback->to_color(color_resolution_context);
|
||||
}
|
||||
return {};
|
||||
};
|
||||
|
||||
auto const& fill = computed_style.property(CSS::PropertyID::Fill);
|
||||
if (fill.has_color())
|
||||
computed_values.set_fill(fill.to_color(color_resolution_context).value());
|
||||
else if (fill.is_url())
|
||||
computed_values.set_fill(fill.as_url().url());
|
||||
computed_values.set_fill(CSS::SVGPaint(fill.as_url().url(), extract_paint_fallback_color(fill.as_url())));
|
||||
auto const& stroke = computed_style.property(CSS::PropertyID::Stroke);
|
||||
if (stroke.has_color())
|
||||
computed_values.set_stroke(stroke.to_color(color_resolution_context).value());
|
||||
else if (stroke.is_url())
|
||||
computed_values.set_stroke(stroke.as_url().url());
|
||||
computed_values.set_stroke(CSS::SVGPaint(stroke.as_url().url(), extract_paint_fallback_color(stroke.as_url())));
|
||||
|
||||
computed_values.set_stop_color(computed_style.color_or_fallback(CSS::PropertyID::StopColor, color_resolution_context, CSS::InitialValues::stop_color()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user