summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-09-06 18:11:10 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-09-06 18:11:10 +0000
commit57da2b3af19406f5736a2b3941c8d0223b098553 (patch)
tree983ba5b691efa8b92e735c843a4356d530da8cd5
parent6167cc8508b7b3add594396c468bca7d8f25d6de (diff)
downloadnetsurf-57da2b3af19406f5736a2b3941c8d0223b098553.tar.gz
netsurf-57da2b3af19406f5736a2b3941c8d0223b098553.tar.bz2
Expose contextual content request API to front ends, via browser window layer.
svn path=/trunk/netsurf/; revision=12755
-rw-r--r--desktop/browser.c54
-rw-r--r--desktop/browser.h13
2 files changed, 67 insertions, 0 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index af9528f76..b18bde482 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -470,6 +470,60 @@ void browser_window_set_scroll(struct browser_window *bw, int x, int y)
}
/**
+ * Internal helper for browser_window_get_contextual_content
+ */
+static void browser_window__get_contextual_content(struct browser_window *bw,
+ int x, int y, struct contextual_content *data)
+{
+ if (bw->children) {
+ /* Browser window has children, so pass request on to
+ * appropriate child */
+ struct browser_window *bwc;
+ int cur_child;
+ int children = bw->rows * bw->cols;
+
+ /* Loop through all children of bw */
+ for (cur_child = 0; cur_child < children; cur_child++) {
+ /* Set current child */
+ 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)
+ continue;
+
+ /* Pass request into this child */
+ 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;
+
+ /* Pass request to content */
+ content_get_contextual_content(bw->current_content, x, y, data);
+ data->main = bw->current_content;
+}
+
+/* exported interface, documented in browser.h */
+void browser_window_get_contextual_content(struct browser_window *bw,
+ int x, int y, struct contextual_content *data)
+{
+ data->link_url = NULL;
+ data->object = NULL;
+ data->main = NULL;
+
+ browser_window__get_contextual_content(bw, x, y, data);
+}
+
+
+/**
* Create and open a new root browser window with the given page.
*
* \param url URL to start fetching in the new window (copied)
diff --git a/desktop/browser.h b/desktop/browser.h
index 3d289767a..cb3b22bb0 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -229,6 +229,19 @@ void browser_window_reformat(struct browser_window *bw, bool background,
int width, int height);
void browser_window_set_scale(struct browser_window *bw, float scale, bool all);
+/**
+ * Get access to any content, link URLs and objects (images) currently
+ * at the given (x, y) 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.
+ */
+void browser_window_get_contextual_content(struct browser_window *bw,
+ int x, int y, struct contextual_content *data);
+
void browser_window_refresh_url_bar(struct browser_window *bw, const char *url,
const char *frag);