From 22d15380f40b82f7d1660648ec13af094643a3ca Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 8 Feb 2014 16:03:06 +0000 Subject: Add function to get browser window's extents. --- desktop/browser.c | 24 ++++++++++++++++++++++++ desktop/browser.h | 12 ++++++++++++ 2 files changed, 36 insertions(+) (limited to 'desktop') diff --git a/desktop/browser.c b/desktop/browser.c index 9061b3371..428c0775b 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -1957,6 +1957,30 @@ bool browser_window_has_content(struct browser_window *bw) } +/* Exported interface, documented in browser.h */ +nserror browser_window_get_extents(struct browser_window *bw, bool scaled, + int *width, int *height) +{ + assert(bw != NULL); + + if (bw->current_content == NULL) { + *width = 0; + *height = 0; + return NSERROR_BAD_CONTENT; + } + + *width = content_get_width(bw->current_content); + *height = content_get_height(bw->current_content); + + if (scaled) { + *width *= bw->scale; + *height *= bw->scale; + } + + return NSERROR_OK; +} + + /* * Get the dimensions of the area a browser window occupies * diff --git a/desktop/browser.h b/desktop/browser.h index c48fd5a4f..b0a5c506c 100644 --- a/desktop/browser.h +++ b/desktop/browser.h @@ -129,6 +129,18 @@ nserror browser_window_navigate(struct browser_window *bw, */ nsurl * browser_window_get_url(struct browser_window *bw); +/** + * Get a browser window's content extents. + * + * \param bw browser window + * \param scaled whether to apply current browser window scale + * \param width updated to content width extent in px + * \param width updated to content height extent in px + * \return NSERROR_OK, or appropriate error otherwise. + */ +nserror browser_window_get_extents(struct browser_window *bw, bool scaled, + int *width, int *height); + /** * Find out if a browser window is currently showing a content. * -- cgit v1.2.3