From 59752807c4fb60d7d0480d7f7b7d73c2a3bb4f58 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 7 Mar 2023 06:13:08 +0300 Subject: [PATCH] Ladybird: Handle close event in WebContentView --- Ladybird/Tab.cpp | 4 ++++ Ladybird/WebContentView.cpp | 1 + Ladybird/WebContentView.h | 2 ++ 3 files changed, 7 insertions(+) diff --git a/Ladybird/Tab.cpp b/Ladybird/Tab.cpp index b38319bd65..1c5ac9349f 100644 --- a/Ladybird/Tab.cpp +++ b/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(); diff --git a/Ladybird/WebContentView.cpp b/Ladybird/WebContentView.cpp index ab922da476..897c273cd2 100644 --- a/Ladybird/WebContentView.cpp +++ b/Ladybird/WebContentView.cpp @@ -966,6 +966,7 @@ void WebContentView::notify_server_did_set_cookie(Badge, AK::U void WebContentView::notify_server_did_close_browsing_context(Badge) { + emit close(); } void WebContentView::notify_server_did_update_cookie(Badge, Web::Cookie::Cookie const& cookie) diff --git a/Ladybird/WebContentView.h b/Ladybird/WebContentView.h index 181d42fd55..814d7eb480 100644 --- a/Ladybird/WebContentView.h +++ b/Ladybird/WebContentView.h @@ -49,6 +49,7 @@ public: explicit WebContentView(StringView webdriver_content_ipc_path); virtual ~WebContentView() override; + Function on_close; Function on_context_menu_request; Function on_link_click; Function 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();