diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2022-08-27 15:33:39 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2022-08-28 15:35:15 +0100 |
commit | 0080e6af76a8b9665fffe30bc71405a52088746d (patch) | |
tree | ec9ad4dc257da136c5cb82e2a1769169a5a060f1 | |
parent | c23624f72a3ec06f9e2cd2443847b34920cb6672 (diff) | |
download | libcss-0080e6af76a8b9665fffe30bc71405a52088746d.tar.gz libcss-0080e6af76a8b9665fffe30bc71405a52088746d.tar.bz2 |
Select: Add computed style clone function
-rw-r--r-- | src/select/computed.c | 31 | ||||
-rw-r--r-- | src/select/computed.h | 4 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/select/computed.c b/src/select/computed.c index c019590..89d6efb 100644 --- a/src/select/computed.c +++ b/src/select/computed.c @@ -233,6 +233,37 @@ css_error css__computed_style_initialise(css_computed_style *style, } /** + * Clone a computed style + * + * \param orig Style to copy + * \param clone_out Returns cloned style on success + * \return CSS_OK on success. + */ +css_error css__computed_style_clone( + const css_computed_style *orig, + css_computed_style **clone_out) +{ + css_error error; + css_computed_style *clone; + + error = css__computed_style_create(&clone); + if (error != CSS_OK) { + return error; + } + + for (size_t i = 0; i < CSS_N_PROPERTIES; i++) { + error = prop_dispatch[i].copy(orig, clone); + if (error != CSS_OK) { + css_computed_style_destroy(clone); + return error; + } + } + + *clone_out = clone; + return CSS_OK; +} + +/** * Compose two computed styles * * \param parent Parent style diff --git a/src/select/computed.h b/src/select/computed.h index a4bd23d..a1e4eed 100644 --- a/src/select/computed.h +++ b/src/select/computed.h @@ -35,6 +35,10 @@ css_error css__computed_style_create(css_computed_style **result); css_error css__computed_style_initialise(css_computed_style *style, struct css_select_handler *handler, void *pw); +css_error css__computed_style_clone( + const css_computed_style *orig, + css_computed_style **clone_out); + css_error css__compute_absolute_values(const css_computed_style *parent, css_computed_style *style, const css_unit_ctx *unit_ctx); |