diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2022-08-27 15:33:39 +0100 |
---|---|---|
committer | Michael Drake <mdrake.unique@gmail.com> | 2022-08-29 13:49:20 +0100 |
commit | 668aaa731a4e3fcb8ad49aa08b694aefe3f7e606 (patch) | |
tree | ec9ad4dc257da136c5cb82e2a1769169a5a060f1 | |
parent | fbea34894d58c202f1bc436511ac7ba61791c8d9 (diff) | |
download | libcss-668aaa731a4e3fcb8ad49aa08b694aefe3f7e606.tar.gz libcss-668aaa731a4e3fcb8ad49aa08b694aefe3f7e606.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); |