From 5526d7e6f2e071a115359f6b9c0dca7b2c4c4efe Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 14 Aug 2012 14:03:54 +0100 Subject: Stop render/search.c from dereferencing bw and remove dependency on html & text contents' bw pointer. --- render/search.c | 31 ++++--------------------------- render/search.h | 12 ++++++++---- 2 files changed, 12 insertions(+), 31 deletions(-) (limited to 'render') diff --git a/render/search.c b/render/search.c index 70ff3337e..d30c43f11 100644 --- a/render/search.c +++ b/render/search.c @@ -30,7 +30,6 @@ #include "content/content.h" #include "content/hlcache.h" -#include "desktop/browser.h" #include "desktop/gui.h" #include "desktop/selection.h" #include "render/box.h" @@ -75,26 +74,6 @@ struct search_context { }; -/** - * Find the browser window that contains the content associated with a search - * - * \param search search context - * \return the browser window, or NULL if none - */ -static struct browser_window *search_get_browser_window( - struct search_context *search) -{ - if (search->c != NULL) { - if (search->is_html == true) { - return html_get_browser_window(search->c); - } else { - return textplain_get_browser_window(search->c); - } - } - return NULL; -} - - /** * create a search_context * \param h the hlcache_handle the search_context is connected to @@ -722,13 +701,11 @@ void search_destroy_context(struct search_context *context) { assert(context != NULL); - if (context->c != NULL) { - struct browser_window *bw = search_get_browser_window(context); + if (context->callbacks.invalidate != NULL) { + context->callbacks.invalidate(context, context->callbacks.p); + } - /* TODO: don't poke inside bw */ - if (bw->cur_search == context) { - bw->cur_search = NULL; - } + if (context->c != NULL) { if (context->is_html) html_set_search(context->c, NULL); diff --git a/render/search.h b/render/search.h index 3d5e9f0e3..e1f58f2ae 100644 --- a/render/search.h +++ b/render/search.h @@ -24,19 +24,23 @@ #include "desktop/search.h" +struct search_context; + /** * Called when a search context is destroyed - * \param p pointer for client data + * \param context search context being invalidated + * \param p pointer for client data */ -typedef void (*search_destroy_callback)(void *p); +typedef void (*search_invalidate_callback)(struct search_context *context, + void *p); struct search_callbacks { struct gui_search_callbacks *gui; void *gui_p; /* private gui owned data */ + search_invalidate_callback invalidate; + void *p; /* private client data */ }; -struct search_context; - struct search_context * search_create_context(struct hlcache_handle *h, struct search_callbacks callbacks); -- cgit v1.2.3