Text.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/FlyString.h>
  8. #include <AK/String.h>
  9. #include <LibWeb/DOM/CharacterData.h>
  10. namespace Web::DOM {
  11. class Text final : public CharacterData {
  12. public:
  13. using WrapperType = Bindings::TextWrapper;
  14. explicit Text(Document&, const String&);
  15. virtual ~Text() override = default;
  16. static NonnullRefPtr<Text> create_with_global_object(Bindings::WindowObject& window, String const& data);
  17. // ^Node
  18. virtual FlyString node_name() const override { return "#text"; }
  19. virtual bool is_editable() const override { return m_always_editable || CharacterData::is_editable(); }
  20. void set_always_editable(bool b) { m_always_editable = b; }
  21. void set_owner_input_element(Badge<HTML::HTMLInputElement>, HTML::HTMLInputElement&);
  22. HTML::HTMLInputElement* owner_input_element() { return m_owner_input_element; }
  23. ExceptionOr<NonnullRefPtr<Text>> split_text(size_t offset);
  24. private:
  25. WeakPtr<HTML::HTMLInputElement> m_owner_input_element;
  26. bool m_always_editable { false };
  27. };
  28. }