CharacterData.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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/DeprecatedString.h>
  8. #include <LibWeb/DOM/ChildNode.h>
  9. #include <LibWeb/DOM/Node.h>
  10. #include <LibWeb/DOM/NonDocumentTypeChildNode.h>
  11. namespace Web::DOM {
  12. class CharacterData
  13. : public Node
  14. , public ChildNode<CharacterData>
  15. , public NonDocumentTypeChildNode<CharacterData> {
  16. WEB_PLATFORM_OBJECT(CharacterData, Node);
  17. public:
  18. virtual ~CharacterData() override = default;
  19. DeprecatedString const& data() const { return m_data; }
  20. void set_data(DeprecatedString);
  21. unsigned length() const { return m_data.length(); }
  22. WebIDL::ExceptionOr<DeprecatedString> substring_data(size_t offset, size_t count) const;
  23. WebIDL::ExceptionOr<void> append_data(DeprecatedString const&);
  24. WebIDL::ExceptionOr<void> insert_data(size_t offset, DeprecatedString const&);
  25. WebIDL::ExceptionOr<void> delete_data(size_t offset, size_t count);
  26. WebIDL::ExceptionOr<void> replace_data(size_t offset, size_t count, DeprecatedString const&);
  27. protected:
  28. CharacterData(Document&, NodeType, DeprecatedString const&);
  29. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  30. private:
  31. DeprecatedString m_data;
  32. };
  33. }