mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 13:25:08 +00:00
LibWeb: Add cm, in, mm and Q CSS units
This commit is contained in:
parent
279a49cdf4
commit
a9335eea1c
3 changed files with 45 additions and 3 deletions
|
@ -284,6 +284,9 @@ static CSS::Length parse_length(const CSS::ParsingContext& context, const String
|
|||
} else if (view.ends_with("pt", CaseSensitivity::CaseInsensitive)) {
|
||||
type = CSS::Length::Type::Pt;
|
||||
value = try_parse_float(view.substring_view(0, view.length() - 2));
|
||||
} else if (view.ends_with("mm", CaseSensitivity::CaseInsensitive)) {
|
||||
type = CSS::Length::Type::Mm;
|
||||
value = try_parse_float(view.substring_view(0, view.length() - 2));
|
||||
} else if (view.ends_with("rem", CaseSensitivity::CaseInsensitive)) {
|
||||
type = CSS::Length::Type::Rem;
|
||||
value = try_parse_float(view.substring_view(0, view.length() - 3));
|
||||
|
@ -305,6 +308,15 @@ static CSS::Length parse_length(const CSS::ParsingContext& context, const String
|
|||
} 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.ends_with("cm", CaseSensitivity::CaseInsensitive)) {
|
||||
type = CSS::Length::Type::Cm;
|
||||
value = try_parse_float(view.substring_view(0, view.length() - 2));
|
||||
} else if (view.ends_with("in", CaseSensitivity::CaseInsensitive)) {
|
||||
type = CSS::Length::Type::In;
|
||||
value = try_parse_float(view.substring_view(0, view.length() - 2));
|
||||
} else if (view.ends_with("Q", CaseSensitivity::CaseInsensitive)) {
|
||||
type = CSS::Length::Type::Q;
|
||||
value = try_parse_float(view.substring_view(0, view.length() - 1));
|
||||
} else if (view == "0") {
|
||||
type = CSS::Length::Type::Px;
|
||||
value = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue