diff --git a/Tests/LibWeb/Ref/css-read-only-read-write-selectors-ref.html b/Tests/LibWeb/Ref/css-read-only-read-write-selectors-ref.html new file mode 100644 index 0000000000..a01bac2daf --- /dev/null +++ b/Tests/LibWeb/Ref/css-read-only-read-write-selectors-ref.html @@ -0,0 +1,13 @@ + + + + +
Well hello friends
+Well hello friends
diff --git a/Tests/LibWeb/Ref/css-read-only-read-write-selectors.html b/Tests/LibWeb/Ref/css-read-only-read-write-selectors.html new file mode 100644 index 0000000000..989e6dbf98 --- /dev/null +++ b/Tests/LibWeb/Ref/css-read-only-read-write-selectors.html @@ -0,0 +1,13 @@ + + + + +Well hello friends
+Well hello friends
diff --git a/Tests/LibWeb/Ref/manifest.json b/Tests/LibWeb/Ref/manifest.json index 60d30ac5b2..c2b8f0605c 100644 --- a/Tests/LibWeb/Ref/manifest.json +++ b/Tests/LibWeb/Ref/manifest.json @@ -10,6 +10,7 @@ "css-lang-selector.html": "css-lang-selector-ref.html", "css-local-link-selector.html": "css-local-link-selector-ref.html", "css-gradients.html": "css-gradients-ref.html", + "css-read-only-read-write-selectors.html": "css-read-only-read-write-selectors-ref.html", "svg-symbol.html": "svg-symbol-ref.html", "svg-gradient-spreadMethod.html": "svg-gradient-spreadMethod-ref.html", "svg-radialGradient.html": "svg-radialGradient-ref.html" diff --git a/Userland/Libraries/LibWeb/CSS/PseudoClasses.json b/Userland/Libraries/LibWeb/CSS/PseudoClasses.json index c74a23fb2e..21b749d6ea 100644 --- a/Userland/Libraries/LibWeb/CSS/PseudoClasses.json +++ b/Userland/Libraries/LibWeb/CSS/PseudoClasses.json @@ -98,6 +98,12 @@ "playing": { "argument": "" }, + "read-only": { + "argument": "" + }, + "read-write": { + "argument": "" + }, "root": { "argument": "" }, diff --git a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp index 1bbf994edc..8486a66eca 100644 --- a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp +++ b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp @@ -209,6 +209,34 @@ static inline DOM::Element const* next_sibling_with_same_tag_name(DOM::Element c return nullptr; } +// https://html.spec.whatwg.org/multipage/semantics-other.html#selector-read-write +static bool matches_read_write_pseudo_class(DOM::Element const& element) +{ + // The :read-write pseudo-class must match any element falling into one of the following categories, + // which for the purposes of Selectors are thus considered user-alterable: [SELECTORS] + // - input elements to which the readonly attribute applies, and that are mutable + // (i.e. that do not have the readonly attribute specified and that are not disabled) + if (is