mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibWeb: Add the missing SubmitEvent IDL constructor
This commit also removes the SubmitEvent.cpp file, as all of the method implementations were trivial and could be inlined into the header file.
This commit is contained in:
parent
d44857d34d
commit
1e8ba0d9d3
Notes:
sideshowbarker
2024-07-18 03:14:14 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/1e8ba0d9d36 Pull-request: https://github.com/SerenityOS/serenity/pull/10299
5 changed files with 31 additions and 39 deletions
|
@ -175,7 +175,6 @@ set(SOURCES
|
|||
HTML/Parser/StackOfOpenElements.cpp
|
||||
HTML/Scripting/ClassicScript.cpp
|
||||
HTML/Scripting/Script.cpp
|
||||
HTML/SubmitEvent.cpp
|
||||
HTML/SyntaxHighlighter/SyntaxHighlighter.cpp
|
||||
HTML/TagNames.cpp
|
||||
HTML/WebSocket.cpp
|
||||
|
|
|
@ -59,7 +59,9 @@ void HTMLFormElement::submit_form(RefPtr<HTMLElement> submitter, bool from_submi
|
|||
if (submitter != this)
|
||||
submitter_button = submitter;
|
||||
|
||||
auto submit_event = SubmitEvent::create(EventNames::submit, submitter_button);
|
||||
SubmitEventInit event_init {};
|
||||
event_init.submitter = submitter_button;
|
||||
auto submit_event = SubmitEvent::create(EventNames::submit, event_init);
|
||||
submit_event->set_bubbles(true);
|
||||
submit_event->set_cancelable(true);
|
||||
bool continue_ = dispatch_event(submit_event);
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
#include <LibWeb/HTML/SubmitEvent.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
NonnullRefPtr<SubmitEvent> SubmitEvent::create(const FlyString& event_name, RefPtr<HTMLElement> submitter)
|
||||
{
|
||||
return adopt_ref(*new SubmitEvent(event_name, move(submitter)));
|
||||
}
|
||||
|
||||
SubmitEvent::SubmitEvent(const FlyString& event_name, RefPtr<HTMLElement> submitter)
|
||||
: DOM::Event(event_name)
|
||||
, m_submitter(submitter)
|
||||
{
|
||||
}
|
||||
|
||||
SubmitEvent::~SubmitEvent()
|
||||
{
|
||||
}
|
||||
|
||||
RefPtr<HTMLElement> SubmitEvent::submitter() const
|
||||
{
|
||||
return m_submitter;
|
||||
}
|
||||
|
||||
}
|
|
@ -6,22 +6,39 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/HTMLElementWrapper.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
struct SubmitEventInit : public DOM::EventInit {
|
||||
RefPtr<HTMLElement> submitter { nullptr };
|
||||
};
|
||||
|
||||
class SubmitEvent final : public DOM::Event {
|
||||
public:
|
||||
using WrapperType = Bindings::SubmitEventWrapper;
|
||||
|
||||
static NonnullRefPtr<SubmitEvent> create(const FlyString& event_name, RefPtr<HTMLElement> submitter);
|
||||
static NonnullRefPtr<SubmitEvent> create(FlyString const& event_name, SubmitEventInit const& event_init)
|
||||
{
|
||||
return adopt_ref(*new SubmitEvent(event_name, event_init));
|
||||
}
|
||||
static NonnullRefPtr<SubmitEvent> create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, SubmitEventInit const& event_init)
|
||||
{
|
||||
return SubmitEvent::create(event_name, event_init);
|
||||
}
|
||||
|
||||
virtual ~SubmitEvent() override;
|
||||
virtual ~SubmitEvent() override = default;
|
||||
|
||||
RefPtr<HTMLElement> submitter() const;
|
||||
RefPtr<HTMLElement> submitter() const { return m_submitter; }
|
||||
|
||||
private:
|
||||
SubmitEvent(const FlyString& event_name, RefPtr<HTMLElement> submitter);
|
||||
SubmitEvent(FlyString const& event_name, SubmitEventInit const& event_init)
|
||||
: DOM::Event(event_name, event_init)
|
||||
, m_submitter(event_init.submitter)
|
||||
{
|
||||
}
|
||||
|
||||
RefPtr<HTMLElement> m_submitter;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
#import <DOM/Event.idl>
|
||||
|
||||
interface SubmitEvent : Event {
|
||||
constructor(DOMString type, optional SubmitEventInit eventInitDict = {});
|
||||
|
||||
readonly attribute HTMLElement? submitter;
|
||||
|
||||
};
|
||||
|
||||
dictionary SubmitEventInit : EventInit {
|
||||
HTMLElement? submitter = null;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue