2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2019-10-12 23:26:47 +02:00
|
|
|
#pragma once
|
|
|
|
|
2023-09-07 21:36:05 +12:00
|
|
|
#include <AK/String.h>
|
2021-09-29 16:25:48 +01:00
|
|
|
#include <LibWeb/DOM/ChildNode.h>
|
2020-03-07 10:32:51 +01:00
|
|
|
#include <LibWeb/DOM/Node.h>
|
2020-08-03 20:30:02 +02:00
|
|
|
#include <LibWeb/DOM/NonDocumentTypeChildNode.h>
|
2019-10-12 23:26:47 +02:00
|
|
|
|
2020-07-26 19:37:56 +02:00
|
|
|
namespace Web::DOM {
|
2020-03-07 10:27:02 +01:00
|
|
|
|
2020-08-03 20:30:02 +02:00
|
|
|
class CharacterData
|
|
|
|
: public Node
|
2021-09-29 16:25:48 +01:00
|
|
|
, public ChildNode<CharacterData>
|
2020-08-03 20:30:02 +02:00
|
|
|
, public NonDocumentTypeChildNode<CharacterData> {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(CharacterData, Node);
|
2023-11-19 19:47:52 +01:00
|
|
|
JS_DECLARE_ALLOCATOR(CharacterData);
|
2020-08-03 20:50:45 +02:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
public:
|
2022-03-14 13:21:51 -06:00
|
|
|
virtual ~CharacterData() override = default;
|
2019-10-12 23:26:47 +02:00
|
|
|
|
2023-09-07 21:36:05 +12:00
|
|
|
String const& data() const { return m_data; }
|
|
|
|
void set_data(String const&);
|
2019-10-12 23:26:47 +02:00
|
|
|
|
2023-09-07 21:36:05 +12:00
|
|
|
// FIXME: This should be in UTF-16 code units, not byte size.
|
|
|
|
unsigned length() const { return m_data.bytes().size(); }
|
2020-08-03 20:50:45 +02:00
|
|
|
|
2023-09-07 21:36:05 +12:00
|
|
|
WebIDL::ExceptionOr<String> substring_data(size_t offset, size_t count) const;
|
|
|
|
WebIDL::ExceptionOr<void> append_data(String const&);
|
|
|
|
WebIDL::ExceptionOr<void> insert_data(size_t offset, String const&);
|
2022-09-25 17:03:42 +01:00
|
|
|
WebIDL::ExceptionOr<void> delete_data(size_t offset, size_t count);
|
2023-09-07 21:36:05 +12:00
|
|
|
WebIDL::ExceptionOr<void> replace_data(size_t offset, size_t count, String const&);
|
2022-03-21 17:20:42 +01:00
|
|
|
|
2019-10-12 23:26:47 +02:00
|
|
|
protected:
|
2023-09-07 21:36:05 +12:00
|
|
|
CharacterData(Document&, NodeType, String const&);
|
2019-10-12 23:26:47 +02:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2023-01-10 06:28:20 -05:00
|
|
|
|
2019-10-12 23:26:47 +02:00
|
|
|
private:
|
2023-09-07 21:36:05 +12:00
|
|
|
String m_data;
|
2019-10-12 23:26:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|