mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:18:11 +00:00
LibWeb+LibWebView+WebContent: Add an Inspector IPC to open context menus
The Inspector will have context menu support to manipulate the DOM, e.g. adding or removing nodes/attributes. This context menu will require some detailed knowledge about what element in the Inspector has been clicked. To support this, we intercept the `contextmenu` event and collect the required information to be sent to the Inspector client over IPC.
This commit is contained in:
parent
2d69a009fb
commit
2633ea8c79
13 changed files with 89 additions and 1 deletions
|
@ -81,6 +81,26 @@ InspectorClient::InspectorClient(ViewImplementation& content_web_view, ViewImple
|
|||
m_content_web_view.js_console_request_messages(0);
|
||||
};
|
||||
|
||||
m_inspector_web_view.on_inspector_requested_dom_tree_context_menu = [this](auto node_id, auto position, auto const& type, auto const& tag_or_attribute_name) {
|
||||
m_context_menu_dom_node_id = node_id;
|
||||
m_context_menu_tag_or_attribute_name = tag_or_attribute_name;
|
||||
|
||||
if (type.is_one_of("text"sv, "comment"sv)) {
|
||||
if (on_requested_dom_node_text_context_menu)
|
||||
on_requested_dom_node_text_context_menu(position);
|
||||
} else if (type == "tag"sv) {
|
||||
VERIFY(m_context_menu_tag_or_attribute_name.has_value());
|
||||
|
||||
if (on_requested_dom_node_tag_context_menu)
|
||||
on_requested_dom_node_tag_context_menu(position, *m_context_menu_tag_or_attribute_name);
|
||||
} else if (type == "attribute"sv) {
|
||||
VERIFY(m_context_menu_tag_or_attribute_name.has_value());
|
||||
|
||||
if (on_requested_dom_node_attribute_context_menu)
|
||||
on_requested_dom_node_attribute_context_menu(position, *m_context_menu_tag_or_attribute_name);
|
||||
}
|
||||
};
|
||||
|
||||
m_inspector_web_view.on_inspector_selected_dom_node = [this](auto node_id, auto const& pseudo_element) {
|
||||
auto inspected_node_properties = m_content_web_view.inspect_dom_node(node_id, pseudo_element);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue