diff options
Diffstat (limited to 'Userland')
36 files changed, 123 insertions, 121 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp index 6d32dc4bf7..cc9e0091d6 100644 --- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp +++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp @@ -395,7 +395,7 @@ JS::VM& main_thread_vm() } // https://dom.spec.whatwg.org/#queue-a-mutation-observer-compound-microtask -void queue_mutation_observer_microtask(DOM::Document& document) +void queue_mutation_observer_microtask(DOM::Document const& document) { auto& vm = main_thread_vm(); auto& custom_data = verify_cast<WebEngineCustomData>(*vm.custom_data()); diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h index 2e7b7a6de3..4000cbf8ad 100644 --- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h +++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h @@ -52,7 +52,7 @@ struct WebEngineCustomJobCallbackData final : public JS::JobCallback::CustomData HTML::Script* active_script(); JS::VM& main_thread_vm(); -void queue_mutation_observer_microtask(DOM::Document&); +void queue_mutation_observer_microtask(DOM::Document const&); NonnullOwnPtr<JS::ExecutionContext> create_a_new_javascript_realm(JS::VM&, Function<JS::Object*(JS::Realm&)> create_global_object, Function<JS::Object*(JS::Realm&)> create_global_this_value); } diff --git a/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp b/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp index 6c3766c645..9cce5645f1 100644 --- a/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp +++ b/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp @@ -18,7 +18,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<AccessibilityTreeNode>> AccessibilityTreeNo return MUST_OR_THROW_OOM(document->heap().allocate<AccessibilityTreeNode>(document->realm(), value)); } -AccessibilityTreeNode::AccessibilityTreeNode(JS::GCPtr<DOM::Node> value) +AccessibilityTreeNode::AccessibilityTreeNode(JS::GCPtr<DOM::Node const> value) : m_value(value) { m_children = {}; @@ -29,7 +29,7 @@ void AccessibilityTreeNode::serialize_tree_as_json(JsonObjectSerializer<StringBu if (value()->is_document()) { VERIFY_NOT_REACHED(); } else if (value()->is_element()) { - auto const* element = static_cast<DOM::Element*>(value().ptr()); + auto const* element = static_cast<DOM::Element const*>(value().ptr()); if (element->include_in_accessibility_tree()) { MUST(object.add("type"sv, "element"sv)); @@ -53,7 +53,7 @@ void AccessibilityTreeNode::serialize_tree_as_json(JsonObjectSerializer<StringBu } else if (value()->is_text()) { MUST(object.add("type"sv, "text"sv)); - auto const* text_node = static_cast<DOM::Text*>(value().ptr()); + auto const* text_node = static_cast<DOM::Text const*>(value().ptr()); MUST(object.add("text"sv, text_node->data())); } @@ -73,7 +73,7 @@ void AccessibilityTreeNode::serialize_tree_as_json(JsonObjectSerializer<StringBu void AccessibilityTreeNode::visit_edges(Visitor& visitor) { Base::visit_edges(visitor); - visitor.visit(*value()); + visitor.visit(value()); for (auto child : children()) child->visit_edges(visitor); } diff --git a/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.h b/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.h index bfa556b4ad..84f47be048 100644 --- a/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.h +++ b/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.h @@ -20,8 +20,8 @@ public: static WebIDL::ExceptionOr<JS::NonnullGCPtr<AccessibilityTreeNode>> create(Document*, DOM::Node const*); virtual ~AccessibilityTreeNode() override = default; - JS::GCPtr<DOM::Node> value() const { return m_value; } - void set_value(JS::GCPtr<DOM::Node> value) { m_value = value; } + JS::GCPtr<DOM::Node const> value() const { return m_value; } + void set_value(JS::GCPtr<DOM::Node const> value) { m_value = value; } Vector<AccessibilityTreeNode*> children() const { return m_children; } void append_child(AccessibilityTreeNode* child) { m_children.append(child); } @@ -31,9 +31,9 @@ protected: virtual void visit_edges(Visitor&) override; private: - explicit AccessibilityTreeNode(JS::GCPtr<DOM::Node>); + explicit AccessibilityTreeNode(JS::GCPtr<DOM::Node const>); - JS::GCPtr<DOM::Node> m_value; + JS::GCPtr<DOM::Node const> m_value; Vector<AccessibilityTreeNode*> m_children; }; diff --git a/Userland/Libraries/LibWeb/DOM/Attr.cpp b/Userland/Libraries/LibWeb/DOM/Attr.cpp index 915689cbec..fc5ce191f6 100644 --- a/Userland/Libraries/LibWeb/DOM/Attr.cpp +++ b/Userland/Libraries/LibWeb/DOM/Attr.cpp @@ -45,11 +45,6 @@ void Attr::visit_edges(Cell::Visitor& visitor) visitor.visit(m_owner_element.ptr()); } -Element* Attr::owner_element() -{ - return m_owner_element.ptr(); -} - Element const* Attr::owner_element() const { return m_owner_element.ptr(); @@ -79,7 +74,7 @@ void Attr::set_value(DeprecatedString value) } // https://dom.spec.whatwg.org/#handle-attribute-changes -void Attr::handle_attribute_changes(Element& element, DeprecatedString const& old_value, [[maybe_unused]] DeprecatedString const& new_value) +void Attr::handle_attribute_changes(Element const& element, DeprecatedString const& old_value, [[maybe_unused]] DeprecatedString const& new_value) { // 1. Queue a mutation record of "attributes" for element with attribute’s local name, attribute’s namespace, oldValue, « », « », null, and null. auto added_node_list = StaticNodeList::create(realm(), {}).release_value_but_fixme_should_propagate_errors(); diff --git a/Userland/Libraries/LibWeb/DOM/Attr.h b/Userland/Libraries/LibWeb/DOM/Attr.h index 5fb1ecbfa9..d3d88bb69d 100644 --- a/Userland/Libraries/LibWeb/DOM/Attr.h +++ b/Userland/Libraries/LibWeb/DOM/Attr.h @@ -33,14 +33,13 @@ public: DeprecatedString const& value() const { return m_value; } void set_value(DeprecatedString value); - Element* owner_element(); Element const* owner_element() const; void set_owner_element(Element const* owner_element); // Always returns true: https://dom.spec.whatwg.org/#dom-attr-specified constexpr bool specified() const { return true; } - void handle_attribute_changes(Element&, DeprecatedString const& old_value, DeprecatedString const& new_value); + void handle_attribute_changes(Element const&, DeprecatedString const& old_value, DeprecatedString const& new_value); private: Attr(Document&, QualifiedName, DeprecatedString value, Element const*); @@ -50,7 +49,7 @@ private: QualifiedName m_qualified_name; DeprecatedString m_value; - JS::GCPtr<Element> m_owner_element; + JS::GCPtr<Element const> m_owner_element; }; template<> diff --git a/Userland/Libraries/LibWeb/DOM/ChildNode.h b/Userland/Libraries/LibWeb/DOM/ChildNode.h index c4304fd536..1de358115e 100644 --- a/Userland/Libraries/LibWeb/DOM/ChildNode.h +++ b/Userland/Libraries/LibWeb/DOM/ChildNode.h @@ -117,9 +117,9 @@ protected: ChildNode() = default; private: - JS::GCPtr<Node> viable_previous_sibling_for_insertion(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes) const + JS::GCPtr<Node> viable_previous_sibling_for_insertion(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes) { - auto* node = static_cast<NodeType const*>(this); + auto* node = static_cast<NodeType*>(this); while (auto* previous_sibling = node->previous_sibling()) { bool contained_in_nodes = false; @@ -142,9 +142,9 @@ private: return nullptr; } - JS::GCPtr<Node> viable_nest_sibling_for_insertion(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes) const + JS::GCPtr<Node> viable_nest_sibling_for_insertion(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes) { - auto* node = static_cast<NodeType const*>(this); + auto* node = static_cast<NodeType*>(this); while (auto* next_sibling = node->next_sibling()) { bool contained_in_nodes = false; diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp index ba0fddd7a1..ab85a1cf59 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp @@ -52,14 +52,14 @@ inline void replace_in_ordered_set(Vector<DeprecatedString>& set, StringView ite namespace Web::DOM { -WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMTokenList>> DOMTokenList::create(Element const& associated_element, DeprecatedFlyString associated_attribute) +WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMTokenList>> DOMTokenList::create(Element& associated_element, DeprecatedFlyString associated_attribute) { auto& realm = associated_element.realm(); return MUST_OR_THROW_OOM(realm.heap().allocate<DOMTokenList>(realm, associated_element, move(associated_attribute))); } // https://dom.spec.whatwg.org/#ref-for-domtokenlist%E2%91%A0%E2%91%A2 -DOMTokenList::DOMTokenList(Element const& associated_element, DeprecatedFlyString associated_attribute) +DOMTokenList::DOMTokenList(Element& associated_element, DeprecatedFlyString associated_attribute) : Bindings::LegacyPlatformObject(associated_element.realm()) , m_associated_element(associated_element) , m_associated_attribute(move(associated_attribute)) diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.h b/Userland/Libraries/LibWeb/DOM/DOMTokenList.h index 8c88ab14c3..84d859d80f 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.h +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.h @@ -24,7 +24,7 @@ class DOMTokenList final : public Bindings::LegacyPlatformObject { WEB_PLATFORM_OBJECT(DOMTokenList, Bindings::LegacyPlatformObject); public: - static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMTokenList>> create(Element const& associated_element, DeprecatedFlyString associated_attribute); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMTokenList>> create(Element& associated_element, DeprecatedFlyString associated_attribute); ~DOMTokenList() = default; void associated_attribute_changed(StringView value); @@ -44,7 +44,7 @@ public: void set_value(DeprecatedString value); private: - DOMTokenList(Element const& associated_element, DeprecatedFlyString associated_attribute); + DOMTokenList(Element& associated_element, DeprecatedFlyString associated_attribute); virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 9ec12f1951..97700e6617 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -754,7 +754,7 @@ Vector<CSS::BackgroundLayerData> const* Document::background_layers() const void Document::update_base_element(Badge<HTML::HTMLBaseElement>) { - JS::GCPtr<HTML::HTMLBaseElement> base_element; + JS::GCPtr<HTML::HTMLBaseElement const> base_element; for_each_in_subtree_of_type<HTML::HTMLBaseElement>([&base_element](HTML::HTMLBaseElement const& base_element_in_tree) { if (base_element_in_tree.has_attribute(HTML::AttributeNames::href)) { @@ -768,7 +768,7 @@ void Document::update_base_element(Badge<HTML::HTMLBaseElement>) m_first_base_element_with_href_in_tree_order = base_element; } -JS::GCPtr<HTML::HTMLBaseElement> Document::first_base_element_with_href_in_tree_order() const +JS::GCPtr<HTML::HTMLBaseElement const> Document::first_base_element_with_href_in_tree_order() const { return m_first_base_element_with_href_in_tree_order; } diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index d13b507295..18ea750466 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -106,7 +106,7 @@ public: AK::URL base_url() const; void update_base_element(Badge<HTML::HTMLBaseElement>); - JS::GCPtr<HTML::HTMLBaseElement> first_base_element_with_href_in_tree_order() const; + JS::GCPtr<HTML::HTMLBaseElement const> first_base_element_with_href_in_tree_order() const; DeprecatedString url_string() const { return m_url.to_deprecated_string(); } DeprecatedString document_uri() const { return m_url.to_deprecated_string(); } @@ -611,7 +611,7 @@ private: JS::GCPtr<Selection::Selection> m_selection; // NOTE: This is a cache to make finding the first <base href> element O(1). - JS::GCPtr<HTML::HTMLBaseElement> m_first_base_element_with_href_in_tree_order; + JS::GCPtr<HTML::HTMLBaseElement const> m_first_base_element_with_href_in_tree_order; }; } diff --git a/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp b/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp index d5118f5311..9fe81a39b3 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp +++ b/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp @@ -12,12 +12,12 @@ namespace Web::DOM { -WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationRecord>> MutationRecord::create(JS::Realm& realm, DeprecatedFlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value) +WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationRecord>> MutationRecord::create(JS::Realm& realm, DeprecatedFlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value) { return MUST_OR_THROW_OOM(realm.heap().allocate<MutationRecord>(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value)); } -MutationRecord::MutationRecord(JS::Realm& realm, DeprecatedFlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value) +MutationRecord::MutationRecord(JS::Realm& realm, DeprecatedFlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value) : PlatformObject(realm) , m_type(type) , m_target(JS::make_handle(target)) diff --git a/Userland/Libraries/LibWeb/DOM/MutationRecord.h b/Userland/Libraries/LibWeb/DOM/MutationRecord.h index 183d30ce34..14c99a5826 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationRecord.h +++ b/Userland/Libraries/LibWeb/DOM/MutationRecord.h @@ -15,7 +15,7 @@ class MutationRecord : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(MutationRecord, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationRecord>> create(JS::Realm&, DeprecatedFlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value); + static WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationRecord>> create(JS::Realm&, DeprecatedFlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value); virtual ~MutationRecord() override; @@ -30,13 +30,13 @@ public: DeprecatedString const& old_value() const { return m_old_value; } private: - MutationRecord(JS::Realm& realm, DeprecatedFlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value); + MutationRecord(JS::Realm& realm, DeprecatedFlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value); virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; DeprecatedFlyString m_type; - JS::GCPtr<Node> m_target; + JS::GCPtr<Node const> m_target; JS::GCPtr<NodeList> m_added_nodes; JS::GCPtr<NodeList> m_removed_nodes; JS::GCPtr<Node> m_previous_sibling; diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index d4540cceed..df322dcd44 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -1390,7 +1390,7 @@ Painting::PaintableBox const* Node::paint_box() const } // https://dom.spec.whatwg.org/#queue-a-mutation-record -void Node::queue_mutation_record(DeprecatedFlyString const& type, DeprecatedString attribute_name, DeprecatedString attribute_namespace, DeprecatedString old_value, JS::NonnullGCPtr<NodeList> added_nodes, JS::NonnullGCPtr<NodeList> removed_nodes, Node* previous_sibling, Node* next_sibling) +void Node::queue_mutation_record(DeprecatedFlyString const& type, DeprecatedString attribute_name, DeprecatedString attribute_namespace, DeprecatedString old_value, JS::NonnullGCPtr<NodeList> added_nodes, JS::NonnullGCPtr<NodeList> removed_nodes, Node* previous_sibling, Node* next_sibling) const { // NOTE: We defer garbage collection until the end of the scope, since we can't safely use MutationObserver* as a hashmap key otherwise. // FIXME: This is a total hack. @@ -1401,7 +1401,7 @@ void Node::queue_mutation_record(DeprecatedFlyString const& type, DeprecatedStri OrderedHashMap<MutationObserver*, DeprecatedString> interested_observers; // 2. Let nodes be the inclusive ancestors of target. - Vector<JS::Handle<Node>> nodes; + Vector<JS::Handle<Node const>> nodes; nodes.append(JS::make_handle(*this)); for (auto* parent_node = parent(); parent_node; parent_node = parent_node->parent()) @@ -1558,18 +1558,18 @@ bool Node::is_following(Node const& other) const return false; } -void Node::build_accessibility_tree(AccessibilityTreeNode& parent) const +void Node::build_accessibility_tree(AccessibilityTreeNode& parent) { if (is_uninteresting_whitespace_node()) return; if (is_document()) { - auto const* document = static_cast<DOM::Document const*>(this); - auto const* document_element = document->document_element(); + auto* document = static_cast<DOM::Document*>(this); + auto* document_element = document->document_element(); if (document_element) { parent.set_value(document_element); if (document_element->has_child_nodes()) - document_element->for_each_child([&parent](DOM::Node const& child) { + document_element->for_each_child([&parent](DOM::Node& child) { child.build_accessibility_tree(parent); }); } @@ -1580,7 +1580,7 @@ void Node::build_accessibility_tree(AccessibilityTreeNode& parent) const return; if (element->include_in_accessibility_tree()) { - auto current_node = AccessibilityTreeNode::create(const_cast<Document*>(&this->document()), this).release_value_but_fixme_should_propagate_errors(); + auto current_node = AccessibilityTreeNode::create(&document(), this).release_value_but_fixme_should_propagate_errors(); parent.append_child(current_node); if (has_child_nodes()) { for_each_child([¤t_node](DOM::Node& child) { @@ -1593,7 +1593,7 @@ void Node::build_accessibility_tree(AccessibilityTreeNode& parent) const }); } } else if (is_text()) { - parent.append_child(AccessibilityTreeNode::create(const_cast<Document*>(&this->document()), this).release_value_but_fixme_should_propagate_errors()); + parent.append_child(AccessibilityTreeNode::create(&document(), this).release_value_but_fixme_should_propagate_errors()); if (has_child_nodes()) { for_each_child([&parent](DOM::Node& child) { child.build_accessibility_tree(parent); diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h index ca542ce624..172fc6a756 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.h +++ b/Userland/Libraries/LibWeb/DOM/Node.h @@ -224,7 +224,7 @@ public: void add_registered_observer(RegisteredObserver& registered_observer) { m_registered_observer_list.append(registered_observer); } - void queue_mutation_record(DeprecatedFlyString const& type, DeprecatedString attribute_name, DeprecatedString attribute_namespace, DeprecatedString old_value, JS::NonnullGCPtr<NodeList> added_nodes, JS::NonnullGCPtr<NodeList> removed_nodes, Node* previous_sibling, Node* next_sibling); + void queue_mutation_record(DeprecatedFlyString const& type, DeprecatedString attribute_name, DeprecatedString attribute_namespace, DeprecatedString old_value, JS::NonnullGCPtr<NodeList> added_nodes, JS::NonnullGCPtr<NodeList> removed_nodes, Node* previous_sibling, Node* next_sibling) const; // https://dom.spec.whatwg.org/#concept-shadow-including-descendant template<typename Callback> @@ -434,7 +434,7 @@ public: template<typename U, typename Callback> IterationDecision for_each_in_inclusive_subtree_of_type(Callback callback) { - if (is<U>(static_cast<Node const&>(*this))) { + if (is<U>(static_cast<Node&>(*this))) { if (callback(static_cast<U&>(*this)) == IterationDecision::Break) return IterationDecision::Break; } @@ -644,7 +644,7 @@ protected: // "Nodes have a strong reference to registered observers in their registered observer list." https://dom.spec.whatwg.org/#garbage-collection Vector<RegisteredObserver&> m_registered_observer_list; - void build_accessibility_tree(AccessibilityTreeNode& parent) const; + void build_accessibility_tree(AccessibilityTreeNode& parent); ErrorOr<String> name_or_description(NameOrDescription, Document const&, HashTable<i32>&) const; diff --git a/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h b/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h index 060e1e1eeb..f4dbe1b7ce 100644 --- a/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h +++ b/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h @@ -17,9 +17,9 @@ namespace Web::DOM { template<typename NodeType> class NonElementParentNode { public: - JS::GCPtr<Element> get_element_by_id(DeprecatedFlyString const& id) const + JS::GCPtr<Element const> get_element_by_id(DeprecatedFlyString const& id) const { - JS::GCPtr<Element> found_element; + JS::GCPtr<Element const> found_element; static_cast<NodeType const*>(this)->template for_each_in_inclusive_subtree_of_type<Element>([&](auto& element) { if (element.attribute(HTML::AttributeNames::id) == id) { found_element = &element; @@ -29,9 +29,18 @@ public: }); return found_element; } + JS::GCPtr<Element> get_element_by_id(DeprecatedFlyString const& id) { - return const_cast<NonElementParentNode const*>(this)->get_element_by_id(id); + JS::GCPtr<Element> found_element; + static_cast<NodeType*>(this)->template for_each_in_inclusive_subtree_of_type<Element>([&](auto& element) { + if (element.attribute(HTML::AttributeNames::id) == id) { + found_element = &element; + return IterationDecision::Break; + } + return IterationDecision::Continue; + }); + return found_element; } protected: diff --git a/Userland/Libraries/LibWeb/DOM/Range.cpp b/Userland/Libraries/LibWeb/DOM/Range.cpp index 4f8d7a5a65..663fd16e51 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.cpp +++ b/Userland/Libraries/LibWeb/DOM/Range.cpp @@ -139,7 +139,7 @@ RelativeBoundaryPointPosition position_of_boundary_point_relative_to_other_bound // 4. If nodeA is an ancestor of nodeB: if (node_a.is_ancestor_of(node_b)) { // 1. Let child be nodeB. - JS::NonnullGCPtr<Node> child = node_b; + JS::NonnullGCPtr<Node const> child = node_b; // 2. While child is not a child of nodeA, set child to its parent. while (!node_a.is_parent_of(child)) { @@ -405,7 +405,7 @@ void Range::collapse(bool to_start) } // https://dom.spec.whatwg.org/#dom-range-selectnodecontents -WebIDL::ExceptionOr<void> Range::select_node_contents(Node const& node) +WebIDL::ExceptionOr<void> Range::select_node_contents(Node& node) { // 1. If node is a doctype, throw an "InvalidNodeTypeError" DOMException. if (is<DocumentType>(node)) @@ -657,7 +657,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract() // 11. Let contained children be a list of all children of common ancestor that are contained in range, in tree order. Vector<JS::NonnullGCPtr<Node>> contained_children; - for (Node const* node = common_ancestor->first_child(); node; node = node->next_sibling()) { + for (Node* node = common_ancestor->first_child(); node; node = node->next_sibling()) { if (contains_node(*node)) contained_children.append(*node); } @@ -983,7 +983,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_the_content // 11. Let contained children be a list of all children of common ancestor that are contained in range, in tree order. Vector<JS::NonnullGCPtr<Node>> contained_children; - for (Node const* node = common_ancestor->first_child(); node; node = node->next_sibling()) { + for (Node* node = common_ancestor->first_child(); node; node = node->next_sibling()) { if (contains_node(*node)) contained_children.append(*node); } diff --git a/Userland/Libraries/LibWeb/DOM/Range.h b/Userland/Libraries/LibWeb/DOM/Range.h index 1f046b75e4..e644d84bfa 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.h +++ b/Userland/Libraries/LibWeb/DOM/Range.h @@ -43,7 +43,7 @@ public: WebIDL::ExceptionOr<void> set_end_after(Node& node); WebIDL::ExceptionOr<void> select_node(Node& node); void collapse(bool to_start); - WebIDL::ExceptionOr<void> select_node_contents(Node const&); + WebIDL::ExceptionOr<void> select_node_contents(Node&); // https://dom.spec.whatwg.org/#dom-range-start_to_start enum HowToCompareBoundaryPoints : u16 { diff --git a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp index 869401c5c8..6274ede44a 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp +++ b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp @@ -42,7 +42,7 @@ JS::ThrowCompletionOr<void> XMLSerializer::initialize(JS::Realm& realm) } // https://w3c.github.io/DOM-Parsing/#dom-xmlserializer-serializetostring -WebIDL::ExceptionOr<DeprecatedString> XMLSerializer::serialize_to_string(JS::NonnullGCPtr<DOM::Node> root) +WebIDL::ExceptionOr<DeprecatedString> XMLSerializer::serialize_to_string(JS::NonnullGCPtr<DOM::Node const> root) { // The serializeToString(root) method must produce an XML serialization of root passing a value of false for the require well-formed parameter, and return the result. return serialize_node_to_xml_string(root, RequireWellFormed::No); @@ -121,10 +121,10 @@ static bool prefix_is_in_prefix_map(DeprecatedString const& prefix, HashMap<Depr return candidates_list_iterator->value.contains_slow(prefix); } -WebIDL::ExceptionOr<DeprecatedString> serialize_node_to_xml_string_impl(JS::NonnullGCPtr<DOM::Node> root, Optional<DeprecatedFlyString>& namespace_, HashMap<DeprecatedFlyString, Vector<DeprecatedString>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed); +WebIDL::ExceptionOr<DeprecatedString> serialize_node_to_xml_string_impl(JS::NonnullGCPtr<DOM::Node const> root, Optional<DeprecatedFlyString>& namespace_, HashMap<DeprecatedFlyString, Vector<DeprecatedString>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed); // https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization -WebIDL::ExceptionOr<DeprecatedString> serialize_node_to_xml_string(JS::NonnullGCPtr<DOM::Node> root, RequireWellFormed require_well_formed) +WebIDL::ExceptionOr<DeprecatedString> serialize_node_to_xml_string(JS::NonnullGCPtr<DOM::Node const> root, RequireWellFormed require_well_formed) { // 1. Let namespace be a context namespace with value null. The context namespace tracks the XML serialization algorithm's current default namespace. // The context namespace is changed when either an Element Node has a default namespace declaration, or the algorithm generates a default namespace declaration @@ -157,7 +157,7 @@ static WebIDL::ExceptionOr<DeprecatedString> serialize_document_type(DOM::Docume static WebIDL::ExceptionOr<DeprecatedString> serialize_processing_instruction(DOM::ProcessingInstruction const& processing_instruction, RequireWellFormed require_well_formed); // https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization-algorithm -WebIDL::ExceptionOr<DeprecatedString> serialize_node_to_xml_string_impl(JS::NonnullGCPtr<DOM::Node> root, Optional<DeprecatedFlyString>& namespace_, HashMap<DeprecatedFlyString, Vector<DeprecatedString>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed) +WebIDL::ExceptionOr<DeprecatedString> serialize_node_to_xml_string_impl(JS::NonnullGCPtr<DOM::Node const> root, Optional<DeprecatedFlyString>& namespace_, HashMap<DeprecatedFlyString, Vector<DeprecatedString>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed) { // Each of the following algorithms for producing an XML serialization of a DOM node take as input a node to serialize and the following arguments: // - A context namespace namespace @@ -173,43 +173,43 @@ WebIDL::ExceptionOr<DeprecatedString> serialize_node_to_xml_string_impl(JS::Nonn if (is<DOM::Element>(*root)) { // -> Element // Run the algorithm for XML serializing an Element node node. - return serialize_element(static_cast<DOM::Element&>(*root), namespace_, namespace_prefix_map, prefix_index, require_well_formed); + return serialize_element(static_cast<DOM::Element const&>(*root), namespace_, namespace_prefix_map, prefix_index, require_well_formed); } if (is<DOM::Document>(*root)) { // -> Document // Run the algorithm for XML serializing a Document node node. - return serialize_document(static_cast<DOM::Document&>(*root), namespace_, namespace_prefix_map, prefix_index, require_well_formed); + return serialize_document(static_cast<DOM::Document const&>(*root), namespace_, namespace_prefix_map, prefix_index, require_well_formed); } if (is<DOM::Comment>(*root)) { // -> Comment // Run the algorithm for XML serializing a Comment node node. - return serialize_comment(static_cast<DOM::Comment&>(*root), require_well_formed); + return serialize_comment(static_cast<DOM::Comment const&>(*root), require_well_formed); } if (is<DOM::Text>(*root) || is<DOM::CDATASection>(*root)) { // -> Text // Run the algorithm for XML serializing a Text node node. - return serialize_text(static_cast<DOM::Text&>(*root), require_well_formed); + return serialize_text(static_cast<DOM::Text const&>(*root), require_well_formed); } if (is<DOM::DocumentFragment>(*root)) { // -> DocumentFragment // Run the algorithm for XML serializing a DocumentFragment node node. - return serialize_document_fragment(static_cast<DOM::DocumentFragment&>(*root), namespace_, namespace_prefix_map, prefix_index, require_well_formed); + return serialize_document_fragment(static_cast<DOM::DocumentFragment const&>(*root), namespace_, namespace_prefix_map, prefix_index, require_well_formed); } if (is<DOM::DocumentType>(*root)) { // -> DocumentType // Run the algorithm for XML serializing a DocumentType node node. - return serialize_document_type(static_cast<DOM::DocumentType&>(*root), require_well_formed); + return serialize_document_type(static_cast<DOM::DocumentType const&>(*root), require_well_formed); } if (is<DOM::ProcessingInstruction>(*root)) { // -> ProcessingInstruction // Run the algorithm for XML serializing a ProcessingInstruction node node. - return serialize_processing_instruction(static_cast<DOM::ProcessingInstruction&>(*root), require_well_formed); + return serialize_processing_instruction(static_cast<DOM::ProcessingInstruction const&>(*root), require_well_formed); } if (is<DOM::Attr>(*root)) { diff --git a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h index 2f82d0d073..411ce23d17 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h +++ b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h @@ -18,7 +18,7 @@ public: virtual ~XMLSerializer() override; - WebIDL::ExceptionOr<DeprecatedString> serialize_to_string(JS::NonnullGCPtr<DOM::Node> root); + WebIDL::ExceptionOr<DeprecatedString> serialize_to_string(JS::NonnullGCPtr<DOM::Node const> root); private: explicit XMLSerializer(JS::Realm&); @@ -31,6 +31,5 @@ enum class RequireWellFormed { Yes, }; -WebIDL::ExceptionOr<DeprecatedString> serialize_node_to_xml_string(JS::NonnullGCPtr<DOM::Node> root, RequireWellFormed require_well_formed); - +WebIDL::ExceptionOr<DeprecatedString> serialize_node_to_xml_string(JS::NonnullGCPtr<DOM::Node const> root, RequireWellFormed require_well_formed); } diff --git a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index ac6a064a73..f7a5480b3a 100644 --- a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -97,7 +97,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Infrastructure::FetchController>> fetch(JS: // response consume body is processResponseConsumeBody, process response end-of-body is processResponseEndOfBody, // task destination is taskDestination, and cross-origin isolated capability is crossOriginIsolatedCapability. auto fetch_params = Infrastructure::FetchParams::create(vm, request, timing_info); - fetch_params->set_algorithms(move(algorithms)); + fetch_params->set_algorithms(algorithms); if (task_destination) fetch_params->set_task_destination({ *task_destination }); fetch_params->set_cross_origin_isolated_capability(cross_origin_isolated_capability); @@ -506,7 +506,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS:: } // https://fetch.spec.whatwg.org/#fetch-finale -WebIDL::ExceptionOr<void> fetch_response_handover(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, Infrastructure::Response const& response) +WebIDL::ExceptionOr<void> fetch_response_handover(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, Infrastructure::Response& response) { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'fetch response handover' with: fetch_params @ {}, response @ {}", &fetch_params, &response); @@ -958,7 +958,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_fetch(JS::Realm& rea } // https://fetch.spec.whatwg.org/#concept-http-redirect-fetch -WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_redirect_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, Infrastructure::Response const& response) +WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_redirect_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, Infrastructure::Response& response) { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'HTTP-redirect fetch' with: fetch_params @ {}, response = {}", &fetch_params, &response); @@ -1103,7 +1103,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet auto request = fetch_params.request(); // 2. Let httpFetchParams be null. - JS::GCPtr<Infrastructure::FetchParams> http_fetch_params; + JS::GCPtr<Infrastructure::FetchParams const> http_fetch_params; // 3. Let httpRequest be null. JS::GCPtr<Infrastructure::Request> http_request; @@ -1151,11 +1151,12 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet // 2. Set httpFetchParams to a copy of fetchParams. // 3. Set httpFetchParams’s request to httpRequest. - http_fetch_params = Infrastructure::FetchParams::create(vm, *http_request, fetch_params.timing_info()); - http_fetch_params->set_algorithms(fetch_params.algorithms()); - http_fetch_params->set_task_destination(fetch_params.task_destination()); - http_fetch_params->set_cross_origin_isolated_capability(fetch_params.cross_origin_isolated_capability()); - http_fetch_params->set_preloaded_response_candidate(fetch_params.preloaded_response_candidate()); + auto new_http_fetch_params = Infrastructure::FetchParams::create(vm, *http_request, fetch_params.timing_info()); + new_http_fetch_params->set_algorithms(fetch_params.algorithms()); + new_http_fetch_params->set_task_destination(fetch_params.task_destination()); + new_http_fetch_params->set_cross_origin_isolated_capability(fetch_params.cross_origin_isolated_capability()); + new_http_fetch_params->set_preloaded_response_candidate(fetch_params.preloaded_response_candidate()); + http_fetch_params = new_http_fetch_params; } // 3. Let includeCredentials be true if one of @@ -1678,7 +1679,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> nonstandard_resource_load } // https://fetch.spec.whatwg.org/#cors-preflight-fetch-0 -WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> cors_preflight_fetch(JS::Realm& realm, Infrastructure::Request const& request) +WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> cors_preflight_fetch(JS::Realm& realm, Infrastructure::Request& request) { dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'CORS-preflight fetch' with request @ {}", &request); diff --git a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.h b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.h index 04d4d46ee4..06c9df0caf 100644 --- a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.h +++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.h @@ -31,12 +31,11 @@ ENUMERATE_BOOL_PARAMS WebIDL::ExceptionOr<JS::NonnullGCPtr<Infrastructure::FetchController>> fetch(JS::Realm&, Infrastructure::Request&, Infrastructure::FetchAlgorithms const&, UseParallelQueue use_parallel_queue = UseParallelQueue::No); WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::Realm&, Infrastructure::FetchParams const&, Recursive recursive = Recursive::No); -WebIDL::ExceptionOr<void> fetch_response_handover(JS::Realm&, Infrastructure::FetchParams const&, Infrastructure::Response const&); +WebIDL::ExceptionOr<void> fetch_response_handover(JS::Realm&, Infrastructure::FetchParams const&, Infrastructure::Response&); WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> scheme_fetch(JS::Realm&, Infrastructure::FetchParams const&); WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_fetch(JS::Realm&, Infrastructure::FetchParams const&, MakeCORSPreflight make_cors_preflight = MakeCORSPreflight::No); -WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_redirect_fetch(JS::Realm&, Infrastructure::FetchParams const&, Infrastructure::Response const&); +WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_redirect_fetch(JS::Realm&, Infrastructure::FetchParams const&, Infrastructure::Response&); WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fetch(JS::Realm&, Infrastructure::FetchParams const&, IsAuthenticationFetch is_authentication_fetch = IsAuthenticationFetch::No, IsNewConnectionFetch is_new_connection_fetch = IsNewConnectionFetch::No); WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> nonstandard_resource_loader_http_network_fetch(JS::Realm&, Infrastructure::FetchParams const&, IncludeCredentials include_credentials = IncludeCredentials::No, IsNewConnectionFetch is_new_connection_fetch = IsNewConnectionFetch::No); -WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> cors_preflight_fetch(JS::Realm&, Infrastructure::Request const&); - +WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> cors_preflight_fetch(JS::Realm&, Infrastructure::Request&); } diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h index 5c2e1f2730..3ef35f1388 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h @@ -34,8 +34,8 @@ public: [[nodiscard]] JS::NonnullGCPtr<FetchController> controller() const { return m_controller; } [[nodiscard]] JS::NonnullGCPtr<FetchTimingInfo> timing_info() const { return m_timing_info; } - [[nodiscard]] JS::NonnullGCPtr<FetchAlgorithms> algorithms() const { return m_algorithms; } - void set_algorithms(JS::NonnullGCPtr<FetchAlgorithms> algorithms) { m_algorithms = algorithms; } + [[nodiscard]] JS::NonnullGCPtr<FetchAlgorithms const> algorithms() const { return m_algorithms; } + void set_algorithms(JS::NonnullGCPtr<FetchAlgorithms const> algorithms) { m_algorithms = algorithms; } [[nodiscard]] TaskDestination& task_destination() { return m_task_destination; } [[nodiscard]] TaskDestination const& task_destination() const { return m_task_destination; } @@ -74,7 +74,7 @@ private: // https://fetch.spec.whatwg.org/#fetch-params-process-response-consume-body // process response consume body (default null) // Null or an algorithm. - JS::NonnullGCPtr<FetchAlgorithms> m_algorithms; + JS::NonnullGCPtr<FetchAlgorithms const> m_algorithms; // https://fetch.spec.whatwg.org/#fetch-params-task-destination // task destination (default null) diff --git a/Userland/Libraries/LibWeb/Fetch/Request.cpp b/Userland/Libraries/LibWeb/Fetch/Request.cpp index e9986723a4..07a090f0e1 100644 --- a/Userland/Libraries/LibWeb/Fetch/Request.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Request.cpp @@ -116,7 +116,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm auto base_url = HTML::relevant_settings_object(*request_object).api_base_url(); // 4. Let signal be null. - DOM::AbortSignal const* input_signal = nullptr; + DOM::AbortSignal* input_signal = nullptr; // 5. If input is a string, then: if (input.has<String>()) { diff --git a/Userland/Libraries/LibWeb/FileAPI/FileList.h b/Userland/Libraries/LibWeb/FileAPI/FileList.h index cd340aeb70..6227c57483 100644 --- a/Userland/Libraries/LibWeb/FileAPI/FileList.h +++ b/Userland/Libraries/LibWeb/FileAPI/FileList.h @@ -25,6 +25,12 @@ public: unsigned long length() const { return m_files.size(); } // https://w3c.github.io/FileAPI/#dfn-item + File* item(size_t index) + { + return index < m_files.size() ? m_files[index].ptr() : nullptr; + } + + // https://w3c.github.io/FileAPI/#dfn-item File const* item(size_t index) const { return index < m_files.size() ? m_files[index].ptr() : nullptr; diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp index 94120c1150..cef6687c0f 100644 --- a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp +++ b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp @@ -256,7 +256,7 @@ void queue_global_task(HTML::Task::Source source, JS::Object& global_object, JS: } // https://html.spec.whatwg.org/#queue-a-microtask -void queue_a_microtask(DOM::Document* document, JS::SafeFunction<void()> steps) +void queue_a_microtask(DOM::Document const* document, JS::SafeFunction<void()> steps) { // 1. If event loop was not given, set event loop to the implied event loop. auto& event_loop = HTML::main_thread_event_loop(); diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.h b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.h index 3827297abe..66410b448e 100644 --- a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.h +++ b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.h @@ -115,7 +115,7 @@ private: EventLoop& main_thread_event_loop(); void old_queue_global_task_with_document(HTML::Task::Source, DOM::Document&, JS::SafeFunction<void()> steps); void queue_global_task(HTML::Task::Source, JS::Object&, JS::SafeFunction<void()> steps); -void queue_a_microtask(DOM::Document*, JS::SafeFunction<void()> steps); +void queue_a_microtask(DOM::Document const*, JS::SafeFunction<void()> steps); void perform_a_microtask_checkpoint(); } diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/Task.cpp b/Userland/Libraries/LibWeb/HTML/EventLoop/Task.cpp index 475383efc4..91f89765a4 100644 --- a/Userland/Libraries/LibWeb/HTML/EventLoop/Task.cpp +++ b/Userland/Libraries/LibWeb/HTML/EventLoop/Task.cpp @@ -9,7 +9,7 @@ namespace Web::HTML { -Task::Task(Source source, DOM::Document* document, JS::SafeFunction<void()> steps) +Task::Task(Source source, DOM::Document const* document, JS::SafeFunction<void()> steps) : m_source(source) , m_steps(move(steps)) , m_document(JS::make_handle(document)) @@ -30,11 +30,6 @@ bool Task::is_runnable() const return !m_document.ptr() || m_document->is_fully_active(); } -DOM::Document* Task::document() -{ - return m_document.ptr(); -} - DOM::Document const* Task::document() const { return m_document.ptr(); diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/Task.h b/Userland/Libraries/LibWeb/HTML/EventLoop/Task.h index 4b84809630..a850df2152 100644 --- a/Userland/Libraries/LibWeb/HTML/EventLoop/Task.h +++ b/Userland/Libraries/LibWeb/HTML/EventLoop/Task.h @@ -31,7 +31,7 @@ public: JavaScriptEngine, }; - static NonnullOwnPtr<Task> create(Source source, DOM::Document* document, JS::SafeFunction<void()> steps) + static NonnullOwnPtr<Task> create(Source source, DOM::Document const* document, JS::SafeFunction<void()> steps) { return adopt_own(*new Task(source, document, move(steps))); } @@ -40,17 +40,16 @@ public: Source source() const { return m_source; } void execute(); - DOM::Document* document(); DOM::Document const* document() const; bool is_runnable() const; private: - Task(Source, DOM::Document*, JS::SafeFunction<void()> steps); + Task(Source, DOM::Document const*, JS::SafeFunction<void()> steps); Source m_source { Source::Unspecified }; JS::SafeFunction<void()> m_steps; - JS::Handle<DOM::Document> m_document; + JS::Handle<DOM::Document const> m_document; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 8b9943944c..9aa7ca591e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -350,7 +350,7 @@ void HTMLScriptElement::prepare_script() else if (m_script_type == ScriptType::Module) { // Fetch an external module script graph given url, settings object, options, and onComplete. // FIXME: Pass options. - fetch_external_module_script_graph(url, settings_object, [this](auto const* result) { + fetch_external_module_script_graph(url, settings_object, [this](auto* result) { // 1. Mark as ready el given result. if (!result) mark_as_ready(ResultState::Null {}); @@ -382,7 +382,7 @@ void HTMLScriptElement::prepare_script() // 2. Fetch an inline module script graph, given source text, base URL, settings object, options, and with the following steps given result: // FIXME: Pass options - fetch_inline_module_script_graph(m_document->url().to_deprecated_string(), source_text, base_url, document().relevant_settings_object(), [this](auto const* result) { + fetch_inline_module_script_graph(m_document->url().to_deprecated_string(), source_text, base_url, document().relevant_settings_object(), [this](auto* result) { // 1. Mark as ready el given result. if (!result) mark_as_ready(ResultState::Null {}); diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp index cb480c1baf..4a4ec18666 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp @@ -616,7 +616,7 @@ HTMLParser::AdjustedInsertionLocation HTMLParser::find_appropriate_place_for_ins return adjusted_insertion_location; } -JS::NonnullGCPtr<DOM::Element> HTMLParser::create_element_for(HTMLToken const& token, DeprecatedFlyString const& namespace_, DOM::Node const& intended_parent) +JS::NonnullGCPtr<DOM::Element> HTMLParser::create_element_for(HTMLToken const& token, DeprecatedFlyString const& namespace_, DOM::Node& intended_parent) { // FIXME: 1. If the active speculative HTML parser is not null, then return the result of creating a speculative mock element given given namespace, the tag name of the given token, and the attributes of the given token. // FIXME: 2. Otherwise, optionally create a speculative mock element given given namespace, the tag name of the given token, and the attributes of the given token. @@ -3562,7 +3562,7 @@ DeprecatedString HTMLParser::serialize_html_fragment(DOM::Node const& node) { // The algorithm takes as input a DOM Element, Document, or DocumentFragment referred to as the node. VERIFY(node.is_element() || node.is_document() || node.is_document_fragment()); - JS::NonnullGCPtr<DOM::Node> actual_node = node; + JS::NonnullGCPtr<DOM::Node const> actual_node = node; if (is<DOM::Element>(node)) { auto& element = verify_cast<DOM::Element>(node); diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h index 1fc9841b9e..cb0257e755 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h @@ -119,7 +119,7 @@ private: void generate_implied_end_tags(DeprecatedFlyString const& exception = {}); void generate_all_implied_end_tags_thoroughly(); - JS::NonnullGCPtr<DOM::Element> create_element_for(HTMLToken const&, DeprecatedFlyString const& namespace_, DOM::Node const& intended_parent); + JS::NonnullGCPtr<DOM::Element> create_element_for(HTMLToken const&, DeprecatedFlyString const& namespace_, DOM::Node& intended_parent); struct AdjustedInsertionLocation { JS::GCPtr<DOM::Node> parent; diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h index b2d2fae0f2..1b30e5c40c 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h +++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h @@ -45,7 +45,7 @@ public: // https://html.spec.whatwg.org/multipage/workers.html#the-workerglobalscope-common-interface // https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-self - JS::NonnullGCPtr<WorkerGlobalScope> self() const { return *this; } + JS::NonnullGCPtr<WorkerGlobalScope const> self() const { return *this; } JS::NonnullGCPtr<WorkerLocation> location() const; JS::NonnullGCPtr<WorkerNavigator> navigator() const; diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index b4ef6f2476..b66df8c6fd 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -24,7 +24,7 @@ namespace Web { -static JS::GCPtr<DOM::Node> dom_node_for_event_dispatch(Painting::Paintable const& paintable) +static JS::GCPtr<DOM::Node> dom_node_for_event_dispatch(Painting::Paintable& paintable) { if (auto node = paintable.mouse_event_target()) return node; @@ -35,7 +35,7 @@ static JS::GCPtr<DOM::Node> dom_node_for_event_dispatch(Painting::Paintable cons return nullptr; } -static bool parent_element_for_event_dispatch(Painting::Paintable const& paintable, JS::GCPtr<DOM::Node>& node, Layout::Node const*& layout_node) +static bool parent_element_for_event_dispatch(Painting::Paintable& paintable, JS::GCPtr<DOM::Node>& node, Layout::Node*& layout_node) { layout_node = &paintable.layout_node(); while (layout_node && node && !node->is_element() && layout_node->parent()) { @@ -180,7 +180,7 @@ bool EventHandler::handle_mousewheel(CSSPixelPoint position, unsigned button, un } // Search for the first parent of the hit target that's an element. - Layout::Node const* layout_node; + Layout::Node* layout_node; if (!parent_element_for_event_dispatch(*paintable, node, layout_node)) return false; @@ -240,7 +240,7 @@ bool EventHandler::handle_mouseup(CSSPixelPoint position, unsigned button, unsig // Search for the first parent of the hit target that's an element. // "The click event type MUST be dispatched on the topmost event target indicated by the pointer." (https://www.w3.org/TR/uievents/#event-type-click) // "The topmost event target MUST be the element highest in the rendering order which is capable of being an event target." (https://www.w3.org/TR/uievents/#topmost-event-target) - Layout::Node const* layout_node; + Layout::Node* layout_node; if (!parent_element_for_event_dispatch(*paintable, node, layout_node)) { // FIXME: This is pretty ugly but we need to bail out here. goto after_node_use; @@ -272,7 +272,7 @@ bool EventHandler::handle_mouseup(CSSPixelPoint position, unsigned button, unsig // implemented in BrowsingContext::choose_a_browsing_context: // // https://html.spec.whatwg.org/multipage/browsers.html#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name - if (JS::GCPtr<HTML::HTMLAnchorElement> link = node->enclosing_link_element()) { + if (JS::GCPtr<HTML::HTMLAnchorElement const> link = node->enclosing_link_element()) { JS::NonnullGCPtr<DOM::Document> document = *m_browsing_context.active_document(); auto href = link->href(); auto url = document->parse_url(href); @@ -364,7 +364,7 @@ bool EventHandler::handle_mousedown(CSSPixelPoint position, unsigned button, uns // Search for the first parent of the hit target that's an element. // "The click event type MUST be dispatched on the topmost event target indicated by the pointer." (https://www.w3.org/TR/uievents/#event-type-click) // "The topmost event target MUST be the element highest in the rendering order which is capable of being an event target." (https://www.w3.org/TR/uievents/#topmost-event-target) - Layout::Node const* layout_node; + Layout::Node* layout_node; if (!parent_element_for_event_dispatch(*paintable, node, layout_node)) return false; @@ -462,7 +462,7 @@ bool EventHandler::handle_mousemove(CSSPixelPoint position, unsigned buttons, un // Search for the first parent of the hit target that's an element. // "The click event type MUST be dispatched on the topmost event target indicated by the pointer." (https://www.w3.org/TR/uievents/#event-type-click) // "The topmost event target MUST be the element highest in the rendering order which is capable of being an event target." (https://www.w3.org/TR/uievents/#topmost-event-target) - Layout::Node const* layout_node; + Layout::Node* layout_node; bool found_parent_element = parent_element_for_event_dispatch(*paintable, node, layout_node); hovered_node_changed = node.ptr() != document.hovered_node(); document.set_hovered_node(node); @@ -515,7 +515,7 @@ bool EventHandler::handle_mousemove(CSSPixelPoint position, unsigned buttons, un page->client().page_did_request_cursor_change(hovered_node_cursor); if (hovered_node_changed) { - JS::GCPtr<HTML::HTMLElement> hovered_html_element = document.hovered_node() ? document.hovered_node()->enclosing_html_element_with_attribute(HTML::AttributeNames::title) : nullptr; + JS::GCPtr<HTML::HTMLElement const> hovered_html_element = document.hovered_node() ? document.hovered_node()->enclosing_html_element_with_attribute(HTML::AttributeNames::title) : nullptr; if (hovered_html_element && !hovered_html_element->title().is_null()) { page->client().page_did_enter_tooltip_area(m_browsing_context.to_top_level_position(position), hovered_html_element->title()); } else { @@ -570,7 +570,7 @@ bool EventHandler::handle_doubleclick(CSSPixelPoint position, unsigned button, u // Search for the first parent of the hit target that's an element. // "The topmost event target MUST be the element highest in the rendering order which is capable of being an event target." (https://www.w3.org/TR/uievents/#topmost-event-target) - Layout::Node const* layout_node; + Layout::Node* layout_node; if (!parent_element_for_event_dispatch(*paintable, node, layout_node)) return false; diff --git a/Userland/Libraries/LibWeb/Painting/Paintable.cpp b/Userland/Libraries/LibWeb/Painting/Paintable.cpp index e3cfde2461..24839e0bba 100644 --- a/Userland/Libraries/LibWeb/Painting/Paintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/Paintable.cpp @@ -35,7 +35,7 @@ Paintable::DispatchEventOfSameName Paintable::handle_mousemove(Badge<EventHandle bool Paintable::handle_mousewheel(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned, int wheel_delta_x, int wheel_delta_y) { - if (auto* containing_block = this->containing_block()) { + if (auto const* containing_block = this->containing_block()) { if (!containing_block->is_scrollable()) return false; auto new_offset = containing_block->scroll_offset(); @@ -56,7 +56,7 @@ Optional<HitTestResult> Paintable::hit_test(CSSPixelPoint, HitTestType) const Paintable const* Paintable::first_child() const { - auto* layout_child = m_layout_node->first_child(); + auto const* layout_child = m_layout_node->first_child(); for (; layout_child && !layout_child->paintable(); layout_child = layout_child->next_sibling()) ; return layout_child ? layout_child->paintable() : nullptr; @@ -64,7 +64,7 @@ Paintable const* Paintable::first_child() const Paintable const* Paintable::next_sibling() const { - auto* layout_node = m_layout_node->next_sibling(); + auto const* layout_node = m_layout_node->next_sibling(); for (; layout_node && !layout_node->paintable(); layout_node = layout_node->next_sibling()) ; return layout_node ? layout_node->paintable() : nullptr; @@ -72,7 +72,7 @@ Paintable const* Paintable::next_sibling() const Paintable const* Paintable::last_child() const { - auto* layout_child = m_layout_node->last_child(); + auto const* layout_child = m_layout_node->last_child(); for (; layout_child && !layout_child->paintable(); layout_child = layout_child->previous_sibling()) ; return layout_child ? layout_child->paintable() : nullptr; @@ -80,7 +80,7 @@ Paintable const* Paintable::last_child() const Paintable const* Paintable::previous_sibling() const { - auto* layout_node = m_layout_node->previous_sibling(); + auto const* layout_node = m_layout_node->previous_sibling(); for (; layout_node && !layout_node->paintable(); layout_node = layout_node->previous_sibling()) ; return layout_node ? layout_node->paintable() : nullptr; diff --git a/Userland/Libraries/LibWeb/Painting/Paintable.h b/Userland/Libraries/LibWeb/Painting/Paintable.h index c784006646..0a37c9d6bd 100644 --- a/Userland/Libraries/LibWeb/Painting/Paintable.h +++ b/Userland/Libraries/LibWeb/Painting/Paintable.h @@ -143,8 +143,8 @@ protected: virtual void visit_edges(Cell::Visitor&) override; private: - JS::NonnullGCPtr<Layout::Node> m_layout_node; - Optional<JS::GCPtr<Layout::Box>> mutable m_containing_block; + JS::NonnullGCPtr<Layout::Node const> m_layout_node; + Optional<JS::GCPtr<Layout::Box const>> mutable m_containing_block; }; inline DOM::Node* HitTestResult::dom_node() |