/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Web::DOM { class Text : public CharacterData { public: using WrapperType = Bindings::TextWrapper; explicit Text(Document&, String const&); virtual ~Text() override = default; static NonnullRefPtr create_with_global_object(Bindings::WindowObject& window, String const& data); // ^Node virtual FlyString node_name() const override { return "#text"; } virtual bool is_editable() const override { return m_always_editable || CharacterData::is_editable(); } void set_always_editable(bool b) { m_always_editable = b; } void set_owner_input_element(Badge, HTML::HTMLInputElement&); HTML::HTMLInputElement* owner_input_element() { return m_owner_input_element; } ExceptionOr> split_text(size_t offset); protected: Text(Document&, NodeType, String const&); private: WeakPtr m_owner_input_element; bool m_always_editable { false }; }; template<> inline bool Node::fast_is() const { return is_text(); } }