Bug 1442861 - Clear mNeedStyleFlush flag after ProcessPendingRestyles(). r=emilio

mNeedStyleFlush is also set by animation restyle request.  So it's possible
that the flag is set again in PostRestyleForThrottledAnimations() or in
sequential tasks for updating animations after the flag is cleared at the top
DoFlushPendingNotifications().

MozReview-Commit-ID: KPSS6cJb4HX

--HG--
extra : rebase_source : 31d839f12b654d52b352cd50e19bc1953c46b7c2
This commit is contained in:
Hiroyuki Ikezoe 2018-03-06 06:34:02 +09:00
parent 7b7f160bef
commit 0476fc2aa7
2 changed files with 37 additions and 3 deletions

View File

@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<title>DOMWindowUtils test with animation</title>
<script src="/tests/SimpleTest/paint_listener.js"></script>
</head>
<body>
<script type="application/javascript">
@ -148,8 +149,7 @@ function test_getUnanimatedComputedStyle() {
div.remove();
next();
window.close();
test_needsFlushWithThrottledAnimations();
}
function checkUnanimatedComputedStyle(property, initialStyle, pseudoType,
@ -183,6 +183,38 @@ function checkUnanimatedComputedStyle(property, initialStyle, pseudoType,
div.remove();
}
function test_needsFlushWithThrottledAnimations() {
const div = document.createElement("div");
div.style = "width: 100px; height: 100px; background-color: blue;";
document.body.appendChild(div);
const animation = div.animate({ opacity: [ 0, 1 ] },
{ duration: 100000, iterations: Infinity });
animation.ready.then(() => {
// Make sure pending styles in the previous test has been already processed.
// (I.e. the target element in the test has surely removed.)
waitForAllPaintsFlushed(() => {
ok(SpecialPowers.wrap(animation).isRunningOnCompositor,
"Opacity animation should run on the compositor");
// FIXME! Bug 1442861: We should make sure needsFlush() returns true
// before flusing layout.
//ok(utils.needsFlush(SpecialPowers.Ci.nsIDOMWindowUtils.FLUSH_STYLE),
// "needsFlush should return true if there is an animation on the compositor");
// Flush layout.
document.documentElement.getBoundingClientRect();
ok(!utils.needsFlush(SpecialPowers.Ci.nsIDOMWindowUtils.FLUSH_STYLE),
"needsFlush should return false after flushing layout");
div.remove();
next();
window.close();
});
});
}
window.addEventListener("load", test_getUnanimatedComputedStyle);
</script>

View File

@ -4235,11 +4235,13 @@ PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush)
#endif
mPresContext->RestyleManager()->ProcessPendingRestyles();
// Clear mNeedStyleFlush here agagin to make this flag work properly for
// optimization since the flag might have set in ProcessPendingRestyles().
mNeedStyleFlush = false;
}
didStyleFlush = true;
// There might be more pending constructors now, but we're not going to
// worry about them. They can't be triggered during reflow, so we should
// be good.