mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:22:46 +00:00 
			
		
		
		
	LibWeb: Fix a few const-ness issues
This commit is contained in:
		
							parent
							
								
									70a2ca7fc0
								
							
						
					
					
						commit
						c0b2fa74ac
					
				
					 36 changed files with 123 additions and 121 deletions
				
			
		|  | @ -395,7 +395,7 @@ JS::VM& main_thread_vm() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // https://dom.spec.whatwg.org/#queue-a-mutation-observer-compound-microtask
 | // 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& vm = main_thread_vm(); | ||||||
|     auto& custom_data = verify_cast<WebEngineCustomData>(*vm.custom_data()); |     auto& custom_data = verify_cast<WebEngineCustomData>(*vm.custom_data()); | ||||||
|  |  | ||||||
|  | @ -52,7 +52,7 @@ struct WebEngineCustomJobCallbackData final : public JS::JobCallback::CustomData | ||||||
| 
 | 
 | ||||||
| HTML::Script* active_script(); | HTML::Script* active_script(); | ||||||
| JS::VM& main_thread_vm(); | 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); | 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); | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -18,7 +18,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<AccessibilityTreeNode>> AccessibilityTreeNo | ||||||
|     return MUST_OR_THROW_OOM(document->heap().allocate<AccessibilityTreeNode>(document->realm(), value)); |     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_value(value) | ||||||
| { | { | ||||||
|     m_children = {}; |     m_children = {}; | ||||||
|  | @ -29,7 +29,7 @@ void AccessibilityTreeNode::serialize_tree_as_json(JsonObjectSerializer<StringBu | ||||||
|     if (value()->is_document()) { |     if (value()->is_document()) { | ||||||
|         VERIFY_NOT_REACHED(); |         VERIFY_NOT_REACHED(); | ||||||
|     } else if (value()->is_element()) { |     } 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()) { |         if (element->include_in_accessibility_tree()) { | ||||||
|             MUST(object.add("type"sv, "element"sv)); |             MUST(object.add("type"sv, "element"sv)); | ||||||
|  | @ -53,7 +53,7 @@ void AccessibilityTreeNode::serialize_tree_as_json(JsonObjectSerializer<StringBu | ||||||
|     } else if (value()->is_text()) { |     } else if (value()->is_text()) { | ||||||
|         MUST(object.add("type"sv, "text"sv)); |         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())); |         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) | void AccessibilityTreeNode::visit_edges(Visitor& visitor) | ||||||
| { | { | ||||||
|     Base::visit_edges(visitor); |     Base::visit_edges(visitor); | ||||||
|     visitor.visit(*value()); |     visitor.visit(value()); | ||||||
|     for (auto child : children()) |     for (auto child : children()) | ||||||
|         child->visit_edges(visitor); |         child->visit_edges(visitor); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -20,8 +20,8 @@ public: | ||||||
|     static WebIDL::ExceptionOr<JS::NonnullGCPtr<AccessibilityTreeNode>> create(Document*, DOM::Node const*); |     static WebIDL::ExceptionOr<JS::NonnullGCPtr<AccessibilityTreeNode>> create(Document*, DOM::Node const*); | ||||||
|     virtual ~AccessibilityTreeNode() override = default; |     virtual ~AccessibilityTreeNode() override = default; | ||||||
| 
 | 
 | ||||||
|     JS::GCPtr<DOM::Node> value() const { return m_value; } |     JS::GCPtr<DOM::Node const> value() const { return m_value; } | ||||||
|     void set_value(JS::GCPtr<DOM::Node> value) { m_value = value; } |     void set_value(JS::GCPtr<DOM::Node const> value) { m_value = value; } | ||||||
|     Vector<AccessibilityTreeNode*> children() const { return m_children; } |     Vector<AccessibilityTreeNode*> children() const { return m_children; } | ||||||
|     void append_child(AccessibilityTreeNode* child) { m_children.append(child); } |     void append_child(AccessibilityTreeNode* child) { m_children.append(child); } | ||||||
| 
 | 
 | ||||||
|  | @ -31,9 +31,9 @@ protected: | ||||||
|     virtual void visit_edges(Visitor&) override; |     virtual void visit_edges(Visitor&) override; | ||||||
| 
 | 
 | ||||||
| private: | 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; |     Vector<AccessibilityTreeNode*> m_children; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -45,11 +45,6 @@ void Attr::visit_edges(Cell::Visitor& visitor) | ||||||
|     visitor.visit(m_owner_element.ptr()); |     visitor.visit(m_owner_element.ptr()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Element* Attr::owner_element() |  | ||||||
| { |  | ||||||
|     return m_owner_element.ptr(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Element const* Attr::owner_element() const | Element const* Attr::owner_element() const | ||||||
| { | { | ||||||
|     return m_owner_element.ptr(); |     return m_owner_element.ptr(); | ||||||
|  | @ -79,7 +74,7 @@ void Attr::set_value(DeprecatedString value) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // https://dom.spec.whatwg.org/#handle-attribute-changes
 | // 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.
 |     // 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(); |     auto added_node_list = StaticNodeList::create(realm(), {}).release_value_but_fixme_should_propagate_errors(); | ||||||
|  |  | ||||||
|  | @ -33,14 +33,13 @@ public: | ||||||
|     DeprecatedString const& value() const { return m_value; } |     DeprecatedString const& value() const { return m_value; } | ||||||
|     void set_value(DeprecatedString value); |     void set_value(DeprecatedString value); | ||||||
| 
 | 
 | ||||||
|     Element* owner_element(); |  | ||||||
|     Element const* owner_element() const; |     Element const* owner_element() const; | ||||||
|     void set_owner_element(Element const* owner_element); |     void set_owner_element(Element const* owner_element); | ||||||
| 
 | 
 | ||||||
|     // Always returns true: https://dom.spec.whatwg.org/#dom-attr-specified
 |     // Always returns true: https://dom.spec.whatwg.org/#dom-attr-specified
 | ||||||
|     constexpr bool specified() const { return true; } |     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: | private: | ||||||
|     Attr(Document&, QualifiedName, DeprecatedString value, Element const*); |     Attr(Document&, QualifiedName, DeprecatedString value, Element const*); | ||||||
|  | @ -50,7 +49,7 @@ private: | ||||||
| 
 | 
 | ||||||
|     QualifiedName m_qualified_name; |     QualifiedName m_qualified_name; | ||||||
|     DeprecatedString m_value; |     DeprecatedString m_value; | ||||||
|     JS::GCPtr<Element> m_owner_element; |     JS::GCPtr<Element const> m_owner_element; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| template<> | template<> | ||||||
|  |  | ||||||
|  | @ -117,9 +117,9 @@ protected: | ||||||
|     ChildNode() = default; |     ChildNode() = default; | ||||||
| 
 | 
 | ||||||
| private: | 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()) { |         while (auto* previous_sibling = node->previous_sibling()) { | ||||||
|             bool contained_in_nodes = false; |             bool contained_in_nodes = false; | ||||||
|  | @ -142,9 +142,9 @@ private: | ||||||
|         return nullptr; |         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()) { |         while (auto* next_sibling = node->next_sibling()) { | ||||||
|             bool contained_in_nodes = false; |             bool contained_in_nodes = false; | ||||||
|  |  | ||||||
|  | @ -52,14 +52,14 @@ inline void replace_in_ordered_set(Vector<DeprecatedString>& set, StringView ite | ||||||
| 
 | 
 | ||||||
| namespace Web::DOM { | 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(); |     auto& realm = associated_element.realm(); | ||||||
|     return MUST_OR_THROW_OOM(realm.heap().allocate<DOMTokenList>(realm, associated_element, move(associated_attribute))); |     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
 | // 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()) |     : Bindings::LegacyPlatformObject(associated_element.realm()) | ||||||
|     , m_associated_element(associated_element) |     , m_associated_element(associated_element) | ||||||
|     , m_associated_attribute(move(associated_attribute)) |     , m_associated_attribute(move(associated_attribute)) | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ class DOMTokenList final : public Bindings::LegacyPlatformObject { | ||||||
|     WEB_PLATFORM_OBJECT(DOMTokenList, Bindings::LegacyPlatformObject); |     WEB_PLATFORM_OBJECT(DOMTokenList, Bindings::LegacyPlatformObject); | ||||||
| 
 | 
 | ||||||
| public: | 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; |     ~DOMTokenList() = default; | ||||||
| 
 | 
 | ||||||
|     void associated_attribute_changed(StringView value); |     void associated_attribute_changed(StringView value); | ||||||
|  | @ -44,7 +44,7 @@ public: | ||||||
|     void set_value(DeprecatedString value); |     void set_value(DeprecatedString value); | ||||||
| 
 | 
 | ||||||
| private: | 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 JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; | ||||||
|     virtual void visit_edges(Cell::Visitor&) override; |     virtual void visit_edges(Cell::Visitor&) override; | ||||||
|  |  | ||||||
|  | @ -754,7 +754,7 @@ Vector<CSS::BackgroundLayerData> const* Document::background_layers() const | ||||||
| 
 | 
 | ||||||
| void Document::update_base_element(Badge<HTML::HTMLBaseElement>) | 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) { |     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)) { |         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; |     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; |     return m_first_base_element_with_href_in_tree_order; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -106,7 +106,7 @@ public: | ||||||
|     AK::URL base_url() const; |     AK::URL base_url() const; | ||||||
| 
 | 
 | ||||||
|     void update_base_element(Badge<HTML::HTMLBaseElement>); |     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 url_string() const { return m_url.to_deprecated_string(); } | ||||||
|     DeprecatedString document_uri() 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; |     JS::GCPtr<Selection::Selection> m_selection; | ||||||
| 
 | 
 | ||||||
|     // NOTE: This is a cache to make finding the first <base href> element O(1).
 |     // 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; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -12,12 +12,12 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web::DOM { | 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)); |     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) |     : PlatformObject(realm) | ||||||
|     , m_type(type) |     , m_type(type) | ||||||
|     , m_target(JS::make_handle(target)) |     , m_target(JS::make_handle(target)) | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ class MutationRecord : public Bindings::PlatformObject { | ||||||
|     WEB_PLATFORM_OBJECT(MutationRecord, Bindings::PlatformObject); |     WEB_PLATFORM_OBJECT(MutationRecord, Bindings::PlatformObject); | ||||||
| 
 | 
 | ||||||
| public: | 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; |     virtual ~MutationRecord() override; | ||||||
| 
 | 
 | ||||||
|  | @ -30,13 +30,13 @@ public: | ||||||
|     DeprecatedString const& old_value() const { return m_old_value; } |     DeprecatedString const& old_value() const { return m_old_value; } | ||||||
| 
 | 
 | ||||||
| private: | 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 JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; | ||||||
|     virtual void visit_edges(Cell::Visitor&) override; |     virtual void visit_edges(Cell::Visitor&) override; | ||||||
| 
 | 
 | ||||||
|     DeprecatedFlyString m_type; |     DeprecatedFlyString m_type; | ||||||
|     JS::GCPtr<Node> m_target; |     JS::GCPtr<Node const> m_target; | ||||||
|     JS::GCPtr<NodeList> m_added_nodes; |     JS::GCPtr<NodeList> m_added_nodes; | ||||||
|     JS::GCPtr<NodeList> m_removed_nodes; |     JS::GCPtr<NodeList> m_removed_nodes; | ||||||
|     JS::GCPtr<Node> m_previous_sibling; |     JS::GCPtr<Node> m_previous_sibling; | ||||||
|  |  | ||||||
|  | @ -1390,7 +1390,7 @@ Painting::PaintableBox const* Node::paint_box() const | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // https://dom.spec.whatwg.org/#queue-a-mutation-record
 | // 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.
 |     // 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.
 |     // FIXME: This is a total hack.
 | ||||||
|  | @ -1401,7 +1401,7 @@ void Node::queue_mutation_record(DeprecatedFlyString const& type, DeprecatedStri | ||||||
|     OrderedHashMap<MutationObserver*, DeprecatedString> interested_observers; |     OrderedHashMap<MutationObserver*, DeprecatedString> interested_observers; | ||||||
| 
 | 
 | ||||||
|     // 2. Let nodes be the inclusive ancestors of target.
 |     // 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)); |     nodes.append(JS::make_handle(*this)); | ||||||
| 
 | 
 | ||||||
|     for (auto* parent_node = parent(); parent_node; parent_node = parent_node->parent()) |     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; |     return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Node::build_accessibility_tree(AccessibilityTreeNode& parent) const | void Node::build_accessibility_tree(AccessibilityTreeNode& parent) | ||||||
| { | { | ||||||
|     if (is_uninteresting_whitespace_node()) |     if (is_uninteresting_whitespace_node()) | ||||||
|         return; |         return; | ||||||
| 
 | 
 | ||||||
|     if (is_document()) { |     if (is_document()) { | ||||||
|         auto const* document = static_cast<DOM::Document const*>(this); |         auto* document = static_cast<DOM::Document*>(this); | ||||||
|         auto const* document_element = document->document_element(); |         auto* document_element = document->document_element(); | ||||||
|         if (document_element) { |         if (document_element) { | ||||||
|             parent.set_value(document_element); |             parent.set_value(document_element); | ||||||
|             if (document_element->has_child_nodes()) |             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); |                     child.build_accessibility_tree(parent); | ||||||
|                 }); |                 }); | ||||||
|         } |         } | ||||||
|  | @ -1580,7 +1580,7 @@ void Node::build_accessibility_tree(AccessibilityTreeNode& parent) const | ||||||
|             return; |             return; | ||||||
| 
 | 
 | ||||||
|         if (element->include_in_accessibility_tree()) { |         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); |             parent.append_child(current_node); | ||||||
|             if (has_child_nodes()) { |             if (has_child_nodes()) { | ||||||
|                 for_each_child([¤t_node](DOM::Node& child) { |                 for_each_child([¤t_node](DOM::Node& child) { | ||||||
|  | @ -1593,7 +1593,7 @@ void Node::build_accessibility_tree(AccessibilityTreeNode& parent) const | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|     } else if (is_text()) { |     } 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()) { |         if (has_child_nodes()) { | ||||||
|             for_each_child([&parent](DOM::Node& child) { |             for_each_child([&parent](DOM::Node& child) { | ||||||
|                 child.build_accessibility_tree(parent); |                 child.build_accessibility_tree(parent); | ||||||
|  |  | ||||||
|  | @ -224,7 +224,7 @@ public: | ||||||
| 
 | 
 | ||||||
|     void add_registered_observer(RegisteredObserver& registered_observer) { m_registered_observer_list.append(registered_observer); } |     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
 |     // https://dom.spec.whatwg.org/#concept-shadow-including-descendant
 | ||||||
|     template<typename Callback> |     template<typename Callback> | ||||||
|  | @ -434,7 +434,7 @@ public: | ||||||
|     template<typename U, typename Callback> |     template<typename U, typename Callback> | ||||||
|     IterationDecision for_each_in_inclusive_subtree_of_type(Callback 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) |             if (callback(static_cast<U&>(*this)) == IterationDecision::Break) | ||||||
|                 return 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
 |     // "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; |     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; |     ErrorOr<String> name_or_description(NameOrDescription, Document const&, HashTable<i32>&) const; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -17,9 +17,9 @@ namespace Web::DOM { | ||||||
| template<typename NodeType> | template<typename NodeType> | ||||||
| class NonElementParentNode { | class NonElementParentNode { | ||||||
| public: | 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) { |         static_cast<NodeType const*>(this)->template for_each_in_inclusive_subtree_of_type<Element>([&](auto& element) { | ||||||
|             if (element.attribute(HTML::AttributeNames::id) == id) { |             if (element.attribute(HTML::AttributeNames::id) == id) { | ||||||
|                 found_element = &element; |                 found_element = &element; | ||||||
|  | @ -29,9 +29,18 @@ public: | ||||||
|         }); |         }); | ||||||
|         return found_element; |         return found_element; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|     JS::GCPtr<Element> get_element_by_id(DeprecatedFlyString const& id) |     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: | protected: | ||||||
|  |  | ||||||
|  | @ -139,7 +139,7 @@ RelativeBoundaryPointPosition position_of_boundary_point_relative_to_other_bound | ||||||
|     // 4. If nodeA is an ancestor of nodeB:
 |     // 4. If nodeA is an ancestor of nodeB:
 | ||||||
|     if (node_a.is_ancestor_of(node_b)) { |     if (node_a.is_ancestor_of(node_b)) { | ||||||
|         // 1. Let child be nodeB.
 |         // 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.
 |         // 2. While child is not a child of nodeA, set child to its parent.
 | ||||||
|         while (!node_a.is_parent_of(child)) { |         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
 | // 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.
 |     // 1. If node is a doctype, throw an "InvalidNodeTypeError" DOMException.
 | ||||||
|     if (is<DocumentType>(node)) |     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.
 |     // 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; |     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)) |         if (contains_node(*node)) | ||||||
|             contained_children.append(*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.
 |     // 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; |     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)) |         if (contains_node(*node)) | ||||||
|             contained_children.append(*node); |             contained_children.append(*node); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -43,7 +43,7 @@ public: | ||||||
|     WebIDL::ExceptionOr<void> set_end_after(Node& node); |     WebIDL::ExceptionOr<void> set_end_after(Node& node); | ||||||
|     WebIDL::ExceptionOr<void> select_node(Node& node); |     WebIDL::ExceptionOr<void> select_node(Node& node); | ||||||
|     void collapse(bool to_start); |     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
 |     // https://dom.spec.whatwg.org/#dom-range-start_to_start
 | ||||||
|     enum HowToCompareBoundaryPoints : u16 { |     enum HowToCompareBoundaryPoints : u16 { | ||||||
|  |  | ||||||
|  | @ -42,7 +42,7 @@ JS::ThrowCompletionOr<void> XMLSerializer::initialize(JS::Realm& realm) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // https://w3c.github.io/DOM-Parsing/#dom-xmlserializer-serializetostring
 | // 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.
 |     // 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); |     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); |     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
 | // 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.
 |     // 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
 |     //    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); | 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
 | // 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:
 |     // 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
 |     // - A context namespace namespace
 | ||||||
|  | @ -173,43 +173,43 @@ WebIDL::ExceptionOr<DeprecatedString> serialize_node_to_xml_string_impl(JS::Nonn | ||||||
|     if (is<DOM::Element>(*root)) { |     if (is<DOM::Element>(*root)) { | ||||||
|         // -> Element
 |         // -> Element
 | ||||||
|         //    Run the algorithm for XML serializing an Element node node.
 |         //    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)) { |     if (is<DOM::Document>(*root)) { | ||||||
|         // -> Document
 |         // -> Document
 | ||||||
|         //    Run the algorithm for XML serializing a Document node node.
 |         //    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)) { |     if (is<DOM::Comment>(*root)) { | ||||||
|         // -> Comment
 |         // -> Comment
 | ||||||
|         //    Run the algorithm for XML serializing a Comment node node.
 |         //    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)) { |     if (is<DOM::Text>(*root) || is<DOM::CDATASection>(*root)) { | ||||||
|         // -> Text
 |         // -> Text
 | ||||||
|         //    Run the algorithm for XML serializing a Text node node.
 |         //    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)) { |     if (is<DOM::DocumentFragment>(*root)) { | ||||||
|         // -> DocumentFragment
 |         // -> DocumentFragment
 | ||||||
|         //    Run the algorithm for XML serializing a DocumentFragment node node.
 |         //    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)) { |     if (is<DOM::DocumentType>(*root)) { | ||||||
|         // -> DocumentType
 |         // -> DocumentType
 | ||||||
|         //    Run the algorithm for XML serializing a DocumentType node node.
 |         //    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)) { |     if (is<DOM::ProcessingInstruction>(*root)) { | ||||||
|         // -> ProcessingInstruction
 |         // -> ProcessingInstruction
 | ||||||
|         //    Run the algorithm for XML serializing a ProcessingInstruction node node.
 |         //    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)) { |     if (is<DOM::Attr>(*root)) { | ||||||
|  |  | ||||||
|  | @ -18,7 +18,7 @@ public: | ||||||
| 
 | 
 | ||||||
|     virtual ~XMLSerializer() override; |     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: | private: | ||||||
|     explicit XMLSerializer(JS::Realm&); |     explicit XMLSerializer(JS::Realm&); | ||||||
|  | @ -31,6 +31,5 @@ enum class RequireWellFormed { | ||||||
|     Yes, |     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); | ||||||
| 
 |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -97,7 +97,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Infrastructure::FetchController>> fetch(JS: | ||||||
|     //    response consume body is processResponseConsumeBody, process response end-of-body is processResponseEndOfBody,
 |     //    response consume body is processResponseConsumeBody, process response end-of-body is processResponseEndOfBody,
 | ||||||
|     //    task destination is taskDestination, and cross-origin isolated capability is crossOriginIsolatedCapability.
 |     //    task destination is taskDestination, and cross-origin isolated capability is crossOriginIsolatedCapability.
 | ||||||
|     auto fetch_params = Infrastructure::FetchParams::create(vm, request, timing_info); |     auto fetch_params = Infrastructure::FetchParams::create(vm, request, timing_info); | ||||||
|     fetch_params->set_algorithms(move(algorithms)); |     fetch_params->set_algorithms(algorithms); | ||||||
|     if (task_destination) |     if (task_destination) | ||||||
|         fetch_params->set_task_destination({ *task_destination }); |         fetch_params->set_task_destination({ *task_destination }); | ||||||
|     fetch_params->set_cross_origin_isolated_capability(cross_origin_isolated_capability); |     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
 | // 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); |     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
 | // 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); |     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(); |     auto request = fetch_params.request(); | ||||||
| 
 | 
 | ||||||
|     // 2. Let httpFetchParams be null.
 |     // 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.
 |     // 3. Let httpRequest be null.
 | ||||||
|     JS::GCPtr<Infrastructure::Request> http_request; |     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.
 |             // 2. Set httpFetchParams to a copy of fetchParams.
 | ||||||
|             // 3. Set httpFetchParams’s request to httpRequest.
 |             // 3. Set httpFetchParams’s request to httpRequest.
 | ||||||
|             http_fetch_params = Infrastructure::FetchParams::create(vm, *http_request, fetch_params.timing_info()); |             auto new_http_fetch_params = Infrastructure::FetchParams::create(vm, *http_request, fetch_params.timing_info()); | ||||||
|             http_fetch_params->set_algorithms(fetch_params.algorithms()); |             new_http_fetch_params->set_algorithms(fetch_params.algorithms()); | ||||||
|             http_fetch_params->set_task_destination(fetch_params.task_destination()); |             new_http_fetch_params->set_task_destination(fetch_params.task_destination()); | ||||||
|             http_fetch_params->set_cross_origin_isolated_capability(fetch_params.cross_origin_isolated_capability()); |             new_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()); |             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
 |         // 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
 | // 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); |     dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'CORS-preflight fetch' with request @ {}", &request); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -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<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<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>> 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_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>> 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>> 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&); | ||||||
| 
 |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -34,8 +34,8 @@ public: | ||||||
|     [[nodiscard]] JS::NonnullGCPtr<FetchController> controller() const { return m_controller; } |     [[nodiscard]] JS::NonnullGCPtr<FetchController> controller() const { return m_controller; } | ||||||
|     [[nodiscard]] JS::NonnullGCPtr<FetchTimingInfo> timing_info() const { return m_timing_info; } |     [[nodiscard]] JS::NonnullGCPtr<FetchTimingInfo> timing_info() const { return m_timing_info; } | ||||||
| 
 | 
 | ||||||
|     [[nodiscard]] JS::NonnullGCPtr<FetchAlgorithms> algorithms() const { return m_algorithms; } |     [[nodiscard]] JS::NonnullGCPtr<FetchAlgorithms const> algorithms() const { return m_algorithms; } | ||||||
|     void set_algorithms(JS::NonnullGCPtr<FetchAlgorithms> algorithms) { m_algorithms = algorithms; } |     void set_algorithms(JS::NonnullGCPtr<FetchAlgorithms const> algorithms) { m_algorithms = algorithms; } | ||||||
| 
 | 
 | ||||||
|     [[nodiscard]] TaskDestination& task_destination() { return m_task_destination; } |     [[nodiscard]] TaskDestination& task_destination() { return m_task_destination; } | ||||||
|     [[nodiscard]] TaskDestination const& task_destination() const { 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
 |     // https://fetch.spec.whatwg.org/#fetch-params-process-response-consume-body
 | ||||||
|     // process response consume body (default null)
 |     // process response consume body (default null)
 | ||||||
|     //     Null or an algorithm.
 |     //     Null or an algorithm.
 | ||||||
|     JS::NonnullGCPtr<FetchAlgorithms> m_algorithms; |     JS::NonnullGCPtr<FetchAlgorithms const> m_algorithms; | ||||||
| 
 | 
 | ||||||
|     // https://fetch.spec.whatwg.org/#fetch-params-task-destination
 |     // https://fetch.spec.whatwg.org/#fetch-params-task-destination
 | ||||||
|     // task destination (default null)
 |     // task destination (default null)
 | ||||||
|  |  | ||||||
|  | @ -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(); |     auto base_url = HTML::relevant_settings_object(*request_object).api_base_url(); | ||||||
| 
 | 
 | ||||||
|     // 4. Let signal be null.
 |     // 4. Let signal be null.
 | ||||||
|     DOM::AbortSignal const* input_signal = nullptr; |     DOM::AbortSignal* input_signal = nullptr; | ||||||
| 
 | 
 | ||||||
|     // 5. If input is a string, then:
 |     // 5. If input is a string, then:
 | ||||||
|     if (input.has<String>()) { |     if (input.has<String>()) { | ||||||
|  |  | ||||||
|  | @ -24,6 +24,12 @@ public: | ||||||
|     // https://w3c.github.io/FileAPI/#dfn-length
 |     // https://w3c.github.io/FileAPI/#dfn-length
 | ||||||
|     unsigned long length() const { return m_files.size(); } |     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
 |     // https://w3c.github.io/FileAPI/#dfn-item
 | ||||||
|     File const* item(size_t index) const |     File const* item(size_t index) const | ||||||
|     { |     { | ||||||
|  |  | ||||||
|  | @ -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
 | // 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.
 |     // 1. If event loop was not given, set event loop to the implied event loop.
 | ||||||
|     auto& event_loop = HTML::main_thread_event_loop(); |     auto& event_loop = HTML::main_thread_event_loop(); | ||||||
|  |  | ||||||
|  | @ -115,7 +115,7 @@ private: | ||||||
| EventLoop& main_thread_event_loop(); | EventLoop& main_thread_event_loop(); | ||||||
| void old_queue_global_task_with_document(HTML::Task::Source, DOM::Document&, JS::SafeFunction<void()> steps); | 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_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(); | void perform_a_microtask_checkpoint(); | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web::HTML { | 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_source(source) | ||||||
|     , m_steps(move(steps)) |     , m_steps(move(steps)) | ||||||
|     , m_document(JS::make_handle(document)) |     , m_document(JS::make_handle(document)) | ||||||
|  | @ -30,11 +30,6 @@ bool Task::is_runnable() const | ||||||
|     return !m_document.ptr() || m_document->is_fully_active(); |     return !m_document.ptr() || m_document->is_fully_active(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| DOM::Document* Task::document() |  | ||||||
| { |  | ||||||
|     return m_document.ptr(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| DOM::Document const* Task::document() const | DOM::Document const* Task::document() const | ||||||
| { | { | ||||||
|     return m_document.ptr(); |     return m_document.ptr(); | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ public: | ||||||
|         JavaScriptEngine, |         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))); |         return adopt_own(*new Task(source, document, move(steps))); | ||||||
|     } |     } | ||||||
|  | @ -40,17 +40,16 @@ public: | ||||||
|     Source source() const { return m_source; } |     Source source() const { return m_source; } | ||||||
|     void execute(); |     void execute(); | ||||||
| 
 | 
 | ||||||
|     DOM::Document* document(); |  | ||||||
|     DOM::Document const* document() const; |     DOM::Document const* document() const; | ||||||
| 
 | 
 | ||||||
|     bool is_runnable() const; |     bool is_runnable() const; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     Task(Source, DOM::Document*, JS::SafeFunction<void()> steps); |     Task(Source, DOM::Document const*, JS::SafeFunction<void()> steps); | ||||||
| 
 | 
 | ||||||
|     Source m_source { Source::Unspecified }; |     Source m_source { Source::Unspecified }; | ||||||
|     JS::SafeFunction<void()> m_steps; |     JS::SafeFunction<void()> m_steps; | ||||||
|     JS::Handle<DOM::Document> m_document; |     JS::Handle<DOM::Document const> m_document; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -350,7 +350,7 @@ void HTMLScriptElement::prepare_script() | ||||||
|         else if (m_script_type == ScriptType::Module) { |         else if (m_script_type == ScriptType::Module) { | ||||||
|             // Fetch an external module script graph given url, settings object, options, and onComplete.
 |             // Fetch an external module script graph given url, settings object, options, and onComplete.
 | ||||||
|             // FIXME: Pass options.
 |             // 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.
 |                 // 1. Mark as ready el given result.
 | ||||||
|                 if (!result) |                 if (!result) | ||||||
|                     mark_as_ready(ResultState::Null {}); |                     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:
 |             // 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
 |             // 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.
 |                 // 1. Mark as ready el given result.
 | ||||||
|                 if (!result) |                 if (!result) | ||||||
|                     mark_as_ready(ResultState::Null {}); |                     mark_as_ready(ResultState::Null {}); | ||||||
|  |  | ||||||
|  | @ -616,7 +616,7 @@ HTMLParser::AdjustedInsertionLocation HTMLParser::find_appropriate_place_for_ins | ||||||
|     return adjusted_insertion_location; |     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: 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.
 |     // 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.
 |     // 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()); |     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)) { |     if (is<DOM::Element>(node)) { | ||||||
|         auto& element = verify_cast<DOM::Element>(node); |         auto& element = verify_cast<DOM::Element>(node); | ||||||
|  |  | ||||||
|  | @ -119,7 +119,7 @@ private: | ||||||
| 
 | 
 | ||||||
|     void generate_implied_end_tags(DeprecatedFlyString const& exception = {}); |     void generate_implied_end_tags(DeprecatedFlyString const& exception = {}); | ||||||
|     void generate_all_implied_end_tags_thoroughly(); |     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 { |     struct AdjustedInsertionLocation { | ||||||
|         JS::GCPtr<DOM::Node> parent; |         JS::GCPtr<DOM::Node> parent; | ||||||
|  |  | ||||||
|  | @ -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#the-workerglobalscope-common-interface
 | ||||||
| 
 | 
 | ||||||
|     // https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-self
 |     // 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<WorkerLocation> location() const; | ||||||
|     JS::NonnullGCPtr<WorkerNavigator> navigator() const; |     JS::NonnullGCPtr<WorkerNavigator> navigator() const; | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | 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()) |     if (auto node = paintable.mouse_event_target()) | ||||||
|         return node; |         return node; | ||||||
|  | @ -35,7 +35,7 @@ static JS::GCPtr<DOM::Node> dom_node_for_event_dispatch(Painting::Paintable cons | ||||||
|     return nullptr; |     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(); |     layout_node = &paintable.layout_node(); | ||||||
|     while (layout_node && node && !node->is_element() && layout_node->parent()) { |     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.
 |             // 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)) |             if (!parent_element_for_event_dispatch(*paintable, node, layout_node)) | ||||||
|                 return false; |                 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.
 |             // 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 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)
 |             // "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)) { |             if (!parent_element_for_event_dispatch(*paintable, node, layout_node)) { | ||||||
|                 // FIXME: This is pretty ugly but we need to bail out here.
 |                 // FIXME: This is pretty ugly but we need to bail out here.
 | ||||||
|                 goto after_node_use; |                 goto after_node_use; | ||||||
|  | @ -272,7 +272,7 @@ bool EventHandler::handle_mouseup(CSSPixelPoint position, unsigned button, unsig | ||||||
|                 //        implemented in BrowsingContext::choose_a_browsing_context:
 |                 //        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
 |                 //        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(); |                     JS::NonnullGCPtr<DOM::Document> document = *m_browsing_context.active_document(); | ||||||
|                     auto href = link->href(); |                     auto href = link->href(); | ||||||
|                     auto url = document->parse_url(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.
 |         // 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 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)
 |         // "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)) |         if (!parent_element_for_event_dispatch(*paintable, node, layout_node)) | ||||||
|             return false; |             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.
 |         // 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 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)
 |         // "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); |         bool found_parent_element = parent_element_for_event_dispatch(*paintable, node, layout_node); | ||||||
|         hovered_node_changed = node.ptr() != document.hovered_node(); |         hovered_node_changed = node.ptr() != document.hovered_node(); | ||||||
|         document.set_hovered_node(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); |         page->client().page_did_request_cursor_change(hovered_node_cursor); | ||||||
| 
 | 
 | ||||||
|         if (hovered_node_changed) { |         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()) { |             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()); |                 page->client().page_did_enter_tooltip_area(m_browsing_context.to_top_level_position(position), hovered_html_element->title()); | ||||||
|             } else { |             } 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.
 |     // 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)
 |     // "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)) |     if (!parent_element_for_event_dispatch(*paintable, node, layout_node)) | ||||||
|         return false; |         return false; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -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) | 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()) |         if (!containing_block->is_scrollable()) | ||||||
|             return false; |             return false; | ||||||
|         auto new_offset = containing_block->scroll_offset(); |         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 | 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()) |     for (; layout_child && !layout_child->paintable(); layout_child = layout_child->next_sibling()) | ||||||
|         ; |         ; | ||||||
|     return layout_child ? layout_child->paintable() : nullptr; |     return layout_child ? layout_child->paintable() : nullptr; | ||||||
|  | @ -64,7 +64,7 @@ Paintable const* Paintable::first_child() const | ||||||
| 
 | 
 | ||||||
| Paintable const* Paintable::next_sibling() 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()) |     for (; layout_node && !layout_node->paintable(); layout_node = layout_node->next_sibling()) | ||||||
|         ; |         ; | ||||||
|     return layout_node ? layout_node->paintable() : nullptr; |     return layout_node ? layout_node->paintable() : nullptr; | ||||||
|  | @ -72,7 +72,7 @@ Paintable const* Paintable::next_sibling() const | ||||||
| 
 | 
 | ||||||
| Paintable const* Paintable::last_child() 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()) |     for (; layout_child && !layout_child->paintable(); layout_child = layout_child->previous_sibling()) | ||||||
|         ; |         ; | ||||||
|     return layout_child ? layout_child->paintable() : nullptr; |     return layout_child ? layout_child->paintable() : nullptr; | ||||||
|  | @ -80,7 +80,7 @@ Paintable const* Paintable::last_child() const | ||||||
| 
 | 
 | ||||||
| Paintable const* Paintable::previous_sibling() 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()) |     for (; layout_node && !layout_node->paintable(); layout_node = layout_node->previous_sibling()) | ||||||
|         ; |         ; | ||||||
|     return layout_node ? layout_node->paintable() : nullptr; |     return layout_node ? layout_node->paintable() : nullptr; | ||||||
|  |  | ||||||
|  | @ -143,8 +143,8 @@ protected: | ||||||
|     virtual void visit_edges(Cell::Visitor&) override; |     virtual void visit_edges(Cell::Visitor&) override; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     JS::NonnullGCPtr<Layout::Node> m_layout_node; |     JS::NonnullGCPtr<Layout::Node const> m_layout_node; | ||||||
|     Optional<JS::GCPtr<Layout::Box>> mutable m_containing_block; |     Optional<JS::GCPtr<Layout::Box const>> mutable m_containing_block; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| inline DOM::Node* HitTestResult::dom_node() | inline DOM::Node* HitTestResult::dom_node() | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Matthew Olsson
						Matthew Olsson