From e34f9d3a387fba655a8dcc47d7659655dc4b5fb3 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 17 Nov 2019 10:13:56 +0000 Subject: move remaining mouse action drag handling into separate functions --- content/handlers/html/interaction.c | 81 +++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 21 deletions(-) diff --git a/content/handlers/html/interaction.c b/content/handlers/html/interaction.c index f238341f7..9e59aed3f 100644 --- a/content/handlers/html/interaction.c +++ b/content/handlers/html/interaction.c @@ -504,6 +504,62 @@ mouse_action_drag_scrollbar(html_content *html, } +/** + * handle mouse actions while dragging in a text area + */ +static nserror +mouse_action_drag_textarea(html_content *html, + struct browser_window *bw, + browser_mouse_state mouse, + int x, int y) +{ + struct box *box; + int box_x = 0; + int box_y = 0; + + box = html->drag_owner.textarea; + + assert(box->gadget != NULL); + assert(box->gadget->type == GADGET_TEXTAREA || + box->gadget->type == GADGET_PASSWORD || + box->gadget->type == GADGET_TEXTBOX); + + box_coords(box, &box_x, &box_y); + textarea_mouse_action(box->gadget->data.text.ta, + mouse, + x - box_x, + y - box_y); + + /* TODO: Set appropriate statusbar message */ + return NSERROR_OK; +} + + +/** + * handle mouse actions while dragging in a content + */ +static nserror +mouse_action_drag_content(html_content *html, + struct browser_window *bw, + browser_mouse_state mouse, + int x, int y) +{ + struct box *box; + int box_x = 0; + int box_y = 0; + + box = html->drag_owner.content; + assert(box->object != NULL); + + box_coords(box, &box_x, &box_y); + content_mouse_track(box->object, + bw, mouse, + x - box_x, + y - box_y); + return NSERROR_OK; +} + + /* exported interface documented in html/interaction.h */ nserror html_mouse_track(struct content *c, struct browser_window *bw, @@ -572,30 +628,13 @@ html_mouse_action(struct content *c, } if (html->drag_type == HTML_DRAG_TEXTAREA_SELECTION || - html->drag_type == HTML_DRAG_TEXTAREA_SCROLLBAR) { - box = html->drag_owner.textarea; - assert(box->gadget != NULL); - assert(box->gadget->type == GADGET_TEXTAREA || - box->gadget->type == GADGET_PASSWORD || - box->gadget->type == GADGET_TEXTBOX); - - box_coords(box, &box_x, &box_y); - textarea_mouse_action(box->gadget->data.text.ta, mouse, - x - box_x, y - box_y); - - /* TODO: Set appropriate statusbar message */ - return NSERROR_OK; + html->drag_type == HTML_DRAG_TEXTAREA_SCROLLBAR) { + return mouse_action_drag_textarea(html, bw, mouse, x, y); } if (html->drag_type == HTML_DRAG_CONTENT_SELECTION || - html->drag_type == HTML_DRAG_CONTENT_SCROLL) { - box = html->drag_owner.content; - assert(box->object != NULL); - - box_coords(box, &box_x, &box_y); - content_mouse_track(box->object, bw, mouse, - x - box_x, y - box_y); - return NSERROR_OK; + html->drag_type == HTML_DRAG_CONTENT_SCROLL) { + return mouse_action_drag_content(html, bw, mouse, x, y); } /* Content related drags handled by now */ -- cgit v1.2.3