1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:58:12 +00:00

LibWeb: Make <input type=checkbox> honor the "checked" attribute

Implemented according to spec, although it's very possible that I missed
one or two details. :^)
This commit is contained in:
Andreas Kling 2022-02-15 19:16:57 +01:00
parent 05c9fd962d
commit 8a89a7bd95
4 changed files with 70 additions and 8 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -28,7 +28,15 @@ public:
void set_value(String);
bool checked() const { return m_checked; }
void set_checked(bool);
enum class ChangeSource {
Programmatic,
User,
};
enum class ShouldRunActivationBehavior {
No,
Yes,
};
void set_checked(bool, ChangeSource = ChangeSource::Programmatic, ShouldRunActivationBehavior = ShouldRunActivationBehavior::Yes);
bool enabled() const;
@ -36,6 +44,9 @@ public:
virtual bool is_focusable() const override;
virtual void parse_attribute(FlyString const&, String const&) override;
virtual void did_remove_attribute(FlyString const&) override;
private:
// ^DOM::Node
virtual void inserted() override;
@ -43,11 +54,16 @@ private:
// ^DOM::EventTarget
virtual void did_receive_focus() override;
virtual void run_activation_behavior() override;
void create_shadow_tree_if_needed();
void run_input_activation_behavior();
RefPtr<DOM::Text> m_text_node;
bool m_checked { false };
// https://html.spec.whatwg.org/multipage/input.html#concept-input-checked-dirty-flag
bool m_dirty_checkedness { false };
};
}