HTMLElement.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. // https://html.spec.whatwg.org/multipage/forms.html#category-label
  35. virtual bool is_labelable() const { return false; }
  36. protected:
  37. virtual void parse_attribute(const FlyString& name, const String& value) override;
  38. private:
  39. // ^HTML::GlobalEventHandlers
  40. virtual DOM::EventTarget& global_event_handlers_to_event_target() override { return *this; }
  41. enum class ContentEditableState {
  42. True,
  43. False,
  44. Inherit,
  45. };
  46. ContentEditableState content_editable_state() const;
  47. NonnullRefPtr<DOMStringMap> m_dataset;
  48. // https://html.spec.whatwg.org/multipage/interaction.html#locked-for-focus
  49. bool m_locked_for_focus { false };
  50. // https://html.spec.whatwg.org/multipage/interaction.html#click-in-progress-flag
  51. bool m_click_in_progress { false };
  52. };
  53. }