diff --git a/dom/html/HTMLElement.cpp b/dom/html/HTMLElement.cpp index bccb117034ec..37daa19d4fb9 100644 --- a/dom/html/HTMLElement.cpp +++ b/dom/html/HTMLElement.cpp @@ -381,10 +381,6 @@ HTMLFieldSetElement* HTMLElement::GetFieldSetInternal() const { bool HTMLElement::CanBeDisabled() const { return IsFormAssociatedElement(); } -bool HTMLElement::DoesReadOnlyApply() const { - return IsFormAssociatedElement(); -} - void HTMLElement::UpdateDisabledState(bool aNotify) { bool oldState = IsDisabled(); nsGenericHTMLFormElement::UpdateDisabledState(aNotify); diff --git a/dom/html/HTMLElement.h b/dom/html/HTMLElement.h index 727e6ab487e0..177904527f86 100644 --- a/dom/html/HTMLElement.h +++ b/dom/html/HTMLElement.h @@ -75,7 +75,6 @@ class HTMLElement final : public nsGenericHTMLFormElement { void SetFieldSetInternal(HTMLFieldSetElement* aFieldset) override; HTMLFieldSetElement* GetFieldSetInternal() const override; bool CanBeDisabled() const override; - bool DoesReadOnlyApply() const override; void UpdateDisabledState(bool aNotify) override; void UpdateFormOwner(bool aBindToTree, Element* aFormIdElement) override; diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 9a7f7e02bdb1..67c692084c95 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -6553,7 +6553,7 @@ HTMLInputElement::ValueModeType HTMLInputElement::GetValueMode() const { bool HTMLInputElement::IsMutable() const { return !IsDisabled() && - !(DoesReadOnlyApply() && State().HasState(ElementState::READONLY)); + !(DoesReadWriteApply() && State().HasState(ElementState::READONLY)); } bool HTMLInputElement::DoesRequiredApply() const { diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index 440a7cfcb794..59d0b07aed9d 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2233,7 +2233,7 @@ void nsGenericHTMLFormElement::UpdateDisabledState(bool aNotify) { if (!changedStates.IsEmpty()) { ToggleStates(changedStates, aNotify); - if (DoesReadOnlyApply()) { + if (DoesReadWriteApply()) { // :disabled influences :read-only / :read-write. UpdateReadOnlyState(aNotify); } @@ -2241,7 +2241,7 @@ void nsGenericHTMLFormElement::UpdateDisabledState(bool aNotify) { } bool nsGenericHTMLFormElement::IsReadOnlyInternal() const { - if (DoesReadOnlyApply()) { + if (DoesReadWriteApply()) { return IsDisabled() || GetBoolAttr(nsGkAtoms::readonly); } return nsGenericHTMLElement::IsReadOnlyInternal(); @@ -2682,7 +2682,7 @@ bool nsGenericHTMLFormControlElement::CanBeDisabled() const { return type != FormControlType::Object && type != FormControlType::Output; } -bool nsGenericHTMLFormControlElement::DoesReadOnlyApply() const { +bool nsGenericHTMLFormControlElement::DoesReadWriteApply() const { auto type = ControlType(); if (!IsInputElement(type) && type != FormControlType::Textarea) { return false; @@ -2716,7 +2716,7 @@ bool nsGenericHTMLFormControlElement::DoesReadOnlyApply() const { case FormControlType::InputDatetimeLocal: return true; default: - MOZ_ASSERT_UNREACHABLE("Unexpected input type in DoesReadOnlyApply()"); + MOZ_ASSERT_UNREACHABLE("Unexpected input type in DoesReadWriteApply()"); return true; #else // DEBUG default: diff --git a/dom/html/nsGenericHTMLElement.h b/dom/html/nsGenericHTMLElement.h index 31fc5e1e58cd..ea85e34dfbdf 100644 --- a/dom/html/nsGenericHTMLElement.h +++ b/dom/html/nsGenericHTMLElement.h @@ -1140,9 +1140,10 @@ class nsGenericHTMLFormElement : public nsGenericHTMLElement { virtual bool CanBeDisabled() const { return false; } /** - * Returns if the readonly attribute applies. + * Returns true if :read-write pseudo class may match the element even if the + * element isn't part of designMode or contenteditable. */ - virtual bool DoesReadOnlyApply() const { return false; } + virtual bool DoesReadWriteApply() const { return false; } /** * Returns true if the element is a form associated element. @@ -1200,7 +1201,7 @@ class nsGenericHTMLFormControlElement : public nsGenericHTMLFormElement, // nsGenericHTMLFormElement bool CanBeDisabled() const override; - bool DoesReadOnlyApply() const override; + bool DoesReadWriteApply() const override; void SetFormInternal(mozilla::dom::HTMLFormElement* aForm, bool aBindToTree) override; mozilla::dom::HTMLFormElement* GetFormInternal() const override; diff --git a/testing/web-platform/tests/html/semantics/selectors/pseudo-classes/readwrite-readonly.html b/testing/web-platform/tests/html/semantics/selectors/pseudo-classes/readwrite-readonly.html index fb8a5b9ad70e..ad579ccc0eaf 100644 --- a/testing/web-platform/tests/html/semantics/selectors/pseudo-classes/readwrite-readonly.html +++ b/testing/web-platform/tests/html/semantics/selectors/pseudo-classes/readwrite-readonly.html @@ -5,6 +5,17 @@ +
@@ -58,6 +69,14 @@
+
+ content + content + content + content + content +
+