diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 8c88b000ec..53c73de795 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -445,6 +445,16 @@ Tab::Tab(BrowserWindow& window) load(url); }; + view().on_back_button = [this] { + if (m_history.can_go_back()) + go_back(); + }; + + view().on_forward_button = [this] { + if (m_history.can_go_forward()) + go_forward(); + }; + m_tab_context_menu = GUI::Menu::construct(); m_tab_context_menu->add_action(GUI::CommonActions::make_reload_action([this](auto&) { reload(); diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp index bd614c1239..b0bdce2ae7 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp @@ -174,6 +174,12 @@ void OutOfProcessWebView::mousedown_event(GUI::MouseEvent& event) void OutOfProcessWebView::mouseup_event(GUI::MouseEvent& event) { enqueue_input_event(event); + + if (event.button() == GUI::MouseButton::Backward && on_back_button) { + on_back_button(); + } else if (event.button() == GUI::MouseButton::Forward && on_forward_button) { + on_forward_button(); + } } void OutOfProcessWebView::mousemove_event(GUI::MouseEvent& event) diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.h b/Userland/Libraries/LibWebView/OutOfProcessWebView.h index 890793fa2c..ffb885e4bd 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.h @@ -111,6 +111,8 @@ public: Function on_maximize_window; Function on_minimize_window; Function on_fullscreen_window; + Function on_back_button; + Function on_forward_button; private: OutOfProcessWebView();