From 430b63e2429179f422b68e1da0d576c8662b5d5a Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 14 Jul 2011 10:27:24 +0000 Subject: Remove assumption of gui window from search. svn path=/trunk/netsurf/; revision=12603 --- desktop/browser.c | 33 +++++++++++++++++++++++++-------- desktop/browser.h | 21 +++++++++++++++++++++ desktop/search.c | 5 ++--- 3 files changed, 48 insertions(+), 11 deletions(-) (limited to 'desktop') diff --git a/desktop/browser.c b/desktop/browser.c index 54c89fe64..7fd572e21 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -378,15 +378,32 @@ struct selection *browser_window_get_selection(struct browser_window *bw) return bw->cur_sel; } -/** - * Set scroll offsets for a browser window. - * - * \param bw The browser window - * \param x The x scroll offset to set - * \param y The y scroll offset to set - */ +/* exported interface, documented in browser.h */ +void browser_window_scroll_visible(struct browser_window *bw, + const struct rect *rect) +{ + assert(bw != NULL); -static void browser_window_set_scroll(struct browser_window *bw, int x, int y) + switch (bw->browser_window_type) { + default: + /* fall through to NORMAL until frame(set)s are handled + * in the core */ + case BROWSER_WINDOW_NORMAL: + gui_window_scroll_visible(bw->window, + rect->x0, rect->y0, rect->x1, rect->y1); + break; + + case BROWSER_WINDOW_IFRAME: + if (bw->scroll_x != NULL) + scrollbar_set(bw->scroll_x, rect->x0, false); + if (bw->scroll_y != NULL) + scrollbar_set(bw->scroll_y, rect->y0, false); + break; + } +} + +/* exported interface, documented in browser.h */ +void browser_window_set_scroll(struct browser_window *bw, int x, int y) { if (bw->window != NULL) { gui_window_set_scroll(bw->window, x, y); diff --git a/desktop/browser.h b/desktop/browser.h index f008cfc00..3d982e32e 100644 --- a/desktop/browser.h +++ b/desktop/browser.h @@ -339,6 +339,27 @@ void browser_window_get_position(struct browser_window *bw, bool root, */ void browser_window_set_position(struct browser_window *bw, int x, int y); +/* + * Scroll the browser window to display the passed area + * + * \param bw browser window to scroll + * \param rect area to display + */ +void browser_window_scroll_visible(struct browser_window *bw, + const struct rect *rect); + +/** + * Set scroll offsets for a browser window. + * + * \param bw The browser window + * \param x The x scroll offset to set + * \param y The y scroll offset to set + * + * TODO -- Do we really need this and browser_window_scroll_visible? + * Ditto for gui_window_* variants. + */ +void browser_window_set_scroll(struct browser_window *bw, int x, int y); + /* * Set the position of the current browser window with respect to the parent * browser window diff --git a/desktop/search.c b/desktop/search.c index 977f12ebe..09f5a5958 100644 --- a/desktop/search.c +++ b/desktop/search.c @@ -193,7 +193,7 @@ void search_step(struct search_context *context, search_flags_t flags, context->callbacks->back_state(false, context->p); if (context->callbacks->forward_state != NULL) context->callbacks->forward_state(false, context->p); - gui_window_set_scroll(context->bw->window, 0, 0); + browser_window_set_scroll(context->bw, 0, 0); return; } search_text(string, string_len, context, flags); @@ -367,8 +367,7 @@ void search_text(const char *string, int string_len, break; } - gui_window_scroll_visible(context->bw->window, - bounds.x0, bounds.y0, bounds.x1, bounds.y1); + browser_window_scroll_visible(context->bw, &bounds); } /** -- cgit v1.2.3