2020-01-18 09:38:21 +01:00
|
|
|
/*
|
2021-04-20 11:50:29 +02:00
|
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2019-11-25 21:21:55 +01:00
|
|
|
#pragma once
|
|
|
|
|
2020-07-26 15:08:16 +02:00
|
|
|
#include <LibWeb/HTML/HTMLElement.h>
|
|
|
|
#include <LibWeb/HTML/HTMLInputElement.h>
|
2019-11-25 21:21:55 +01:00
|
|
|
|
2020-07-28 18:20:36 +02:00
|
|
|
namespace Web::HTML {
|
2020-03-07 10:27:02 +01:00
|
|
|
|
2020-07-28 02:54:19 +01:00
|
|
|
class HTMLFormElement final : public HTMLElement {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(HTMLFormElement, HTMLElement);
|
2020-07-27 05:04:26 +01:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
public:
|
2019-11-25 21:21:55 +01:00
|
|
|
virtual ~HTMLFormElement() override;
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString action() const;
|
|
|
|
DeprecatedString method() const { return attribute(HTML::AttributeNames::method); }
|
2019-11-25 21:21:55 +01:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
void submit_form(JS::GCPtr<HTMLElement> submitter, bool from_submit_binding = false);
|
2020-11-21 21:53:18 +00:00
|
|
|
|
2022-12-22 19:32:20 -05:00
|
|
|
void reset_form();
|
|
|
|
|
2020-11-21 21:53:18 +00:00
|
|
|
// NOTE: This is for the JS bindings. Use submit_form instead.
|
|
|
|
void submit();
|
|
|
|
|
2022-12-22 19:32:20 -05:00
|
|
|
// NOTE: This is for the JS bindings. Use submit_form instead.
|
|
|
|
void reset();
|
|
|
|
|
2021-04-20 23:34:49 +02:00
|
|
|
void add_associated_element(Badge<FormAssociatedElement>, HTMLElement&);
|
|
|
|
void remove_associated_element(Badge<FormAssociatedElement>, HTMLElement&);
|
|
|
|
|
2022-09-01 20:50:16 +02:00
|
|
|
JS::NonnullGCPtr<DOM::HTMLCollection> elements() const;
|
2022-02-25 21:19:06 +01:00
|
|
|
unsigned length() const;
|
|
|
|
|
2020-11-21 21:53:18 +00:00
|
|
|
private:
|
2022-08-28 13:42:07 +02:00
|
|
|
HTMLFormElement(DOM::Document&, DOM::QualifiedName);
|
|
|
|
|
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
2020-11-21 21:53:18 +00:00
|
|
|
bool m_firing_submission_events { false };
|
2021-04-20 23:34:49 +02:00
|
|
|
|
2022-12-22 19:32:20 -05:00
|
|
|
// https://html.spec.whatwg.org/multipage/forms.html#locked-for-reset
|
|
|
|
bool m_locked_for_reset { false };
|
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
Vector<JS::GCPtr<HTMLElement>> m_associated_elements;
|
2022-11-24 19:04:05 +01:00
|
|
|
|
|
|
|
JS::GCPtr<DOM::HTMLCollection> mutable m_elements;
|
2019-11-25 21:21:55 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|