mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
LibWeb/HTML: Invalidate :checked style on <input> type attribute change
The :checked (and :unchecked) psuedo classes depend on both the checked state of input elements as well as what the type of that input element is.
This commit is contained in:
committed by
Andreas Kling
parent
2f40939aee
commit
354cca350a
Notes:
github-actions[bot]
2026-02-06 11:02:37 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/354cca350a6 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7636
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) 2018-2025, Andreas Kling <andreas@ladybird.org>
|
||||
* Copyright (c) 2022, Adam Hodgen <ant1441@gmail.com>
|
||||
* Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
|
||||
* Copyright (c) 2023-2025, Shannon Booth <shannon@serenityos.org>
|
||||
* Copyright (c) 2023-2026, Shannon Booth <shannon@serenityos.org>
|
||||
* Copyright (c) 2023, Bastiaan van der Plaat <bastiaan.v.d.plaat@gmail.com>
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
* Copyright (c) 2024, Fernando Kiotheka <fer@k6a.dev>
|
||||
@@ -1534,6 +1534,16 @@ void HTMLInputElement::type_attribute_changed(TypeAttributeState old_state, Type
|
||||
auto new_value_attribute_mode = value_attribute_mode_for_type_state(new_state);
|
||||
auto old_value_attribute_mode = value_attribute_mode_for_type_state(old_state);
|
||||
|
||||
if (checked_applies(old_state) != checked_applies(new_state)) {
|
||||
invalidate_style(
|
||||
DOM::StyleInvalidationReason::HTMLInputElementSetType,
|
||||
{
|
||||
{ .type = CSS::InvalidationSet::Property::Type::PseudoClass, .value = CSS::PseudoClass::Checked },
|
||||
{ .type = CSS::InvalidationSet::Property::Type::PseudoClass, .value = CSS::PseudoClass::Unchecked },
|
||||
},
|
||||
{});
|
||||
}
|
||||
|
||||
// 1. If the previous state of the element's type attribute put the value IDL attribute in the value mode, and the element's
|
||||
// value is not the empty string, and the new state of the element's type attribute puts the value IDL attribute in either
|
||||
// the default mode or the default/on mode, then set the element's value content attribute to the element's value.
|
||||
@@ -3273,9 +3283,9 @@ bool HTMLInputElement::required_applies() const
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#do-not-apply
|
||||
bool HTMLInputElement::checked_applies() const
|
||||
bool HTMLInputElement::checked_applies(TypeAttributeState type_state)
|
||||
{
|
||||
switch (type_state()) {
|
||||
switch (type_state) {
|
||||
case TypeAttributeState::Checkbox:
|
||||
case TypeAttributeState::RadioButton:
|
||||
return true;
|
||||
@@ -3284,6 +3294,11 @@ bool HTMLInputElement::checked_applies() const
|
||||
}
|
||||
}
|
||||
|
||||
bool HTMLInputElement::checked_applies() const
|
||||
{
|
||||
return checked_applies(type_state());
|
||||
}
|
||||
|
||||
bool HTMLInputElement::has_selectable_text() const
|
||||
{
|
||||
// Potential FIXME: Date, Month, Week, Time and LocalDateAndTime are rendered as a basic text input for now,
|
||||
|
||||
Reference in New Issue
Block a user