ladybird/Userland/Libraries/LibWeb/DOM/CharacterData.h
Andreas Kling bfd354492e LibWeb: Put most LibWeb GC objects in type-specific heap blocks
With this change, we now have ~1200 CellAllocators across both LibJS and
LibWeb in a normal WebContent instance.

This gives us a minimum heap size of 4.7 MiB in the scenario where we
only have one cell allocated per type. Of course, in practice there will
be many more of each type, so the effective overhead is quite a bit
smaller than that in practice.

I left a few types unconverted to this mechanism because I got tired of
doing this. :^)
2023-11-19 22:00:48 +01:00

47 lines
1.3 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/String.h>
#include <LibWeb/DOM/ChildNode.h>
#include <LibWeb/DOM/Node.h>
#include <LibWeb/DOM/NonDocumentTypeChildNode.h>
namespace Web::DOM {
class CharacterData
: public Node
, public ChildNode<CharacterData>
, public NonDocumentTypeChildNode<CharacterData> {
WEB_PLATFORM_OBJECT(CharacterData, Node);
JS_DECLARE_ALLOCATOR(CharacterData);
public:
virtual ~CharacterData() override = default;
String const& data() const { return m_data; }
void set_data(String const&);
// FIXME: This should be in UTF-16 code units, not byte size.
unsigned length() const { return m_data.bytes().size(); }
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&);
WebIDL::ExceptionOr<void> delete_data(size_t offset, size_t count);
WebIDL::ExceptionOr<void> replace_data(size_t offset, size_t count, String const&);
protected:
CharacterData(Document&, NodeType, String const&);
virtual void initialize(JS::Realm&) override;
private:
String m_data;
};
}