1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:08:13 +00:00

LibWeb: Add support for viewport-relative length units (#3433)

We can now use vh, vw, vmax and vmin as length units in CSS.
This commit is contained in:
Jakob-Niklas See 2020-09-08 20:39:09 +02:00 committed by GitHub
parent d467a0ffef
commit dcc2c8a125
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 1 deletions

View file

@ -292,6 +292,18 @@ static CSS::Length parse_length(const CSS::ParsingContext& context, const String
} else if (view.ends_with("ex", CaseSensitivity::CaseInsensitive)) {
type = CSS::Length::Type::Ex;
value = try_parse_float(view.substring_view(0, view.length() - 2));
} else if (view.ends_with("vw", CaseSensitivity::CaseInsensitive)) {
type = CSS::Length::Type::Vw;
value = try_parse_float(view.substring_view(0, view.length() - 2));
} else if (view.ends_with("vh", CaseSensitivity::CaseInsensitive)) {
type = CSS::Length::Type::Vh;
value = try_parse_float(view.substring_view(0, view.length() - 2));
} else if (view.ends_with("vmax", CaseSensitivity::CaseInsensitive)) {
type = CSS::Length::Type::Vmax;
value = try_parse_float(view.substring_view(0, view.length() - 4));
} else if (view.ends_with("vmin", CaseSensitivity::CaseInsensitive)) {
type = CSS::Length::Type::Vmin;
value = try_parse_float(view.substring_view(0, view.length() - 4));
} else if (view == "0") {
type = CSS::Length::Type::Px;
value = 0;