mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 08:07: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:
parent
af2bcc3b56
commit
88f8ea7c60
9 changed files with 56 additions and 88 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,9 +36,7 @@ void Internals::initialize(JS::Realm& realm)
|
|||
|
||||
void Internals::signal_text_test_is_done()
|
||||
{
|
||||
if (auto* page = global_object().browsing_context()->page()) {
|
||||
page->client().page_did_finish_text_test();
|
||||
}
|
||||
global_object().browsing_context()->page().client().page_did_finish_text_test();
|
||||
}
|
||||
|
||||
void Internals::gc()
|
||||
|
@ -65,33 +63,23 @@ JS::Object* Internals::hit_test(double x, double y)
|
|||
|
||||
void Internals::send_text(HTML::HTMLElement& target, String const& text)
|
||||
{
|
||||
auto* page = global_object().browsing_context()->page();
|
||||
if (!page)
|
||||
return;
|
||||
|
||||
auto& page = global_object().browsing_context()->page();
|
||||
target.focus();
|
||||
|
||||
for (auto code_point : text.code_points())
|
||||
page->handle_keydown(code_point_to_key_code(code_point), 0, code_point);
|
||||
page.handle_keydown(code_point_to_key_code(code_point), 0, code_point);
|
||||
}
|
||||
|
||||
void Internals::commit_text()
|
||||
{
|
||||
auto* page = global_object().browsing_context()->page();
|
||||
if (!page)
|
||||
return;
|
||||
|
||||
page->handle_keydown(Key_Return, 0, 0);
|
||||
global_object().browsing_context()->page().handle_keydown(Key_Return, 0, 0);
|
||||
}
|
||||
|
||||
void Internals::click(double x, double y)
|
||||
{
|
||||
auto* page = global_object().browsing_context()->page();
|
||||
if (!page)
|
||||
return;
|
||||
|
||||
page->handle_mousedown({ x, y }, { x, y }, 1, 0, 0);
|
||||
page->handle_mouseup({ x, y }, { x, y }, 1, 0, 0);
|
||||
auto& page = global_object().browsing_context()->page();
|
||||
page.handle_mousedown({ x, y }, { x, y }, 1, 0, 0);
|
||||
page.handle_mouseup({ x, y }, { x, y }, 1, 0, 0);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<bool> Internals::dispatch_user_activated_event(DOM::EventTarget& target, DOM::Event& event)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue