mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-09 12:42:54 +00:00
LibHTML: Tolerate "px" suffix on CSS lengths
We only support "px" units (and "auto") but we shouldn't choke just because someone actually says "10px" instead of just "10"
This commit is contained in:
parent
00d171e4d6
commit
df16c9676b
Notes:
sideshowbarker
2024-07-19 11:09:52 +09:00
Author: https://github.com/awesomekling
Commit: df16c9676b
1 changed files with 4 additions and 7 deletions
|
@ -25,13 +25,10 @@ static Optional<Color> parse_css_color(const StringView& view)
|
|||
NonnullRefPtr<StyleValue> parse_css_value(const StringView& view)
|
||||
{
|
||||
String string(view);
|
||||
bool ok;
|
||||
int as_int = string.to_int(ok);
|
||||
if (ok)
|
||||
return LengthStyleValue::create(Length(as_int, Length::Type::Absolute));
|
||||
unsigned as_uint = string.to_uint(ok);
|
||||
if (ok)
|
||||
return LengthStyleValue::create(Length(as_uint, Length::Type::Absolute));
|
||||
char* endptr = nullptr;
|
||||
long value = strtol(String(view).characters(), &endptr, 10);
|
||||
if (endptr && ((!*endptr) || (endptr[0] == 'p' && endptr[1] == 'x' && endptr[2] == '\0')))
|
||||
return LengthStyleValue::create(Length(value, Length::Type::Absolute));
|
||||
if (string == "inherit")
|
||||
return InheritStyleValue::create();
|
||||
if (string == "initial")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue