mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1215406 - Part 3: Change the types of direction and fillmode in AnimationTiming. r=heycam
Use mozilla::dom::FillMode and mozilla::dom::PlaybackDirection in AnimationTiming.
This commit is contained in:
parent
87c441885a
commit
1d04a6bf75
@ -5,6 +5,7 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/KeyframeEffect.h"
|
||||
|
||||
#include "mozilla/dom/AnimationEffectReadOnlyBinding.h"
|
||||
#include "mozilla/dom/KeyframeEffectBinding.h"
|
||||
#include "mozilla/dom/PropertyIndexedKeyframesBinding.h"
|
||||
@ -22,43 +23,21 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
bool
|
||||
AnimationTiming::FillsForwards() const
|
||||
{
|
||||
return mFillMode == dom::FillMode::Both ||
|
||||
mFillMode == dom::FillMode::Forwards;
|
||||
}
|
||||
|
||||
bool
|
||||
AnimationTiming::FillsBackwards() const
|
||||
{
|
||||
return mFillMode == dom::FillMode::Both ||
|
||||
mFillMode == dom::FillMode::Backwards;
|
||||
}
|
||||
|
||||
// Helper functions for generating a ComputedTimingProperties dictionary
|
||||
static dom::FillMode
|
||||
ConvertFillMode(uint8_t aFill)
|
||||
{
|
||||
switch (aFill) {
|
||||
case NS_STYLE_ANIMATION_FILL_MODE_NONE:
|
||||
return dom::FillMode::None;
|
||||
case NS_STYLE_ANIMATION_FILL_MODE_FORWARDS:
|
||||
return dom::FillMode::Forwards;
|
||||
case NS_STYLE_ANIMATION_FILL_MODE_BACKWARDS:
|
||||
return dom::FillMode::Backwards;
|
||||
case NS_STYLE_ANIMATION_FILL_MODE_BOTH:
|
||||
return dom::FillMode::Both;
|
||||
default:
|
||||
MOZ_ASSERT(false, "The mapping of FillMode is not correct");
|
||||
return dom::FillMode::None;
|
||||
}
|
||||
}
|
||||
|
||||
static dom::PlaybackDirection
|
||||
ConvertPlaybackDirection(uint8_t aDirection)
|
||||
{
|
||||
switch (aDirection) {
|
||||
case NS_STYLE_ANIMATION_DIRECTION_NORMAL:
|
||||
return dom::PlaybackDirection::Normal;
|
||||
case NS_STYLE_ANIMATION_DIRECTION_REVERSE:
|
||||
return dom::PlaybackDirection::Reverse;
|
||||
case NS_STYLE_ANIMATION_DIRECTION_ALTERNATE:
|
||||
return dom::PlaybackDirection::Alternate;
|
||||
case NS_STYLE_ANIMATION_DIRECTION_ALTERNATE_REVERSE:
|
||||
return dom::PlaybackDirection::Alternate_reverse;
|
||||
default:
|
||||
MOZ_ASSERT(false, "The mapping of PlaybackDirection is not correct");
|
||||
return dom::PlaybackDirection::Normal;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
GetComputedTimingDictionary(const ComputedTiming& aComputedTiming,
|
||||
const Nullable<TimeDuration>& aLocalTime,
|
||||
@ -67,10 +46,10 @@ GetComputedTimingDictionary(const ComputedTiming& aComputedTiming,
|
||||
{
|
||||
// AnimationEffectTimingProperties
|
||||
aRetVal.mDelay = aTiming.mDelay.ToMilliseconds();
|
||||
aRetVal.mFill = ConvertFillMode(aTiming.mFillMode);
|
||||
aRetVal.mFill = aTiming.mFillMode;
|
||||
aRetVal.mIterations = aTiming.mIterationCount;
|
||||
aRetVal.mDuration.SetAsUnrestrictedDouble() = aTiming.mIterationDuration.ToMilliseconds();
|
||||
aRetVal.mDirection = ConvertPlaybackDirection(aTiming.mDirection);
|
||||
aRetVal.mDirection = aTiming.mDirection;
|
||||
|
||||
// ComputedTimingProperties
|
||||
aRetVal.mActiveDuration = aComputedTiming.mActiveDuration.ToMilliseconds();
|
||||
@ -271,18 +250,20 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
|
||||
|
||||
bool thisIterationReverse = false;
|
||||
switch (aTiming.mDirection) {
|
||||
case NS_STYLE_ANIMATION_DIRECTION_NORMAL:
|
||||
case PlaybackDirection::Normal:
|
||||
thisIterationReverse = false;
|
||||
break;
|
||||
case NS_STYLE_ANIMATION_DIRECTION_REVERSE:
|
||||
case PlaybackDirection::Reverse:
|
||||
thisIterationReverse = true;
|
||||
break;
|
||||
case NS_STYLE_ANIMATION_DIRECTION_ALTERNATE:
|
||||
case PlaybackDirection::Alternate:
|
||||
thisIterationReverse = (result.mCurrentIteration & 1) == 1;
|
||||
break;
|
||||
case NS_STYLE_ANIMATION_DIRECTION_ALTERNATE_REVERSE:
|
||||
case PlaybackDirection::Alternate_reverse:
|
||||
thisIterationReverse = (result.mCurrentIteration & 1) == 0;
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT(true, "Unknown PlaybackDirection type");
|
||||
}
|
||||
if (thisIterationReverse) {
|
||||
result.mProgress.SetValue(1.0 - result.mProgress.Value());
|
||||
@ -570,8 +551,8 @@ KeyframeEffectReadOnly::ConvertKeyframeEffectOptions(
|
||||
animationTiming.mIterationDuration = TimeDuration(0);
|
||||
}
|
||||
animationTiming.mIterationCount = 1.0f;
|
||||
animationTiming.mDirection = NS_STYLE_ANIMATION_DIRECTION_NORMAL;
|
||||
animationTiming.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_NONE;
|
||||
animationTiming.mDirection = PlaybackDirection::Normal;
|
||||
animationTiming.mFillMode = FillMode::None;
|
||||
|
||||
return animationTiming;
|
||||
}
|
||||
|
@ -51,17 +51,11 @@ struct AnimationTiming
|
||||
TimeDuration mIterationDuration;
|
||||
TimeDuration mDelay;
|
||||
float mIterationCount; // mozilla::PositiveInfinity<float>() means infinite
|
||||
uint8_t mDirection;
|
||||
uint8_t mFillMode;
|
||||
dom::PlaybackDirection mDirection;
|
||||
dom::FillMode mFillMode;
|
||||
|
||||
bool FillsForwards() const {
|
||||
return mFillMode == NS_STYLE_ANIMATION_FILL_MODE_BOTH ||
|
||||
mFillMode == NS_STYLE_ANIMATION_FILL_MODE_FORWARDS;
|
||||
}
|
||||
bool FillsBackwards() const {
|
||||
return mFillMode == NS_STYLE_ANIMATION_FILL_MODE_BOTH ||
|
||||
mFillMode == NS_STYLE_ANIMATION_FILL_MODE_BACKWARDS;
|
||||
}
|
||||
bool FillsForwards() const;
|
||||
bool FillsBackwards() const;
|
||||
bool operator==(const AnimationTiming& aOther) const {
|
||||
return mIterationDuration == aOther.mIterationDuration &&
|
||||
mDelay == aOther.mDelay &&
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "mozilla/StyleAnimationValue.h" // for StyleAnimationValue, etc
|
||||
#include "mozilla/WidgetUtils.h" // for ComputeTransformForRotation
|
||||
#include "mozilla/dom/KeyframeEffect.h" // for KeyframeEffectReadOnly
|
||||
#include "mozilla/dom/AnimationEffectReadOnlyBinding.h" // for dom::FillMode
|
||||
#include "mozilla/gfx/BaseRect.h" // for BaseRect
|
||||
#include "mozilla/gfx/Point.h" // for RoundedToInt, PointTyped
|
||||
#include "mozilla/gfx/Rect.h" // for RoundedToInt, RectTyped
|
||||
@ -583,12 +584,12 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
|
||||
// into their start time, hence the delay is effectively zero.
|
||||
timing.mDelay = TimeDuration(0);
|
||||
timing.mIterationCount = animation.iterationCount();
|
||||
timing.mDirection = animation.direction();
|
||||
timing.mDirection = static_cast<dom::PlaybackDirection>(animation.direction());
|
||||
// Animations typically only run on the compositor during their active
|
||||
// interval but if we end up sampling them outside that range (for
|
||||
// example, while they are waiting to be removed) we currently just
|
||||
// assume that we should fill.
|
||||
timing.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_BOTH;
|
||||
timing.mFillMode = dom::FillMode::Both;
|
||||
|
||||
ComputedTiming computedTiming =
|
||||
dom::KeyframeEffectReadOnly::GetComputedTimingAt(
|
||||
|
@ -383,7 +383,7 @@ AddAnimationForProperty(nsIFrame* aFrame, const AnimationProperty& aProperty,
|
||||
- timing.mDelay;
|
||||
animation->duration() = timing.mIterationDuration;
|
||||
animation->iterationCount() = timing.mIterationCount;
|
||||
animation->direction() = timing.mDirection;
|
||||
animation->direction() = static_cast<uint32_t>(timing.mDirection);
|
||||
animation->property() = aProperty.mProperty;
|
||||
animation->playbackRate() = aAnimation->PlaybackRate();
|
||||
animation->data() = aData;
|
||||
|
@ -54,7 +54,7 @@ ElementPropertyTransition::CurrentValuePortion() const
|
||||
// case, we override the fill mode to 'both' to ensure the progress
|
||||
// is never null.
|
||||
AnimationTiming timingToUse = mTiming;
|
||||
timingToUse.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_BOTH;
|
||||
timingToUse.mFillMode = dom::FillMode::Both;
|
||||
ComputedTiming computedTiming = GetComputedTiming(&timingToUse);
|
||||
|
||||
MOZ_ASSERT(!computedTiming.mProgress.IsNull(),
|
||||
@ -658,8 +658,8 @@ nsTransitionManager::ConsiderStartingTransition(
|
||||
timing.mIterationDuration = TimeDuration::FromMilliseconds(duration);
|
||||
timing.mDelay = TimeDuration::FromMilliseconds(delay);
|
||||
timing.mIterationCount = 1;
|
||||
timing.mDirection = NS_STYLE_ANIMATION_DIRECTION_NORMAL;
|
||||
timing.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_BACKWARDS;
|
||||
timing.mDirection = dom::PlaybackDirection::Normal;
|
||||
timing.mFillMode = dom::FillMode::Backwards;
|
||||
|
||||
RefPtr<ElementPropertyTransition> pt =
|
||||
new ElementPropertyTransition(aElement->OwnerDoc(), aElement,
|
||||
|
Loading…
Reference in New Issue
Block a user