diff options
Diffstat (limited to 'render')
-rw-r--r-- | render/box.c | 14 | ||||
-rw-r--r-- | render/box.h | 2 | ||||
-rw-r--r-- | render/html.c | 1 | ||||
-rw-r--r-- | render/html.h | 5 | ||||
-rw-r--r-- | render/html_interaction.c | 42 | ||||
-rw-r--r-- | render/html_internal.h | 4 | ||||
-rw-r--r-- | render/html_redraw.c | 4 |
7 files changed, 46 insertions, 26 deletions
diff --git a/render/box.c b/render/box.c index 60b5b9381..17d73c5fd 100644 --- a/render/box.c +++ b/render/box.c @@ -999,16 +999,16 @@ void box_dump(FILE *stream, struct box *box, unsigned int depth) * 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 @@ bool box_handle_scrollbars(struct browser_window *bw, struct box *box, 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 @@ bool box_handle_scrollbars(struct browser_window *bw, struct box *box, } 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 - diff --git a/render/box.h b/render/box.h index 99f67ee1f..9c8161373 100644 --- a/render/box.h +++ b/render/box.h @@ -331,7 +331,7 @@ 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 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); diff --git a/render/html.c b/render/html.c index 16b18263c..a45e26b7e 100644 --- a/render/html.c +++ b/render/html.c @@ -242,6 +242,7 @@ nserror html_create_html_data(html_content *c, const http_parameter *params) 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) { diff --git a/render/html.h b/render/html.h index 9f4f3f698..426541342 100644 --- a/render/html.h +++ b/render/html.h @@ -85,6 +85,11 @@ struct content_html_object { bool background; /**< This object is a background image. */ }; +struct html_scrollbar_data { + struct content *c; + struct box *box; +}; + /** Frame tree (<frameset>, <frame>) */ struct content_html_frames { int cols; /** number of columns in frameset */ diff --git a/render/html_interaction.c b/render/html_interaction.c index 3b0dd767f..453c9cbbf 100644 --- a/render/html_interaction.c +++ b/render/html_interaction.c @@ -142,6 +142,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw, 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 @@ void html_mouse_action(struct content *c, struct browser_window *bw, 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 @@ gui_pointer_shape get_pointer_shape(struct browser_window *bw, struct box *box, /** - * 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 @@ void html_overflow_scroll_callback(void *client_data, 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); + browser_window_set_drag_type(html->bw, DRAGGING_OTHER); - bw->scrollbar = scrollbar_data->scrollbar; - gui_window_box_scroll_start(bw->window, + 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 @@ void html_overflow_scroll_drag_end(struct scrollbar *scrollbar, 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; diff --git a/render/html_internal.h b/render/html_internal.h index cbb323844..ad7235313 100644 --- a/render/html_internal.h +++ b/render/html_internal.h @@ -84,6 +84,10 @@ typedef struct html_content { 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; diff --git a/render/html_redraw.c b/render/html_redraw.c index f89ab84d2..31f81d363 100644 --- a/render/html_redraw.c +++ b/render/html_redraw.c @@ -723,7 +723,9 @@ bool html_redraw_box(struct box *box, int x_parent, int y_parent, 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; |