mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 07:09:47 +00:00
LibWeb/CSS: Interpret NaN as 0 when resolving alpha and rgb values
Fixes the crash in css/css-color/parsing/color-valid-hwb.html.
The crash was probably introduced in 248e4bb5
, as it was the first
commit to VERIFY that the value given to `Color::with_opacity` were in
the correct range. As the values in color-valid-hwb.html were resolved
as NaN, the check never passed.
This commit is contained in:
parent
edf29857f8
commit
6804ce348e
Notes:
github-actions[bot]
2024-12-04 16:12:33 +00:00
Author: https://github.com/LucasChollet
Commit: 6804ce348e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2724
Reviewed-by: https://github.com/AtkinsSJ ✅
4 changed files with 121 additions and 0 deletions
|
@ -18,6 +18,8 @@ Color CSSRGB::to_color(Optional<Layout::NodeWithStyle const&>) const
|
|||
auto resolve_rgb_to_u8 = [](CSSStyleValue const& style_value) -> Optional<u8> {
|
||||
// <number> | <percentage> | none
|
||||
auto normalized = [](double number) {
|
||||
if (isnan(number))
|
||||
number = 0;
|
||||
return llround(clamp(number, 0.0, 255.0));
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue