mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
LibWeb: Fix some FIXMEs related to ExceptionOr<T>
This fixes a few FIXMEs mentioned in 5beacf08a2
,
which depended on #6075 being fixed.
This commit is contained in:
parent
8ba2b5f36f
commit
9c201767a0
Notes:
sideshowbarker
2024-07-18 20:24:30 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/9c201767a01 Pull-request: https://github.com/SerenityOS/serenity/pull/6293 Issue: https://github.com/SerenityOS/serenity/issues/6075 Reviewed-by: https://github.com/Lubrsi ✅ Reviewed-by: https://github.com/linusg
4 changed files with 16 additions and 24 deletions
|
@ -743,17 +743,13 @@ void Document::adopt_node(Node& node)
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-adoptnode
|
||||
NonnullRefPtr<Node> Document::adopt_node_binding(NonnullRefPtr<Node> node)
|
||||
ExceptionOr<NonnullRefPtr<Node>> Document::adopt_node_binding(NonnullRefPtr<Node> node)
|
||||
{
|
||||
if (is<Document>(*node)) {
|
||||
dbgln("Document::adopt_node_binding: Cannot adopt a document into a document (FIXME: throw as NotSupportedError exception, see issue #6075");
|
||||
return node;
|
||||
}
|
||||
if (is<Document>(*node))
|
||||
return DOM ::NotSupportedError::create("Cannot adopt a document into a document");
|
||||
|
||||
if (is<ShadowRoot>(*node)) {
|
||||
dbgln("Document::adopt_node_binding: Cannot adopt a shadow root into a document (FIXME: throw as HierarchyRequestError exception, see issue #6075");
|
||||
return node;
|
||||
}
|
||||
if (is<ShadowRoot>(*node))
|
||||
return DOM::HierarchyRequestError::create("Cannot adopt a shadow root into a document");
|
||||
|
||||
if (is<DocumentFragment>(*node) && downcast<DocumentFragment>(*node).host())
|
||||
return node;
|
||||
|
|
|
@ -189,7 +189,7 @@ public:
|
|||
void set_quirks_mode(QuirksMode mode) { m_quirks_mode = mode; }
|
||||
|
||||
void adopt_node(Node&);
|
||||
NonnullRefPtr<Node> adopt_node_binding(NonnullRefPtr<Node>);
|
||||
ExceptionOr<NonnullRefPtr<Node>> adopt_node_binding(NonnullRefPtr<Node>);
|
||||
|
||||
const DocumentType* doctype() const;
|
||||
const String& compat_mode() const;
|
||||
|
|
|
@ -280,13 +280,11 @@ void Node::insert_before(NonnullRefPtr<Node> node, RefPtr<Node> child, bool supp
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-node-pre-insert
|
||||
NonnullRefPtr<Node> Node::pre_insert(NonnullRefPtr<Node> node, RefPtr<Node> child)
|
||||
ExceptionOr<NonnullRefPtr<Node>> Node::pre_insert(NonnullRefPtr<Node> node, RefPtr<Node> child)
|
||||
{
|
||||
auto validity_result = ensure_pre_insertion_validity(node, child);
|
||||
if (validity_result.is_exception()) {
|
||||
dbgln("Node::pre_insert: ensure_pre_insertion_validity failed: {}. (FIXME: throw as exception, see issue #6075)", validity_result.exception().message());
|
||||
return node;
|
||||
}
|
||||
if (validity_result.is_exception())
|
||||
return NonnullRefPtr<DOMException>(validity_result.exception());
|
||||
|
||||
auto reference_child = child;
|
||||
if (reference_child == node)
|
||||
|
@ -297,12 +295,10 @@ NonnullRefPtr<Node> Node::pre_insert(NonnullRefPtr<Node> node, RefPtr<Node> chil
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-node-pre-remove
|
||||
NonnullRefPtr<Node> Node::pre_remove(NonnullRefPtr<Node> child)
|
||||
ExceptionOr<NonnullRefPtr<Node>> Node::pre_remove(NonnullRefPtr<Node> child)
|
||||
{
|
||||
if (child->parent() != this) {
|
||||
dbgln("Node::pre_remove: Child doesn't belong to this node. (FIXME: throw NotFoundError DOMException, see issue #6075)");
|
||||
return child;
|
||||
}
|
||||
if (child->parent() != this)
|
||||
return DOM::NotFoundError::create("Child does not belong to this node");
|
||||
|
||||
child->remove();
|
||||
|
||||
|
@ -310,7 +306,7 @@ NonnullRefPtr<Node> Node::pre_remove(NonnullRefPtr<Node> child)
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-node-append
|
||||
NonnullRefPtr<Node> Node::append_child(NonnullRefPtr<Node> node)
|
||||
ExceptionOr<NonnullRefPtr<Node>> Node::append_child(NonnullRefPtr<Node> node)
|
||||
{
|
||||
return pre_insert(node, nullptr);
|
||||
}
|
||||
|
|
|
@ -93,10 +93,10 @@ public:
|
|||
|
||||
virtual bool is_editable() const;
|
||||
|
||||
NonnullRefPtr<Node> pre_insert(NonnullRefPtr<Node>, RefPtr<Node>);
|
||||
NonnullRefPtr<Node> pre_remove(NonnullRefPtr<Node>);
|
||||
ExceptionOr<NonnullRefPtr<Node>> pre_insert(NonnullRefPtr<Node>, RefPtr<Node>);
|
||||
ExceptionOr<NonnullRefPtr<Node>> pre_remove(NonnullRefPtr<Node>);
|
||||
|
||||
NonnullRefPtr<Node> append_child(NonnullRefPtr<Node>);
|
||||
ExceptionOr<NonnullRefPtr<Node>> append_child(NonnullRefPtr<Node>);
|
||||
void insert_before(NonnullRefPtr<Node> node, RefPtr<Node> child, bool suppress_observers = false);
|
||||
void remove(bool suppress_observers = false);
|
||||
void remove_all_children(bool suppress_observers = false);
|
||||
|
|
Loading…
Reference in a new issue