Skip to content

Commit

Permalink
Make fieldset match :enabled and :disabled again
Browse files Browse the repository at this point in the history
In http://crrev.com/1122658 I made fieldset not disableable to get
around some event dispatching issues, and also made it stop matching
:disabled and :enabled. Due to feedback in
whatwg/html#5886 (comment) I am
making it match :disabled and :enabled again in this patch.

Bug: 588760
Change-Id: I3793c02353fe0ffbd45e94d90b79e5f7b61b97dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4627174
Reviewed-by: Di Zhang <dizhangg@chromium.org>
Commit-Queue: Di Zhang <dizhangg@chromium.org>
Auto-Submit: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1160137}
  • Loading branch information
josepharhar authored and Chromium LUCI CQ committed Jun 20, 2023
1 parent 920c900 commit d90d4f2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 61 deletions.
11 changes: 11 additions & 0 deletions third_party/blink/renderer/core/css/selector_checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/fullscreen/fullscreen.h"
#include "third_party/blink/renderer/core/html/custom/element_internals.h"
#include "third_party/blink/renderer/core/html/forms/html_field_set_element.h"
#include "third_party/blink/renderer/core/html/forms/html_form_control_element.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/forms/html_option_element.h"
Expand Down Expand Up @@ -1619,6 +1620,16 @@ bool SelectorChecker::CheckPseudoClass(const SelectorCheckingContext& context,
case CSSSelector::kPseudoDefault:
return element.MatchesDefaultPseudoClass();
case CSSSelector::kPseudoDisabled:
if (auto* fieldset = DynamicTo<HTMLFieldSetElement>(element)) {
if (RuntimeEnabledFeatures::
SendMouseEventsDisabledFormControlsEnabled()) {
// <fieldset> should never be considered disabled, but should still
// match the :enabled or :disabled pseudo-classes according to whether
// the attribute is set or not. See here for context:
// https://github.com/whatwg/html/issues/5886#issuecomment-1582410112
return fieldset->IsActuallyDisabled();
}
}
return element.IsDisabledFormControl();
case CSSSelector::kPseudoReadOnly:
return element.MatchesReadOnlyPseudoClass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,15 @@ bool HTMLFieldSetElement::IsDisabledFormControl() const {
return HTMLFormControlElement::IsDisabledFormControl();
}

// <fieldset> should never be considered disabled, but should still match the
// :enabled or :disabled pseudo-classes according to whether the attribute is
// set or not. See here for context:
// https://github.com/whatwg/html/issues/5886#issuecomment-1582410112
bool HTMLFieldSetElement::MatchesEnabledPseudoClass() const {
if (RuntimeEnabledFeatures::SendMouseEventsDisabledFormControlsEnabled()) {
return !IsActuallyDisabled();
}
return HTMLFormControlElement::MatchesEnabledPseudoClass();
}

} // namespace blink
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class CORE_EXPORT HTMLFieldSetElement final : public HTMLFormControlElement {
bool AreAuthorShadowsAllowed() const override { return false; }
bool IsSubmittableElement() override;
bool AlwaysCreateUserAgentShadowRoot() const override { return false; }
bool MatchesEnabledPseudoClass() const final;

Element* InvalidateDescendantDisabledStateAndFindFocusedOne(Element& base);
};
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit d90d4f2

Please sign in to comment.