diff options
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/browser.c | 52 | ||||
-rw-r--r-- | desktop/browser.h | 44 | ||||
-rw-r--r-- | desktop/textarea.h | 2 |
3 files changed, 69 insertions, 29 deletions
diff --git a/desktop/browser.c b/desktop/browser.c index b1c4044c2..82585ab0d 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -560,18 +560,28 @@ void browser_window_set_scroll(struct browser_window *bw, int x, int y) } /** - * Internal helper for browser_window_get_contextual_content + * Internal helper for getting the positional features + * + * \param[in] bw browser window to examine. + * \param[in] x x-coordinate of point of interest + * \param[in] y y-coordinate of point of interest + * \param[out] data Feature structure to update. + * \return NSERROR_OK or appropriate error code on faliure. */ -static void browser_window__get_contextual_content(struct browser_window *bw, - int x, int y, struct contextual_content *data) +static nserror +browser_window__get_contextual_content(struct browser_window *bw, + int x, int y, struct browser_window_features *data) { + nserror ret = NSERROR_OK; + /* Handle (i)frame scroll offset (core-managed browser windows only) */ x += scrollbar_get_offset(bw->scroll_x); y += scrollbar_get_offset(bw->scroll_y); if (bw->children) { /* Browser window has children, so pass request on to - * appropriate child */ + * appropriate child. + */ struct browser_window *bwc; int cur_child; int children = bw->rows * bw->cols; @@ -582,39 +592,41 @@ static void browser_window__get_contextual_content(struct browser_window *bw, bwc = &bw->children[cur_child]; /* Skip this frame if (x, y) coord lies outside */ - if (x < bwc->x || bwc->x + bwc->width < x || - y < bwc->y || bwc->y + bwc->height < y) + if ((x < bwc->x) || + (bwc->x + bwc->width < x) || + (y < bwc->y) || + (bwc->y + bwc->height < y)) { continue; + } /* Pass request into this child */ - browser_window__get_contextual_content(bwc, + return browser_window__get_contextual_content(bwc, (x - bwc->x), (y - bwc->y), data); - return; } /* Coordinate not contained by any frame */ - return; - } - if (bw->current_content == NULL) - /* No content; nothing to set */ - return; + } else if (bw->current_content != NULL) { + /* Pass request to content */ + ret = content_get_contextual_content(bw->current_content, + x, y, data); + data->main = bw->current_content; + } - /* Pass request to content */ - content_get_contextual_content(bw->current_content, x, y, data); - data->main = bw->current_content; + return ret; } /* exported interface, documented in browser.h */ -void browser_window_get_contextual_content(struct browser_window *bw, - int x, int y, struct contextual_content *data) +nserror browser_window_get_features(struct browser_window *bw, + int x, int y, struct browser_window_features *data) { - data->link_url = NULL; + /* clear the features structure to empty values */ + data->link = NULL; data->object = NULL; data->main = NULL; data->form_features = CTX_FORM_NONE; - browser_window__get_contextual_content(bw, x, y, data); + return browser_window__get_contextual_content(bw, x, y, data); } /* exported interface, documented in browser.h */ diff --git a/desktop/browser.h b/desktop/browser.h index 5a1d70d7b..1d896dd72 100644 --- a/desktop/browser.h +++ b/desktop/browser.h @@ -117,6 +117,27 @@ enum browser_window_nav_flags { }; /** + * Page features at a specific spatial location. + */ +struct browser_window_features { + /** URL of a link or NULL. */ + struct nsurl *link; + + /** Object at position or NULL. */ + struct hlcache_handle *object; + + /** handle of top level content. */ + struct hlcache_handle *main; + + /** type of form feature. */ + enum { + CTX_FORM_NONE, + CTX_FORM_TEXT, + CTX_FORM_FILE + } form_features; +}; + +/** * Create and open a new root browser window with the given page. * * \param flags Flags to control operation @@ -302,17 +323,22 @@ void browser_window_set_scale(struct browser_window *bw, float scale, bool all); float browser_window_get_scale(struct browser_window *bw); /** - * Get access to any content, link URLs and objects (images) currently - * at the given (x, y) coordinates. + * Get access to any page features at the given coordinates. * - * \param bw browser window to look inside - * \param x x-coordinate of point of interest - * \param y y-coordinate of point of interest - * \param data pointer to contextual_content struct. Its fields are updated - * with pointers to any relevent content, or set to NULL if none. + * Fetches page features like content, link URLs and objects (images) + * at the specified co-ordinates within the browsing context. + * + * Fields within the supplied features structure are updated with + * pointers to any relevent content, or set to NULL if none. + * + * \param[in] bw browser window to examine. + * \param[in] x x-coordinate of point of interest + * \param[in] y y-coordinate of point of interest + * \param[out] data Feature structure to update. + * \return NSERROR_OK or appropriate error code on faliure. */ -void browser_window_get_contextual_content(struct browser_window *bw, - int x, int y, struct contextual_content *data); +nserror browser_window_get_features(struct browser_window *bw, + int x, int y, struct browser_window_features *data); /** * Send a scroll request to a browser window at a particular point. The diff --git a/desktop/textarea.h b/desktop/textarea.h index 0927f4bbb..de63b3ffb 100644 --- a/desktop/textarea.h +++ b/desktop/textarea.h @@ -27,6 +27,8 @@ #include <stdint.h> #include <stdbool.h> +#include "utils/types.h" + struct textarea; /* Text area flags */ |