summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2009-08-14 23:10:53 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2009-08-14 23:10:53 +0000
commitc26611b32b3796d4bbc886e7efd839ad999885c6 (patch)
treed6ba79dc0aa97c326449ee0e7eb57e25abed21c0
parent45e05288f0b7f521dfe706ce152072c422cc8ae1 (diff)
downloadnetsurf-c26611b32b3796d4bbc886e7efd839ad999885c6.tar.gz
netsurf-c26611b32b3796d4bbc886e7efd839ad999885c6.tar.bz2
Merge from Paul Blokus' selectscroll branch. Fixes text input scrollbar behaviour.
svn path=/trunk/netsurf/; revision=9306
-rw-r--r--desktop/scroll.c23
-rw-r--r--desktop/scroll.h4
-rw-r--r--desktop/textinput.c3
-rw-r--r--render/box.c25
-rw-r--r--render/box.h5
-rw-r--r--render/html_redraw.c3
6 files changed, 39 insertions, 24 deletions
diff --git a/desktop/scroll.c b/desktop/scroll.c
index 248c70908..8b14e7a2a 100644
--- a/desktop/scroll.c
+++ b/desktop/scroll.c
@@ -489,24 +489,33 @@ int scroll_get_offset(struct scroll *scroll)
/**
- * Set the length of the scroll and the visible part of the scrolled area.
+ * Set the length of the scroll and the visible or scrolled part of the scrolled
+ * area.
*
* \param scroll the scroll to set the values for
- * \param length the new scroll length to be set
- * \param scrolled_visible the new value of the visible part of the
+ * \param length -1 or the new scroll length to be set
+ * \param scrolled_visible -1 or the new value of the visible part of the
* scrolled area to be set
+ * \param scrolled_dimension -1 or the new dimension of the scrolled content
*/
-void scroll_set_length_and_visible(struct scroll *scroll, int length,
- int scrolled_visible)
+void scroll_set_extents(struct scroll *scroll, int length,
+ int scrolled_visible, int scrolled_dimension)
{
int well_length;
- scroll->length = length;
- scroll->scrolled_vis = scrolled_visible;
+ if (length != -1)
+ scroll->length = length;
+ if (scrolled_visible != -1)
+ scroll->scrolled_vis = scrolled_visible;
+ if (scrolled_dimension != -1)
+ scroll->scrolled_d = scrolled_dimension;
+
well_length = length - 2 * SCROLLBAR_WIDTH;
scroll->bar_len = (well_length * scrolled_visible) /
scroll->scrolled_d;
+ scroll->bar_off = (well_length * scroll->area_scroll) /
+ scroll->scrolled_d;
}
/**
diff --git a/desktop/scroll.h b/desktop/scroll.h
index f0569c37f..3e15d5f3e 100644
--- a/desktop/scroll.h
+++ b/desktop/scroll.h
@@ -71,8 +71,8 @@ bool scroll_redraw(struct scroll *scroll, int x, int y,
void scroll_set(struct scroll *scroll, int scroll_val, bool bar);
int scroll_get_offset(struct scroll *scroll);
-void scroll_set_length_and_visible(struct scroll *scroll, int length,
- int scrolled_visible);
+void scroll_set_extents(struct scroll *scroll, int length,
+ int scrolled_visible, int scrolled_dimension);
bool scroll_is_horizontal(struct scroll *scroll);
diff --git a/desktop/textinput.c b/desktop/textinput.c
index 4a0aef467..f05f57fe1 100644
--- a/desktop/textinput.c
+++ b/desktop/textinput.c
@@ -2098,6 +2098,9 @@ void textarea_reflow(struct browser_window *bw, struct box *textarea,
textarea->width = width;
textarea->height = height;
layout_calculate_descendant_bboxes(textarea);
+ box_handle_scrollbars(bw, textarea,
+ box_hscrollbar_present(textarea),
+ box_vscrollbar_present(textarea));
}
diff --git a/render/box.c b/render/box.c
index 0c0985dab..b355e68d1 100644
--- a/render/box.c
+++ b/render/box.c
@@ -997,15 +997,14 @@ void box_duplicate_update(struct box *box,
* Applies the given scroll setup to a box. This includes scroll
* creation/deletion as well as scroll dimension updates.
*
+ * \param bw browser window in which the box is located
* \param box the box to handle the scrolls for
- * \param x X coordinate of the box
- * \param y Y coordinate of the box
* \param bottom whether the horizontal scrollbar should be present
* \param right whether the vertical scrollbar should be present
* \return true on success false otherwise
*/
-bool box_handle_scrollbars(struct box *box, int x, int y, bool bottom,
- bool right)
+bool box_handle_scrollbars(struct browser_window *bw, struct box *box,
+ bool bottom, bool right)
{
struct browser_scroll_data *data;
int padding_width, padding_height;
@@ -1021,7 +1020,7 @@ bool box_handle_scrollbars(struct box *box, int x, int y, bool bottom,
}
if (!right && box->scroll_y != NULL) {
- data = scroll_get_data(box->scroll_x);
+ data = scroll_get_data(box->scroll_y);
scroll_destroy(box->scroll_y);
free(data);
box->scroll_y = NULL;
@@ -1038,7 +1037,7 @@ bool box_handle_scrollbars(struct box *box, int x, int y, bool bottom,
warn_user("NoMemory", 0);
return false;
}
- data->bw = current_redraw_browser;
+ data->bw = bw;
data->box = box;
if (!scroll_create(false,
padding_height,
@@ -1049,8 +1048,10 @@ bool box_handle_scrollbars(struct box *box, int x, int y, bool bottom,
&(box->scroll_y)))
return false;
} else
- scroll_set_length_and_visible(box->scroll_y,
- padding_height, box->height);
+ scroll_set_extents(box->scroll_y,
+ padding_height, box->height,
+ box->descendant_y1 -
+ box->descendant_y0);
}
if (bottom) {
if (box->scroll_x == NULL) {
@@ -1060,7 +1061,7 @@ bool box_handle_scrollbars(struct box *box, int x, int y, bool bottom,
warn_user("NoMemory", 0);
return false;
}
- data->bw = current_redraw_browser;
+ data->bw = bw;
data->box = box;
if (!scroll_create(true,
padding_width -
@@ -1072,10 +1073,12 @@ bool box_handle_scrollbars(struct box *box, int x, int y, bool bottom,
&box->scroll_x))
return false;
} else
- scroll_set_length_and_visible(box->scroll_x,
+ scroll_set_extents(box->scroll_x,
padding_width -
(right ? SCROLLBAR_WIDTH : 0),
- box->width);
+ box->width,
+ box->descendant_x1 -
+ box->descendant_x0);
}
if (right && bottom)
diff --git a/render/box.h b/render/box.h
index 39a6c2521..b53e0481c 100644
--- a/render/box.h
+++ b/render/box.h
@@ -91,6 +91,7 @@
#include <stdio.h>
#include <libxml/HTMLparser.h>
+#include "desktop/browser.h"
#include "css/css.h"
struct box;
@@ -314,8 +315,8 @@ bool box_visible(struct box *box);
void box_dump(FILE *stream, struct box *box, unsigned int depth);
bool box_extract_link(const char *rel, const char *base, char **result);
-bool box_handle_scrollbars(struct box *box, int x, int y, bool bottom,
- bool right);
+bool box_handle_scrollbars(struct browser_window *bw, struct box *box,
+ bool bottom, bool right);
bool box_vscrollbar_present(const struct box *box);
bool box_hscrollbar_present(const struct box *box);
diff --git a/render/html_redraw.c b/render/html_redraw.c
index 2f4fdf794..becf99fe4 100644
--- a/render/html_redraw.c
+++ b/render/html_redraw.c
@@ -712,8 +712,7 @@ bool html_redraw_box(struct box *box,
has_y_scroll = box_vscrollbar_present(box);
- if (!box_handle_scrollbars(box,
- x_parent + box->x, y_parent + box->y,
+ if (!box_handle_scrollbars(current_redraw_browser,box,
has_x_scroll, has_y_scroll))
return false;