summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2022-08-27 17:15:26 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2022-08-28 15:35:15 +0100
commit8cdeff91d7fd09d9bacf64af666477158893814a (patch)
tree18bcb16dbe4a4c40e4d17a76f9ddfec8a4871de6
parent18314b535072d6b6a8b7d23ffedc375d2bef67db (diff)
downloadlibcss-8cdeff91d7fd09d9bacf64af666477158893814a.tar.gz
libcss-8cdeff91d7fd09d9bacf64af666477158893814a.tar.bz2
Select: Support CSS property-wide 'revert' value
-rw-r--r--src/select/select.c79
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;