1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 11:45:06 +00:00
serenity/Userland/Libraries/LibWeb/DOM/Text.h
Timothy Flynn 2692db8699 LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errors
Note that as of this commit, there aren't any such throwers, and the
call site in Heap::allocate will drop exceptions on the floor. This
commit only serves to change the declaration of the overrides, make sure
they return an empty value, and to propagate OOM errors frm their base
initialize invocations.
2023-01-29 00:02:45 +00:00

54 lines
1.6 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/DeprecatedFlyString.h>
#include <AK/DeprecatedString.h>
#include <LibWeb/DOM/CharacterData.h>
namespace Web::DOM {
class Text : public CharacterData {
WEB_PLATFORM_OBJECT(Text, CharacterData);
public:
virtual ~Text() override = default;
static JS::NonnullGCPtr<Text> construct_impl(JS::Realm& realm, DeprecatedString const& data);
// ^Node
virtual DeprecatedFlyString 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&);
HTML::HTMLInputElement* owner_input_element() { return m_owner_input_element.ptr(); }
WebIDL::ExceptionOr<JS::NonnullGCPtr<Text>> split_text(size_t offset);
bool is_password_input() const { return m_is_password_input; }
void set_is_password_input(Badge<HTML::HTMLInputElement>, bool b) { m_is_password_input = b; }
protected:
Text(Document&, DeprecatedString const&);
Text(Document&, NodeType, DeprecatedString const&);
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
private:
JS::GCPtr<HTML::HTMLInputElement> m_owner_input_element;
bool m_always_editable { false };
bool m_is_password_input { false };
};
template<>
inline bool Node::fast_is<Text>() const { return is_text(); }
}