summaryrefslogtreecommitdiff
path: root/content/handlers/html
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2020-05-23 23:33:52 +0100
committerVincent Sanders <vince@kyllikki.org>2020-05-23 23:33:52 +0100
commit5ce8f0baf1af7ce119c0c3c5b4d32934a1d95a0a (patch)
treea739586369f7ad25a791563d256320b6560b9553 /content/handlers/html
parent6108d210d508e754904c46f687adbc87ab98dc78 (diff)
downloadnetsurf-5ce8f0baf1af7ce119c0c3c5b4d32934a1d95a0a.tar.gz
netsurf-5ce8f0baf1af7ce119c0c3c5b4d32934a1d95a0a.tar.bz2
make text selection context an opaque interface
Diffstat (limited to 'content/handlers/html')
-rw-r--r--content/handlers/html/html.c14
-rw-r--r--content/handlers/html/interaction.c20
-rw-r--r--content/handlers/html/private.h4
-rw-r--r--content/handlers/html/redraw.c2
4 files changed, 21 insertions, 19 deletions
diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index a133d15a9..5b74e42da 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);
+ c->sel = selection_create((struct content *)c);
nerror = http_parameter_list_find_item(params, corestring_lwc_charset, &charset);
if (nerror == NSERROR_OK) {
@@ -1056,7 +1056,7 @@ static void html_reformat(struct content *c, int width, int height)
if (c->height < layout->y + layout->descendant_y1)
c->height = layout->y + layout->descendant_y1;
- selection_reinit(&htmlc->sel);
+ selection_reinit(htmlc->sel);
htmlc->reflowing = false;
htmlc->had_initial_layout = true;
@@ -1184,6 +1184,8 @@ static void html_destroy(struct content *c)
}
}
+ selection_destroy(html->sel);
+
/* Destroy forms */
for (f = html->forms; f != NULL; f = g) {
g = f->prev;
@@ -1304,7 +1306,7 @@ html_open(struct content *c,
html->drag_owner.no_owner = true;
/* text selection */
- selection_init(&html->sel);
+ selection_init(html->sel);
html->selection_type = HTML_SELECTION_NONE;
html->selection_owner.none = true;
@@ -1323,7 +1325,7 @@ static nserror html_close(struct content *c)
html_content *htmlc = (html_content *) c;
nserror ret = NSERROR_OK;
- selection_clear(&htmlc->sel, false);
+ selection_clear(htmlc->sel, false);
/* clear the html content reference to the browser window */
htmlc->bw = NULL;
@@ -1359,7 +1361,7 @@ static void html_clear_selection(struct content *c)
break;
case HTML_SELECTION_SELF:
assert(html->selection_owner.none == false);
- selection_clear(&html->sel, true);
+ selection_clear(html->sel, true);
break;
case HTML_SELECTION_CONTENT:
content_clear_selection(html->selection_owner.content->object);
@@ -1388,7 +1390,7 @@ static char *html_get_selection(struct content *c)
gadget->data.text.ta);
case HTML_SELECTION_SELF:
assert(html->selection_owner.none == false);
- return selection_get_copy(&html->sel);
+ return selection_get_copy(html->sel);
case HTML_SELECTION_CONTENT:
return content_get_selection(
html->selection_owner.content->object);
diff --git a/content/handlers/html/interaction.c b/content/handlers/html/interaction.c
index 79846ae6a..421535c69 100644
--- a/content/handlers/html/interaction.c
+++ b/content/handlers/html/interaction.c
@@ -401,14 +401,14 @@ mouse_action_drag_selection(html_content *html,
if (!mouse) {
/* End of selection drag */
- if (selection_dragging_start(&html->sel)) {
+ if (selection_dragging_start(html->sel)) {
dir = 1;
}
idx = html_selection_drag_end(html, mouse, x, y, dir);
if (idx != 0) {
- selection_track(&html->sel, mouse, idx);
+ selection_track(html->sel, mouse, idx);
}
drag_owner.no_owner = true;
@@ -417,7 +417,7 @@ mouse_action_drag_selection(html_content *html,
return NSERROR_OK;
}
- if (selection_dragging_start(&html->sel)) {
+ if (selection_dragging_start(html->sel)) {
dir = 1;
}
@@ -432,7 +432,7 @@ mouse_action_drag_selection(html_content *html,
&idx,
&pixel_offset);
- selection_track(&html->sel, mouse, box->byte_offset + idx);
+ selection_track(html->sel, mouse, box->byte_offset + idx);
}
return NSERROR_OK;
}
@@ -1219,7 +1219,7 @@ default_mouse_action(html_content *html,
&idx,
&pixel_offset);
- if (selection_click(&html->sel,
+ if (selection_click(html->sel,
html->bw,
mouse,
mas->text.box->byte_offset + idx)) {
@@ -1229,7 +1229,7 @@ default_mouse_action(html_content *html,
html_drag_type drag_type;
union html_drag_owner drag_owner;
- if (selection_dragging(&html->sel)) {
+ if (selection_dragging(html->sel)) {
drag_type = HTML_DRAG_SELECTION;
drag_owner.no_owner = true;
html_set_drag_type(html,
@@ -1244,10 +1244,10 @@ default_mouse_action(html_content *html,
} else if (mouse & BROWSER_MOUSE_PRESS_1) {
sel_owner.none = true;
- selection_clear(&html->sel, true);
+ selection_clear(html->sel, true);
}
- if (selection_active(&html->sel)) {
+ if (selection_active(html->sel)) {
sel_owner.none = false;
html_set_selection(html,
HTML_SELECTION_SELF,
@@ -1518,7 +1518,7 @@ html_mouse_action(struct content *c,
bool html_keypress(struct content *c, uint32_t key)
{
html_content *html = (html_content *) c;
- struct selection *sel = &html->sel;
+ struct selection *sel = html->sel;
/** \todo
* At the moment, the front end interface for keypress only gives
@@ -1763,7 +1763,7 @@ void html_set_selection(html_content *html, html_selection_type selection_type,
case HTML_SELECTION_SELF:
if (same_type)
break;
- selection_clear(&html->sel, true);
+ selection_clear(html->sel, true);
break;
case HTML_SELECTION_TEXTAREA:
if (same_type && html->selection_owner.textarea ==
diff --git a/content/handlers/html/private.h b/content/handlers/html/private.h
index 43b0e84f2..2bd9cff9d 100644
--- a/content/handlers/html/private.h
+++ b/content/handlers/html/private.h
@@ -28,13 +28,13 @@
#include "netsurf/types.h"
#include "content/content_protected.h"
-#include "desktop/selection.h"
#include "content/handlers/css/utils.h"
struct gui_layout_table;
struct scrollbar_msg_data;
struct content_redraw_data;
+struct selection;
typedef enum {
HTML_DRAG_NONE, /** No drag */
@@ -203,7 +203,7 @@ typedef struct html_content {
union html_focus_owner focus_owner;
/** HTML content's own text selection object */
- struct selection sel;
+ struct selection *sel;
/**
* Open core-handled form SELECT menu, or NULL if none
diff --git a/content/handlers/html/redraw.c b/content/handlers/html/redraw.c
index 08a284b57..9807512b9 100644
--- a/content/handlers/html/redraw.c
+++ b/content/handlers/html/redraw.c
@@ -1148,7 +1148,7 @@ static bool html_redraw_text_box(const html_content *html, struct box *box,
scale,
excluded,
(struct content *)html,
- &html->sel,
+ html->sel,
ctx))
return false;