LibWeb: Make node cloning methods const

This commit is contained in:
Tim Ledbetter 2025-01-11 17:37:08 +00:00 committed by Jelle Raaijmakers
commit a467005855
Notes: github-actions[bot] 2025-01-11 22:11:18 +00:00
20 changed files with 23 additions and 23 deletions

View file

@ -28,7 +28,7 @@ GC::Ref<Attr> Attr::create(Document& document, QualifiedName qualified_name, Str
return document.realm().create<Attr>(document, move(qualified_name), move(value), owner_element); return document.realm().create<Attr>(document, move(qualified_name), move(value), owner_element);
} }
GC::Ref<Attr> Attr::clone(Document& document) GC::Ref<Attr> Attr::clone(Document& document) const
{ {
return realm().create<Attr>(document, m_qualified_name, m_value, nullptr); return realm().create<Attr>(document, m_qualified_name, m_value, nullptr);
} }

View file

@ -20,7 +20,7 @@ class Attr final : public Node {
public: public:
[[nodiscard]] static GC::Ref<Attr> create(Document&, QualifiedName, String value = {}, Element* = nullptr); [[nodiscard]] static GC::Ref<Attr> create(Document&, QualifiedName, String value = {}, Element* = nullptr);
[[nodiscard]] static GC::Ref<Attr> create(Document&, FlyString local_name, String value = {}, Element* = nullptr); [[nodiscard]] static GC::Ref<Attr> create(Document&, FlyString local_name, String value = {}, Element* = nullptr);
GC::Ref<Attr> clone(Document&); GC::Ref<Attr> clone(Document&) const;
virtual ~Attr() override = default; virtual ~Attr() override = default;

View file

@ -1030,7 +1030,7 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Node::replace_child(GC::Ref<Node> node, GC::R
} }
// https://dom.spec.whatwg.org/#concept-node-clone // https://dom.spec.whatwg.org/#concept-node-clone
WebIDL::ExceptionOr<GC::Ref<Node>> Node::clone_node(Document* document, bool subtree, Node* parent) WebIDL::ExceptionOr<GC::Ref<Node>> Node::clone_node(Document* document, bool subtree, Node* parent) const
{ {
// To clone a node given a node node and an optional document document (default nodes node document), // To clone a node given a node node and an optional document document (default nodes node document),
// boolean subtree (default false), and node-or-null parent (default null): // boolean subtree (default false), and node-or-null parent (default null):
@ -1085,7 +1085,7 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Node::clone_node(Document* document, bool sub
} }
// https://dom.spec.whatwg.org/#clone-a-single-node // https://dom.spec.whatwg.org/#clone-a-single-node
WebIDL::ExceptionOr<GC::Ref<Node>> Node::clone_single_node(Document& document) WebIDL::ExceptionOr<GC::Ref<Node>> Node::clone_single_node(Document& document) const
{ {
// To clone a single node given a node node and document document: // To clone a single node given a node node and document document:

View file

@ -199,8 +199,8 @@ public:
WebIDL::ExceptionOr<GC::Ref<Node>> replace_child(GC::Ref<Node> node, GC::Ref<Node> child); WebIDL::ExceptionOr<GC::Ref<Node>> replace_child(GC::Ref<Node> node, GC::Ref<Node> child);
WebIDL::ExceptionOr<GC::Ref<Node>> clone_node(Document* document = nullptr, bool subtree = false, Node* parent = nullptr); WebIDL::ExceptionOr<GC::Ref<Node>> clone_node(Document* document = nullptr, bool subtree = false, Node* parent = nullptr) const;
WebIDL::ExceptionOr<GC::Ref<Node>> clone_single_node(Document&); WebIDL::ExceptionOr<GC::Ref<Node>> clone_single_node(Document&) const;
WebIDL::ExceptionOr<GC::Ref<Node>> clone_node_binding(bool subtree); WebIDL::ExceptionOr<GC::Ref<Node>> clone_node_binding(bool subtree);
// NOTE: This is intended for the JS bindings. // NOTE: This is intended for the JS bindings.
@ -263,7 +263,7 @@ public:
virtual void removed_from(Node*); virtual void removed_from(Node*);
virtual void children_changed() { } virtual void children_changed() { }
virtual void adopted_from(Document&) { } virtual void adopted_from(Document&) { }
virtual WebIDL::ExceptionOr<void> cloned(Node&, bool) { return {}; } virtual WebIDL::ExceptionOr<void> cloned(Node&, bool) const { return {}; }
Layout::Node const* layout_node() const { return m_layout_node; } Layout::Node const* layout_node() const { return m_layout_node; }
Layout::Node* layout_node() { return m_layout_node; } Layout::Node* layout_node() { return m_layout_node; }

View file

@ -612,7 +612,7 @@ void HTMLElement::attribute_changed(FlyString const& name, Optional<String> cons
#undef __ENUMERATE #undef __ENUMERATE
} }
WebIDL::ExceptionOr<void> HTMLElement::cloned(Web::DOM::Node& copy, bool clone_children) WebIDL::ExceptionOr<void> HTMLElement::cloned(Web::DOM::Node& copy, bool clone_children) const
{ {
TRY(Base::cloned(copy, clone_children)); TRY(Base::cloned(copy, clone_children));
TRY(HTMLOrSVGElement::cloned(copy, clone_children)); TRY(HTMLOrSVGElement::cloned(copy, clone_children));

View file

@ -137,7 +137,7 @@ protected:
virtual void initialize(JS::Realm&) override; virtual void initialize(JS::Realm&) override;
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
virtual WebIDL::ExceptionOr<void> cloned(DOM::Node&, bool) override; virtual WebIDL::ExceptionOr<void> cloned(DOM::Node&, bool) const override;
virtual void inserted() override; virtual void inserted() override;
virtual void visit_edges(Cell::Visitor&) override; virtual void visit_edges(Cell::Visitor&) override;

View file

@ -1706,7 +1706,7 @@ void HTMLInputElement::apply_presentational_hints(GC::Ref<CSS::CascadedPropertie
} }
// https://html.spec.whatwg.org/multipage/input.html#the-input-element%3Aconcept-node-clone-ext // https://html.spec.whatwg.org/multipage/input.html#the-input-element%3Aconcept-node-clone-ext
WebIDL::ExceptionOr<void> HTMLInputElement::cloned(DOM::Node& copy, bool subtree) WebIDL::ExceptionOr<void> HTMLInputElement::cloned(DOM::Node& copy, bool subtree) const
{ {
TRY(Base::cloned(copy, subtree)); TRY(Base::cloned(copy, subtree));

View file

@ -183,7 +183,7 @@ public:
virtual void form_associated_element_was_removed(DOM::Node*) override; virtual void form_associated_element_was_removed(DOM::Node*) override;
virtual void form_associated_element_attribute_changed(FlyString const&, Optional<String> const&, Optional<FlyString> const&) override; virtual void form_associated_element_attribute_changed(FlyString const&, Optional<String> const&, Optional<FlyString> const&) override;
virtual WebIDL::ExceptionOr<void> cloned(Node&, bool) override; virtual WebIDL::ExceptionOr<void> cloned(Node&, bool) const override;
GC::Ref<ValidityState const> validity() const; GC::Ref<ValidityState const> validity() const;

View file

@ -78,7 +78,7 @@ void HTMLOrSVGElement<ElementBase>::attribute_changed(FlyString const& local_nam
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#dom-noncedelement-nonce // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#dom-noncedelement-nonce
template<typename ElementBase> template<typename ElementBase>
WebIDL::ExceptionOr<void> HTMLOrSVGElement<ElementBase>::cloned(DOM::Node& copy, bool) WebIDL::ExceptionOr<void> HTMLOrSVGElement<ElementBase>::cloned(DOM::Node& copy, bool) const
{ {
// The cloning steps for elements that include HTMLOrSVGElement given node, copy, and subtree // The cloning steps for elements that include HTMLOrSVGElement given node, copy, and subtree
// are to set copy's [[CryptographicNonce]] to node's [[CryptographicNonce]]. // are to set copy's [[CryptographicNonce]] to node's [[CryptographicNonce]].

View file

@ -26,7 +26,7 @@ public:
protected: protected:
void attribute_changed(FlyString const&, Optional<String> const&, Optional<String> const&, Optional<FlyString> const&); void attribute_changed(FlyString const&, Optional<String> const&, Optional<String> const&, Optional<FlyString> const&);
WebIDL::ExceptionOr<void> cloned(DOM::Node&, bool); WebIDL::ExceptionOr<void> cloned(DOM::Node&, bool) const;
void inserted(); void inserted();
void visit_edges(JS::Cell::Visitor&); void visit_edges(JS::Cell::Visitor&);

View file

@ -651,7 +651,7 @@ void HTMLScriptElement::set_async(bool async)
} }
// https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model:concept-node-clone-ext // https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model:concept-node-clone-ext
WebIDL::ExceptionOr<void> HTMLScriptElement::cloned(Node& copy, bool subtree) WebIDL::ExceptionOr<void> HTMLScriptElement::cloned(Node& copy, bool subtree) const
{ {
TRY(Base::cloned(copy, subtree)); TRY(Base::cloned(copy, subtree));

View file

@ -63,7 +63,7 @@ public:
[[nodiscard]] bool async() const; [[nodiscard]] bool async() const;
void set_async(bool); void set_async(bool);
virtual WebIDL::ExceptionOr<void> cloned(Node&, bool) override; virtual WebIDL::ExceptionOr<void> cloned(Node&, bool) const override;
private: private:
HTMLScriptElement(DOM::Document&, DOM::QualifiedName); HTMLScriptElement(DOM::Document&, DOM::QualifiedName);

View file

@ -46,7 +46,7 @@ void HTMLTemplateElement::adopted_from(DOM::Document&)
} }
// https://html.spec.whatwg.org/multipage/scripting.html#the-template-element:concept-node-clone-ext // https://html.spec.whatwg.org/multipage/scripting.html#the-template-element:concept-node-clone-ext
WebIDL::ExceptionOr<void> HTMLTemplateElement::cloned(Node& copy, bool subtree) WebIDL::ExceptionOr<void> HTMLTemplateElement::cloned(Node& copy, bool subtree) const
{ {
TRY(Base::cloned(copy, subtree)); TRY(Base::cloned(copy, subtree));

View file

@ -24,7 +24,7 @@ public:
void set_template_contents(GC::Ref<DOM::DocumentFragment>); void set_template_contents(GC::Ref<DOM::DocumentFragment>);
virtual void adopted_from(DOM::Document&) override; virtual void adopted_from(DOM::Document&) override;
virtual WebIDL::ExceptionOr<void> cloned(Node& copy, bool clone_children) override; virtual WebIDL::ExceptionOr<void> cloned(Node& copy, bool clone_children) const override;
private: private:
HTMLTemplateElement(DOM::Document&, DOM::QualifiedName); HTMLTemplateElement(DOM::Document&, DOM::QualifiedName);

View file

@ -136,7 +136,7 @@ void HTMLTextAreaElement::clear_algorithm()
} }
// https://html.spec.whatwg.org/multipage/forms.html#the-textarea-element:concept-node-clone-ext // https://html.spec.whatwg.org/multipage/forms.html#the-textarea-element:concept-node-clone-ext
WebIDL::ExceptionOr<void> HTMLTextAreaElement::cloned(DOM::Node& copy, bool subtree) WebIDL::ExceptionOr<void> HTMLTextAreaElement::cloned(DOM::Node& copy, bool subtree) const
{ {
TRY(Base::cloned(copy, subtree)); TRY(Base::cloned(copy, subtree));

View file

@ -64,7 +64,7 @@ public:
virtual void reset_algorithm() override; virtual void reset_algorithm() override;
virtual void clear_algorithm() override; virtual void clear_algorithm() override;
virtual WebIDL::ExceptionOr<void> cloned(Node&, bool) override; virtual WebIDL::ExceptionOr<void> cloned(Node&, bool) const override;
virtual void form_associated_element_was_inserted() override; virtual void form_associated_element_was_inserted() override;
virtual void form_associated_element_was_removed(DOM::Node*) override; virtual void form_associated_element_was_removed(DOM::Node*) override;

View file

@ -26,7 +26,7 @@ void MathMLElement::attribute_changed(FlyString const& local_name, Optional<Stri
HTMLOrSVGElement::attribute_changed(local_name, old_value, value, namespace_); HTMLOrSVGElement::attribute_changed(local_name, old_value, value, namespace_);
} }
WebIDL::ExceptionOr<void> MathMLElement::cloned(DOM::Node& node, bool clone_children) WebIDL::ExceptionOr<void> MathMLElement::cloned(DOM::Node& node, bool clone_children) const
{ {
TRY(Base::cloned(node, clone_children)); TRY(Base::cloned(node, clone_children));
TRY(HTMLOrSVGElement::cloned(node, clone_children)); TRY(HTMLOrSVGElement::cloned(node, clone_children));

View file

@ -25,7 +25,7 @@ public:
protected: protected:
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
virtual WebIDL::ExceptionOr<void> cloned(DOM::Node&, bool) override; virtual WebIDL::ExceptionOr<void> cloned(DOM::Node&, bool) const override;
virtual void inserted() override; virtual void inserted() override;
virtual GC::Ptr<DOM::EventTarget> global_event_handlers_to_event_target(FlyString const&) override { return *this; } virtual GC::Ptr<DOM::EventTarget> global_event_handlers_to_event_target(FlyString const&) override { return *this; }

View file

@ -83,7 +83,7 @@ void SVGElement::attribute_changed(FlyString const& local_name, Optional<String>
update_use_elements_that_reference_this(); update_use_elements_that_reference_this();
} }
WebIDL::ExceptionOr<void> SVGElement::cloned(DOM::Node& copy, bool clone_children) WebIDL::ExceptionOr<void> SVGElement::cloned(DOM::Node& copy, bool clone_children) const
{ {
TRY(Base::cloned(copy, clone_children)); TRY(Base::cloned(copy, clone_children));
TRY(HTMLOrSVGElement::cloned(copy, clone_children)); TRY(HTMLOrSVGElement::cloned(copy, clone_children));

View file

@ -35,7 +35,7 @@ protected:
virtual void visit_edges(Cell::Visitor&) override; virtual void visit_edges(Cell::Visitor&) override;
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
virtual WebIDL::ExceptionOr<void> cloned(DOM::Node&, bool) override; virtual WebIDL::ExceptionOr<void> cloned(DOM::Node&, bool) const override;
virtual void children_changed() override; virtual void children_changed() override;
virtual void inserted() override; virtual void inserted() override;
virtual void removed_from(Node*) override; virtual void removed_from(Node*) override;