LibWeb: Make BrowsingContextGroup & TraversableNavigable return a Page&

Removing another batch of uneeded null checks :^)
This commit is contained in:
Shannon Booth 2023-12-03 20:06:06 +13:00 committed by Andreas Kling
parent 88f8ea7c60
commit 0cb0d60ac5
8 changed files with 13 additions and 16 deletions

View file

@ -1900,10 +1900,7 @@ void Document::update_readiness(HTML::DocumentReadyState readiness_value)
if (readiness_value == HTML::DocumentReadyState::Complete && is_active() && navigable()->is_traversable()) {
HTML::HTMLLinkElement::load_fallback_favicon_if_needed(*this).release_value_but_fixme_should_propagate_errors();
if (auto* page = navigable()->traversable_navigable()->page()) {
page->client().page_did_finish_loading(url());
}
navigable()->traversable_navigable()->page().client().page_did_finish_loading(url());
}
}

View file

@ -1668,8 +1668,8 @@ static ErrorOr<void> scroll_an_element_into_view(DOM::Element& target, Bindings:
(void)behavior;
// AD-HOC:
auto* page = document.navigable()->traversable_navigable()->page();
page->client().page_did_request_scroll_to(position.location());
auto& page = document.navigable()->traversable_navigable()->page();
page.client().page_did_request_scroll_to(position.location());
}
// If scrolling box is associated with an element
else {

View file

@ -27,8 +27,8 @@ public:
~BrowsingContextGroup();
Page* page() { return m_page; }
Page const* page() const { return m_page; }
Page& page() { return m_page; }
Page const& page() const { return m_page; }
auto& browsing_context_set() { return m_browsing_context_set; }
auto const& browsing_context_set() const { return m_browsing_context_set; }

View file

@ -454,7 +454,7 @@ static bool decode_favicon(ReadonlyBytes favicon_data, AK::URL const& favicon_ur
dbgln_if(IMAGE_DECODER_DEBUG, "Decoded favicon, {}", favicon_bitmap->size());
if (navigable && navigable->is_traversable())
navigable->traversable_navigable()->page()->client().page_did_change_favicon(*favicon_bitmap);
navigable->traversable_navigable()->page().client().page_did_change_favicon(*favicon_bitmap);
return favicon_bitmap;
}

View file

@ -30,7 +30,7 @@ void HTMLTitleElement::children_changed()
{
HTMLElement::children_changed();
if (navigable() && navigable()->is_traversable()) {
navigable()->traversable_navigable()->page()->client().page_did_change_title(document().title().to_deprecated_string());
navigable()->traversable_navigable()->page().client().page_did_change_title(document().title().to_deprecated_string());
}
}

View file

@ -362,7 +362,7 @@ Navigable::ChosenNavigable Navigable::choose_a_navigable(StringView name, Tokeni
else {
// --> If current's active window does not have transient activation and the user agent has been configured to
// not show popups (i.e., the user agent has a "popup blocker" enabled)
if (!active_window()->has_transient_activation() && traversable_navigable()->page()->should_block_pop_ups()) {
if (!active_window()->has_transient_activation() && traversable_navigable()->page().should_block_pop_ups()) {
// FIXME: The user agent may inform the user that a popup has been blocked.
dbgln("Pop-up blocked!");
}
@ -418,7 +418,7 @@ Navigable::ChosenNavigable Navigable::choose_a_navigable(StringView name, Tokeni
else {
// 1. Set chosen to the result of creating a new top-level traversable given currentNavigable's active browsing context and targetName.
// FIXME: Make this method return WebIDL::ExceptionOr<ChosenNavigable>
chosen = TraversableNavigable::create_a_new_top_level_traversable(*traversable_navigable()->page(), active_browsing_context(), target_name).release_value_but_fixme_should_propagate_errors();
chosen = TraversableNavigable::create_a_new_top_level_traversable(traversable_navigable()->page(), active_browsing_context(), target_name).release_value_but_fixme_should_propagate_errors();
// FIXME: 2. If sandboxingFlagSet's sandboxed navigation browsing context flag is set,
// then set chosen's active browsing context's one permitted sandboxed navigator to currentNavigable's active browsing context.
@ -1978,7 +1978,7 @@ void Navigable::set_needs_display(CSSPixelRect const& rect)
return;
if (is<TraversableNavigable>(*this)) {
static_cast<TraversableNavigable*>(this)->page()->client().page_did_invalidate(to_top_level_rect(rect));
static_cast<TraversableNavigable*>(this)->page().client().page_did_invalidate(to_top_level_rect(rect));
return;
}

View file

@ -63,8 +63,8 @@ public:
m_session_history_traversal_queue.process();
}
Page* page() { return m_page; }
Page const* page() const { return m_page; }
Page& page() { return m_page; }
Page const& page() const { return m_page; }
private:
TraversableNavigable(JS::NonnullGCPtr<Page>);

View file

@ -175,7 +175,7 @@ bool Page::handle_keyup(KeyCode key, unsigned modifiers, u32 code_point)
void Page::set_top_level_traversable(JS::NonnullGCPtr<HTML::TraversableNavigable> navigable)
{
VERIFY(!m_top_level_traversable); // Replacement is not allowed!
VERIFY(navigable->page() == this);
VERIFY(&navigable->page() == this);
m_top_level_traversable = navigable;
}