From 4ec38922ac17f72a52cccb1e3ad875618ce00df5 Mon Sep 17 00:00:00 2001 From: Rob Kendrick Date: Tue, 11 Mar 2008 00:14:39 +0000 Subject: [PATCH] Change meaning of c->redraw_time to be the earliest time to reflow during page asset fetch. Have the time selected vary depending on how long the last reflow took. svn path=/trunk/netsurf/; revision=3925 --- content/content.h | 6 +++--- desktop/options.c | 4 ++-- desktop/options.h | 2 +- render/html.c | 19 +++++++++++++++---- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/content/content.h b/content/content.h index c49aef3a5..4f2fa0ed6 100644 --- a/content/content.h +++ b/content/content.h @@ -205,9 +205,9 @@ struct content { LOADING or READY, otherwise total time. */ - unsigned int reformat_time; /**< Time the HTML content was last - reformatted. Used while fetching - a page's objects. */ + unsigned int reformat_time; /**< Earliest time to attempt a + period reflow while fetching a + page's objects. */ unsigned int size; /**< Estimated size of all data associated with this content, except diff --git a/desktop/options.c b/desktop/options.c index cfa89abcc..9a1111c83 100644 --- a/desktop/options.c +++ b/desktop/options.c @@ -132,9 +132,9 @@ int option_scale = 100; bool option_incremental_reflow = true; /* Minimum time between HTML reflows while objects are fetching */ #ifdef riscos -int option_min_reflow_period = 100; /* time in cs */ +unsigned int option_min_reflow_period = 100; /* time in cs */ #else -int option_min_reflow_period = 25; /* time in cs */ +unsigned int option_min_reflow_period = 25; /* time in cs */ #endif /* Fetcher configuration */ diff --git a/desktop/options.h b/desktop/options.h index 6b9fd66e7..89e99969b 100644 --- a/desktop/options.h +++ b/desktop/options.h @@ -81,7 +81,7 @@ extern int option_window_screen_height; extern int option_toolbar_status_width; extern int option_scale; extern bool option_incremental_reflow; -extern int option_min_reflow_period; +extern unsigned int option_min_reflow_period; /* Fetcher configuration. */ extern int option_max_fetchers; diff --git a/render/html.c b/render/html.c index d7dff203a..e803f2ea6 100644 --- a/render/html.c +++ b/render/html.c @@ -407,6 +407,7 @@ bool html_convert(struct content *c, int width, int height) xmlDoc *document; xmlNode *html, *head; union content_msg_data msg_data; + unsigned int time_before, time_taken; /* finish parsing */ if (c->source_size == 0) @@ -491,8 +492,15 @@ bool html_convert(struct content *c, int width, int height) 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); - c->reformat_time = wallclock(); + 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(c->data.html.layout->children, 0);*/ if (c->active == 0) @@ -1417,10 +1425,13 @@ void html_object_callback(content_msg msg, struct content *object, else if (option_incremental_reflow && msg == CONTENT_MSG_DONE && (c->status == CONTENT_STATUS_READY || c->status == CONTENT_STATUS_DONE) && - (option_min_reflow_period < - (int)(wallclock() - c->reformat_time))) { + (wallclock() > c->reformat_time)) { + unsigned int time_before = wallclock(), time_taken; content_reformat(c, c->available_width, c->height); - c->reformat_time = wallclock(); + time_taken = wallclock() - time_before; + c->reformat_time = wallclock() + + ((time_taken < option_min_reflow_period ? + option_min_reflow_period : time_taken * 1.25)); } if (c->status == CONTENT_STATUS_READY) html_set_status(c, "");