diff options
author | Andreas Kling <kling@serenityos.org> | 2022-02-15 00:25:51 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-15 02:05:53 +0100 |
commit | e842e955e5d378fbd2d71ea32c4842f3e5a9214e (patch) | |
tree | da108859f19bdd9894715dc07e670106c79adaf6 /Userland/Libraries/LibWeb/HTML/HTMLElement.cpp | |
parent | 1347c5032b0f71b4b62bfbff5c855ae6675e788f (diff) | |
download | serenity-e842e955e5d378fbd2d71ea32c4842f3e5a9214e.zip |
LibWeb: Implement HTMLElement.click()
This doesn't send the correct type of click event, but it does send
something, so it's already somewhat useful. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/HTMLElement.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLElement.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp index 170d18fd94..344c3de16c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -389,4 +389,24 @@ void HTMLElement::focus() // 5. Unmark the element as locked for focus. m_locked_for_focus = false; } + +// https://html.spec.whatwg.org/multipage/interaction.html#dom-click +void HTMLElement::click() +{ + // FIXME: 1. If this element is a form control that is disabled, then return. + + // 2. If this element's click in progress flag is set, then return. + if (m_click_in_progress) + return; + + // 3. Set this element's click in progress flag. + m_click_in_progress = true; + + // FIXME: 4. Fire a synthetic pointer event named click at this element, with the not trusted flag set. + dispatch_event(DOM::Event::create("click")); + + // 5. Unset this element's click in progress flag. + m_click_in_progress = false; +} + } |