mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-23 00:19:18 +00:00
LibWeb/SVG: Resolve fill
URI reference values
This commit is contained in:
parent
8d46a11748
commit
05432d7157
Notes:
github-actions[bot]
2025-08-20 22:35:08 +00:00
Author: https://github.com/tcl3
Commit: 05432d7157
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5932
Reviewed-by: https://github.com/gmta ✅
6 changed files with 43 additions and 7 deletions
|
@ -161,13 +161,19 @@ Optional<Gfx::Color> SVGGraphicsElement::fill_color() const
|
|||
{
|
||||
if (!layout_node())
|
||||
return {};
|
||||
// FIXME: In the working-draft spec, `fill` is intended to be a shorthand, with `fill-color`
|
||||
// being what we actually want to use. But that's not final or widely supported yet.
|
||||
return layout_node()->computed_values().fill().map([&](auto& paint) -> Gfx::Color {
|
||||
if (!paint.is_color())
|
||||
return Color::Black;
|
||||
return paint.as_color();
|
||||
});
|
||||
|
||||
auto paint = layout_node()->computed_values().fill();
|
||||
if (!paint.has_value())
|
||||
return {};
|
||||
|
||||
if (paint->is_url()) {
|
||||
if (auto referenced_element = try_resolve_url_to<SVGGraphicsElement const>(paint->as_url()))
|
||||
return referenced_element->fill_color();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
return paint->as_color();
|
||||
}
|
||||
|
||||
Optional<Gfx::Color> SVGGraphicsElement::stroke_color() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue