HTMLElement.h 1.7 KB

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