mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-02 04:27:12 +02: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:
Notes:
sideshowbarker
2024-07-19 02:49:37 +09:00
Author: https://github.com/networkException 🔰 Commit: https://github.com/SerenityOS/serenity/commit/dcc2c8a1254 Pull-request: https://github.com/SerenityOS/serenity/pull/3433 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/linusg
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user