diff options
author | Srikavin Ramkumar <srikavinramkumar@gmail.com> | 2023-03-20 04:34:43 -0400 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2023-03-20 10:15:58 +0000 |
commit | d177d83b44b7ad354cdd776ea1e3e9a165b6ed98 (patch) | |
tree | ff0efe8804aa20e6e5d11d1193ff6f72c9efacf3 | |
parent | aad4051885c68b1ae353fe29a917732863e9fd94 (diff) | |
download | serenity-d177d83b44b7ad354cdd776ea1e3e9a165b6ed98.zip |
LibWeb: Implement indeterminate IDL attribute in HTMLInputElement
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp | 11 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLInputElement.h | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl | 1 |
3 files changed, 18 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 4ac1c0e4da..1cbb2757b6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -107,6 +107,13 @@ void HTMLInputElement::set_checked_binding(bool checked) } } +// https://html.spec.whatwg.org/multipage/input.html#dom-input-indeterminate +void HTMLInputElement::set_indeterminate(bool value) +{ + // On setting, it must be set to the new value. It has no effect except for changing the appearance of checkbox controls. + m_indeterminate = value; +} + // https://html.spec.whatwg.org/multipage/input.html#dom-input-files JS::GCPtr<FileAPI::FileList> HTMLInputElement::files() { @@ -797,14 +804,15 @@ void HTMLInputElement::set_checked_within_group() void HTMLInputElement::legacy_pre_activation_behavior() { m_before_legacy_pre_activation_behavior_checked = checked(); + m_before_legacy_pre_activation_behavior_indeterminate = indeterminate(); // 1. If this element's type attribute is in the Checkbox state, then set // this element's checkedness to its opposite value (i.e. true if it is // false, false if it is true) and set this element's indeterminate IDL // attribute to false. - // FIXME: Set indeterminate to false when that exists. if (type_state() == TypeAttributeState::Checkbox) { set_checked(!checked(), ChangeSource::User); + set_indeterminate(false); } // 2. If this element's type attribute is in the Radio Button state, then @@ -834,6 +842,7 @@ void HTMLInputElement::legacy_cancelled_activation_behavior() // to the values they had before the legacy-pre-activation behavior was run. if (type_state() == TypeAttributeState::Checkbox) { set_checked(m_before_legacy_pre_activation_behavior_checked, ChangeSource::Programmatic); + set_indeterminate(m_before_legacy_pre_activation_behavior_indeterminate); } // 2. If this element 's type attribute is in the Radio Button state, then diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index 582e16434a..4cbfaabe06 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -78,6 +78,9 @@ public: bool checked_binding() const { return checked(); } void set_checked_binding(bool); + bool indeterminate() const { return m_indeterminate; }; + void set_indeterminate(bool); + void did_edit_text_node(Badge<BrowsingContext>); JS::GCPtr<FileAPI::FileList> files(); @@ -156,6 +159,9 @@ private: JS::GCPtr<DOM::Text> m_text_node; bool m_checked { false }; + // https://html.spec.whatwg.org/multipage/input.html#dom-input-indeterminate + bool m_indeterminate { false }; + // https://html.spec.whatwg.org/multipage/input.html#concept-input-checked-dirty-flag bool m_dirty_checkedness { false }; @@ -164,6 +170,7 @@ private: // https://html.spec.whatwg.org/multipage/input.html#the-input-element:legacy-pre-activation-behavior bool m_before_legacy_pre_activation_behavior_checked { false }; + bool m_before_legacy_pre_activation_behavior_indeterminate { false }; JS::GCPtr<HTMLInputElement> m_legacy_pre_activation_behavior_checked_element_in_group; // https://html.spec.whatwg.org/multipage/input.html#concept-input-type-file-selected diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl index 04f49cf7ba..d79040bb51 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl @@ -22,6 +22,7 @@ interface HTMLInputElement : HTMLElement { [Reflect=value] attribute DOMString defaultValue; attribute DOMString type; + attribute boolean indeterminate; [LegacyNullToEmptyString] attribute DOMString value; |