summaryrefslogtreecommitdiff
path: root/content/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'content/handlers')
-rw-r--r--content/handlers/html/html.c8
-rw-r--r--content/handlers/html/interaction.c76
-rw-r--r--content/handlers/html/private.h5
-rw-r--r--content/handlers/html/redraw.c23
-rw-r--r--content/handlers/text/textplain.c89
5 files changed, 19 insertions, 182 deletions
diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index a3d426461..88098ebee 100644
--- a/content/handlers/html/html.c
+++ b/content/handlers/html/html.c
@@ -481,8 +481,6 @@ html_create_html_data(html_content *c, const http_parameter *params)
c->selection_owner.none = true;
c->focus_type = HTML_FOCUS_SELF;
c->focus_owner.self = true;
- c->search = NULL;
- c->search_string = NULL;
c->scripts_count = 0;
c->scripts = NULL;
c->jsthread = NULL;
@@ -1326,10 +1324,6 @@ static nserror html_close(struct content *c)
selection_clear(&htmlc->sel, false);
- if (htmlc->search != NULL) {
- content_textsearch_destroy(htmlc->search);
- }
-
/* clear the html content reference to the browser window */
htmlc->bw = NULL;
@@ -2204,8 +2198,6 @@ static const content_handler html_content_handler = {
.get_contextual_content = html_get_contextual_content,
.scroll_at_point = html_scroll_at_point,
.drop_file_at_point = html_drop_file_at_point,
- .search = html_search,
- .search_clear = html_search_clear,
.debug_dump = html_debug_dump,
.debug = html_debug,
.clone = html_clone,
diff --git a/content/handlers/html/interaction.c b/content/handlers/html/interaction.c
index 8ae5144c0..f2eae70df 100644
--- a/content/handlers/html/interaction.c
+++ b/content/handlers/html/interaction.c
@@ -1599,82 +1599,6 @@ bool html_keypress(struct content *c, uint32_t key)
/**
- * Handle search.
- *
- * \param c content of type HTML
- * \param fe_ctx front end private data
- * \param flags search flags
- * \param string search string
- */
-void
-html_search(struct content *c,
- void *fe_ctx,
- search_flags_t flags,
- const char *string)
-{
- html_content *html = (html_content *)c;
- nserror res;
-
- assert(c != NULL);
-
- if ((string != NULL) &&
- (html->search_string != NULL) &&
- (strcmp(string, html->search_string) == 0) &&
- (html->search != NULL)) {
- /* Continue prev. search */
- content_textsearch_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) {
- content_textsearch_destroy(html->search);
- html->search = NULL;
- }
-
- res = content_textsearch_create(c, fe_ctx, &html->search);
- if (res != NSERROR_OK) {
- return;
- }
-
- content_textsearch_step(html->search, flags, string);
-
- } else {
- /* Clear search */
- html_search_clear(c);
-
- free(html->search_string);
- html->search_string = NULL;
- }
-}
-
-
-/**
- * Terminate a text 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) {
- content_textsearch_destroy(html->search);
- }
- html->search = NULL;
-}
-
-
-/**
* Callback for in-page scrollbars.
*/
void html_overflow_scroll_callback(void *client_data,
diff --git a/content/handlers/html/private.h b/content/handlers/html/private.h
index 1367c624c..dde61c2a9 100644
--- a/content/handlers/html/private.h
+++ b/content/handlers/html/private.h
@@ -210,11 +210,6 @@ typedef struct html_content {
*/
struct form_control *visible_select_menu;
- /** Context for free text search, or NULL if none */
- struct textsearch_context *search;
- /** Search string or NULL */
- char *search_string;
-
} html_content;
/**
diff --git a/content/handlers/html/redraw.c b/content/handlers/html/redraw.c
index f9fb6b4fd..aa99782c7 100644
--- a/content/handlers/html/redraw.c
+++ b/content/handlers/html/redraw.c
@@ -167,7 +167,6 @@ text_redraw(const char *utf8_text,
bool excluded,
struct content *c,
const struct selection *sel,
- struct textsearch_context *search,
const struct redraw_context *ctx)
{
bool highlighted = false;
@@ -195,8 +194,8 @@ text_redraw(const char *utf8_text,
/* what about the current search operation, if any? */
if (!highlighted &&
- (search != NULL) &&
- content_textsearch_ishighlighted(search,
+ (c->textsearch.context != NULL) &&
+ content_textsearch_ishighlighted(c->textsearch.context,
offset,
offset + len,
&start_idx,
@@ -1138,11 +1137,19 @@ static bool html_redraw_text_box(const html_content *html, struct box *box,
font_plot_style_from_css(&html->len_ctx, box->style, &fstyle);
fstyle.background = current_background_color;
- if (!text_redraw(box->text, box->length, box->byte_offset,
- box->space, &fstyle, x, y,
- clip, box->height, scale, excluded,
- (struct content *)html, &html->sel,
- html->search, ctx))
+ if (!text_redraw(box->text,
+ box->length,
+ box->byte_offset,
+ box->space,
+ &fstyle,
+ x, y,
+ clip,
+ box->height,
+ scale,
+ excluded,
+ (struct content *)html,
+ &html->sel,
+ ctx))
return false;
return true;
diff --git a/content/handlers/text/textplain.c b/content/handlers/text/textplain.c
index e8c38314e..750c5eb3d 100644
--- a/content/handlers/text/textplain.c
+++ b/content/handlers/text/textplain.c
@@ -70,10 +70,6 @@ typedef struct textplain_content {
struct selection sel; /** Selection state */
- /** Context for free text search, or NULL if none */
- struct textsearch_context *search;
- /** Current search string, or NULL if none */
- char *search_string;
} textplain_content;
@@ -738,77 +734,6 @@ static bool textplain_keypress(struct content *c, uint32_t key)
}
-/**
- * Terminate a search.
- *
- * \param c content of type text
- */
-static void textplain_search_clear(struct content *c)
-{
- textplain_content *text = (textplain_content *) c;
-
- assert(c != NULL);
-
- free(text->search_string);
- text->search_string = NULL;
-
- if (text->search != NULL) {
- content_textsearch_destroy(text->search);
- }
- text->search = NULL;
-}
-
-
-/**
- * Handle search.
- *
- * \param c content of type text
- * \param gui_data front end private data
- * \param flags search flags
- * \param string search string
- */
-static void textplain_search(struct content *c, void *gui_data,
- search_flags_t flags, const char *string)
-{
- textplain_content *text = (textplain_content *) c;
- nserror res;
-
- assert(c != NULL);
-
- if (string != NULL &&
- text->search_string != NULL &&
- strcmp(string, text->search_string) == 0 &&
- text->search != NULL) {
- /* Continue prev. search */
- content_textsearch_step(text->search, flags, string);
-
- } else if (string != NULL) {
- /* New search */
- free(text->search_string);
- text->search_string = strdup(string);
- if (text->search_string == NULL)
- return;
-
- if (text->search != NULL) {
- content_textsearch_destroy(text->search);
- text->search = NULL;
- }
-
- res = content_textsearch_create(c, gui_data, &text->search);
- if (res != NSERROR_OK) {
- return;
- }
-
- content_textsearch_step(text->search, flags, string);
-
- } else {
- /* Clear search */
- textplain_search_clear(c);
-
- free(text->search_string);
- text->search_string = NULL;
- }
-}
/**
@@ -868,8 +793,8 @@ text_draw(const char *utf8_text,
/* what about the current search operation, if any? */
if (!highlighted &&
- (text->search != NULL) &&
- content_textsearch_ishighlighted(text->search,
+ (text->base.textsearch.context != NULL) &&
+ content_textsearch_ishighlighted(text->base.textsearch.context,
offset,
offset + len,
&start_idx,
@@ -1164,10 +1089,10 @@ textplain_redraw(struct content *c,
}
if (!highlighted &&
- (text->search != NULL)) {
+ (c->textsearch.context != NULL)) {
unsigned start_idx, end_idx;
if (content_textsearch_ishighlighted(
- text->search,
+ c->textsearch.context,
tab_ofst,
tab_ofst + 1,
&start_idx,
@@ -1227,10 +1152,6 @@ static nserror textplain_close(struct content *c)
{
textplain_content *text = (textplain_content *) c;
- if (text->search != NULL) {
- content_textsearch_destroy(text->search);
- }
-
text->bw = NULL;
return NSERROR_OK;
@@ -1305,8 +1226,6 @@ static const content_handler textplain_content_handler = {
.mouse_track = textplain_mouse_track,
.mouse_action = textplain_mouse_action,
.keypress = textplain_keypress,
- .search = textplain_search,
- .search_clear = textplain_search_clear,
.redraw = textplain_redraw,
.open = textplain_open,
.close = textplain_close,