summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'desktop')
-rw-r--r--desktop/browser.c76
-rw-r--r--desktop/browser.h23
-rw-r--r--desktop/frames.c8
-rw-r--r--desktop/print.c2
4 files changed, 91 insertions, 18 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index 5a663e34d..7a0ce97e2 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -174,7 +174,6 @@ void browser_window_update_extent(struct browser_window *bw)
void browser_window_get_position(struct browser_window *bw, bool root,
int *pos_x, int *pos_y)
{
- int x, y;
*pos_x = 0;
*pos_y = 0;
@@ -189,11 +188,9 @@ void browser_window_get_position(struct browser_window *bw, bool root,
/* There is no offset to the root browser window */
break;
case BROWSER_WINDOW_IFRAME:
- /* offset comes from its box position in parent bw */
- box_coords(bw->box, &x, &y);
- *pos_x += x * bw->scale;
- *pos_y += y * bw->scale;
+ *pos_x += bw->x * bw->scale;
+ *pos_y += bw->y * bw->scale;
break;
}
@@ -207,6 +204,26 @@ void browser_window_get_position(struct browser_window *bw, bool root,
}
}
+/* exported interface, documented in browser.h */
+void browser_window_set_position(struct browser_window *bw, int x, int y)
+{
+ assert(bw != NULL);
+
+ switch (bw->browser_window_type) {
+ default:
+ /* fall through to NORMAL until frame(set)s are handled
+ * in the core */
+ case BROWSER_WINDOW_NORMAL:
+ /* TODO: Not implemented yet */
+ break;
+ case BROWSER_WINDOW_IFRAME:
+
+ bw->x = x;
+ bw->y = y;
+ break;
+ }
+}
+
/**
* Create and open a new root browser window with the given page.
*
@@ -603,7 +620,7 @@ nserror browser_window_callback(hlcache_handle *c,
/* Format the new content to the correct dimensions */
browser_window_get_dimensions(bw, &width, &height, true);
- content_reformat(c, width, height);
+ content_reformat(c, false, width, height);
browser_window_remove_caret(bw);
@@ -711,7 +728,10 @@ nserror browser_window_callback(hlcache_handle *c,
if (bw->move_callback)
bw->move_callback(bw, bw->caret_p);
- browser_window_update(bw, false);
+ if (!(event->data.background)) {
+ /* Reformatted content should be redrawn */
+ browser_window_update(bw, false);
+ }
break;
case CONTENT_MSG_REDRAW:
@@ -750,15 +770,12 @@ nserror browser_window_callback(hlcache_handle *c,
void browser_window_get_dimensions(struct browser_window *bw,
int *width, int *height, bool scaled)
{
- struct rect rect;
+ assert(bw);
switch (bw->browser_window_type) {
case BROWSER_WINDOW_IFRAME:
- /* browser window is size of associated box */
- box_bounds(bw->box, &rect);
-LOG(("SCALED: %s", scaled ? "yes" : "no"));
- *width = rect.x1 - rect.x0;
- *height = rect.y1 - rect.y0;
+ *width = bw->width;
+ *height = bw->height;
break;
case BROWSER_WINDOW_FRAME:
@@ -773,6 +790,34 @@ LOG(("SCALED: %s", scaled ? "yes" : "no"));
}
+/*
+ * Set the dimensions of the area a browser window occupies
+ *
+ * \param bw The browser window to set dimensions of
+ * \param width Width in pixels
+ * \param height Height in pixels
+ */
+
+void browser_window_set_dimensions(struct browser_window *bw,
+ int width, int height)
+{
+ assert(bw);
+
+ switch (bw->browser_window_type) {
+ case BROWSER_WINDOW_IFRAME:
+ bw->width = width;
+ bw->height = height;
+ break;
+
+ case BROWSER_WINDOW_FRAME:
+ case BROWSER_WINDOW_FRAMESET:
+ case BROWSER_WINDOW_NORMAL:
+ /* TODO: Not implemented yet */
+ break;
+ }
+}
+
+
/**
* Transfer the loading_content to a new download window.
*/
@@ -1323,7 +1368,8 @@ struct browser_window *browser_window_owner(struct browser_window *bw)
* \param height new height
*/
-void browser_window_reformat(struct browser_window *bw, int width, int height)
+void browser_window_reformat(struct browser_window *bw, bool background,
+ int width, int height)
{
hlcache_handle *c = bw->current_content;
@@ -1336,7 +1382,7 @@ void browser_window_reformat(struct browser_window *bw, int width, int height)
height /= bw->scale;
}
- content_reformat(c, width, height);
+ content_reformat(c, background, width, height);
}
diff --git a/desktop/browser.h b/desktop/browser.h
index 5fbf44e8f..830b22b0a 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -123,12 +123,18 @@ struct browser_window {
/** Window has been resized, and content needs reformatting. */
bool reformat_pending;
- /** Window dimensions */
+ /** Window dimensions (to be phased out) */
int x0;
int y0;
int x1;
int y1;
+ /** Window dimensions */
+ int x;
+ int y;
+ int width;
+ int height;
+
/** scale of window contents */
float scale;
@@ -213,6 +219,8 @@ void browser_window_go_unverifiable(struct browser_window *bw,
struct hlcache_handle *parent);
void browser_window_get_dimensions(struct browser_window *bw,
int *width, int *height, bool scaled);
+void browser_window_set_dimensions(struct browser_window *bw,
+ int width, int height);
void browser_window_download(struct browser_window *bw,
const char *url, const char *referrer);
void browser_window_update(struct browser_window *bw, bool scroll_to_top);
@@ -222,7 +230,8 @@ void browser_window_stop(struct browser_window *bw);
void browser_window_reload(struct browser_window *bw, bool all);
void browser_window_destroy(struct browser_window *bw);
struct browser_window * browser_window_owner(struct browser_window *bw);
-void browser_window_reformat(struct browser_window *bw, int width, int height);
+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);
void browser_window_refresh_url_bar(struct browser_window *bw, const char *url,
@@ -310,6 +319,16 @@ void browser_window_update_extent(struct browser_window *bw);
void browser_window_get_position(struct browser_window *bw, bool root,
int *pos_x, int *pos_y);
+/*
+ * Set the position of the current browser window with respect to the parent
+ * browser window
+ *
+ * \param bw browser window to get the position of
+ * \param x x position of bw
+ * \param y y position of bw
+ */
+void browser_window_set_position(struct browser_window *bw, int x, int y);
+
/* In platform specific hotlist.c. */
void hotlist_visited(struct hlcache_handle *c);
diff --git a/desktop/frames.c b/desktop/frames.c
index 39d841754..055b4a4aa 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -58,6 +58,7 @@ void browser_window_create_iframes(struct browser_window *bw,
struct content_html_iframe *iframe) {
struct browser_window *window;
struct content_html_iframe *cur;
+ struct rect rect;
int iframes = 0;
int index;
@@ -94,6 +95,13 @@ void browser_window_create_iframes(struct browser_window *bw,
window->box = cur->box;
window->parent = bw;
window->box->iframe = window;
+
+ /* iframe dimensions */
+ box_bounds(window->box, &rect);
+
+ browser_window_set_position(window, rect.x0, rect.y0);
+ browser_window_set_dimensions(window, rect.x1 - rect.x0,
+ rect.y1 - rect.y0);
}
/* calculate dimensions */
diff --git a/desktop/print.c b/desktop/print.c
index 13f26e5d5..42dd0a77a 100644
--- a/desktop/print.c
+++ b/desktop/print.c
@@ -189,7 +189,7 @@ bool print_apply_settings(hlcache_handle *content,
FIXTOFLT(FSUB(settings->margins[MARGINTOP],
settings->margins[MARGINBOTTOM]))) / settings->scale;
- content_reformat(content, page_content_width, 0);
+ content_reformat(content, false, page_content_width, 0);
LOG(("New layout applied.New height = %d ; New width = %d ",
content_get_height(content),