Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b9ea94f94e83317bc7a6a2e796e3216b3bb577c9
      
https://github.com/WebKit/WebKit/commit/b9ea94f94e83317bc7a6a2e796e3216b3bb577c9
  Author: Chris Dumez <[email protected]>
  Date:   2026-04-02 (Thu, 02 Apr 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/input-in-range-in-has-with-readonly-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/input-in-range-in-has-with-readonly.html
    M Source/WebCore/html/HTMLFormControlElement.cpp
    M Source/WebCore/html/HTMLFormControlElement.h
    M Source/WebCore/html/ValidatedFormListedElement.cpp

  Log Message:
  -----------
  Use PseudoClassChangeInvalidation for :in-range/:out-of-range/:valid/:invalid 
when readonly changes
https://bugs.webkit.org/show_bug.cgi?id=311244

Reviewed by Tim Nguyen and Anne van Kesteren.

HTMLFormControlElement::readOnlyStateChanged() was using 
invalidateStyleForSubtree()
to handle :in-range/:out-of-range pseudo-classes changing when the readonly 
attribute
is toggled. These pseudo-classes depend on willValidate(), which returns false 
for
readonly form controls.

invalidateStyleForSubtree() is both too broad (marks the entire subtree dirty) 
and
too narrow (doesn't invalidate ancestors). The latter means :has() selectors 
like
`form:has(input:in-range)` fail to update when a descendant's readonly state 
changes.

Fix this by adding PseudoClassChangeInvalidation for :in-range, :out-of-range,
:valid, and :invalid in ValidatedFormListedElement::parseReadOnlyAttribute(),
alongside the existing invalidation for :read-only/:read-write. To compute the 
exact
new pseudo-class values, we temporarily apply the new readonly state (updating
m_hasReadOnlyAttribute and clearing the willValidate cache), query the element's
pseudo-class matching methods (matchesValidPseudoClass, 
matchesInvalidPseudoClass,
isInRange, isOutOfRange), then restore the old state before constructing the 
RAII
invalidation objects so their constructors correctly capture the before-change 
state.

This also removes the now-unnecessary 
HTMLFormControlElement::readOnlyStateChanged()
override since it was only there for the invalidateStyleForSubtree() call.

Test: 
imported/w3c/web-platform-tests/css/selectors/invalidation/input-in-range-in-has-with-readonly.html

* 
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/input-in-range-in-has-with-readonly-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/input-in-range-in-has-with-readonly.html:
 Added.
* Source/WebCore/html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::readOnlyStateChanged): Deleted.
* Source/WebCore/html/HTMLFormControlElement.h:
* Source/WebCore/html/ValidatedFormListedElement.cpp:
(WebCore::ValidatedFormListedElement::parseReadOnlyAttribute):

Canonical link: https://commits.webkit.org/310484@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to