From 2ea577c47ecca38a0b2d15b15d242c771ce59e29 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 23 May 2020 22:09:40 +0100 Subject: [PATCH] remove unused is_html parameter to text selection routines --- content/handlers/html/html.c | 2 +- content/handlers/html/textselection.c | 4 +--- content/handlers/text/textplain.c | 6 ++---- desktop/selection.c | 25 ++++++++----------------- desktop/selection.h | 6 ++---- 5 files changed, 14 insertions(+), 29 deletions(-) diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c index 2c471ae40..5ae6ee502 100644 --- a/content/handlers/html/html.c +++ b/content/handlers/html/html.c @@ -493,7 +493,7 @@ html_create_html_data(html_content *c, const http_parameter *params) return NSERROR_NOMEM; } - selection_prepare(&c->sel, (struct content *)c, true); + selection_prepare(&c->sel, (struct content *)c); nerror = http_parameter_list_find_item(params, corestring_lwc_charset, &charset); if (nerror == NSERROR_OK) { diff --git a/content/handlers/html/textselection.c b/content/handlers/html/textselection.c index 06e28e11f..becebb882 100644 --- a/content/handlers/html/textselection.c +++ b/content/handlers/html/textselection.c @@ -265,13 +265,11 @@ nserror html_create_selection(struct content *c, struct selection **sel_out) { struct selection *sel; - sel = selection_create(c, true); + sel = selection_create(c); if (sel == NULL) { return NSERROR_NOMEM; } - selection_init(sel); - *sel_out = sel; return NSERROR_OK; } diff --git a/content/handlers/text/textplain.c b/content/handlers/text/textplain.c index 1165bcf5d..c91b81dbd 100644 --- a/content/handlers/text/textplain.c +++ b/content/handlers/text/textplain.c @@ -169,7 +169,7 @@ textplain_create_internal(textplain_content *c, lwc_string *encoding) c->formatted_width = 0; c->bw = NULL; - selection_prepare(&c->sel, (struct content *)c, false); + selection_prepare(&c->sel, (struct content *)c); return NSERROR_OK; @@ -1575,13 +1575,11 @@ static nserror textplain_create_selection(struct content *c, struct selection **sel_out) { struct selection *sel; - sel = selection_create(c, false); + sel = selection_create(c); if (sel == NULL) { return NSERROR_NOMEM; } - selection_init(sel); - *sel_out = sel; return NSERROR_OK; } diff --git a/desktop/selection.c b/desktop/selection.c index 40edff885..1fac7e225 100644 --- a/desktop/selection.c +++ b/desktop/selection.c @@ -49,13 +49,6 @@ #include "netsurf/window.h" #include "desktop/gui_internal.h" -/** - * Text selection works by labelling each node in the box tree with its - * start index in the textual representation of the tree's content. - */ - -#define SPACE_LEN(b) ((b->space == 0) ? 0 : 1) - struct selection_string { char *buffer; @@ -67,8 +60,6 @@ struct selection_string { }; - - /** * Redraws the given range of text. * @@ -254,24 +245,24 @@ selection_string_append(const char *text, /* exported interface documented in desktop/selection.h */ -struct selection *selection_create(struct content *c, bool is_html) +struct selection *selection_create(struct content *c) { - struct selection *s; - s = calloc(1, sizeof(struct selection)); - if (s) { - selection_prepare(s, c, is_html); + struct selection *sel; + sel = calloc(1, sizeof(struct selection)); + if (sel) { + selection_prepare(sel, c); + selection_init(sel); } - return s; + return sel; } /* exported interface documented in desktop/selection.h */ -void selection_prepare(struct selection *s, struct content *c, bool is_html) +void selection_prepare(struct selection *s, struct content *c) { if (s) { s->c = c; - s->is_html = is_html; s->root = NULL; s->drag_state = DRAG_NONE; s->max_idx = 0; diff --git a/desktop/selection.h b/desktop/selection.h index e570d8311..4f3e8b002 100644 --- a/desktop/selection.h +++ b/desktop/selection.h @@ -53,7 +53,6 @@ struct selection unsigned end_idx; bool defined; - bool is_html; seln_drag_state drag_state; }; @@ -79,7 +78,7 @@ struct selection * * \return new selection context */ -struct selection *selection_create(struct content *c, bool is_html); +struct selection *selection_create(struct content *c); /** * Prepare a newly created selection object for use. @@ -88,9 +87,8 @@ struct selection *selection_create(struct content *c, bool is_html); * * \param s selection object * \param c content - * \param is_html true if content is html false if content is textplain */ -void selection_prepare(struct selection *s, struct content *c, bool is_html); +void selection_prepare(struct selection *s, struct content *c); /** * Destroys a selection object clearing it if nesessary