diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2011-08-31 17:53:40 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2011-08-31 17:53:40 +0000 |
commit | 6e3e168d08a6d9ae12d33f65ffcdae20306e9d06 (patch) | |
tree | 1f8ac1f32f7ac9135df7bd6056096592ced5749f /render/box.c | |
parent | 5af7a9c03c71cae313853a3550d34c9f4e42f4f8 (diff) | |
download | netsurf-6e3e168d08a6d9ae12d33f65ffcdae20306e9d06.tar.gz netsurf-6e3e168d08a6d9ae12d33f65ffcdae20306e9d06.tar.bz2 |
Avoid instance of using bw->current_content outside desktop/.
svn path=/trunk/netsurf/; revision=12690
Diffstat (limited to 'render/box.c')
-rw-r--r-- | render/box.c | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/render/box.c b/render/box.c index 17d73c5fd..b48b07e8f 100644 --- a/render/box.c +++ b/render/box.c @@ -784,7 +784,7 @@ bool box_nearest_text_box(struct box *box, int bx, int by, * the mouse pointer, or nearest in the given direction if the pointer is * not over a text box. * - * \param h html content's high level cache handle + * \param html an HTML content * \param x coordinate of mouse * \param y coordinate of mouse * \param dir direction to search (-1 = above-left, +1 = below-right) @@ -792,47 +792,51 @@ bool box_nearest_text_box(struct box *box, int bx, int by, * \param dy receives y ordinate of mouse relative to text box */ -struct box *box_pick_text_box(hlcache_handle *h, +struct box *box_pick_text_box(struct html_content *html, int x, int y, int dir, int *dx, int *dy) { struct box *text_box = NULL; + struct box *box; + int nr_xd, nr_yd; + int bx, by; + int fx, fy; + int tx, ty; - if (h != NULL && content_get_type(h) == CONTENT_HTML) { - struct box *box = html_get_box_tree(h); - int nr_xd, nr_yd; - int bx = box->margin[LEFT]; - int by = box->margin[TOP]; - int fx = bx; - int fy = by; - int tx, ty; - - if (!box_nearest_text_box(box, bx, by, fx, fy, x, y, - dir, &text_box, &tx, &ty, &nr_xd, &nr_yd)) { - if (text_box && text_box->text && !text_box->object) { - int w = (text_box->padding[LEFT] + - text_box->width + - text_box->padding[RIGHT]); - int h = (text_box->padding[TOP] + - text_box->height + - text_box->padding[BOTTOM]); - int x1, y1; - - y1 = ty + h; - x1 = tx + w; - - /* ensure point lies within the text box */ - if (x < tx) x = tx; - if (y < ty) y = ty; - if (y > y1) y = y1; - if (x > x1) x = x1; - } - } + if (html == NULL) + return NULL; - /* return coordinates relative to box */ - *dx = x - tx; - *dy = y - ty; + box = html->layout; + bx = box->margin[LEFT]; + by = box->margin[TOP]; + fx = bx; + fy = by; + + if (!box_nearest_text_box(box, bx, by, fx, fy, x, y, + dir, &text_box, &tx, &ty, &nr_xd, &nr_yd)) { + if (text_box && text_box->text && !text_box->object) { + int w = (text_box->padding[LEFT] + + text_box->width + + text_box->padding[RIGHT]); + int h = (text_box->padding[TOP] + + text_box->height + + text_box->padding[BOTTOM]); + int x1, y1; + + y1 = ty + h; + x1 = tx + w; + + /* ensure point lies within the text box */ + if (x < tx) x = tx; + if (y < ty) y = ty; + if (y > y1) y = y1; + if (x > x1) x = x1; + } } + /* return coordinates relative to box */ + *dx = x - tx; + *dy = y - ty; + return text_box; } |