summaryrefslogtreecommitdiff
path: root/css
diff options
context:
space:
mode:
Diffstat (limited to 'css')
-rw-r--r--css/css.c27
-rw-r--r--css/css.h2
2 files changed, 29 insertions, 0 deletions
diff --git a/css/css.c b/css/css.c
index b0a3cd472..ef38d76aa 100644
--- a/css/css.c
+++ b/css/css.c
@@ -326,6 +326,33 @@ void nscss_destroy_css_data(struct content_css_data *c)
}
}
+bool nscss_clone(const struct content *old, struct content *new_content)
+{
+ const char *data;
+ unsigned long size;
+
+ /* Simply replay create/process/convert */
+ /** \todo We need the charset of the old sheet */
+ if (nscss_create_css_data(&new_content->data.css,
+ content__get_url(new_content),
+ NULL, new_content->quirks) != NSERROR_OK)
+ return false;
+
+ data = content__get_source_data(new_content, &size);
+ if (size > 0) {
+ if (nscss_process_data(new_content, data, size) == false)
+ return false;
+ }
+
+ if (old->status == CONTENT_STATUS_READY ||
+ old->status == CONTENT_STATUS_DONE) {
+ if (nscss_convert(new_content) == false)
+ return false;
+ }
+
+ return true;
+}
+
/**
* Retrieve imported stylesheets
*
diff --git a/css/css.h b/css/css.h
index cd09beda6..c95f87053 100644
--- a/css/css.h
+++ b/css/css.h
@@ -57,6 +57,8 @@ bool nscss_convert(struct content *c);
void nscss_destroy(struct content *c);
+bool nscss_clone(const struct content *old, struct content *new_content);
+
nserror nscss_create_css_data(struct content_css_data *c,
const char *url, const char *charset, bool quirks);
css_error nscss_process_css_data(struct content_css_data *c, const char *data,