LibWeb/HTML: Convert drop-shadow() lengths to pixels

Using the raw value meant that 1em would be incorrectly treated as 1px,
for example.

I've updated our canvas-filters test to demonstrate this - without the
code change this would instead have an x-offset of 2px.
This commit is contained in:
Sam Atkins 2025-01-22 13:06:58 +00:00 committed by Jelle Raaijmakers
parent 0321d1392c
commit d7ea949d2f
Notes: github-actions[bot] 2025-01-24 12:57:22 +00:00
3 changed files with 4 additions and 4 deletions

View file

@ -910,12 +910,12 @@ void CanvasRenderingContext2D::set_filter(String filter)
[&](CSS::FilterOperation::DropShadow const& drop_shadow) {
auto resolution_context = CSS::Length::ResolutionContext::for_layout_node(*layout_node);
float offset_x = static_cast<float>(drop_shadow.offset_x.resolved(resolution_context).raw_value());
float offset_y = static_cast<float>(drop_shadow.offset_y.resolved(resolution_context).raw_value());
float offset_x = static_cast<float>(drop_shadow.offset_x.resolved(resolution_context).to_px(resolution_context));
float offset_y = static_cast<float>(drop_shadow.offset_y.resolved(resolution_context).to_px(resolution_context));
float radius = 0.0f;
if (drop_shadow.radius.has_value()) {
radius = drop_shadow.radius->resolved(resolution_context).raw_value();
radius = static_cast<float>(drop_shadow.radius->resolved(resolution_context).to_px(resolution_context));
};
auto color = drop_shadow.color.value_or(Gfx::Color { 0, 0, 0, 255 });