Commit 711a5d9b authored by rune@opera.com's avatar rune@opera.com

Missing return after class invalidation short-cut.

scheduleStyleInvalidationForClassChange skipped comparison when oldClasses
was empty, but forgot to return afterwards, causing invalidation sets to be
scheduled twice.

This fix increases runs/s by 10%+ on the added performance test.

R=esprehn@chromium.org,chrishtr@chromium.org
BUG=380874

Review URL: https://codereview.chromium.org/313963006

git-svn-id: svn://svn.chromium.org/blink/trunk@175568 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e4c7ff30
<!DOCTYPE html>
<script src="../resources/runner.js"></script>
<style>
.a .b { background-color: green }
</style>
<div id="root"></div>
<script>
function appendDivChildren(root, childCount, levels) {
if (levels <= 0)
return;
for (var i = 0; i < childCount; i++) {
var div = document.createElement("div");
appendDivChildren(div, childCount, levels - 1)
root.appendChild(div);
}
}
var root = document.getElementById("root");
appendDivChildren(root, 5, 5);
root.firstChild.className = "b";
document.body.offsetTop; // force style recalc.
PerfTestRunner.measureRunsPerSecond({
description: "Measure the style recalc performance when changing a class affecting the style of a single descendant.",
run: function() {
root.className = "a";
root.offsetTop; // force recalc.
root.className = "";
root.offsetTop; // force recalc.
}});
</script>
......@@ -446,8 +446,10 @@ void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitStr
void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses, Element& element)
{
if (!oldClasses.size())
if (!oldClasses.size()) {
scheduleStyleInvalidationForClassChange(newClasses, element);
return;
}
// Class vectors tend to be very short. This is faster than using a hash table.
BitVector remainingClassBits;
......
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