diff --git a/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Libraries/LibWeb/CSS/Parser/Parser.cpp index 5a857b996cc..441e1de4924 100644 --- a/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -304,9 +304,13 @@ OwnPtr Parser::parse_supports_feature(TokenStreamcontains_unknown_webkit_pseudo_element(); + return Supports::Selector::create(builder.to_string_without_validation(), matches); } // ` = font-tech( )` diff --git a/Libraries/LibWeb/CSS/Selector.cpp b/Libraries/LibWeb/CSS/Selector.cpp index ea887630363..85016c1289e 100644 --- a/Libraries/LibWeb/CSS/Selector.cpp +++ b/Libraries/LibWeb/CSS/Selector.cpp @@ -646,6 +646,24 @@ NonnullRefPtr Selector::relative_to(SimpleSelector const& parent) cons return Selector::create(move(copied_compound_selectors)); } +bool Selector::contains_unknown_webkit_pseudo_element() const +{ + for (auto const& compound_selector : m_compound_selectors) { + for (auto const& simple_selector : compound_selector.simple_selectors) { + if (simple_selector.type == SimpleSelector::Type::PseudoClass) { + for (auto const& child_selector : simple_selector.pseudo_class().argument_selector_list) { + if (child_selector->contains_unknown_webkit_pseudo_element()) { + return true; + } + } + } + if (simple_selector.type == SimpleSelector::Type::PseudoElement && simple_selector.pseudo_element().type() == PseudoElement::Type::UnknownWebKit) + return true; + } + } + return false; +} + RefPtr Selector::absolutized(Selector::SimpleSelector const& selector_for_nesting) const { if (!contains_the_nesting_selector()) diff --git a/Libraries/LibWeb/CSS/Selector.h b/Libraries/LibWeb/CSS/Selector.h index 49e218e0a57..f1d06669b48 100644 --- a/Libraries/LibWeb/CSS/Selector.h +++ b/Libraries/LibWeb/CSS/Selector.h @@ -262,6 +262,7 @@ public: NonnullRefPtr relative_to(SimpleSelector const&) const; bool contains_the_nesting_selector() const { return m_contains_the_nesting_selector; } bool contains_hover_pseudo_class() const { return m_contains_hover_pseudo_class; } + bool contains_unknown_webkit_pseudo_element() const; RefPtr absolutized(SimpleSelector const& selector_for_nesting) const; u32 specificity() const; String serialize() const; diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/at-supports-selector-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/at-supports-selector-001.html new file mode 100644 index 00000000000..6bb830972b2 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/at-supports-selector-001.html @@ -0,0 +1,19 @@ + +CSS Conditional Test: @supports selector() with compound selector + + + + + + +

Test passes if there is a filled green square and no red.

+
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/at-supports-selector-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/at-supports-selector-002.html new file mode 100644 index 00000000000..97c135d1278 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/at-supports-selector-002.html @@ -0,0 +1,18 @@ + +CSS Conditional Test: @supports selector() with pseudo-elements. + + + + + +

Test passes if there is a filled green square and no red.

+
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/at-supports-selector-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/at-supports-selector-003.html new file mode 100644 index 00000000000..0fefd3be139 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/at-supports-selector-003.html @@ -0,0 +1,18 @@ + +CSS Conditional Test: @supports selector() with -webkit- unknown pseudo-elements and negation. + + + + + +

Test passes if there is a filled green square and no red.

+
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/at-supports-selector-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/at-supports-selector-004.html new file mode 100644 index 00000000000..d07a88d341d --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-conditional/at-supports-selector-004.html @@ -0,0 +1,18 @@ + +CSS Conditional Test: @supports selector() with multiple selectors doesn't work. + + + + + +

Test passes if there is a filled green square and no red.

+
diff --git a/Tests/LibWeb/Text/expected/css/supports.txt b/Tests/LibWeb/Text/expected/css/supports.txt index a42e2dbfee7..10560b1f716 100644 --- a/Tests/LibWeb/Text/expected/css/supports.txt +++ b/Tests/LibWeb/Text/expected/css/supports.txt @@ -13,5 +13,5 @@ These should all fail: @supports (width: yellow) or (height: green): FAIL @supports (flogwizzle: purple): FAIL @supports selector(.....nope): FAIL -@supports selector(::-webkit-input-placeholder): PASS +@supports selector(::-webkit-input-placeholder): FAIL @supports selector(32) or selector(thing[foo??????bar]): FAIL