Bug 1235002 - Skip requesting a restyle when mProperties is empty. r=birtles

The test case here does not check whether requesting restyles for empty
properties are skipped or not.  It just checks that whether restyles happen or
not because there is no way to check each request for restyles yet.

MozReview-Commit-ID: I5XMYfCTYU8

--HG--
extra : rebase_source : 893aaaf2c47e05f37bce9913df4f14e3021f215a
This commit is contained in:
Hiroyuki Ikezoe 2016-05-09 12:33:52 +09:00
parent 817b6c705e
commit 8fd021fbd4
2 changed files with 33 additions and 10 deletions

View File

@ -168,18 +168,11 @@ KeyframeEffectReadOnly::NotifyAnimationTimingUpdated()
// Request restyle if necessary.
//
// Bug 1235002: We should skip requesting a restyle when mProperties is empty.
// However, currently we don't properly encapsulate mProperties so we can't
// detect when it changes. As a result, if we skip requesting restyles when
// mProperties is empty and we play an animation and *then* add properties to
// it (as we currently do when building CSS animations), we will fail to
// request a restyle at all. Since animations without properties are rare, we
// currently just request the restyle regardless of whether mProperties is
// empty or not.
//
// Bug 1216843: When we implement iteration composite modes, we need to
// also detect if the current iteration has changed.
if (mAnimation && GetComputedTiming().mProgress != mProgressOnLastCompose) {
if (mAnimation &&
!mProperties.IsEmpty() &&
GetComputedTiming().mProgress != mProgressOnLastCompose) {
EffectCompositor::RestyleType restyleType =
CanThrottle() ?
EffectCompositor::RestyleType::Throttled :

View File

@ -442,6 +442,36 @@ waitForAllPaints(function() {
yield ensureElementRemoval(div);
});
add_task(function* restyling_for_empty_keyframes() {
var div = addDiv(null);
var animation = div.animate({ }, 100 * MS_PER_SEC);
yield animation.ready;
var markers = yield observeStyling(5);
is(markers.length, 0,
'Animations with no keyframes should not cause restyles');
animation.effect.setFrames({ backgroundColor: ['red', 'blue'] });
markers = yield observeStyling(5);
// There are 5 eRestyle_CSSAnimations and 1 eRestyle_CSSTransitions.
// 1 eRestyle_CSSTransitions comes from
// EffectCompositor::UpdateCascadeResults.
ok(markers.length == 6,
'Setting valid keyframes should cause regular animation restyles to ' +
'occur');
animation.effect.setFrames({ });
markers = yield observeStyling(5);
is(markers.length, 1,
'Setting an empty set of keyframes should trigger a single restyle ' +
'to remove the previous animated style');
yield ensureElementRemoval(div);
});
});
</script>