summaryrefslogtreecommitdiff
path: root/desktop/scrollbar.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-08-30 18:13:23 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-08-30 18:13:23 +0000
commit525bf15f73edcaba6febfc531951409582bfd28d (patch)
treee447106bbdbf6283bdf30d812082daba605b4c03 /desktop/scrollbar.c
parent14a724c62b77a08ba651b16ede0715c9c5a8f53c (diff)
downloadnetsurf-525bf15f73edcaba6febfc531951409582bfd28d.tar.gz
netsurf-525bf15f73edcaba6febfc531951409582bfd28d.tar.bz2
More robustification.
svn path=/trunk/netsurf/; revision=12678
Diffstat (limited to 'desktop/scrollbar.c')
-rw-r--r--desktop/scrollbar.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index 3fc36bf18..1c4b46d47 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -412,8 +412,9 @@ void scrollbar_set(struct scrollbar *s, int value, bool bar_pos)
else
s->bar_pos = value;
- s->offset = ((s->full_size - s->visible_size) * (s->bar_pos)) /
- (well_length - s->bar_len);
+ s->offset = ((well_length - s->bar_len) < 1) ? 0 :
+ (((s->full_size - s->visible_size) *
+ s->bar_pos) / (well_length - s->bar_len));
} else {
if (value > s->full_size - s->visible_size)
@@ -421,7 +422,8 @@ void scrollbar_set(struct scrollbar *s, int value, bool bar_pos)
else
s->offset = value;
- s->bar_pos = (well_length * s->offset) / s->full_size;
+ s->bar_pos = (s->full_size < 1) ? 0 :
+ ((well_length * s->offset) / s->full_size);
}
msg.scrollbar = s;
@@ -478,8 +480,13 @@ void scrollbar_set_extents(struct scrollbar *s, int length,
well_length = s->length - 2 * SCROLLBAR_WIDTH;
- s->bar_len = (well_length * s->visible_size) / s->full_size;
- s->bar_pos = (well_length * s->offset) / s->full_size;
+ if (s->full_size < 1) {
+ s->bar_len = well_length;
+ s->bar_pos = 0;
+ } else {
+ s->bar_len = (well_length * s->visible_size) / s->full_size;
+ s->bar_pos = (well_length * s->offset) / s->full_size;
+ }
}