diff options
author | Linus Groh <mail@linusgroh.de> | 2020-05-11 00:51:57 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-11 10:48:54 +0200 |
commit | 673527d314a9f58ddb04e2a75bebe3bacd79af0c (patch) | |
tree | 1566fcbb1bdb3db014ea2c88a99d739817d0639f | |
parent | a427821dd1c331c0828f6b113865787cfbfb42cc (diff) | |
download | serenity-673527d314a9f58ddb04e2a75bebe3bacd79af0c.zip |
LibWeb: Ignore parsed pseudo-element selectors & empty complex selectors
Currently we don't deal with them, so they shouldn't return a
SimpleSelector - that'd be a false positive.
Also don't produce a ComplexSelector if no SimpleSelector was parsed.
This fixes a couple of rendering issues on awesomekling.github.io:
link colours, footer size, content max-width (and possibly more!)
-rw-r--r-- | Libraries/LibWeb/Parser/CSSParser.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Libraries/LibWeb/Parser/CSSParser.cpp b/Libraries/LibWeb/Parser/CSSParser.cpp index 5a42e92f0a..95a468b137 100644 --- a/Libraries/LibWeb/Parser/CSSParser.cpp +++ b/Libraries/LibWeb/Parser/CSSParser.cpp @@ -383,6 +383,12 @@ public: auto pseudo_name = String::copy(buffer); buffer.clear(); + + // Ignore for now, otherwise we produce a "false positive" selector + // and apply styles to the element itself, not its pseudo element + if (is_pseudo_element) + return {}; + if (pseudo_name == "link") simple_selector.pseudo_class = Selector::SimpleSelector::PseudoClass::Link; else if (pseudo_name == "hover") @@ -442,6 +448,9 @@ public: PARSE_ASSERT(simple_selectors.size() < 100); } + if (simple_selectors.is_empty()) + return {}; + return Selector::ComplexSelector { relation, move(simple_selectors) }; } |