summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2010-03-29 22:33:21 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2010-03-29 22:33:21 +0000
commit9aca901eb1db3b6f373882fe8b707e44959e2ec1 (patch)
treee21e30e702cab909eacdebc067a78dbd17ff8f8f /render
parent2a53c4c811a22b7382f0fd071a2f3ce477594340 (diff)
downloadnetsurf-9aca901eb1db3b6f373882fe8b707e44959e2ec1.tar.gz
netsurf-9aca901eb1db3b6f373882fe8b707e44959e2ec1.tar.bz2
The convert stage of a content's state progression no longer reflows the content to the provided dimensions.
It is now defined as converting the content into a state in which it is ready for use. The user of the content is now responsible for performing an initial reformat (sic) of the content before it can be redrawn. Purge width/height parameters from hlcache_handle_retrieve/content_convert/*_convert APIs. Fix up content handlers affected by the above change in semantics. Ensure that browser_window_callback performs an initial reformat of its content. svn path=/trunk/netsurf/; revision=10207
Diffstat (limited to 'render')
-rw-r--r--render/directory.c4
-rw-r--r--render/directory.h2
-rw-r--r--render/favicon.c2
-rw-r--r--render/html.c44
-rw-r--r--render/html.h2
-rw-r--r--render/textplain.c3
-rw-r--r--render/textplain.h2
7 files changed, 20 insertions, 39 deletions
diff --git a/render/directory.c b/render/directory.c
index 9f002d831..969b0c5b9 100644
--- a/render/directory.c
+++ b/render/directory.c
@@ -52,7 +52,7 @@ bool directory_create(struct content *c, const struct http_parameter *params) {
return true;
}
-bool directory_convert(struct content *c, int width, int height) {
+bool directory_convert(struct content *c) {
char *path;
DIR *parent;
struct dirent *entry;
@@ -135,7 +135,7 @@ bool directory_convert(struct content *c, int width, int height) {
(uint8_t *) footer, sizeof(footer) - 1);
c->type = CONTENT_HTML;
- return html_convert(c, width, height);
+ return html_convert(c);
}
void directory_destroy(struct content *c)
diff --git a/render/directory.h b/render/directory.h
index 766593294..25e5f3281 100644
--- a/render/directory.h
+++ b/render/directory.h
@@ -31,7 +31,7 @@
struct http_parameter;
bool directory_create(struct content *c, const struct http_parameter *params);
-bool directory_convert(struct content *c, int width, int height);
+bool directory_convert(struct content *c);
void directory_destroy(struct content *c);
#endif
diff --git a/render/favicon.c b/render/favicon.c
index 191c55e8a..9f7ad7647 100644
--- a/render/favicon.c
+++ b/render/favicon.c
@@ -155,7 +155,7 @@ bool favicon_get_icon(struct content *c, xmlNode *html)
if (url == NULL)
return false;
- error = hlcache_handle_retrieve(url, 0, NULL, NULL, c->width, c->height,
+ error = hlcache_handle_retrieve(url, 0, NULL, NULL,
favicon_callback, c, NULL, &c->data.html.favicon);
free(url);
diff --git a/render/html.c b/render/html.c
index 37630c65f..3b3abb782 100644
--- a/render/html.c
+++ b/render/html.c
@@ -307,20 +307,18 @@ encoding_change:
* - stylesheets are fetched
* - favicon is retrieved
* - the XML tree is converted to a box tree and object fetches are started
- * - the box tree is laid out
*
* On exit, the content status will be either CONTENT_STATUS_DONE if the
* document is completely loaded or CONTENT_STATUS_READY if objects are still
* being fetched.
*/
-bool html_convert(struct content *c, int width, int height)
+bool html_convert(struct content *c)
{
binding_error err;
xmlNode *html, *head;
union content_msg_data msg_data;
unsigned long size;
- unsigned int time_before, time_taken;
struct form *f;
/* finish parsing */
@@ -483,21 +481,6 @@ bool html_convert(struct content *c, int width, int height)
}
/*imagemap_dump(c);*/
- /* layout the box tree */
- html_set_status(c, messages_get("Formatting"));
- content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
- LOG(("Layout document"));
- time_before = wallclock();
- html_reformat(c, width, height);
- time_taken = wallclock() - time_before;
- LOG(("Layout took %dcs", time_taken));
- c->reformat_time = wallclock() +
- ((time_taken < option_min_reflow_period ?
- option_min_reflow_period : time_taken * 1.25));
- LOG(("Scheduling relayout no sooner than %dcs",
- c->reformat_time - wallclock()));
- /*box_dump(stderr, c->data.html.layout->children, 0);*/
-
/* Destroy the parser binding */
binding_destroy_tree(c->data.html.parser_binding);
c->data.html.parser_binding = NULL;
@@ -835,7 +818,7 @@ bool html_find_stylesheets(struct content *c, xmlNode *html)
c->active = 0;
ns_error = hlcache_handle_retrieve(default_stylesheet_url, 0,
- content__get_url(c), NULL, c->width, c->height,
+ content__get_url(c), NULL,
html_convert_css_callback, c, &child,
&c->data.html.stylesheets[
STYLESHEET_BASE].data.external);
@@ -846,7 +829,7 @@ bool html_find_stylesheets(struct content *c, xmlNode *html)
if (c->data.html.quirks == BINDING_QUIRKS_MODE_FULL) {
ns_error = hlcache_handle_retrieve(quirks_stylesheet_url, 0,
- content__get_url(c), NULL, c->width, c->height,
+ content__get_url(c), NULL,
html_convert_css_callback, c, &child,
&c->data.html.stylesheets[
STYLESHEET_QUIRKS].data.external);
@@ -858,7 +841,7 @@ bool html_find_stylesheets(struct content *c, xmlNode *html)
if (option_block_ads) {
ns_error = hlcache_handle_retrieve(adblock_stylesheet_url, 0,
- content__get_url(c), NULL, c->width, c->height,
+ content__get_url(c), NULL,
html_convert_css_callback, c, &child,
&c->data.html.stylesheets[
STYLESHEET_ADBLOCK].data.external);
@@ -967,7 +950,6 @@ bool html_find_stylesheets(struct content *c, xmlNode *html)
HTML_STYLESHEET_EXTERNAL;
ns_error = hlcache_handle_retrieve(url2, 0,
content__get_url(c), NULL,
- c->width, c->height,
html_convert_css_callback, c, &child,
&c->data.html.stylesheets[i].
data.external);
@@ -1135,7 +1117,7 @@ bool html_process_style_element(struct content *c, unsigned int *index,
}
/* Convert the content -- manually, as we want the result */
- if (nscss_convert_css_data(sheet, c->width, c->height) != CSS_OK) {
+ if (nscss_convert_css_data(sheet) != CSS_OK) {
/* conversion failed */
nscss_destroy_css_data(sheet);
talloc_free(sheet);
@@ -1264,7 +1246,6 @@ bool html_fetch_object(struct content *c, const char *url, struct box *box,
}
error = hlcache_handle_retrieve(url2, 0, content__get_url(c), NULL,
- available_width, available_height,
html_object_callback, c, &child,
&c_fetch);
@@ -1331,8 +1312,6 @@ bool html_replace_object(struct content *c, unsigned int i, const char *url)
/* initialise fetch */
error = hlcache_handle_retrieve(url2, 0, content__get_url(c), NULL,
- c->data.html.object[i].box->width,
- c->data.html.object[i].box->height,
html_object_callback, c, &child,
&c_fetch);
@@ -1509,12 +1488,7 @@ nserror html_object_callback(hlcache_handle *object,
(c->status == CONTENT_STATUS_READY ||
c->status == CONTENT_STATUS_DONE) &&
(wallclock() > c->reformat_time)) {
- unsigned int time_before = wallclock(), time_taken;
content__reformat(c, c->available_width, c->height);
- time_taken = wallclock() - time_before;
- c->reformat_time = wallclock() +
- ((time_taken < option_min_reflow_period ?
- option_min_reflow_period : time_taken * 1.25));
}
return NSERROR_OK;
@@ -1724,6 +1698,9 @@ void html_stop(struct content *c)
void html_reformat(struct content *c, int width, int height)
{
struct box *layout;
+ unsigned int time_before, time_taken;
+
+ time_before = wallclock();
layout_document(c, width, height);
layout = c->data.html.layout;
@@ -1741,6 +1718,11 @@ void html_reformat(struct content *c, int width, int height)
c->width = layout->x + layout->descendant_x1;
if (c->height < layout->y + layout->descendant_y1)
c->height = layout->y + layout->descendant_y1;
+
+ time_taken = wallclock() - time_before;
+ c->reformat_time = wallclock() +
+ ((time_taken < option_min_reflow_period ?
+ option_min_reflow_period : time_taken * 1.25));
}
diff --git a/render/html.h b/render/html.h
index 5ce92ba3d..f56cb585e 100644
--- a/render/html.h
+++ b/render/html.h
@@ -187,7 +187,7 @@ extern bool html_redraw_debug;
bool html_create(struct content *c, const struct http_parameter *params);
bool html_process_data(struct content *c, char *data, unsigned int size);
-bool html_convert(struct content *c, int width, int height);
+bool html_convert(struct content *c);
void html_reformat(struct content *c, int width, int height);
void html_destroy(struct content *c);
bool html_fetch_object(struct content *c, const char *url, struct box *box,
diff --git a/render/textplain.c b/render/textplain.c
index befa9aa50..c259a8b07 100644
--- a/render/textplain.c
+++ b/render/textplain.c
@@ -197,12 +197,11 @@ no_memory:
* Convert a CONTENT_TEXTPLAIN for display.
*/
-bool textplain_convert(struct content *c, int width, int height)
+bool textplain_convert(struct content *c)
{
iconv_close(c->data.textplain.iconv_cd);
c->data.textplain.iconv_cd = 0;
- textplain_reformat(c, width, height);
c->status = CONTENT_STATUS_DONE;
content_set_status(c, messages_get("Done"));
diff --git a/render/textplain.h b/render/textplain.h
index 50e29c5be..355695a4d 100644
--- a/render/textplain.h
+++ b/render/textplain.h
@@ -50,7 +50,7 @@ struct content_textplain_data {
bool textplain_create(struct content *c, const struct http_parameter *params);
bool textplain_process_data(struct content *c, char *data, unsigned int size);
-bool textplain_convert(struct content *c, int width, int height);
+bool textplain_convert(struct content *c);
void textplain_reformat(struct content *c, int width, int height);
void textplain_destroy(struct content *c);
bool textplain_redraw(struct content *c, int x, int y,