1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

LibJS+Everywhere: Propagate Cell::initialize errors from Heap::allocate

Callers that are already in a fallible context will now TRY to allocate
cells. Callers in infallible contexts get a FIXME.
This commit is contained in:
Timothy Flynn 2023-01-28 13:39:44 -05:00 committed by Linus Groh
parent 109b190a19
commit b75b7f0c0d
178 changed files with 565 additions and 565 deletions

View file

@ -743,7 +743,7 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
} else if (is<DocumentType>(this)) {
// DocumentType
auto document_type = verify_cast<DocumentType>(this);
auto document_type_copy = heap().allocate<DocumentType>(realm(), *document);
auto document_type_copy = heap().allocate<DocumentType>(realm(), *document).release_allocated_value_but_fixme_should_propagate_errors();
// Set copys name, public ID, and system ID to those of node.
document_type_copy->set_name(document_type->name());
@ -760,26 +760,26 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
auto text = verify_cast<Text>(this);
// Set copys data to that of node.
auto text_copy = heap().allocate<Text>(realm(), *document, text->data());
auto text_copy = heap().allocate<Text>(realm(), *document, text->data()).release_allocated_value_but_fixme_should_propagate_errors();
copy = move(text_copy);
} else if (is<Comment>(this)) {
// Comment
auto comment = verify_cast<Comment>(this);
// Set copys data to that of node.
auto comment_copy = heap().allocate<Comment>(realm(), *document, comment->data());
auto comment_copy = heap().allocate<Comment>(realm(), *document, comment->data()).release_allocated_value_but_fixme_should_propagate_errors();
copy = move(comment_copy);
} else if (is<ProcessingInstruction>(this)) {
// ProcessingInstruction
auto processing_instruction = verify_cast<ProcessingInstruction>(this);
// Set copys target and data to those of node.
auto processing_instruction_copy = heap().allocate<ProcessingInstruction>(realm(), *document, processing_instruction->data(), processing_instruction->target());
auto processing_instruction_copy = heap().allocate<ProcessingInstruction>(realm(), *document, processing_instruction->data(), processing_instruction->target()).release_allocated_value_but_fixme_should_propagate_errors();
copy = processing_instruction_copy;
}
// Otherwise, Do nothing.
else if (is<DocumentFragment>(this)) {
copy = heap().allocate<DocumentFragment>(realm(), *document);
copy = heap().allocate<DocumentFragment>(realm(), *document).release_allocated_value_but_fixme_should_propagate_errors();
}
// FIXME: 4. Set copys node document and document to copy, if copy is a document, and set copys node document to document otherwise.
@ -1179,7 +1179,7 @@ void Node::string_replace_all(DeprecatedString const& string)
// 2. If string is not the empty string, then set node to a new Text node whose data is string and node document is parents node document.
if (!string.is_empty())
node = heap().allocate<Text>(realm(), document(), string);
node = heap().allocate<Text>(realm(), document(), string).release_allocated_value_but_fixme_should_propagate_errors();
// 3. Replace all with node within parent.
replace_all(node);