зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1237173 - Part2: Change type of duration to Maybe<StickyTimeDuration>. r=birtles
This commit is contained in:
Родитель
642702e0bb
Коммит
cb51780a6e
|
@ -41,25 +41,18 @@ AnimationEffectTiming::SetEndDelay(double aEndDelay)
|
||||||
void
|
void
|
||||||
AnimationEffectTiming::SetDuration(const UnrestrictedDoubleOrString& aDuration)
|
AnimationEffectTiming::SetDuration(const UnrestrictedDoubleOrString& aDuration)
|
||||||
{
|
{
|
||||||
if (mTiming.mDuration.IsUnrestrictedDouble() &&
|
Maybe<StickyTimeDuration> newDuration;
|
||||||
aDuration.IsUnrestrictedDouble() &&
|
|
||||||
mTiming.mDuration.GetAsUnrestrictedDouble() ==
|
|
||||||
aDuration.GetAsUnrestrictedDouble()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mTiming.mDuration.IsString() && aDuration.IsString() &&
|
|
||||||
mTiming.mDuration.GetAsString() == aDuration.GetAsString()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aDuration.IsUnrestrictedDouble()) {
|
if (aDuration.IsUnrestrictedDouble()) {
|
||||||
mTiming.mDuration.SetAsUnrestrictedDouble() =
|
newDuration.emplace(StickyTimeDuration::FromMilliseconds(
|
||||||
aDuration.GetAsUnrestrictedDouble();
|
aDuration.GetAsUnrestrictedDouble()));
|
||||||
} else {
|
|
||||||
mTiming.mDuration.SetAsString() = aDuration.GetAsString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mTiming.mDuration == newDuration) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mTiming.mDuration = newDuration;
|
||||||
|
|
||||||
NotifyTimingUpdate();
|
NotifyTimingUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,17 @@ AnimationEffectTimingReadOnly::WrapObject(JSContext* aCx, JS::Handle<JSObject*>
|
||||||
return AnimationEffectTimingReadOnlyBinding::Wrap(aCx, this, aGivenProto);
|
return AnimationEffectTimingReadOnlyBinding::Wrap(aCx, this, aGivenProto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AnimationEffectTimingReadOnly::GetDuration(
|
||||||
|
OwningUnrestrictedDoubleOrString& aRetVal) const
|
||||||
|
{
|
||||||
|
if (mTiming.mDuration) {
|
||||||
|
aRetVal.SetAsUnrestrictedDouble() = mTiming.mDuration->ToMilliseconds();
|
||||||
|
} else {
|
||||||
|
aRetVal.SetAsString().AssignLiteral("auto");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AnimationEffectTimingReadOnly::GetEasing(nsString& aRetVal) const
|
AnimationEffectTimingReadOnly::GetEasing(nsString& aRetVal) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,10 +41,7 @@ public:
|
||||||
FillMode Fill() const { return mTiming.mFill; }
|
FillMode Fill() const { return mTiming.mFill; }
|
||||||
double IterationStart() const { return mTiming.mIterationStart; }
|
double IterationStart() const { return mTiming.mIterationStart; }
|
||||||
double Iterations() const { return mTiming.mIterations; }
|
double Iterations() const { return mTiming.mIterations; }
|
||||||
void GetDuration(OwningUnrestrictedDoubleOrString& aRetVal) const
|
void GetDuration(OwningUnrestrictedDoubleOrString& aRetVal) const;
|
||||||
{
|
|
||||||
aRetVal = mTiming.mDuration;
|
|
||||||
}
|
|
||||||
PlaybackDirection Direction() const { return mTiming.mDirection; }
|
PlaybackDirection Direction() const { return mTiming.mDirection; }
|
||||||
void GetEasing(nsString& aRetVal) const;
|
void GetEasing(nsString& aRetVal) const;
|
||||||
|
|
||||||
|
|
|
@ -238,12 +238,10 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
|
||||||
// Always return the same object to benefit from return-value optimization.
|
// Always return the same object to benefit from return-value optimization.
|
||||||
ComputedTiming result;
|
ComputedTiming result;
|
||||||
|
|
||||||
if (aTiming.mDuration.IsUnrestrictedDouble()) {
|
if (aTiming.mDuration && aTiming.mDuration.ref() > zeroDuration) {
|
||||||
double durationMs = aTiming.mDuration.GetAsUnrestrictedDouble();
|
result.mDuration = aTiming.mDuration.ref();
|
||||||
if (!IsNaN(durationMs) && durationMs >= 0.0f) {
|
|
||||||
result.mDuration = StickyTimeDuration::FromMilliseconds(durationMs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.mIterations = IsNaN(aTiming.mIterations) || aTiming.mIterations < 0.0f ?
|
result.mIterations = IsNaN(aTiming.mIterations) || aTiming.mIterations < 0.0f ?
|
||||||
1.0f :
|
1.0f :
|
||||||
aTiming.mIterations;
|
aTiming.mIterations;
|
||||||
|
|
|
@ -10,20 +10,23 @@ namespace mozilla {
|
||||||
|
|
||||||
TimingParams::TimingParams(const dom::AnimationEffectTimingProperties& aRhs,
|
TimingParams::TimingParams(const dom::AnimationEffectTimingProperties& aRhs,
|
||||||
const dom::Element* aTarget)
|
const dom::Element* aTarget)
|
||||||
: mDuration(aRhs.mDuration)
|
: mDelay(TimeDuration::FromMilliseconds(aRhs.mDelay))
|
||||||
, mDelay(TimeDuration::FromMilliseconds(aRhs.mDelay))
|
|
||||||
, mEndDelay(TimeDuration::FromMilliseconds(aRhs.mEndDelay))
|
, mEndDelay(TimeDuration::FromMilliseconds(aRhs.mEndDelay))
|
||||||
, mIterations(aRhs.mIterations)
|
, mIterations(aRhs.mIterations)
|
||||||
, mIterationStart(aRhs.mIterationStart)
|
, mIterationStart(aRhs.mIterationStart)
|
||||||
, mDirection(aRhs.mDirection)
|
, mDirection(aRhs.mDirection)
|
||||||
, mFill(aRhs.mFill)
|
, mFill(aRhs.mFill)
|
||||||
{
|
{
|
||||||
|
if (aRhs.mDuration.IsUnrestrictedDouble()) {
|
||||||
|
mDuration.emplace(StickyTimeDuration::FromMilliseconds(
|
||||||
|
aRhs.mDuration.GetAsUnrestrictedDouble()));
|
||||||
|
}
|
||||||
mFunction = AnimationUtils::ParseEasing(aTarget, aRhs.mEasing);
|
mFunction = AnimationUtils::ParseEasing(aTarget, aRhs.mEasing);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimingParams::TimingParams(double aDuration)
|
TimingParams::TimingParams(double aDuration)
|
||||||
{
|
{
|
||||||
mDuration.SetAsUnrestrictedDouble() = aDuration;
|
mDuration.emplace(StickyTimeDuration::FromMilliseconds(aDuration));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class OptionsType>
|
template <class OptionsType>
|
||||||
|
@ -95,18 +98,7 @@ TimingParams::FromOptionsUnion(
|
||||||
bool
|
bool
|
||||||
TimingParams::operator==(const TimingParams& aOther) const
|
TimingParams::operator==(const TimingParams& aOther) const
|
||||||
{
|
{
|
||||||
bool durationEqual;
|
return mDuration == aOther.mDuration &&
|
||||||
if (mDuration.IsUnrestrictedDouble()) {
|
|
||||||
durationEqual = aOther.mDuration.IsUnrestrictedDouble() &&
|
|
||||||
(mDuration.GetAsUnrestrictedDouble() ==
|
|
||||||
aOther.mDuration.GetAsUnrestrictedDouble());
|
|
||||||
} else {
|
|
||||||
// We consider all string values and uninitialized values as meaning "auto".
|
|
||||||
// Since mDuration is either a string or uninitialized, we consider it equal
|
|
||||||
// if aOther.mDuration is also either a string or uninitialized.
|
|
||||||
durationEqual = !aOther.mDuration.IsUnrestrictedDouble();
|
|
||||||
}
|
|
||||||
return durationEqual &&
|
|
||||||
mDelay == aOther.mDelay &&
|
mDelay == aOther.mDelay &&
|
||||||
mIterations == aOther.mIterations &&
|
mIterations == aOther.mIterations &&
|
||||||
mIterationStart == aOther.mIterationStart &&
|
mIterationStart == aOther.mIterationStart &&
|
||||||
|
|
|
@ -44,9 +44,8 @@ struct TimingParams
|
||||||
const dom::UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
|
const dom::UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
|
||||||
const Nullable<dom::ElementOrCSSPseudoElement>& aTarget);
|
const Nullable<dom::ElementOrCSSPseudoElement>& aTarget);
|
||||||
|
|
||||||
// The unitialized state of mDuration represents "auto".
|
// mDuration.isNothing() represents the "auto" value
|
||||||
// Bug 1237173: We will replace this with Maybe<TimeDuration>.
|
Maybe<StickyTimeDuration> mDuration;
|
||||||
dom::OwningUnrestrictedDoubleOrString mDuration;
|
|
||||||
TimeDuration mDelay; // Initializes to zero
|
TimeDuration mDelay; // Initializes to zero
|
||||||
TimeDuration mEndDelay;
|
TimeDuration mEndDelay;
|
||||||
double mIterations = 1.0; // Can be NaN, negative, +/-Infinity
|
double mIterations = 1.0; // Can be NaN, negative, +/-Infinity
|
||||||
|
|
|
@ -583,8 +583,7 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
TimingParams timing;
|
TimingParams timing;
|
||||||
timing.mDuration.SetAsUnrestrictedDouble() =
|
timing.mDuration.emplace(animation.duration());
|
||||||
animation.duration().ToMilliseconds();
|
|
||||||
// Currently animations run on the compositor have their delay factored
|
// Currently animations run on the compositor have their delay factored
|
||||||
// into their start time, hence the delay is effectively zero.
|
// into their start time, hence the delay is effectively zero.
|
||||||
timing.mDelay = TimeDuration(0);
|
timing.mDelay = TimeDuration(0);
|
||||||
|
@ -833,7 +832,7 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer,
|
||||||
// async transformed for async scrolls of this scroll frame's ancestor
|
// async transformed for async scrolls of this scroll frame's ancestor
|
||||||
// scroll frames, not for async scrolls of this scroll frame itself.
|
// scroll frames, not for async scrolls of this scroll frame itself.
|
||||||
// In the loop below, we iterate over scroll frames from inside to outside.
|
// In the loop below, we iterate over scroll frames from inside to outside.
|
||||||
// At each iteration, this array contains the layer's ancestor mask layers
|
// At each iteration, this array contains the layer's ancestor mask layers
|
||||||
// of all scroll frames inside the current one.
|
// of all scroll frames inside the current one.
|
||||||
nsTArray<Layer*> ancestorMaskLayers;
|
nsTArray<Layer*> ancestorMaskLayers;
|
||||||
|
|
||||||
|
|
|
@ -2473,7 +2473,7 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
|
||||||
|
|
||||||
const DisplayItemScrollClip* scrollClip =
|
const DisplayItemScrollClip* scrollClip =
|
||||||
aBuilder->ClipState().GetCurrentInnermostScrollClip();
|
aBuilder->ClipState().GetCurrentInnermostScrollClip();
|
||||||
|
|
||||||
bool needBlendContainer = false;
|
bool needBlendContainer = false;
|
||||||
|
|
||||||
// Passing bg == nullptr in this macro will result in one iteration with
|
// Passing bg == nullptr in this macro will result in one iteration with
|
||||||
|
@ -2963,7 +2963,7 @@ static void CheckForBorderItem(nsDisplayItem *aItem, uint32_t& aFlags)
|
||||||
while (nextItem && nextItem->GetType() == nsDisplayItem::TYPE_BACKGROUND) {
|
while (nextItem && nextItem->GetType() == nsDisplayItem::TYPE_BACKGROUND) {
|
||||||
nextItem = nextItem->GetAbove();
|
nextItem = nextItem->GetAbove();
|
||||||
}
|
}
|
||||||
if (nextItem &&
|
if (nextItem &&
|
||||||
nextItem->Frame() == aItem->Frame() &&
|
nextItem->Frame() == aItem->Frame() &&
|
||||||
nextItem->GetType() == nsDisplayItem::TYPE_BORDER) {
|
nextItem->GetType() == nsDisplayItem::TYPE_BORDER) {
|
||||||
aFlags |= nsCSSRendering::PAINTBG_WILL_PAINT_BORDER;
|
aFlags |= nsCSSRendering::PAINTBG_WILL_PAINT_BORDER;
|
||||||
|
@ -3608,8 +3608,8 @@ nsDisplayBorder::IsInvisibleInRect(const nsRect& aRect)
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsDisplayItemGeometry*
|
nsDisplayItemGeometry*
|
||||||
nsDisplayBorder::AllocateGeometry(nsDisplayListBuilder* aBuilder)
|
nsDisplayBorder::AllocateGeometry(nsDisplayListBuilder* aBuilder)
|
||||||
{
|
{
|
||||||
return new nsDisplayBorderGeometry(this, aBuilder);
|
return new nsDisplayBorderGeometry(this, aBuilder);
|
||||||
|
@ -3636,7 +3636,7 @@ nsDisplayBorder::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
||||||
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
|
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsDisplayBorder::Paint(nsDisplayListBuilder* aBuilder,
|
nsDisplayBorder::Paint(nsDisplayListBuilder* aBuilder,
|
||||||
nsRenderingContext* aCtx) {
|
nsRenderingContext* aCtx) {
|
||||||
|
@ -3923,7 +3923,7 @@ nsDisplayWrapList::nsDisplayWrapList(nsDisplayListBuilder* aBuilder,
|
||||||
|
|
||||||
mList.AppendToTop(aItem);
|
mList.AppendToTop(aItem);
|
||||||
UpdateBounds(aBuilder);
|
UpdateBounds(aBuilder);
|
||||||
|
|
||||||
if (!aFrame || !aFrame->IsTransformed()) {
|
if (!aFrame || !aFrame->IsTransformed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4459,7 +4459,7 @@ nsDisplayBlendContainer::BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||||
if (!container) {
|
if (!container) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
container->SetForceIsolatedGroup(true);
|
container->SetForceIsolatedGroup(true);
|
||||||
return container.forget();
|
return container.forget();
|
||||||
}
|
}
|
||||||
|
@ -4560,7 +4560,7 @@ nsDisplaySubDocument::BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||||
if ((mFlags & GENERATE_SCROLLABLE_LAYER) &&
|
if ((mFlags & GENERATE_SCROLLABLE_LAYER) &&
|
||||||
rootScrollFrame->GetContent() &&
|
rootScrollFrame->GetContent() &&
|
||||||
nsLayoutUtils::HasCriticalDisplayPort(rootScrollFrame->GetContent())) {
|
nsLayoutUtils::HasCriticalDisplayPort(rootScrollFrame->GetContent())) {
|
||||||
params.mInLowPrecisionDisplayPort = true;
|
params.mInLowPrecisionDisplayPort = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Layer> layer = nsDisplayOwnLayer::BuildLayer(aBuilder, aManager, params);
|
RefPtr<Layer> layer = nsDisplayOwnLayer::BuildLayer(aBuilder, aManager, params);
|
||||||
|
@ -4986,7 +4986,7 @@ nsDisplayScrollInfoLayer::ComputeFrameMetrics(Layer* aLayer,
|
||||||
ContainerLayerParameters params = aContainerParameters;
|
ContainerLayerParameters params = aContainerParameters;
|
||||||
if (mScrolledFrame->GetContent() &&
|
if (mScrolledFrame->GetContent() &&
|
||||||
nsLayoutUtils::HasCriticalDisplayPort(mScrolledFrame->GetContent())) {
|
nsLayoutUtils::HasCriticalDisplayPort(mScrolledFrame->GetContent())) {
|
||||||
params.mInLowPrecisionDisplayPort = true;
|
params.mInLowPrecisionDisplayPort = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRect viewport = mScrollFrame->GetRect() -
|
nsRect viewport = mScrollFrame->GetRect() -
|
||||||
|
@ -5443,7 +5443,7 @@ nsDisplayTransform::GetResultingTransformMatrix(const FrameTransformProperties&
|
||||||
return GetResultingTransformMatrixInternal(aProperties, aOrigin, aAppUnitsPerPixel,
|
return GetResultingTransformMatrixInternal(aProperties, aOrigin, aAppUnitsPerPixel,
|
||||||
aFlags, aBoundsOverride, aOutAncestor);
|
aFlags, aBoundsOverride, aOutAncestor);
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4
|
Matrix4x4
|
||||||
nsDisplayTransform::GetResultingTransformMatrix(const nsIFrame* aFrame,
|
nsDisplayTransform::GetResultingTransformMatrix(const nsIFrame* aFrame,
|
||||||
const nsPoint& aOrigin,
|
const nsPoint& aOrigin,
|
||||||
|
|
|
@ -579,7 +579,8 @@ private:
|
||||||
{
|
{
|
||||||
TimingParams timing;
|
TimingParams timing;
|
||||||
|
|
||||||
timing.mDuration.SetAsUnrestrictedDouble() = aStyleAnimation.GetDuration();
|
timing.mDuration.emplace(StickyTimeDuration::FromMilliseconds(
|
||||||
|
aStyleAnimation.GetDuration()));
|
||||||
timing.mDelay = TimeDuration::FromMilliseconds(aStyleAnimation.GetDelay());
|
timing.mDelay = TimeDuration::FromMilliseconds(aStyleAnimation.GetDelay());
|
||||||
timing.mIterations = aStyleAnimation.GetIterationCount();
|
timing.mIterations = aStyleAnimation.GetIterationCount();
|
||||||
timing.mDirection = aStyleAnimation.GetDirection();
|
timing.mDirection = aStyleAnimation.GetDirection();
|
||||||
|
|
|
@ -656,7 +656,7 @@ nsTransitionManager::ConsiderStartingTransition(
|
||||||
}
|
}
|
||||||
|
|
||||||
TimingParams timing;
|
TimingParams timing;
|
||||||
timing.mDuration.SetAsUnrestrictedDouble() = duration;
|
timing.mDuration.emplace(StickyTimeDuration::FromMilliseconds(duration));
|
||||||
timing.mDelay = TimeDuration::FromMilliseconds(delay);
|
timing.mDelay = TimeDuration::FromMilliseconds(delay);
|
||||||
timing.mIterations = 1.0;
|
timing.mIterations = 1.0;
|
||||||
timing.mDirection = dom::PlaybackDirection::Normal;
|
timing.mDirection = dom::PlaybackDirection::Normal;
|
||||||
|
|
|
@ -140,6 +140,5 @@ test(function(t) {
|
||||||
'The returned Animation targets to the correct object');
|
'The returned Animation targets to the correct object');
|
||||||
}, 'CSSPseudoElement.animate() creates an Animation object targeting ' +
|
}, 'CSSPseudoElement.animate() creates an Animation object targeting ' +
|
||||||
'to the correct CSSPseudoElement object');
|
'to the correct CSSPseudoElement object');
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -501,7 +501,7 @@ var gKeyframeEffectOptionTests = [
|
||||||
expected: { duration: NaN } },
|
expected: { duration: NaN } },
|
||||||
{ desc: "a negative value",
|
{ desc: "a negative value",
|
||||||
input: -1,
|
input: -1,
|
||||||
expected: { duration: -1 } },
|
expected: { duration: "auto" } },
|
||||||
{ desc: "an Infinity duration",
|
{ desc: "an Infinity duration",
|
||||||
input: { duration: Infinity },
|
input: { duration: Infinity },
|
||||||
expected: { duration: Infinity } },
|
expected: { duration: Infinity } },
|
||||||
|
@ -513,7 +513,7 @@ var gKeyframeEffectOptionTests = [
|
||||||
expected: { duration: NaN } },
|
expected: { duration: NaN } },
|
||||||
{ desc: "a negative duration",
|
{ desc: "a negative duration",
|
||||||
input: { duration: -1 },
|
input: { duration: -1 },
|
||||||
expected: { duration: -1 } },
|
expected: { duration: "auto" } },
|
||||||
{ desc: "a string duration",
|
{ desc: "a string duration",
|
||||||
input: { duration: "merrychristmas" },
|
input: { duration: "merrychristmas" },
|
||||||
expected: { duration: "merrychristmas" } },
|
expected: { duration: "merrychristmas" } },
|
||||||
|
|
Загрузка…
Ссылка в новой задаче