mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-23 10:52:07 +03:00
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
This commit is contained in:
parent
2c8a235a5d
commit
c75a613546
32
css/css.c
32
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
|
||||
|
Loading…
Reference in New Issue
Block a user