summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2022-08-29 12:34:11 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2022-08-29 12:36:12 +0100
commitb60246562708b36f79fd34d26d440999f6599806 (patch)
treee1bf7d658ae16dc78cc7ac639ad21ebcabb0d3f9
parent81b35acfc1aba461f6213218de2979e389c78fc4 (diff)
downloadlibcss-tlsa/explicit-defaulting.tar.gz
libcss-tlsa/explicit-defaulting.tar.bz2
Select: Only store UA and USER origin styles if revert is usedtlsa/explicit-defaulting
-rw-r--r--src/select/select.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/select/select.c b/src/select/select.c
index f7dc098..0735641 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -53,6 +53,8 @@ struct css_select_ctx {
void *pw; /**< Client's private selection context */
+ bool uses_revert; /**< A sheet used revert property value */
+
css_select_strings str;
/* Interned default style */
@@ -355,6 +357,8 @@ css_error css_select_ctx_insert_sheet(css_select_ctx *ctx,
ctx->sheets[index].origin = origin;
ctx->sheets[index].media = mq;
+ ctx->uses_revert |= sheet->uses_revert;
+
ctx->n_sheets++;
return CSS_OK;
@@ -1289,10 +1293,14 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
#endif
/* Not sharing; need to select. */
- state.revert = calloc(CSS_ORIGIN_AUTHOR, sizeof(*state.revert));
- if (state.revert == NULL) {
- error = CSS_NOMEM;
- goto cleanup;
+ if (ctx->uses_revert ||
+ (inline_style != NULL && inline_style->uses_revert)) {
+ /* Need to track UA and USER origin styles for revert. */
+ state.revert = calloc(CSS_ORIGIN_AUTHOR, sizeof(*state.revert));
+ if (state.revert == NULL) {
+ error = CSS_NOMEM;
+ goto cleanup;
+ }
}
/* Base element style is guaranteed to exist
@@ -1326,7 +1334,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
for (i = 0; i < ctx->n_sheets; i++) {
const css_select_sheet s = ctx->sheets[i];
- if (s.origin != origin) {
+ if (state.revert != NULL && s.origin != origin) {
for (j = 0; j < CSS_PSEUDO_ELEMENT_COUNT; j++) {
if (state.results->styles[j] == NULL) {
continue;