mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Ladybird: Do not scroll the AppKit web view beyond its document rect
For example, the JavaScript console will invoke window.scrollTo(0, INF) to scroll to the bottom of the console after updating its contents. The NSScrollView being scrolled here seems to behave oddly if we scroll beyond its limit (e.g. mouse events stop working). Prevent this by limiting scrolling to the NSScrollView's document rect.
This commit is contained in:
parent
1ffe0d3590
commit
85b2782052
Notes:
sideshowbarker
2024-07-17 14:33:07 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/85b2782052 Pull-request: https://github.com/SerenityOS/serenity/pull/20836 Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 11 additions and 1 deletions
|
@ -244,7 +244,17 @@ struct HideCursor {
|
|||
};
|
||||
|
||||
m_web_view_bridge->on_scroll_to_point = [self](auto position) {
|
||||
[self scrollToPoint:Ladybird::gfx_point_to_ns_point(position)];
|
||||
auto content_rect = [self frame];
|
||||
auto document_rect = [[self documentView] frame];
|
||||
auto ns_position = Ladybird::gfx_point_to_ns_point(position);
|
||||
|
||||
ns_position.x = max(ns_position.x, document_rect.origin.x);
|
||||
ns_position.x = min(ns_position.x, document_rect.size.width - content_rect.size.width);
|
||||
|
||||
ns_position.y = max(ns_position.y, document_rect.origin.y);
|
||||
ns_position.y = min(ns_position.y, document_rect.size.height - content_rect.size.height);
|
||||
|
||||
[self scrollToPoint:ns_position];
|
||||
[[self scrollView] reflectScrolledClipView:self];
|
||||
[self updateViewportRect:Ladybird::WebViewBridge::ForResize::No];
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue