mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
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!
This commit is contained in:
parent
522faa1554
commit
d37f62fd54
Notes:
sideshowbarker
2024-07-18 00:59:38 +09:00
Author: https://github.com/AtkinsSJ
Commit: d37f62fd54
Pull-request: https://github.com/SerenityOS/serenity/pull/10956
Reviewed-by: https://github.com/alimpfard ✅
1 changed files with 4 additions and 3 deletions
|
@ -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 {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue