1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:57:45 +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

@ -34,42 +34,36 @@ void Inspector::initialize(JS::Realm& realm)
void Inspector::inspector_loaded()
{
if (auto* page = global_object().browsing_context()->page())
page->client().inspector_did_load();
global_object().browsing_context()->page().client().inspector_did_load();
}
void Inspector::inspect_dom_node(i32 node_id, Optional<i32> const& pseudo_element)
{
if (auto* page = global_object().browsing_context()->page()) {
page->client().inspector_did_select_dom_node(node_id, pseudo_element.map([](auto value) {
VERIFY(value < to_underlying(Web::CSS::Selector::PseudoElement::PseudoElementCount));
return static_cast<Web::CSS::Selector::PseudoElement>(value);
}));
}
auto& page = global_object().browsing_context()->page();
page.client().inspector_did_select_dom_node(node_id, pseudo_element.map([](auto value) {
VERIFY(value < to_underlying(Web::CSS::Selector::PseudoElement::PseudoElementCount));
return static_cast<Web::CSS::Selector::PseudoElement>(value);
}));
}
void Inspector::set_dom_node_text(i32 node_id, String const& text)
{
if (auto* page = global_object().browsing_context()->page())
page->client().inspector_did_set_dom_node_text(node_id, text);
global_object().browsing_context()->page().client().inspector_did_set_dom_node_text(node_id, text);
}
void Inspector::set_dom_node_tag(i32 node_id, String const& tag)
{
if (auto* page = global_object().browsing_context()->page())
page->client().inspector_did_set_dom_node_tag(node_id, tag);
global_object().browsing_context()->page().client().inspector_did_set_dom_node_tag(node_id, tag);
}
void Inspector::replace_dom_node_attribute(i32 node_id, String const& name, JS::NonnullGCPtr<DOM::NamedNodeMap> replacement_attributes)
{
if (auto* page = global_object().browsing_context()->page())
page->client().inspector_did_replace_dom_node_attribute(node_id, name, replacement_attributes);
global_object().browsing_context()->page().client().inspector_did_replace_dom_node_attribute(node_id, name, replacement_attributes);
}
void Inspector::execute_console_script(String const& script)
{
if (auto* page = global_object().browsing_context()->page())
page->client().inspector_did_execute_console_script(script);
global_object().browsing_context()->page().client().inspector_did_execute_console_script(script);
}
}