mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 15:19:42 +00:00
LibWebView+UI: Remove history traversal WebView callbacks
We can handle these entirely within LibWebView.
This commit is contained in:
parent
9e21e44841
commit
76662d2f01
Notes:
github-actions[bot]
2024-09-22 18:12:13 +00:00
Author: https://github.com/trflynn89
Commit: 76662d2f01
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1487
5 changed files with 10 additions and 58 deletions
|
@ -554,30 +554,6 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
|
||||||
[self updateViewportRect:Ladybird::WebViewBridge::ForResize::Yes];
|
[self updateViewportRect:Ladybird::WebViewBridge::ForResize::Yes];
|
||||||
};
|
};
|
||||||
|
|
||||||
m_web_view_bridge->on_navigate_back = [weak_self]() {
|
|
||||||
LadybirdWebView* self = weak_self;
|
|
||||||
if (self == nil) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
[self navigateBack];
|
|
||||||
};
|
|
||||||
|
|
||||||
m_web_view_bridge->on_navigate_forward = [weak_self]() {
|
|
||||||
LadybirdWebView* self = weak_self;
|
|
||||||
if (self == nil) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
[self navigateForward];
|
|
||||||
};
|
|
||||||
|
|
||||||
m_web_view_bridge->on_refresh = [weak_self]() {
|
|
||||||
LadybirdWebView* self = weak_self;
|
|
||||||
if (self == nil) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
[self reload];
|
|
||||||
};
|
|
||||||
|
|
||||||
m_web_view_bridge->on_request_tooltip_override = [weak_self](auto, auto const& tooltip) {
|
m_web_view_bridge->on_request_tooltip_override = [weak_self](auto, auto const& tooltip) {
|
||||||
LadybirdWebView* self = weak_self;
|
LadybirdWebView* self = weak_self;
|
||||||
if (self == nil) {
|
if (self == nil) {
|
||||||
|
|
|
@ -330,18 +330,6 @@ Tab::Tab(BrowserWindow* window, RefPtr<WebView::WebContentClient> parent_client,
|
||||||
view().request_style_sheet_source(identifier);
|
view().request_style_sheet_source(identifier);
|
||||||
};
|
};
|
||||||
|
|
||||||
view().on_navigate_back = [this]() {
|
|
||||||
back();
|
|
||||||
};
|
|
||||||
|
|
||||||
view().on_navigate_forward = [this]() {
|
|
||||||
forward();
|
|
||||||
};
|
|
||||||
|
|
||||||
view().on_refresh = [this]() {
|
|
||||||
reload();
|
|
||||||
};
|
|
||||||
|
|
||||||
view().on_restore_window = [this]() {
|
view().on_restore_window = [this]() {
|
||||||
m_window->showNormal();
|
m_window->showNormal();
|
||||||
};
|
};
|
||||||
|
|
|
@ -431,13 +431,10 @@ void WebContentView::mouseReleaseEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
enqueue_native_event(Web::MouseEvent::Type::MouseUp, *event);
|
enqueue_native_event(Web::MouseEvent::Type::MouseUp, *event);
|
||||||
|
|
||||||
if (event->button() == Qt::MouseButton::BackButton) {
|
if (event->button() == Qt::MouseButton::BackButton)
|
||||||
if (on_navigate_back)
|
traverse_the_history_by_delta(-1);
|
||||||
on_navigate_back();
|
else if (event->button() == Qt::MouseButton::ForwardButton)
|
||||||
} else if (event->button() == Qt::MouseButton::ForwardButton) {
|
traverse_the_history_by_delta(1);
|
||||||
if (on_navigate_forward)
|
|
||||||
on_navigate_forward();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContentView::wheelEvent(QWheelEvent* event)
|
void WebContentView::wheelEvent(QWheelEvent* event)
|
||||||
|
|
|
@ -171,9 +171,6 @@ public:
|
||||||
Function<void(URL::URL const&, bool)> on_load_start;
|
Function<void(URL::URL const&, bool)> on_load_start;
|
||||||
Function<void(URL::URL const&)> on_load_finish;
|
Function<void(URL::URL const&)> on_load_finish;
|
||||||
Function<void(ByteString const& path, i32)> on_request_file;
|
Function<void(ByteString const& path, i32)> on_request_file;
|
||||||
Function<void()> on_navigate_back;
|
|
||||||
Function<void()> on_navigate_forward;
|
|
||||||
Function<void()> on_refresh;
|
|
||||||
Function<void(Gfx::Bitmap const&)> on_favicon_change;
|
Function<void(Gfx::Bitmap const&)> on_favicon_change;
|
||||||
Function<void(Gfx::StandardCursor)> on_cursor_change;
|
Function<void(Gfx::StandardCursor)> on_cursor_change;
|
||||||
Function<void(Gfx::IntPoint, ByteString const&)> on_request_tooltip_override;
|
Function<void(Gfx::IntPoint, ByteString const&)> on_request_tooltip_override;
|
||||||
|
|
|
@ -102,26 +102,20 @@ void WebContentClient::did_find_in_page(u64 page_id, size_t current_match_index,
|
||||||
|
|
||||||
void WebContentClient::did_request_navigate_back(u64 page_id)
|
void WebContentClient::did_request_navigate_back(u64 page_id)
|
||||||
{
|
{
|
||||||
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
if (auto view = view_for_page_id(page_id); view.has_value())
|
||||||
if (view->on_navigate_back)
|
view->traverse_the_history_by_delta(-1);
|
||||||
view->on_navigate_back();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContentClient::did_request_navigate_forward(u64 page_id)
|
void WebContentClient::did_request_navigate_forward(u64 page_id)
|
||||||
{
|
{
|
||||||
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
if (auto view = view_for_page_id(page_id); view.has_value())
|
||||||
if (view->on_navigate_forward)
|
view->traverse_the_history_by_delta(1);
|
||||||
view->on_navigate_forward();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContentClient::did_request_refresh(u64 page_id)
|
void WebContentClient::did_request_refresh(u64 page_id)
|
||||||
{
|
{
|
||||||
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
if (auto view = view_for_page_id(page_id); view.has_value())
|
||||||
if (view->on_refresh)
|
view->reload();
|
||||||
view->on_refresh();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContentClient::did_request_cursor_change(u64 page_id, i32 cursor_type)
|
void WebContentClient::did_request_cursor_change(u64 page_id, i32 cursor_type)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue