1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:17:44 +00:00

LibWeb: Make BrowsingContex::page() return a Page&

This exposed a whole slew of now-unnecessary null checks. :^)

Co-Authored-By: Andreas Kling <kling@serenityos.org>
This commit is contained in:
Shannon Booth 2023-12-03 20:29:37 +13:00 committed by Andreas Kling
parent af2bcc3b56
commit 88f8ea7c60
9 changed files with 56 additions and 88 deletions

View file

@ -115,8 +115,8 @@ public:
HTML::Window* active_window();
HTML::Window const* active_window() const;
Page* page() { return m_page; }
Page const* page() const { return m_page; }
Page& page() { return m_page; }
Page const& page() const { return m_page; }
Web::EventHandler& event_handler() { return m_event_handler; }
Web::EventHandler const& event_handler() const { return m_event_handler; }

View file

@ -199,7 +199,7 @@ static void show_the_picker_if_applicable(HTMLInputElement& element)
// FIXME: Pass along accept attribute information https://html.spec.whatwg.org/multipage/input.html#attr-input-accept
// The accept attribute may be specified to provide user agents with a hint of what file types will be accepted.
element.document().browsing_context()->top_level_browsing_context()->page()->client().page_did_request_file_picker(weak_element, multiple);
element.document().browsing_context()->top_level_browsing_context()->page().client().page_did_request_file_picker(weak_element, multiple);
return;
}
@ -211,7 +211,7 @@ static void show_the_picker_if_applicable(HTMLInputElement& element)
// (If this closes a file selection picker, then per the above that will lead to firing either input and change events, or a cancel event.)
if (element.type_state() == HTMLInputElement::TypeAttributeState::Color) {
auto weak_element = element.make_weak_ptr<HTMLInputElement>();
element.document().browsing_context()->top_level_browsing_context()->page()->did_request_color_picker(weak_element, Color::from_string(element.value()).value_or(Color(0, 0, 0)));
element.document().browsing_context()->top_level_browsing_context()->page().did_request_color_picker(weak_element, Color::from_string(element.value()).value_or(Color(0, 0, 0)));
}
}

View file

@ -194,8 +194,7 @@ WebIDL::ExceptionOr<void> History::shared_history_push_replace_state(JS::Value v
auto navigable = document->navigable();
if (navigable->is_top_level_traversable()) {
if (auto* page = navigable->active_browsing_context()->page())
page->client().page_did_start_loading(new_url, false);
navigable->active_browsing_context()->page().client().page_did_start_loading(new_url, false);
}
// 10. Run the URL and history update steps given document and newURL, with serializedData set to

View file

@ -193,8 +193,7 @@ void Navigable::activate_history_entry(JS::GCPtr<SessionHistoryEntry> entry)
// Not in the spec:
VERIFY(active_browsing_context());
VERIFY(active_browsing_context()->page());
active_browsing_context()->page()->client().page_did_create_new_document(*new_document);
active_browsing_context()->page().client().page_did_create_new_document(*new_document);
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-document
@ -1331,8 +1330,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate(NavigateParams params)
}
if (is_top_level_traversable()) {
if (auto* page = active_browsing_context()->page())
page->client().page_did_start_loading(url, false);
active_browsing_context()->page().client().page_did_start_loading(url, false);
}
// 20. In parallel, run these steps: