diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2013-05-07 14:41:40 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2013-05-07 14:41:40 +0100 |
commit | 3afd9c97310d58c0c6588d18887244328590731e (patch) | |
tree | 133917633f801613e8742d8b313faee3c4f47e71 /render/html_interaction.c | |
parent | 0647d69a8b8663fcc09af118dde6b256624fe232 (diff) | |
download | netsurf-3afd9c97310d58c0c6588d18887244328590731e.tar.gz netsurf-3afd9c97310d58c0c6588d18887244328590731e.tar.bz2 |
Remove search context from browser window, simplify search interface for front ends.
Added content interface for search.
Removed bw->cur_search search context. Desktop layer now does nothing
except pass search requests from front end onto the bw's current_content
via the content interface.
Search API reduced to a pair of functions at each level:
{desktop|content|html|textplain}_search
and
{desktop|content|html|textplain}_search_clear
Updated front ends to use simplified search API. Only tested GTK and RO builds.
These confine the search stuff to render/. However search still uses struct
selection. The handling for which is still spread over desktop/ and render/.
Also the render/search code itself still fiddles inside html and textplain
privates.
Diffstat (limited to 'render/html_interaction.c')
-rw-r--r-- | render/html_interaction.c | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/render/html_interaction.c b/render/html_interaction.c index 0dc36472d..7c3de2a01 100644 --- a/render/html_interaction.c +++ b/render/html_interaction.c @@ -43,6 +43,7 @@ #include "render/form.h" #include "render/html_internal.h" #include "render/imagemap.h" +#include "render/search.h" #include "javascript/js.h" #include "utils/messages.h" #include "utils/utils.h" @@ -952,7 +953,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw, /** * Handle keypresses. * - * \param c content of type CONTENT_TEXTPLAIN + * \param c content of type HTML * \param key The UCS4 character codepoint * \return true if key handled, false otherwise */ @@ -1005,6 +1006,79 @@ bool html_keypress(struct content *c, uint32_t key) /** + * Handle search. + * + * \param c content of type HTML + * \param gui_callbacks vtable for updating front end + * \param gui_data front end private data + * \param flags search flags + * \param string search string + */ +void html_search(struct content *c, + struct gui_search_callbacks *gui_callbacks, void *gui_data, + search_flags_t flags, const char *string) +{ + html_content *html = (html_content *)c; + + assert(c != NULL); + + if (string != NULL && html->search_string != NULL && + strcmp(string, html->search_string) == 0 && + html->search != NULL) { + /* Continue prev. search */ + search_step(html->search, flags, string); + + } else if (string != NULL) { + /* New search */ + free(html->search_string); + html->search_string = strdup(string); + if (html->search_string == NULL) + return; + + if (html->search != NULL) { + search_destroy_context(html->search); + html->search = NULL; + } + + html->search = search_create_context(c, CONTENT_HTML, + gui_callbacks, gui_data); + + if (html->search == NULL) + return; + + search_step(html->search, flags, string); + + } else { + /* Clear search */ + html_search_clear(c); + + free(html->search_string); + html->search_string = NULL; + } +} + + +/** + * Terminate a search. + * + * \param c content of type HTML + */ +void html_search_clear(struct content *c) +{ + html_content *html = (html_content *)c; + + assert(c != NULL); + + free(html->search_string); + html->search_string = NULL; + + if (html->search != NULL) + search_destroy_context(html->search); + html->search = NULL; +} + + +/** * Callback for in-page scrollbars. */ void html_overflow_scroll_callback(void *client_data, |