Commit 7075110b authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

Handle 'revert' in StylePropertySerializer::CommonShorthandChecks

The 'initial', 'inherit' and 'unset' keywords were handled, but
'revert' was not. This caused crashes when trying to represent certain
declaration block serializations using shorthands.

Change to use IsCSSWideKeyword instead, which includes 'revert'.
(It should also avoid the same problem the next time a new CSS-wide
keyword is added).

Bug: 1071454
Change-Id: I968a32a5ad5b2a1a1958f60ec19679c6a642df14
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2152817Reviewed-by: default avatarYoav Weiss <yoavweiss@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760310}
parent 08ab508b
...@@ -402,9 +402,10 @@ String StylePropertySerializer::CommonShorthandChecks( ...@@ -402,9 +402,10 @@ String StylePropertySerializer::CommonShorthandChecks(
const CSSValue& value = *longhands[i]; const CSSValue& value = *longhands[i];
if (!allow_initial && value.IsInitialValue()) if (!allow_initial && value.IsInitialValue())
return g_empty_string; return g_empty_string;
if (value.IsInheritedValue() || value.IsUnsetValue() || if ((value.IsCSSWideKeyword() && !value.IsInitialValue()) ||
value.IsPendingSubstitutionValue()) value.IsPendingSubstitutionValue()) {
return g_empty_string; return g_empty_string;
}
if (value.IsVariableReferenceValue()) if (value.IsVariableReferenceValue())
return g_empty_string; return g_empty_string;
} }
......
...@@ -130,4 +130,19 @@ test(function() { ...@@ -130,4 +130,19 @@ test(function() {
assert_not_equals(getComputedStyle(elem).backgroundImage, originalComputedValue, assert_not_equals(getComputedStyle(elem).backgroundImage, originalComputedValue,
"getComputedStyle(elem).backgroundImage after setting background-image"); "getComputedStyle(elem).backgroundImage after setting background-image");
}, "Changes to CSS declaration block after a base URL change"); }, "Changes to CSS declaration block after a base URL change");
test(function() {
let e1 = document.createElement('div');
let e2 = document.createElement('div');
document.body.append(e1, e2);
this.add_cleanup(() => {
e1.remove();
e2.remove();
});
e1.style.cssText = "all:revert;border-bottom-left-radius:1px;";
e2.style.cssText = "all:unset;border-bottom-left-radius:1px;";
let processed = e1.style.cssText.split(';')
.map(x => x.replace(/revert$/, 'unset')).join(';');
assert_equals(processed, e2.style.cssText);
}, "Expansion of all:unset and all:revert treated identically");
</script> </script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment