diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2022-08-27 17:15:26 +0100 |
---|---|---|
committer | Michael Drake <mdrake.unique@gmail.com> | 2022-08-29 13:49:20 +0100 |
commit | 9cf3fc5bf2e20de413c15db04cf83c49601638d4 (patch) | |
tree | 18bcb16dbe4a4c40e4d17a76f9ddfec8a4871de6 | |
parent | c14f3c4e05d3a6f38fbd84a2bee78895d8120619 (diff) | |
download | libcss-9cf3fc5bf2e20de413c15db04cf83c49601638d4.tar.gz libcss-9cf3fc5bf2e20de413c15db04cf83c49601638d4.tar.bz2 |
Select: Support CSS property-wide 'revert' value
-rw-r--r-- | src/select/select.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/select/select.c b/src/select/select.c index c7d59b7..bd2af96 100644 --- a/src/select/select.c +++ b/src/select/select.c @@ -1145,6 +1145,27 @@ failed: } +static css_error css__select_revert_property( + css_select_state *select_state, + prop_state *prop_state, + css_origin origin, + enum css_pseudo_element pseudo, + enum css_properties_e property) +{ + css_error error; + + error = prop_dispatch[property].copy( + select_state->revert[origin].style[pseudo], + select_state->results->styles[pseudo]); + if (error != CSS_OK) { + return error; + } + + *prop_state = select_state->revert[origin].props[property][pseudo]; + return CSS_OK; +} + + /** * Select a style for the given node * @@ -1318,6 +1339,34 @@ css_error css_select_style(css_select_ctx *ctx, void *node, for (i = 0; i < CSS_N_PROPERTIES; i++) { prop_state *prop = &state.props[i][CSS_PSEUDO_ELEMENT_NONE]; + if (prop->explicit_default == FLAG_VALUE_REVERT) { + switch (prop->origin) { + case CSS_ORIGIN_AUTHOR: + error = css__select_revert_property(&state, + prop, CSS_ORIGIN_USER, 0, i); + if (error != CSS_OK) { + goto cleanup; + } + if (prop->explicit_default != FLAG_VALUE_REVERT) { + break; + } + /* Fall-through */ + case CSS_ORIGIN_USER: + error = css__select_revert_property(&state, + prop, CSS_ORIGIN_UA, 0, i); + if (error != CSS_OK) { + goto cleanup; + } + if (prop->explicit_default != FLAG_VALUE_REVERT) { + break; + } + /* Fall-through */ + case CSS_ORIGIN_UA: + prop->explicit_default = FLAG_VALUE_UNSET; + break; + } + } + if (prop->explicit_default == FLAG_VALUE_UNSET) { if (prop_dispatch[i].inherited == true) { prop->explicit_default = FLAG_VALUE_INHERIT; @@ -1352,6 +1401,36 @@ css_error css_select_style(css_select_ctx *ctx, void *node, for (i = 0; i < CSS_N_PROPERTIES; i++) { prop_state *prop = &state.props[i][j]; + if (prop->explicit_default == FLAG_VALUE_REVERT) { + switch (prop->origin) { + case CSS_ORIGIN_AUTHOR: + error = css__select_revert_property( + &state, prop, + CSS_ORIGIN_USER, j, i); + if (error != CSS_OK) { + goto cleanup; + } + if (prop->explicit_default != FLAG_VALUE_REVERT) { + break; + } + /* Fall-through */ + case CSS_ORIGIN_USER: + error = css__select_revert_property( + &state, prop, + CSS_ORIGIN_UA, j, i); + if (error != CSS_OK) { + goto cleanup; + } + if (prop->explicit_default != FLAG_VALUE_REVERT) { + break; + } + /* Fall-through */ + case CSS_ORIGIN_UA: + prop->explicit_default = FLAG_VALUE_UNSET; + break; + } + } + if (prop->explicit_default == FLAG_VALUE_UNSET) { if (prop_dispatch[i].inherited == true) { prop->explicit_default = FLAG_VALUE_INHERIT; |