Author: tlsa
Date: Mon Jun 27 17:21:15 2011
New Revision: 12519
URL:
http://source.netsurf-browser.org?rev=12519&view=rev
Log:
HTML contents manage box scrollbars, rather than browser_windows.
Modified:
trunk/netsurf/desktop/browser.c
trunk/netsurf/desktop/browser.h
trunk/netsurf/desktop/textinput.c
trunk/netsurf/render/box.c
trunk/netsurf/render/box.h
trunk/netsurf/render/html.c
trunk/netsurf/render/html.h
trunk/netsurf/render/html_interaction.c
trunk/netsurf/render/html_internal.h
trunk/netsurf/render/html_redraw.c
Modified: trunk/netsurf/desktop/browser.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/desktop/browser.c?rev=125...
==============================================================================
--- trunk/netsurf/desktop/browser.c (original)
+++ trunk/netsurf/desktop/browser.c Mon Jun 27 17:21:15 2011
@@ -633,8 +633,6 @@
browser_window_remove_caret(bw);
- bw->scrollbar = NULL;
-
if (bw->window)
gui_window_new_content(bw->window);
@@ -708,7 +706,6 @@
else if (c == bw->current_content) {
bw->current_content = NULL;
browser_window_remove_caret(bw);
- bw->scrollbar = NULL;
selection_init(bw->sel, NULL);
}
@@ -1803,6 +1800,7 @@
}
selection_drag_end(bw->sel);
}
+ bw->drag_type = DRAGGING_NONE;
break;
case DRAGGING_OTHER:
@@ -1810,19 +1808,14 @@
if (bw->visible_select_menu != NULL) {
form_select_mouse_drag_end(bw->visible_select_menu,
mouse, x, y);
- }
-
- if (bw->scrollbar != NULL) {
- html_overflow_scroll_drag_end(bw->scrollbar,
- mouse, x, y);
+ bw->drag_type = DRAGGING_NONE;
}
break;
default:
- break;
- }
-
- bw->drag_type = DRAGGING_NONE;
+ bw->drag_type = DRAGGING_NONE;
+ break;
+ }
}
Modified: trunk/netsurf/desktop/browser.h
URL:
http://source.netsurf-browser.org/trunk/netsurf/desktop/browser.h?rev=125...
==============================================================================
--- trunk/netsurf/desktop/browser.h (original)
+++ trunk/netsurf/desktop/browser.h Mon Jun 27 17:21:15 2011
@@ -114,10 +114,6 @@
unsigned int drag_resize_up : 1;
unsigned int drag_resize_down : 1;
- /** Scroll capturing all mouse events, updated to any active HTML
- * scrollbar, or NULL when no scrollbar drags active */
- struct scrollbar *scrollbar;
-
/** Current fetch is download */
bool download;
@@ -196,11 +192,6 @@
int status_text_len; /**< Length of the ::status_text buffer. */
int status_match; /**< Number of times an idempotent status-set operation was
performed. */
int status_miss; /**< Number of times status was really updated. */
-};
-
-struct browser_scrollbar_data {
- struct browser_window *bw;
- struct box *box;
};
extern struct browser_window *current_redraw_browser;
Modified: trunk/netsurf/desktop/textinput.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/desktop/textinput.c?rev=1...
==============================================================================
--- trunk/netsurf/desktop/textinput.c (original)
+++ trunk/netsurf/desktop/textinput.c Mon Jun 27 17:21:15 2011
@@ -37,6 +37,7 @@
#include "render/box.h"
#include "render/font.h"
#include "render/form.h"
+#include "render/html_internal.h"
#include "render/layout.h"
#include "utils/log.h"
#include "utils/talloc.h"
@@ -2168,7 +2169,7 @@
textarea->width = width;
textarea->height = height;
layout_calculate_descendant_bboxes(textarea);
- box_handle_scrollbars(bw, textarea,
+ box_handle_scrollbars(c, textarea,
box_hscrollbar_present(textarea),
box_vscrollbar_present(textarea));
}
@@ -2263,6 +2264,8 @@
bool ensure_caret_visible(struct browser_window *bw, struct box *textarea)
{
+ html_content *html = (html_content *)
+ hlcache_handle_get_content(bw->current_content);
int cx, cy;
int scrollx, scrolly;
@@ -2302,14 +2305,14 @@
return false;
if (textarea->scroll_x != NULL) {
- bw->scrollbar = textarea->scroll_x;
+ html->scrollbar = textarea->scroll_x;
scrollbar_set(textarea->scroll_x, scrollx, false);
- bw->scrollbar = NULL;
+ html->scrollbar = NULL;
}
if (textarea->scroll_y != NULL) {
- bw->scrollbar = textarea->scroll_x;
+ html->scrollbar = textarea->scroll_x;
scrollbar_set(textarea->scroll_y, scrolly, false);
- bw->scrollbar = NULL;
+ html->scrollbar = NULL;
}
return true;
Modified: trunk/netsurf/render/box.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/render/box.c?rev=12519&am...
==============================================================================
--- trunk/netsurf/render/box.c (original)
+++ trunk/netsurf/render/box.c Mon Jun 27 17:21:15 2011
@@ -999,16 +999,16 @@
* 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 c content in which the box is located
* \param box the box to handle the scrolls for
* \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 browser_window *bw, struct box *box,
+bool box_handle_scrollbars(struct content *c, struct box *box,
bool bottom, bool right)
{
- struct browser_scrollbar_data *data;
+ struct html_scrollbar_data *data;
int visible_width, visible_height;
int full_width, full_height;
@@ -1043,13 +1043,13 @@
if (right) {
if (box->scroll_y == NULL) {
- data = malloc(sizeof(struct browser_scrollbar_data));
+ data = malloc(sizeof(struct html_scrollbar_data));
if (data == NULL) {
LOG(("malloc failed"));
warn_user("NoMemory", 0);
return false;
}
- data->bw = bw;
+ data->c = c;
data->box = box;
if (!scrollbar_create(false, visible_height,
full_height, visible_height,
@@ -1063,13 +1063,13 @@
}
if (bottom) {
if (box->scroll_x == NULL) {
- data = malloc(sizeof(struct browser_scrollbar_data));
+ data = malloc(sizeof(struct html_scrollbar_data));
if (data == NULL) {
LOG(("malloc failed"));
warn_user("NoMemory", 0);
return false;
}
- data->bw = bw;
+ data->c = c;
data->box = box;
if (!scrollbar_create(true,
visible_width -
Modified: trunk/netsurf/render/box.h
URL:
http://source.netsurf-browser.org/trunk/netsurf/render/box.h?rev=12519&am...
==============================================================================
--- trunk/netsurf/render/box.h (original)
+++ trunk/netsurf/render/box.h Mon Jun 27 17:21:15 2011
@@ -331,7 +331,7 @@
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 browser_window *bw, struct box *box,
+bool box_handle_scrollbars(struct content *c, struct box *box,
bool bottom, bool right);
bool box_vscrollbar_present(const struct box *box);
bool box_hscrollbar_present(const struct box *box);
Modified: trunk/netsurf/render/html.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/render/html.c?rev=12519&a...
==============================================================================
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Mon Jun 27 17:21:15 2011
@@ -242,6 +242,7 @@
c->page = NULL;
c->box = NULL;
c->font_func = &nsfont;
+ c->scrollbar = NULL;
nerror = http_parameter_list_find_item(params, "charset", &charset);
if (nerror == NSERROR_OK) {
Modified: trunk/netsurf/render/html.h
URL:
http://source.netsurf-browser.org/trunk/netsurf/render/html.h?rev=12519&a...
==============================================================================
--- trunk/netsurf/render/html.h (original)
+++ trunk/netsurf/render/html.h Mon Jun 27 17:21:15 2011
@@ -83,6 +83,11 @@
/** Bitmap of acceptable content types */
content_type permitted_types;
bool background; /**< This object is a background image. */
+};
+
+struct html_scrollbar_data {
+ struct content *c;
+ struct box *box;
};
/** Frame tree (<frameset>, <frame>) */
Modified: trunk/netsurf/render/html_interaction.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/render/html_interaction.c...
==============================================================================
--- trunk/netsurf/render/html_interaction.c (original)
+++ trunk/netsurf/render/html_interaction.c Mon Jun 27 17:21:15 2011
@@ -142,6 +142,7 @@
plot_font_style_t fstyle;
int scroll_mouse_x = 0, scroll_mouse_y = 0;
int padding_left, padding_right, padding_top, padding_bottom;
+ html_content *html = (html_content *) c;
if (bw->visible_select_menu != NULL) {
@@ -166,24 +167,30 @@
return;
}
- if (bw->scrollbar != NULL) {
- struct browser_scrollbar_data *data =
- scrollbar_get_data(bw->scrollbar);
+ if (bw->drag_type != DRAGGING_NONE && !mouse &&
+ html->scrollbar != NULL) {
+ /* Scrollbar drag end */
+ html_overflow_scroll_drag_end(html->scrollbar, mouse, x, y);
+ }
+
+ if (html->scrollbar != NULL) {
+ struct html_scrollbar_data *data =
+ scrollbar_get_data(html->scrollbar);
box = data->box;
box_coords(box, &box_x, &box_y);
- if (scrollbar_is_horizontal(bw->scrollbar)) {
+ if (scrollbar_is_horizontal(html->scrollbar)) {
scroll_mouse_x = x - box_x ;
scroll_mouse_y = y - (box_y + box->padding[TOP] +
box->height + box->padding[BOTTOM] -
SCROLLBAR_WIDTH);
- status = scrollbar_mouse_action(bw->scrollbar, mouse,
+ status = scrollbar_mouse_action(html->scrollbar, mouse,
scroll_mouse_x, scroll_mouse_y);
} else {
scroll_mouse_x = x - (box_x + box->padding[LEFT] +
box->width + box->padding[RIGHT] -
SCROLLBAR_WIDTH);
scroll_mouse_y = y - box_y;
- status = scrollbar_mouse_action(bw->scrollbar, mouse,
+ status = scrollbar_mouse_action(html->scrollbar, mouse,
scroll_mouse_x, scroll_mouse_y);
}
@@ -750,13 +757,13 @@
/**
- * Callback for in-page scrolls.
+ * Callback for in-page scrollbars.
*/
void html_overflow_scroll_callback(void *client_data,
struct scrollbar_msg_data *scrollbar_data)
{
- struct browser_scrollbar_data *data = client_data;
- struct browser_window *bw = data->bw;
+ struct html_scrollbar_data *data = client_data;
+ html_content *html = (html_content *)data->c;
struct box *box = data->box;
int x, y, box_x, box_y, diff_x, diff_y;
@@ -779,27 +786,28 @@
diff_x;
y = box_y + scrollbar_get_offset(box->scroll_y);
}
- browser_window_redraw_rect(bw,
+ content__request_redraw((struct content *)html,
x + scrollbar_data->x0,
y + scrollbar_data->y0,
scrollbar_data->x1 - scrollbar_data->x0,
scrollbar_data->y1 - scrollbar_data->y0);
break;
case SCROLLBAR_MSG_MOVED:
- html_redraw_a_box(bw->current_content, box);
+ html_redraw_a_box(html->bw->current_content, box);
break;
case SCROLLBAR_MSG_SCROLL_START:
- browser_window_set_drag_type(bw, DRAGGING_OTHER);
-
- bw->scrollbar = scrollbar_data->scrollbar;
- gui_window_box_scroll_start(bw->window,
+ browser_window_set_drag_type(html->bw, DRAGGING_OTHER);
+
+ html->scrollbar = scrollbar_data->scrollbar;
+ gui_window_box_scroll_start(html->bw->window,
scrollbar_data->x0, scrollbar_data->y0,
scrollbar_data->x1, scrollbar_data->y1);
break;
case SCROLLBAR_MSG_SCROLL_FINISHED:
- bw->scrollbar = NULL;
+ html->scrollbar = NULL;
- browser_window_set_pointer(bw, GUI_POINTER_DEFAULT);
+ browser_window_set_pointer(html->bw,
+ GUI_POINTER_DEFAULT);
break;
}
}
@@ -817,7 +825,7 @@
browser_mouse_state mouse, int x, int y)
{
int scroll_mouse_x, scroll_mouse_y, box_x, box_y;
- struct browser_scrollbar_data *data = scrollbar_get_data(scrollbar);
+ struct html_scrollbar_data *data = scrollbar_get_data(scrollbar);
struct box *box;
box = data->box;
Modified: trunk/netsurf/render/html_internal.h
URL:
http://source.netsurf-browser.org/trunk/netsurf/render/html_internal.h?re...
==============================================================================
--- trunk/netsurf/render/html_internal.h (original)
+++ trunk/netsurf/render/html_internal.h Mon Jun 27 17:21:15 2011
@@ -84,6 +84,10 @@
struct html_content *page;
/** Box containing this, or NULL if not an object. */
struct box *box;
+
+ /** Scrollbar capturing all mouse events, updated to any active HTML
+ * scrollbar, or NULL when no scrollbar drags active */
+ struct scrollbar *scrollbar;
} html_content;
Modified: trunk/netsurf/render/html_redraw.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/render/html_redraw.c?rev=...
==============================================================================
--- trunk/netsurf/render/html_redraw.c (original)
+++ trunk/netsurf/render/html_redraw.c Mon Jun 27 17:21:15 2011
@@ -723,7 +723,9 @@
has_x_scroll = box_hscrollbar_present(box);
has_y_scroll = box_vscrollbar_present(box);
- if (!box_handle_scrollbars(current_redraw_browser, box,
+ /* TODO: pass content down, so we don't need
+ * current_redraw_browser here */
+ if
(!box_handle_scrollbars(hlcache_handle_get_content(current_redraw_browser->current_content),
box,
has_x_scroll, has_y_scroll))
return false;