mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:27:35 +00:00
LibGfx: Make parse_rgba_color use the new double parser
Since this is used by LibWeb when parsing CSS colors we should not use strtod here.
This commit is contained in:
parent
62fc3e50f3
commit
051134a21e
1 changed files with 7 additions and 1 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/FloatingPointStringConversions.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -63,7 +64,12 @@ static Optional<Color> parse_rgba_color(StringView string)
|
|||
auto g = parts[1].to_int().value_or(256);
|
||||
auto b = parts[2].to_int().value_or(256);
|
||||
|
||||
double alpha = strtod(parts[3].to_string().characters(), nullptr);
|
||||
double alpha = 0;
|
||||
char const* start = parts[3].characters_without_null_termination();
|
||||
auto alpha_result = parse_first_floating_point(start, start + parts[3].length());
|
||||
if (alpha_result.parsed_value())
|
||||
alpha = alpha_result.value;
|
||||
|
||||
unsigned a = alpha * 255;
|
||||
|
||||
if (r > 255 || g > 255 || b > 255 || a > 255)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue