diff --git a/Tests/LibWeb/Ref/css-open-closed-selectors.html b/Tests/LibWeb/Ref/css-open-closed-selectors.html new file mode 100644 index 0000000000..2845e8366e --- /dev/null +++ b/Tests/LibWeb/Ref/css-open-closed-selectors.html @@ -0,0 +1,18 @@ + + + +
+ Hi + Well hello friends! +
+
+ Hi + Well hello friends! +
diff --git a/Tests/LibWeb/Ref/reference/css-open-closed-selectors-ref.html b/Tests/LibWeb/Ref/reference/css-open-closed-selectors-ref.html new file mode 100644 index 0000000000..4dd0e89ae4 --- /dev/null +++ b/Tests/LibWeb/Ref/reference/css-open-closed-selectors-ref.html @@ -0,0 +1,17 @@ + + +
+ Hi + Well hello friends! +
+
+ Hi + Well hello friends! +
diff --git a/Userland/Libraries/LibWeb/CSS/PseudoClasses.json b/Userland/Libraries/LibWeb/CSS/PseudoClasses.json index 7e140eaa0b..1523d1ad9b 100644 --- a/Userland/Libraries/LibWeb/CSS/PseudoClasses.json +++ b/Userland/Libraries/LibWeb/CSS/PseudoClasses.json @@ -11,6 +11,9 @@ "checked": { "argument": "" }, + "closed": { + "argument": "" + }, "defined": { "argument": "" }, @@ -92,6 +95,9 @@ "only-of-type": { "argument": "" }, + "open": { + "argument": "" + }, "paused": { "argument": "" }, diff --git a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp index 8e8965ee2a..5633ef5233 100644 --- a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp +++ b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -238,6 +240,24 @@ static bool matches_read_write_pseudo_class(DOM::Element const& element) return element.is_editable(); } +// https://www.w3.org/TR/selectors-4/#open-state +static bool matches_open_state_pseudo_class(DOM::Element const& element, bool open) +{ + // The :open pseudo-class represents an element that has both “open” and “closed” states, + // and which is currently in the “open” state. + // The :closed pseudo-class represents an element that has both “open” and “closed” states, + // and which is currently in the closed state. + + // NOTE: Spec specifically suggests supporting
, , and