diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2021-11-18 11:54:32 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-19 22:35:05 +0100 |
commit | d37f62fd547325773c06fba46296894ca013d466 (patch) | |
tree | ddb167e486cb7ee1877c07953b6888f61bed5cf2 /Userland/Libraries/LibWeb/CSS | |
parent | 522faa15540b6344ce34d65b4f6c3132c9e9de0b (diff) | |
download | serenity-d37f62fd547325773c06fba46296894ca013d466.zip |
LibWeb: Verify that the Tokenizer doesn't produce Dimensions from %
If `12.34%` ever produces a Dimension token instead of a Percentage,
then something has gone wrong and we want to know about it!
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 93b4217ffc..d14aee291b 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -1905,9 +1905,7 @@ Optional<Length> Parser::parse_length(StyleComponentValueRule const& component_v numeric_value = component_value.token().dimension_value(); auto unit_string = component_value.token().m_unit.string_view(); - if (unit_string.equals_ignoring_case("%")) { - type = Length::Type::Percentage; - } else if (unit_string.equals_ignoring_case("px")) { + if (unit_string.equals_ignoring_case("px")) { type = Length::Type::Px; } else if (unit_string.equals_ignoring_case("pt")) { type = Length::Type::Pt; @@ -1937,6 +1935,9 @@ Optional<Length> Parser::parse_length(StyleComponentValueRule const& component_v type = Length::Type::In; } else if (unit_string.equals_ignoring_case("Q")) { type = Length::Type::Q; + } else if (unit_string.equals_ignoring_case("%")) { + // A number followed by `%` must always result in a Percentage token. + VERIFY_NOT_REACHED(); } else { return {}; } |