summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2006-09-16 21:33:55 +0000
committerJames Bursa <james@netsurf-browser.org>2006-09-16 21:33:55 +0000
commit7a08d0f03dddcbb0a5e99ba157b2d59bfbaa437a (patch)
tree720a6fbadf83fa62d5d2b4d22df278bbf763d2d2 /render
parent5b87995de778148aba143743f2ea2c279bbadcf0 (diff)
downloadnetsurf-7a08d0f03dddcbb0a5e99ba157b2d59bfbaa437a.tar.gz
netsurf-7a08d0f03dddcbb0a5e99ba157b2d59bfbaa437a.tar.bz2
Call html_reformat() from html_convert() to eliminate duplicate code. Improve calculations of document width and height.
svn path=/trunk/netsurf/; revision=2956
Diffstat (limited to 'render')
-rw-r--r--render/html.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/render/html.c b/render/html.c
index 6af3e3932..62cb1d615 100644
--- a/render/html.c
+++ b/render/html.c
@@ -353,10 +353,8 @@ bool html_convert(struct content *c, int width, int height)
content_set_status(c, messages_get("Formatting"));
content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
LOG(("Layout document"));
- layout_document(c, width, height);
+ html_reformat(c, width, height);
/*box_dump(c->data.html.layout->children, 0);*/
- c->width = c->data.html.layout->descendant_x1;
- c->height = c->data.html.layout->descendant_y1;
c->size = talloc_total_size(c);
@@ -431,7 +429,7 @@ bool html_meta_refresh(struct content *c, xmlNode *head)
content_broadcast(c, CONTENT_MSG_REFRESH, msg_data);
break;
}
-
+
for ( ; url <= end - 4; url++) {
if (!strncasecmp(url, "url=", 4))
break;
@@ -445,7 +443,7 @@ bool html_meta_refresh(struct content *c, xmlNode *head)
url++;
}
}
-
+
if (url <= end - 4) {
res = url_join(url + 4, c->data.html.base_url,
&refresh);
@@ -1403,17 +1401,25 @@ void html_stop(struct content *c)
void html_reformat(struct content *c, int width, int height)
{
- struct box *doc;
-
- layout_document(c, width, height);
- doc = c->data.html.layout;
+ struct box *layout;
- c->width = doc->descendant_x1 +
- doc->margin[LEFT] + doc->margin[RIGHT];
+ layout_document(c, width, height);
+ layout = c->data.html.layout;
+
+ /* width and height are at least margin box of document */
+ c->width = layout->x + layout->padding[LEFT] + layout->width +
+ layout->padding[RIGHT] + layout->border[RIGHT] +
+ layout->margin[RIGHT];
+ c->height = layout->y + layout->padding[TOP] + layout->height +
+ layout->padding[BOTTOM] + layout->border[BOTTOM] +
+ layout->margin[BOTTOM];
+
+ /* if boxes overflow right or bottom edge, expand to contain it */
+ if (c->width < layout->x + layout->descendant_x1)
+ c->width = layout->x + layout->descendant_x1;
+ if (c->height < layout->y + layout->descendant_y1)
+ c->height = layout->y + layout->descendant_y1;
- c->height = doc->descendant_y1 +
- doc->margin[TOP] + doc->margin[BOTTOM];
-
if ((c->data.html.frameset) && (c->data.html.bw))
browser_window_recalculate_frameset(c->data.html.bw);
if ((c->data.html.iframe) && (c->data.html.bw))
@@ -1443,7 +1449,7 @@ void html_destroy(struct content *c)
/* Free base target */
if (c->data.html.base_target) {
talloc_free(c->data.html.base_target);
- c->data.html.base_target = NULL;
+ c->data.html.base_target = NULL;
}
/* Free frameset */
@@ -1471,7 +1477,7 @@ void html_destroy(struct content *c)
}
talloc_free(c->data.html.working_stylesheet);
-
+
/*if (c->data.html.style)
css_free_style(c->data.html.style);*/
@@ -1490,7 +1496,7 @@ void html_destroy(struct content *c)
void html_destroy_frameset(struct content_html_frames *frameset) {
int i;
-
+
if (frameset->name) {
talloc_free(frameset->name);
frameset->name = NULL;
@@ -1526,7 +1532,7 @@ void html_destroy_iframe(struct content_html_iframe *iframe) {
talloc_free(iframe->name);
if (iframe->url)
talloc_free(iframe->url);
- talloc_free(iframe);
+ talloc_free(iframe);
}
}
@@ -1554,7 +1560,7 @@ void html_open(struct content *c, struct browser_window *bw,
c->data.html.object[i].box,
c->data.html.object[i].box->object_params);
}
-
+
if (c->data.html.frameset)
browser_window_create_frameset(bw, c->data.html.frameset);
if (c->data.html.iframe)