mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:07:35 +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
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…
Add table
Add a link
Reference in a new issue