mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
Ladybird+LibWebView: Add an Inspector action to clone a DOM node
This commit is contained in:
parent
d5d6ff8bf1
commit
7e974f530d
|
@ -186,6 +186,11 @@ static constexpr NSInteger CONTEXT_MENU_COPY_ATTRIBUTE_VALUE_TAG = 3;
|
|||
m_inspector_client->context_menu_create_child_text_node();
|
||||
}
|
||||
|
||||
- (void)cloneDOMNode:(id)sender
|
||||
{
|
||||
m_inspector_client->context_menu_clone_dom_node();
|
||||
}
|
||||
|
||||
- (void)deleteDOMNode:(id)sender
|
||||
{
|
||||
m_inspector_client->context_menu_remove_dom_node();
|
||||
|
@ -265,6 +270,9 @@ static constexpr NSInteger CONTEXT_MENU_COPY_ATTRIBUTE_VALUE_TAG = 3;
|
|||
action:@selector(addDOMAttribute:)
|
||||
keyEquivalent:@""]];
|
||||
[_dom_node_tag_context_menu addItem:[Inspector make_create_child_menu]];
|
||||
[_dom_node_tag_context_menu addItem:[[NSMenuItem alloc] initWithTitle:@"Clone node"
|
||||
action:@selector(cloneDOMNode:)
|
||||
keyEquivalent:@""]];
|
||||
[_dom_node_tag_context_menu addItem:[[NSMenuItem alloc] initWithTitle:@"Delete node"
|
||||
action:@selector(deleteDOMNode:)
|
||||
keyEquivalent:@""]];
|
||||
|
@ -311,6 +319,9 @@ static constexpr NSInteger CONTEXT_MENU_COPY_ATTRIBUTE_VALUE_TAG = 3;
|
|||
action:@selector(addDOMAttribute:)
|
||||
keyEquivalent:@""]];
|
||||
[_dom_node_attribute_context_menu addItem:[Inspector make_create_child_menu]];
|
||||
[_dom_node_attribute_context_menu addItem:[[NSMenuItem alloc] initWithTitle:@"Clone node"
|
||||
action:@selector(cloneDOMNode:)
|
||||
keyEquivalent:@""]];
|
||||
[_dom_node_attribute_context_menu addItem:[[NSMenuItem alloc] initWithTitle:@"Delete node"
|
||||
action:@selector(deleteDOMNode:)
|
||||
keyEquivalent:@""]];
|
||||
|
|
|
@ -42,6 +42,9 @@ InspectorWidget::InspectorWidget(QWidget* tab, WebContentView& content_view)
|
|||
m_create_child_text_node_action = new QAction("Create child &text node", this);
|
||||
connect(m_create_child_text_node_action, &QAction::triggered, [this]() { m_inspector_client->context_menu_create_child_text_node(); });
|
||||
|
||||
m_clone_node_action = new QAction("C&lone node", this);
|
||||
connect(m_clone_node_action, &QAction::triggered, [this]() { m_inspector_client->context_menu_clone_dom_node(); });
|
||||
|
||||
m_delete_node_action = new QAction("&Delete node", this);
|
||||
connect(m_delete_node_action, &QAction::triggered, [this]() { m_inspector_client->context_menu_remove_dom_node(); });
|
||||
|
||||
|
@ -69,6 +72,7 @@ InspectorWidget::InspectorWidget(QWidget* tab, WebContentView& content_view)
|
|||
m_dom_node_tag_context_menu->addSeparator();
|
||||
m_dom_node_tag_context_menu->addAction(m_add_attribute_action);
|
||||
m_dom_node_tag_context_menu->addMenu(create_child_menu);
|
||||
m_dom_node_tag_context_menu->addAction(m_clone_node_action);
|
||||
m_dom_node_tag_context_menu->addAction(m_delete_node_action);
|
||||
m_dom_node_tag_context_menu->addSeparator();
|
||||
m_dom_node_tag_context_menu->addAction(m_copy_node_action);
|
||||
|
@ -81,6 +85,7 @@ InspectorWidget::InspectorWidget(QWidget* tab, WebContentView& content_view)
|
|||
m_dom_node_attribute_context_menu->addSeparator();
|
||||
m_dom_node_attribute_context_menu->addAction(m_add_attribute_action);
|
||||
m_dom_node_attribute_context_menu->addMenu(create_child_menu);
|
||||
m_dom_node_attribute_context_menu->addAction(m_clone_node_action);
|
||||
m_dom_node_attribute_context_menu->addAction(m_delete_node_action);
|
||||
m_dom_node_attribute_context_menu->addSeparator();
|
||||
m_dom_node_attribute_context_menu->addAction(m_copy_node_action);
|
||||
|
|
|
@ -48,6 +48,7 @@ private:
|
|||
QAction* m_screenshot_node_action { nullptr };
|
||||
QAction* m_create_child_element_action { nullptr };
|
||||
QAction* m_create_child_text_node_action { nullptr };
|
||||
QAction* m_clone_node_action { nullptr };
|
||||
QAction* m_delete_node_action { nullptr };
|
||||
QAction* m_add_attribute_action { nullptr };
|
||||
QAction* m_remove_attribute_action { nullptr };
|
||||
|
|
|
@ -34,6 +34,7 @@ InspectorWidget::InspectorWidget(WebView::OutOfProcessWebView& content_view)
|
|||
m_screenshot_node_action = GUI::Action::create("Take node &screenshot"sv, [this](auto&) { m_inspector_client->context_menu_screenshot_dom_node(); });
|
||||
m_create_child_element_action = GUI::Action::create("Create child &element"sv, [this](auto&) { m_inspector_client->context_menu_create_child_element(); });
|
||||
m_create_child_text_node_action = GUI::Action::create("Create child &text node"sv, [this](auto&) { m_inspector_client->context_menu_create_child_text_node(); });
|
||||
m_clone_node_action = GUI::Action::create("C&lone node"sv, [this](auto&) { m_inspector_client->context_menu_clone_dom_node(); });
|
||||
m_delete_node_action = GUI::Action::create("&Delete node"sv, [this](auto&) { m_inspector_client->context_menu_remove_dom_node(); });
|
||||
m_add_attribute_action = GUI::Action::create("&Add attribute"sv, [this](auto&) { m_inspector_client->context_menu_add_dom_node_attribute(); });
|
||||
m_remove_attribute_action = GUI::Action::create("&Remove attribute"sv, [this](auto&) { m_inspector_client->context_menu_remove_dom_node_attribute(); });
|
||||
|
@ -56,6 +57,7 @@ InspectorWidget::InspectorWidget(WebView::OutOfProcessWebView& content_view)
|
|||
m_dom_node_tag_context_menu->add_separator();
|
||||
m_dom_node_tag_context_menu->add_action(*m_add_attribute_action);
|
||||
add_create_child_menu(*m_dom_node_tag_context_menu);
|
||||
m_dom_node_tag_context_menu->add_action(*m_clone_node_action);
|
||||
m_dom_node_tag_context_menu->add_action(*m_delete_node_action);
|
||||
m_dom_node_tag_context_menu->add_separator();
|
||||
m_dom_node_tag_context_menu->add_action(*m_copy_node_action);
|
||||
|
@ -68,6 +70,7 @@ InspectorWidget::InspectorWidget(WebView::OutOfProcessWebView& content_view)
|
|||
m_dom_node_attribute_context_menu->add_separator();
|
||||
m_dom_node_attribute_context_menu->add_action(*m_add_attribute_action);
|
||||
add_create_child_menu(*m_dom_node_attribute_context_menu);
|
||||
m_dom_node_attribute_context_menu->add_action(*m_clone_node_action);
|
||||
m_dom_node_attribute_context_menu->add_action(*m_delete_node_action);
|
||||
m_dom_node_attribute_context_menu->add_separator();
|
||||
m_dom_node_attribute_context_menu->add_action(*m_copy_node_action);
|
||||
|
|
|
@ -44,6 +44,7 @@ private:
|
|||
RefPtr<GUI::Action> m_screenshot_node_action;
|
||||
RefPtr<GUI::Action> m_create_child_element_action;
|
||||
RefPtr<GUI::Action> m_create_child_text_node_action;
|
||||
RefPtr<GUI::Action> m_clone_node_action;
|
||||
RefPtr<GUI::Action> m_delete_node_action;
|
||||
RefPtr<GUI::Action> m_add_attribute_action;
|
||||
RefPtr<GUI::Action> m_remove_attribute_action;
|
||||
|
|
|
@ -274,6 +274,16 @@ void InspectorClient::context_menu_create_child_text_node()
|
|||
m_context_menu_data.clear();
|
||||
}
|
||||
|
||||
void InspectorClient::context_menu_clone_dom_node()
|
||||
{
|
||||
VERIFY(m_context_menu_data.has_value());
|
||||
|
||||
m_pending_selection = m_content_web_view.clone_dom_node(m_context_menu_data->dom_node_id);
|
||||
inspect();
|
||||
|
||||
m_context_menu_data.clear();
|
||||
}
|
||||
|
||||
void InspectorClient::context_menu_remove_dom_node()
|
||||
{
|
||||
VERIFY(m_context_menu_data.has_value());
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
void context_menu_screenshot_dom_node();
|
||||
void context_menu_create_child_element();
|
||||
void context_menu_create_child_text_node();
|
||||
void context_menu_clone_dom_node();
|
||||
void context_menu_remove_dom_node();
|
||||
void context_menu_add_dom_node_attribute();
|
||||
void context_menu_remove_dom_node_attribute();
|
||||
|
|
Loading…
Reference in a new issue