From 6e3e168d08a6d9ae12d33f65ffcdae20306e9d06 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 31 Aug 2011 17:53:40 +0000 Subject: Avoid instance of using bw->current_content outside desktop/. svn path=/trunk/netsurf/; revision=12690 --- render/html_interaction.c | 70 +++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'render/html_interaction.c') diff --git a/render/html_interaction.c b/render/html_interaction.c index 98fb4c9cb..ceea4bf08 100644 --- a/render/html_interaction.c +++ b/render/html_interaction.c @@ -48,6 +48,39 @@ static gui_pointer_shape get_pointer_shape(struct browser_window *bw, struct box *box, bool imagemap); static void html_box_drag_start(struct box *box, int x, int y); + +/** + * End overflow scroll scrollbar drags + * + * \param h html content's high level cache entry + * \param mouse state of mouse buttons and modifier keys + * \param x coordinate of mouse + * \param y coordinate of mouse + */ +static size_t html_selection_drag_end(struct html_content *html, + browser_mouse_state mouse, int x, int y, int dir) +{ + int pixel_offset; + struct box *box; + int dx, dy; + size_t idx = 0; + + box = box_pick_text_box(html, x, y, dir, &dx, &dy); + if (box) { + plot_font_style_t fstyle; + + font_plot_style_from_css(box->style, &fstyle); + + nsfont.font_position_in_string(&fstyle, box->text, box->length, + dx, &idx, &pixel_offset); + + idx += box->byte_offset; + } + + return idx; +} + + /** * Handle mouse tracking (including drags) in an HTML content window. * @@ -62,7 +95,6 @@ void html_mouse_track(struct content *c, struct browser_window *bw, browser_mouse_state mouse, int x, int y) { html_content *html = (html_content*) c; - hlcache_handle *h = bw->current_content; if (bw->drag_type == DRAGGING_SELECTION && !mouse) { int dir = -1; @@ -71,7 +103,7 @@ void html_mouse_track(struct content *c, struct browser_window *bw, if (selection_dragging_start(&html->sel)) dir = 1; - idx = html_selection_drag_end(h, mouse, x, y, dir); + idx = html_selection_drag_end(html, mouse, x, y, dir); if (idx != 0) selection_track(&html->sel, mouse, idx); @@ -88,7 +120,7 @@ void html_mouse_track(struct content *c, struct browser_window *bw, if (selection_dragging_start(&html->sel)) dir = 1; - box = box_pick_text_box(h, x, y, dir, &dx, &dy); + box = box_pick_text_box(html, x, y, dir, &dx, &dy); if (box) { int pixel_offset; @@ -869,38 +901,6 @@ void html_overflow_scroll_drag_end(struct scrollbar *scrollbar, } -/** - * End overflow scroll scrollbar drags - * - * \param h html content's high level cache entry - * \param mouse state of mouse buttons and modifier keys - * \param x coordinate of mouse - * \param y coordinate of mouse - */ -size_t html_selection_drag_end(hlcache_handle *h, browser_mouse_state mouse, - int x, int y, int dir) -{ - int pixel_offset; - struct box *box; - int dx, dy; - size_t idx = 0; - - box = box_pick_text_box(h, x, y, dir, &dx, &dy); - if (box) { - plot_font_style_t fstyle; - - font_plot_style_from_css(box->style, &fstyle); - - nsfont.font_position_in_string(&fstyle, box->text, box->length, - dx, &idx, &pixel_offset); - - idx += box->byte_offset; - } - - return idx; -} - - /** * Start drag scrolling the contents of a box * -- cgit v1.2.3