2020-01-18 09:38:21 +01:00
|
|
|
/*
|
2022-02-15 00:25:51 +01:00
|
|
|
* Copyright (c) 2018-2022, 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-09-29 11:59:38 +02:00
|
|
|
#pragma once
|
|
|
|
|
2020-03-07 10:32:51 +01:00
|
|
|
#include <LibWeb/DOM/Element.h>
|
2021-09-26 15:24:41 +01:00
|
|
|
#include <LibWeb/HTML/DOMStringMap.h>
|
2021-02-03 22:47:50 +01:00
|
|
|
#include <LibWeb/HTML/EventNames.h>
|
|
|
|
#include <LibWeb/HTML/GlobalEventHandlers.h>
|
2019-09-29 11:59:38 +02:00
|
|
|
|
2020-07-28 18:20:36 +02:00
|
|
|
namespace Web::HTML {
|
2020-03-07 10:27:02 +01:00
|
|
|
|
2021-02-03 22:47:50 +01:00
|
|
|
class HTMLElement
|
|
|
|
: public DOM::Element
|
|
|
|
, public HTML::GlobalEventHandlers {
|
2019-09-29 11:59:38 +02:00
|
|
|
public:
|
2020-06-21 14:35:00 +02:00
|
|
|
using WrapperType = Bindings::HTMLElementWrapper;
|
|
|
|
|
2022-02-18 21:00:52 +01:00
|
|
|
HTMLElement(DOM::Document&, DOM::QualifiedName);
|
2019-09-29 11:59:38 +02:00
|
|
|
virtual ~HTMLElement() override;
|
2019-09-29 12:24:36 +02:00
|
|
|
|
2020-06-03 20:51:28 +02:00
|
|
|
String title() const { return attribute(HTML::AttributeNames::title); }
|
2019-09-29 12:24:36 +02:00
|
|
|
|
2020-08-03 02:57:28 +01:00
|
|
|
virtual bool is_editable() const final;
|
|
|
|
String content_editable() const;
|
2021-02-20 00:43:08 +01:00
|
|
|
DOM::ExceptionOr<void> set_content_editable(const String&);
|
2020-08-03 02:57:28 +01:00
|
|
|
|
2020-11-11 09:46:53 +00:00
|
|
|
String inner_text();
|
|
|
|
void set_inner_text(StringView);
|
|
|
|
|
2021-09-30 01:35:19 +02:00
|
|
|
int offset_top() const;
|
|
|
|
int offset_left() const;
|
|
|
|
int offset_width() const;
|
|
|
|
int offset_height() const;
|
2021-04-15 20:48:55 +03:00
|
|
|
|
2020-11-21 21:53:18 +00:00
|
|
|
bool cannot_navigate() const;
|
|
|
|
|
2021-09-26 15:24:41 +01:00
|
|
|
NonnullRefPtr<DOMStringMap> dataset() const { return m_dataset; }
|
|
|
|
|
2022-02-06 18:46:26 +01:00
|
|
|
void focus();
|
|
|
|
|
2022-02-15 00:25:51 +01:00
|
|
|
void click();
|
|
|
|
|
2022-02-25 20:45:19 +01:00
|
|
|
bool fire_a_synthetic_pointer_event(FlyString const& type, DOM::Element& target, bool not_trusted);
|
|
|
|
|
2021-02-03 22:47:50 +01:00
|
|
|
protected:
|
|
|
|
virtual void parse_attribute(const FlyString& name, const String& value) override;
|
|
|
|
|
2019-09-29 12:24:36 +02:00
|
|
|
private:
|
2021-02-03 22:47:50 +01:00
|
|
|
// ^HTML::GlobalEventHandlers
|
|
|
|
virtual EventTarget& global_event_handlers_to_event_target() override { return *this; }
|
|
|
|
|
2020-08-03 02:57:28 +01:00
|
|
|
enum class ContentEditableState {
|
|
|
|
True,
|
|
|
|
False,
|
|
|
|
Inherit,
|
|
|
|
};
|
|
|
|
ContentEditableState content_editable_state() const;
|
2021-09-26 15:24:41 +01:00
|
|
|
|
|
|
|
NonnullRefPtr<DOMStringMap> m_dataset;
|
2022-02-06 18:46:26 +01:00
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/interaction.html#locked-for-focus
|
|
|
|
bool m_locked_for_focus { false };
|
2022-02-15 00:25:51 +01:00
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/interaction.html#click-in-progress-flag
|
|
|
|
bool m_click_in_progress { false };
|
2019-09-29 11:59:38 +02:00
|
|
|
};
|
2019-10-06 20:37:39 +02:00
|
|
|
|
|
|
|
}
|