/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include namespace Web::DOM { // https://dom.spec.whatwg.org/#characterdata class CharacterData : public Node , public ChildNode , public NonDocumentTypeChildNode { WEB_PLATFORM_OBJECT(CharacterData, Node); GC_DECLARE_ALLOCATOR(CharacterData); public: virtual ~CharacterData() override; String const& data() const { return m_data; } void set_data(String const&); unsigned length_in_utf16_code_units() const { return AK::utf16_code_unit_length_from_utf8(m_data); } WebIDL::ExceptionOr substring_data(size_t offset_in_utf16_code_units, size_t count_in_utf16_code_units) const; WebIDL::ExceptionOr append_data(String const&); WebIDL::ExceptionOr insert_data(size_t offset_in_utf16_code_units, String const&); WebIDL::ExceptionOr delete_data(size_t offset_in_utf16_code_units, size_t count_in_utf16_code_units); WebIDL::ExceptionOr replace_data(size_t offset_in_utf16_code_units, size_t count_in_utf16_code_units, String const&); Unicode::Segmenter& grapheme_segmenter() const; Unicode::Segmenter& word_segmenter() const; protected: CharacterData(Document&, NodeType, String const&); virtual void initialize(JS::Realm&) override; private: String m_data; mutable OwnPtr m_grapheme_segmenter; mutable OwnPtr m_word_segmenter; }; }