Parcourir la source

Ladybird: Handle close event in WebContentView

Aliaksandr Kalenik il y a 2 ans
Parent
commit
59752807c4
3 fichiers modifiés avec 7 ajouts et 0 suppressions
  1. 4 0
      Ladybird/Tab.cpp
  2. 1 0
      Ladybird/WebContentView.cpp
  3. 2 0
      Ladybird/WebContentView.h

+ 4 - 0
Ladybird/Tab.cpp

@@ -64,6 +64,10 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path)
     m_toolbar->addAction(m_home_action);
     m_toolbar->addWidget(m_location_edit);
 
+    QObject::connect(m_view, &WebContentView::close, [this] {
+        m_window->close_tab(tab_index());
+    });
+
     QObject::connect(m_view, &WebContentView::link_hovered, [this](QString const& title) {
         m_hover_label->setText(title);
         update_hover_label();

+ 1 - 0
Ladybird/WebContentView.cpp

@@ -966,6 +966,7 @@ void WebContentView::notify_server_did_set_cookie(Badge<WebContentClient>, AK::U
 
 void WebContentView::notify_server_did_close_browsing_context(Badge<WebContentClient>)
 {
+    emit close();
 }
 
 void WebContentView::notify_server_did_update_cookie(Badge<WebContentClient>, Web::Cookie::Cookie const& cookie)

+ 2 - 0
Ladybird/WebContentView.h

@@ -49,6 +49,7 @@ public:
     explicit WebContentView(StringView webdriver_content_ipc_path);
     virtual ~WebContentView() override;
 
+    Function<void()> on_close;
     Function<void(Gfx::IntPoint screen_position)> on_context_menu_request;
     Function<void(const AK::URL&, DeprecatedString const& target, unsigned modifiers)> on_link_click;
     Function<void(const AK::URL&, Gfx::IntPoint screen_position)> on_link_context_menu_request;
@@ -154,6 +155,7 @@ public:
     virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) override;
 
 signals:
+    void close();
     void link_hovered(QString, int timeout = 0);
     void link_unhovered();
     void back_mouse_button();