mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 01:59:31 +00:00
LibWeb/HTML: Implement CommandEvent
class
This implements the `CommandEvent` class.
This commit is contained in:
parent
ffe0b05abd
commit
cce7d8c0fb
Notes:
github-actions[bot]
2025-04-18 11:11:05 +00:00
Author: https://github.com/skyz1
Commit: cce7d8c0fb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4220
Reviewed-by: https://github.com/tcl3 ✅
8 changed files with 297 additions and 0 deletions
46
Libraries/LibWeb/HTML/CommandEvent.h
Normal file
46
Libraries/LibWeb/HTML/CommandEvent.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Glenn Skrzypczak <glenn.skrzypczak@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/DOM/Utils.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
struct CommandEventInit : public DOM::EventInit {
|
||||
GC::Ptr<DOM::Element> source;
|
||||
String command;
|
||||
};
|
||||
|
||||
class CommandEvent : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(CommandEvent, DOM::Event);
|
||||
GC_DECLARE_ALLOCATOR(CommandEvent);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<CommandEvent> create(JS::Realm&, FlyString const& event_name, CommandEventInit = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<CommandEvent>> construct_impl(JS::Realm&, FlyString const& event_name, CommandEventInit);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-commandevent-command
|
||||
String const& command() const { return m_command; }
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-commandevent-source
|
||||
GC::Ptr<DOM::Element> source() const { return as<DOM::Element>(retarget(m_source, current_target())); }
|
||||
|
||||
private:
|
||||
void visit_edges(Visitor&) override;
|
||||
|
||||
CommandEvent(JS::Realm&, FlyString const& event_name, CommandEventInit event_init);
|
||||
|
||||
void initialize(JS::Realm&) override;
|
||||
|
||||
GC::Ptr<DOM::Element> m_source;
|
||||
String m_command;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue