mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 15:10:19 +00:00
LibWeb: Add helper for accessing Inspector's PageClient
This is a bit easier to understand.
This commit is contained in:
parent
240b58e90f
commit
fd49562f50
Notes:
github-actions[bot]
2024-09-03 09:13:36 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/fd49562f501 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1168 Reviewed-by: https://github.com/trflynn89
2 changed files with 15 additions and 8 deletions
|
@ -32,9 +32,14 @@ void Inspector::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(Inspector);
|
||||
}
|
||||
|
||||
PageClient& Inspector::inspector_page_client() const
|
||||
{
|
||||
return global_object().browsing_context()->page().client();
|
||||
}
|
||||
|
||||
void Inspector::inspector_loaded()
|
||||
{
|
||||
global_object().browsing_context()->page().client().inspector_did_load();
|
||||
inspector_page_client().inspector_did_load();
|
||||
}
|
||||
|
||||
void Inspector::inspect_dom_node(i32 node_id, Optional<i32> const& pseudo_element)
|
||||
|
@ -48,37 +53,37 @@ void Inspector::inspect_dom_node(i32 node_id, Optional<i32> const& pseudo_elemen
|
|||
|
||||
void Inspector::set_dom_node_text(i32 node_id, String const& text)
|
||||
{
|
||||
global_object().browsing_context()->page().client().inspector_did_set_dom_node_text(node_id, text);
|
||||
inspector_page_client().inspector_did_set_dom_node_text(node_id, text);
|
||||
}
|
||||
|
||||
void Inspector::set_dom_node_tag(i32 node_id, String const& tag)
|
||||
{
|
||||
global_object().browsing_context()->page().client().inspector_did_set_dom_node_tag(node_id, tag);
|
||||
inspector_page_client().inspector_did_set_dom_node_tag(node_id, tag);
|
||||
}
|
||||
|
||||
void Inspector::add_dom_node_attributes(i32 node_id, JS::NonnullGCPtr<DOM::NamedNodeMap> attributes)
|
||||
{
|
||||
global_object().browsing_context()->page().client().inspector_did_add_dom_node_attributes(node_id, attributes);
|
||||
inspector_page_client().inspector_did_add_dom_node_attributes(node_id, attributes);
|
||||
}
|
||||
|
||||
void Inspector::replace_dom_node_attribute(i32 node_id, WebIDL::UnsignedLongLong attribute_index, JS::NonnullGCPtr<DOM::NamedNodeMap> replacement_attributes)
|
||||
{
|
||||
global_object().browsing_context()->page().client().inspector_did_replace_dom_node_attribute(node_id, static_cast<size_t>(attribute_index), replacement_attributes);
|
||||
inspector_page_client().inspector_did_replace_dom_node_attribute(node_id, static_cast<size_t>(attribute_index), replacement_attributes);
|
||||
}
|
||||
|
||||
void Inspector::request_dom_tree_context_menu(i32 node_id, i32 client_x, i32 client_y, String const& type, Optional<String> const& tag, Optional<WebIDL::UnsignedLongLong> const& attribute_index)
|
||||
{
|
||||
global_object().browsing_context()->page().client().inspector_did_request_dom_tree_context_menu(node_id, { client_x, client_y }, type, tag, attribute_index.map([](auto index) { return static_cast<size_t>(index); }));
|
||||
inspector_page_client().inspector_did_request_dom_tree_context_menu(node_id, { client_x, client_y }, type, tag, attribute_index.map([](auto index) { return static_cast<size_t>(index); }));
|
||||
}
|
||||
|
||||
void Inspector::execute_console_script(String const& script)
|
||||
{
|
||||
global_object().browsing_context()->page().client().inspector_did_execute_console_script(script);
|
||||
inspector_page_client().inspector_did_execute_console_script(script);
|
||||
}
|
||||
|
||||
void Inspector::export_inspector_html(String const& html)
|
||||
{
|
||||
global_object().browsing_context()->page().client().inspector_did_export_inspector_html(html);
|
||||
inspector_page_client().inspector_did_export_inspector_html(html);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ public:
|
|||
private:
|
||||
explicit Inspector(JS::Realm&);
|
||||
|
||||
PageClient& inspector_page_client() const;
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue