diff options
author | Linus Groh <mail@linusgroh.de> | 2020-05-13 17:18:16 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-13 19:25:49 +0200 |
commit | 57857cd8f69cd78516a0cccf7fd58d2bdd249ca1 (patch) | |
tree | aeaa2121b3c1f8e7680387dc8955bafbf555979f /Libraries/LibWeb/Parser/CSSParser.cpp | |
parent | d8cdf3f5e1ee21da1c7ab062c2ca24b2fc7f788b (diff) | |
download | serenity-57857cd8f69cd78516a0cccf7fd58d2bdd249ca1.zip |
LibWeb: Make parsing of most CSS values case-insensitive
These are all valid:
width: AUTO;
height: 10PX;
color: LiMeGrEeN;
Diffstat (limited to 'Libraries/LibWeb/Parser/CSSParser.cpp')
-rw-r--r-- | Libraries/LibWeb/Parser/CSSParser.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Libraries/LibWeb/Parser/CSSParser.cpp b/Libraries/LibWeb/Parser/CSSParser.cpp index bb46b55f7d..5fe882fc82 100644 --- a/Libraries/LibWeb/Parser/CSSParser.cpp +++ b/Libraries/LibWeb/Parser/CSSParser.cpp @@ -43,7 +43,7 @@ namespace Web { static Optional<Color> parse_css_color(const StringView& view) { - auto color = Color::from_string(view); + auto color = Color::from_string(view.to_string().to_lowercase()); if (color.has_value()) return color; @@ -128,7 +128,8 @@ static Optional<float> parse_number(const StringView& view) if (view.ends_with('%')) return parse_number(view.substring_view(0, view.length() - 1)); - if (view.ends_with("px")) + // FIXME: Maybe we should have "ends_with_ignoring_case()" ? + if (view.to_string().to_lowercase().ends_with("px")) return parse_number(view.substring_view(0, view.length() - 2)); return try_parse_float(view); @@ -142,11 +143,12 @@ NonnullRefPtr<StyleValue> parse_css_value(const StringView& string) return PercentageStyleValue::create(number.value()); return LengthStyleValue::create(Length(number.value(), Length::Type::Absolute)); } - if (string == "inherit") + + if (string.equals_ignoring_case("inherit")) return InheritStyleValue::create(); - if (string == "initial") + if (string.equals_ignoring_case("initial")) return InitialStyleValue::create(); - if (string == "auto") + if (string.equals_ignoring_case("auto")) return LengthStyleValue::create(Length()); auto color = parse_css_color(string); |