1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 12:05:07 +00:00
serenity/Userland/Libraries/LibWeb/CSS/Parser
Sam Atkins c8c2a8df56 LibWeb: Make '0' always be both a number and a length in CSS
A '0' token can be interpreted both as a Number, and as a Length. This
is problematic as in our CSS parser, we often call parse_css_value()
first, to figure out what something is, and then assign it. So we do not
know in advance whether we want a Length or not. Previously, it always
got parsed as a Length, and then every place that expected a
NumericStyleValue had to also check for a Length(0), which is easy to
forget to do.

In particular, this was causing issues with the `flex` property parsing.

To solve this, we now always parse 0 as a NumericStyleValue, and NSVs of
0 pretend to be a Length(0px) when asked. In two places, we were casting
to a LengthStyleValue* based on is_length(), which no longer works, so
those have been adjusted to use `StyleValue::to_length()` instead. They
also now check for `is_numeric()` first, to avoid the extra conversion
to a Length and back.

Possibly this opens up new issues elsewhere. In my testing it seems
fine, but until we can get CSS test suites running, it's hard to know
for certain.
2021-08-14 12:45:01 +02:00
..
DeclarationOrAtRule.h LibWeb: Add accessors to CSS::DeclarationOrAtRule 2021-07-11 23:19:56 +02:00
Parser.cpp LibWeb: Make '0' always be both a number and a length in CSS 2021-08-14 12:45:01 +02:00
Parser.h LibWeb: Implement CSS parsing convenience functions 2021-08-02 19:01:25 +04:30
StyleBlockRule.h LibWeb: Give CSS Token and StyleComponentValueRule matching is() funcs 2021-07-11 23:19:56 +02:00
StyleComponentValueRule.h LibWeb: Increase clarity with CSS token debug logging 2021-07-11 23:19:56 +02:00
StyleDeclarationRule.h Everywhere: Use "the SerenityOS developers." in copyright headers 2021-04-29 00:59:26 +02:00
StyleFunctionRule.h LibWeb: Use Selectors instead of a String for :not() selectors 2021-07-14 13:31:00 +02:00
StyleRule.h LibWeb: Merge CSS Parser's QualifiedStyleRule and AtStyleRule 2021-07-11 23:19:56 +02:00
StyleRules.cpp LibWeb: Convert StyleFunctionRule.m_values to ComponentValues 2021-07-11 23:19:56 +02:00
Token.cpp LibWeb: Make CSS 'An+B' parsing spec-compliant 2021-07-31 00:18:11 +02:00
Token.h LibWeb: Make CSS 'An+B' parsing spec-compliant 2021-07-31 00:18:11 +02:00
Tokenizer.cpp LibWeb: Fix EOF handling in CSS Tokenizer peek_{twin,triplet}() 2021-08-04 19:04:12 +04:30
Tokenizer.h LibWeb: Correct escape handling in CSS Tokenizer 2021-07-11 23:19:56 +02:00