diff --git a/desktop/browser_window.c b/desktop/browser_window.c index c70db7cf1..924e7ad66 100644 --- a/desktop/browser_window.c +++ b/desktop/browser_window.c @@ -2403,7 +2403,6 @@ browser_window_scroll_at_point_internal(struct browser_window *bw, int x, int y, int scrx, int scry) { - bool handled_scroll = false; assert(bw != NULL); /* 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; } - /* Try to scroll this window, if scroll not already handled */ - if (handled_scroll == false) { - if (bw->scroll_y && scrollbar_scroll(bw->scroll_y, scry)) { - handled_scroll = true; - } - - if (bw->scroll_x && scrollbar_scroll(bw->scroll_x, scrx)) { - handled_scroll = true; - } - } - - return handled_scroll; + /* Try to scroll this window */ + return scrollbar_scroll(bw->scroll_y, scry) | + scrollbar_scroll(bw->scroll_x, scrx); } diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c index 90ea924cc..35daef107 100644 --- a/desktop/scrollbar.c +++ b/desktop/scrollbar.c @@ -562,11 +562,11 @@ void scrollbar_set(struct scrollbar *s, int value, bool bar_pos) bool scrollbar_scroll(struct scrollbar *s, int change) { int well_length; - int old_offset = s->offset; + int old_offset; struct scrollbar_msg_data msg; - if (change == 0 || s->full_size <= s->visible_size) { - /* zero scroll step, or unscrollable */ + if (s == NULL || change == 0 || s->full_size <= s->visible_size) { + /* scrollbar not present, zero scroll step, or unscrollable */ return false; } @@ -594,6 +594,7 @@ bool scrollbar_scroll(struct scrollbar *s, int change) } /* Get new offset */ + old_offset = s->offset; if (s->offset + change > s->full_size - s->visible_size) { s->offset = s->full_size - s->visible_size; } else if (s->offset + change < 0) {