Improve browser_window_scroll_at_point_internal

This commit is contained in:
Vincent Sanders 2024-05-29 14:32:03 +01:00
parent dcd9baeb80
commit 1d08a36562
2 changed files with 7 additions and 16 deletions

View File

@ -2403,7 +2403,6 @@ browser_window_scroll_at_point_internal(struct browser_window *bw,
int x, int y, int x, int y,
int scrx, int scry) int scrx, int scry)
{ {
bool handled_scroll = false;
assert(bw != NULL); assert(bw != NULL);
/* Handle (i)frame scroll offset (core-managed browser windows only) */ /* Handle (i)frame scroll offset (core-managed browser windows only) */
@ -2443,18 +2442,9 @@ browser_window_scroll_at_point_internal(struct browser_window *bw,
return true; return true;
} }
/* Try to scroll this window, if scroll not already handled */ /* Try to scroll this window */
if (handled_scroll == false) { return scrollbar_scroll(bw->scroll_y, scry) |
if (bw->scroll_y && scrollbar_scroll(bw->scroll_y, scry)) { scrollbar_scroll(bw->scroll_x, scrx);
handled_scroll = true;
}
if (bw->scroll_x && scrollbar_scroll(bw->scroll_x, scrx)) {
handled_scroll = true;
}
}
return handled_scroll;
} }

View File

@ -562,11 +562,11 @@ void scrollbar_set(struct scrollbar *s, int value, bool bar_pos)
bool scrollbar_scroll(struct scrollbar *s, int change) bool scrollbar_scroll(struct scrollbar *s, int change)
{ {
int well_length; int well_length;
int old_offset = s->offset; int old_offset;
struct scrollbar_msg_data msg; struct scrollbar_msg_data msg;
if (change == 0 || s->full_size <= s->visible_size) { if (s == NULL || change == 0 || s->full_size <= s->visible_size) {
/* zero scroll step, or unscrollable */ /* scrollbar not present, zero scroll step, or unscrollable */
return false; return false;
} }
@ -594,6 +594,7 @@ bool scrollbar_scroll(struct scrollbar *s, int change)
} }
/* Get new offset */ /* Get new offset */
old_offset = s->offset;
if (s->offset + change > s->full_size - s->visible_size) { if (s->offset + change > s->full_size - s->visible_size) {
s->offset = s->full_size - s->visible_size; s->offset = s->full_size - s->visible_size;
} else if (s->offset + change < 0) { } else if (s->offset + change < 0) {