HTMLElement.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/DOM/Element.h>
  8. #include <LibWeb/HTML/DOMStringMap.h>
  9. #include <LibWeb/HTML/EventNames.h>
  10. #include <LibWeb/HTML/GlobalEventHandlers.h>
  11. namespace Web::HTML {
  12. class HTMLElement
  13. : public DOM::Element
  14. , public HTML::GlobalEventHandlers {
  15. public:
  16. using WrapperType = Bindings::HTMLElementWrapper;
  17. HTMLElement(DOM::Document&, DOM::QualifiedName);
  18. virtual ~HTMLElement() override;
  19. String title() const { return attribute(HTML::AttributeNames::title); }
  20. virtual bool is_editable() const final;
  21. String content_editable() const;
  22. DOM::ExceptionOr<void> set_content_editable(const String&);
  23. String inner_text();
  24. void set_inner_text(StringView);
  25. int offset_top() const;
  26. int offset_left() const;
  27. int offset_width() const;
  28. int offset_height() const;
  29. bool cannot_navigate() const;
  30. NonnullRefPtr<DOMStringMap> dataset() const { return m_dataset; }
  31. void focus();
  32. void click();
  33. bool fire_a_synthetic_pointer_event(FlyString const& type, DOM::Element& target, bool not_trusted);
  34. protected:
  35. virtual void parse_attribute(const FlyString& name, const String& value) override;
  36. private:
  37. // ^HTML::GlobalEventHandlers
  38. virtual EventTarget& global_event_handlers_to_event_target() override { return *this; }
  39. enum class ContentEditableState {
  40. True,
  41. False,
  42. Inherit,
  43. };
  44. ContentEditableState content_editable_state() const;
  45. NonnullRefPtr<DOMStringMap> m_dataset;
  46. // https://html.spec.whatwg.org/multipage/interaction.html#locked-for-focus
  47. bool m_locked_for_focus { false };
  48. // https://html.spec.whatwg.org/multipage/interaction.html#click-in-progress-flag
  49. bool m_click_in_progress { false };
  50. };
  51. }