зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1197620 - Part 3: Terminate *all* animations if corresponding element style is changed to display:none. r=bbirtles
This commit is contained in:
Родитель
2505b44960
Коммит
443e1dfb4b
|
@ -70,6 +70,64 @@ test(function(t) {
|
|||
}, 'Animation starts playing when its parent element is shown from ' +
|
||||
'"display:none" state');
|
||||
|
||||
test(function(t) {
|
||||
var div = addDiv(t, { style: 'animation: move 100s forwards' });
|
||||
assert_equals(div.getAnimations().length, 1,
|
||||
'display:initial element has animations');
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.finish();
|
||||
assert_equals(div.getAnimations().length, 1,
|
||||
'Element has finished animation if the animation ' +
|
||||
'fill-mode is forwards');
|
||||
|
||||
div.style.display = 'none';
|
||||
assert_equals(animation.playState, 'idle',
|
||||
'The animation.playState should be idle');
|
||||
|
||||
assert_equals(div.getAnimations().length, 0,
|
||||
'display:none element has no animations');
|
||||
|
||||
div.style.display = '';
|
||||
assert_equals(div.getAnimations().length, 1,
|
||||
'Element which is no longer display:none has animations ' +
|
||||
'again');
|
||||
assert_not_equals(div.getAnimations()[0], animation,
|
||||
'Restarted animation is a newly-generated animation');
|
||||
|
||||
}, 'Animation which has already finished starts playing when the element ' +
|
||||
'gets shown from "display:none" state');
|
||||
|
||||
test(function(t) {
|
||||
var parentElement = addDiv(t);
|
||||
var div = addDiv(t, { style: 'animation: move 100s forwards' });
|
||||
parentElement.appendChild(div);
|
||||
assert_equals(div.getAnimations().length, 1,
|
||||
'display:initial element has animations');
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
animation.finish();
|
||||
assert_equals(div.getAnimations().length, 1,
|
||||
'Element has finished animation if the animation ' +
|
||||
'fill-mode is forwards');
|
||||
|
||||
parentElement.style.display = 'none';
|
||||
assert_equals(animation.playState, 'idle',
|
||||
'The animation.playState should be idle');
|
||||
assert_equals(div.getAnimations().length, 0,
|
||||
'Element in display:none subtree has no animations');
|
||||
|
||||
parentElement.style.display = '';
|
||||
assert_equals(div.getAnimations().length, 1,
|
||||
'Element which is no longer in display:none subtree has ' +
|
||||
'animations again');
|
||||
|
||||
assert_not_equals(div.getAnimations()[0], animation,
|
||||
'Restarted animation is a newly-generated animation');
|
||||
|
||||
}, 'Animation which has already finished starts playing when its parent ' +
|
||||
'element is shown from "display:none" state');
|
||||
|
||||
done();
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
|
||||
#include "nsBidiPresUtils.h"
|
||||
#include "RubyUtils.h"
|
||||
#include "nsAnimationManager.h"
|
||||
|
||||
// For triple-click pref
|
||||
#include "imgIContainer.h"
|
||||
|
@ -688,7 +689,7 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
|||
}
|
||||
}
|
||||
|
||||
if (nsLayoutUtils::HasCurrentAnimations(static_cast<nsIFrame*>(this))) {
|
||||
if (HasCSSAnimations()) {
|
||||
// If no new frame for this element is created by the end of the
|
||||
// restyling process, stop animations for this frame
|
||||
RestyleManager::AnimationsWithDestroyedFrame* adf =
|
||||
|
@ -9053,6 +9054,14 @@ nsIFrame::CaretPosition::~CaretPosition()
|
|||
{
|
||||
}
|
||||
|
||||
bool
|
||||
nsFrame::HasCSSAnimations()
|
||||
{
|
||||
AnimationCollection* collection =
|
||||
PresContext()->AnimationManager()->GetAnimationCollection(this);
|
||||
return collection && collection->mAnimations.Length() > 0;
|
||||
}
|
||||
|
||||
// Box layout debugging
|
||||
#ifdef DEBUG_REFLOW
|
||||
int32_t gIndent2 = 0;
|
||||
|
|
|
@ -676,6 +676,9 @@ private:
|
|||
|
||||
NS_IMETHODIMP RefreshSizeCache(nsBoxLayoutState& aState);
|
||||
|
||||
// Returns true if this frame has any kind of CSS animations.
|
||||
bool HasCSSAnimations();
|
||||
|
||||
#ifdef DEBUG_FRAME_DUMP
|
||||
public:
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче