From 4cef0f955c3be33344361f84d600bccf1b28ce75 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 20 May 2020 23:17:48 +0100 Subject: pass the browser window to selection click handler this means the content handlers do not have to provide a separate method to extract their browser window and it can simply be passed in. --- desktop/selection.c | 18 ++---------------- desktop/selection.h | 3 ++- 2 files changed, 4 insertions(+), 17 deletions(-) (limited to 'desktop') diff --git a/desktop/selection.c b/desktop/selection.c index 4bbcda9a7..47d51f83e 100644 --- a/desktop/selection.c +++ b/desktop/selection.c @@ -77,21 +77,6 @@ typedef bool (*seln_traverse_handler)(const char *text, size_t length, const char *whitespace_text, size_t whitespace_length); -/** - * Get the browser window containing the content a selection object belongs to. - * - * \param s selection object - * \return the browser window - */ -static struct browser_window * selection_get_browser_window(struct selection *s) -{ - if (s->is_html) - return html_get_browser_window(s->c); - else - return textplain_get_browser_window(s->c); -} - - /** * Label each text box in the given box subtree with its position * in a textual representation of the content. @@ -691,13 +676,14 @@ selection_init(struct selection *s, /* exported interface documented in desktop/selection.h */ bool selection_click(struct selection *s, + struct browser_window *top, browser_mouse_state mouse, unsigned idx) { browser_mouse_state modkeys = (mouse & (BROWSER_MOUSE_MOD_1 | BROWSER_MOUSE_MOD_2)); int pos = -1; /* 0 = inside selection, 1 = after it */ - struct browser_window *top = selection_get_browser_window(s); + top = browser_window_get_root(top); if (selection_defined(s)) { diff --git a/desktop/selection.h b/desktop/selection.h index ca0d19fe9..cfaf59baf 100644 --- a/desktop/selection.h +++ b/desktop/selection.h @@ -28,6 +28,7 @@ #include "content/handlers/css/utils.h" struct box; +struct browser_window; typedef enum { DRAG_NONE, @@ -166,7 +167,7 @@ void selection_set_position(struct selection *s, unsigned start, unsigned end); * \param idx byte offset within textual representation * \return true iff the click has been handled by the selection code */ -bool selection_click(struct selection *s, browser_mouse_state mouse, unsigned idx); +bool selection_click(struct selection *s, struct browser_window *top, browser_mouse_state mouse, unsigned idx); /** * Handles movements related to the selection, eg. dragging of start and -- cgit v1.2.3