Commit e5cef4a3 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

[cascade] Actually use the pending substitution cache

I forgot to actually set the CSSValue (i.e. cache key), which means the
cache was never used.

This CL adds a performance test for this which should catch regressions
in the future. The test works by specifying a couple of shorthands, each
of which has a large number of var() references that needs resolving.

Local testing on my machine shows ~170ms with the cache enabled, and
over 500ms with the cache disabled.

Change-Id: I867679969bb6617219388e0b6f28adc3ae223f5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2080262Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746436}
parent 1e5ce727
<!DOCTYPE html>
<script src="../resources/runner.js"></script>
<script src="resources/utils.js"></script>
<link help="https://drafts.csswg.org/css-variables/#pending-substitution-value">
<div id="container" style="height: 100px; overflow: hidden"></div>
<script>
createDOMTree(container, 2, 3);
applyCSSRule(':root { --border: 4mm ridge rgba(170, 50, 220, .6); }');
applyCSSRule(':root { --margin: 1px 2px 3px 4px; }');
applyCSSRule(':root { --padding: 1px 2px 3px 4px; }');
applyCSSRule(':root { --background: content-box radial-gradient(crimson, skyblue); }');
const sequence_size = 2000;
function create_var_sequence() {
let chain = [];
for (let i = 0; i < sequence_size; ++i) {
chain.push(`var(--v${i}, )`);
}
return chain.join(' ');
}
applyCSSRule(`div { border: ${create_var_sequence()} var(--border); }`);
applyCSSRule(`div { margin: ${create_var_sequence()} var(--margin); }`);
applyCSSRule(`div { padding: ${create_var_sequence()} var(--padding); }`);
applyCSSRule(`div { background: ${create_var_sequence()} var(--bakground); }`);
PerfTestRunner.measureTime({
description: 'Measure impact of resolving pending-substitution-values',
run: function() {
container.style.setProperty('display', 'none');
forceStyleRecalc(container);
container.style.setProperty('display', 'block');
forceStyleRecalc(container);
}
});
</script>
...@@ -490,6 +490,7 @@ const CSSValue* StyleCascade::ResolvePendingSubstitution( ...@@ -490,6 +490,7 @@ const CSSValue* StyleCascade::ResolvePendingSubstitution(
return cssvalue::CSSUnsetValue::Create(); return cssvalue::CSSUnsetValue::Create();
} }
resolver.shorthand_cache_.value = &value;
resolver.shorthand_cache_.parsed_properties = std::move(parsed_properties); resolver.shorthand_cache_.parsed_properties = std::move(parsed_properties);
} }
......
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