summaryrefslogtreecommitdiff
path: root/css/css.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-07-27 19:40:55 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-07-27 19:40:55 +0000
commitc75a61354615efe5ac3968c25b0c0906fe9a71c2 (patch)
tree6654eefa1c0b484ebd137ef17fbad62f107a94fc /css/css.c
parent2c8a235a5d823bc56be247480bb29a8dd4433bd9 (diff)
downloadnetsurf-c75a61354615efe5ac3968c25b0c0906fe9a71c2.tar.gz
netsurf-c75a61354615efe5ac3968c25b0c0906fe9a71c2.tar.bz2
Add stylesheet size + size of imported sheets onto CSS content size.
Remove imported contents once we've fetched them and imported them into their parent (once this has happened, the content object is just an empty shell, so not worth keeping around). svn path=/trunk/netsurf/; revision=8831
Diffstat (limited to 'css/css.c')
-rw-r--r--css/css.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/css/css.c b/css/css.c
index 8bdfe0b57..cf8902037 100644
--- a/css/css.c
+++ b/css/css.c
@@ -205,6 +205,8 @@ bool nscss_process_data(struct content *c, char *data, unsigned int size)
bool nscss_convert(struct content *c, int w, int h)
{
union content_msg_data msg_data;
+ uint32_t i;
+ size_t size;
css_error error;
error = css_stylesheet_data_done(c->data.css.sheet);
@@ -212,7 +214,6 @@ bool nscss_convert(struct content *c, int w, int h)
/* Process pending imports */
while (error == CSS_IMPORTS_PENDING) {
struct nscss_import *imports;
- uint32_t i;
lwc_string *uri;
uint64_t media;
css_stylesheet *sheet;
@@ -302,6 +303,35 @@ bool nscss_convert(struct content *c, int w, int h)
error = CSS_IMPORTS_PENDING;
}
+ /* Retrieve the size of this sheet */
+ error = css_stylesheet_size(c->data.css.sheet, &size);
+ if (error != CSS_OK) {
+ msg_data.error = "?";
+ content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ c->status = CONTENT_STATUS_ERROR;
+ return false;
+ }
+ c->size += size;
+
+ /* Add on the size of the imported sheets, removing ourselves from
+ * their user list as we go (they're of no use to us now, as we've
+ * inserted the sheet into ourselves) */
+ for (i = 0; i < c->data.css.import_count; i++) {
+ if (c->data.css.imports[i].c != NULL) {
+ c->size += c->data.css.imports[i].c->size;
+
+ content_remove_user(c->data.css.imports[i].c,
+ nscss_import, (uintptr_t) c, i);
+ }
+
+ c->data.css.imports[i].c = NULL;
+ }
+
+ /* Remove the imports */
+ c->data.css.import_count = 0;
+ free(c->data.css.imports);
+ c->data.css.imports = NULL;
+
c->status = CONTENT_STATUS_DONE;
/* Filthy hack to stop this content being reused