mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-16 15:49:24 +03:00
Expose contextual content request API to front ends, via browser window layer.
svn path=/trunk/netsurf/; revision=12755
This commit is contained in:
parent
6167cc8508
commit
57da2b3af1
@ -469,6 +469,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.
|
* Create and open a new root browser window with the given page.
|
||||||
*
|
*
|
||||||
|
@ -229,6 +229,19 @@ void browser_window_reformat(struct browser_window *bw, bool background,
|
|||||||
int width, int height);
|
int width, int height);
|
||||||
void browser_window_set_scale(struct browser_window *bw, float scale, bool all);
|
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,
|
void browser_window_refresh_url_bar(struct browser_window *bw, const char *url,
|
||||||
const char *frag);
|
const char *frag);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user