mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
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:
parent
0321d1392c
commit
d7ea949d2f
Notes:
github-actions[bot]
2025-01-24 12:57:22 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/d7ea949d2f5 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3348 Reviewed-by: https://github.com/gmta ✅
3 changed files with 4 additions and 4 deletions
|
@ -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 });
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 303 KiB After Width: | Height: | Size: 258 KiB |
|
@ -37,7 +37,7 @@
|
|||
{id: 'canvas-opacity', filter: 'opacity(50%)'},
|
||||
{id: 'canvas-saturate', filter: 'saturate(200%)'},
|
||||
{id: 'canvas-sepia', filter: 'sepia(100%)'},
|
||||
{id: 'canvas-drop-shadow', filter: 'drop-shadow(10px 10px 10px rgba(0, 0, 0, 0.5))'},
|
||||
{id: 'canvas-drop-shadow', filter: 'drop-shadow(2em 10px 10px rgba(0, 0, 0, 0.5))'},
|
||||
];
|
||||
|
||||
const img = new Image();
|
||||
|
|
Loading…
Add table
Reference in a new issue