mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 23:06:52 +00:00
6886edf464
- Bug 1249428 - Unlink binding properly from element , r=mccr8 (61e1084b4f) - Bug 1216842 - Part 1: Add null_t into TimingFunction to skip calculation of linear timing function. r=cam (cc284bfe07) - Bug 1216842 - Part 2: Add LayerAnimationUtils. r=cam (52b3dbcfd4) - Bug 1216842 - Part 3: Change ComputedTimingFunction* to Maybe<ComputedTimingFunction>. r=cam (3608dd0159) - Bug 1216842 - Part 4: Move ParseEasing into AnimationUtils. r=cam (1c653d9d9a) - Bug 1216842 - Part 5: Store ComputedTimingFunction in TimingParams. r=cam (9305c15a32) - Bug 1216842 - Part 6: Make mTimingFunction in OrderedKeyframeValueEntry const Maybe<>*. r=cam (b79276ad15) - Bug 1216842 - Part 7: Add easing function to laryer::Animation. r=cam (3861a1f1a6) - Bug 1216842 - Part 8: Calculate transformed progress using animation effect's timing function. r=cam (4effa68fef) - Bug 1216842 - Part 9: Tests that easing property in KeyframeEffectOptions is passed to KeyframeEffectReadOnly. r=cam (cf8beaabc1) - Bug 1216842 - Part 10: Remove the limit of the computed timing progress. r=birtles (a000603812) - Bug 1216842 - Part 11: Clamp values of step functions outside [0, 1]. r=birtles (2893588686) - Bug 1216842 - Part 12: Extrapolate bezier function outside [0,1]. r=birtles (16231dccaa) - Bug 1216842 - Part 13: Tests for effect-level easing. r=birtles (95d844046f) - Bug 1239889 part 1 - Throw if the animation target does not have a current document; r=heycam (4162ae8c5b) - Bug 1174575 - Part 2: Replace Element in KeyframeEffectReadOnly WebIDL. r=birtles, r=smaug (65cfa82b96) - Bug 1244595 - Don't check whether shorthands are non-animatable when parsing JS keyframe objects. r=birtles (749b4708c2) - Bug 1174575 - Part 3: Implement KeyframeEffectReadOnly::GetTarget(). r=birtles (19ad097a72) - Bug 1174575 - Part 4: Support CSSPseudoElement for TimingParams. r=birtles (ef76ef8cc6) - Bug 1174575 - Part 5: Support pseudo-element type in StyleAnimation. r=birtles (33f7244799) - Bug 1174575 - Part 6: Implement KeyframeEffectReadOnly Constructor for CSSPseudoElement. r=birtles (78c2bf0322) - Bug 1154791 - Remember all ranges for all selections when splitting nodes in the editor transactions; r=ehsan (ba888befe0) - Bug 1245113 - Fixed uninitialized variables warnings. r=ehsan (6ac649d296) - Bug 1184289 - Remove a spammy editor warning (f3688b4a51) - Bug 1184689 - Remove two spammy editor warnings (de2baa3ce4) - Bug 1244894: Steal the failed nsresult when bailing early. r=bz (7dce640e2d) - Bug 1158452. Pass in the right node when messing with font sizes in editor. r=ehsan (0937be30f5) - Bug 1158651 - Correctly ignore non-editable nodes in nsHTMLEditRules::GetParagraphFormatNodes; r=roc (025d58ac20) - Bug 650572 - Add crashtest. (4eef4013c6) - Bug 667321 - Add crashtest. (76b38b38cf)
173 lines
6.0 KiB
C++
173 lines
6.0 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "ComputedTimingFunction.h"
|
|
#include "nsAlgorithm.h" // For clamped()
|
|
#include "nsStyleUtil.h"
|
|
|
|
namespace mozilla {
|
|
|
|
void
|
|
ComputedTimingFunction::Init(const nsTimingFunction &aFunction)
|
|
{
|
|
mType = aFunction.mType;
|
|
if (nsTimingFunction::IsSplineType(mType)) {
|
|
mTimingFunction.Init(aFunction.mFunc.mX1, aFunction.mFunc.mY1,
|
|
aFunction.mFunc.mX2, aFunction.mFunc.mY2);
|
|
} else {
|
|
mSteps = aFunction.mSteps;
|
|
mStepSyntax = aFunction.mStepSyntax;
|
|
}
|
|
}
|
|
|
|
static inline double
|
|
StepEnd(uint32_t aSteps, double aPortion)
|
|
{
|
|
MOZ_ASSERT(0.0 <= aPortion && aPortion <= 1.0, "out of range");
|
|
uint32_t step = uint32_t(aPortion * aSteps); // floor
|
|
return double(step) / double(aSteps);
|
|
}
|
|
|
|
double
|
|
ComputedTimingFunction::GetValue(double aPortion) const
|
|
{
|
|
if (HasSpline()) {
|
|
// Check for a linear curve.
|
|
// (GetSplineValue(), below, also checks this but doesn't work when
|
|
// aPortion is outside the range [0.0, 1.0]).
|
|
if (mTimingFunction.X1() == mTimingFunction.Y1() &&
|
|
mTimingFunction.X2() == mTimingFunction.Y2()) {
|
|
return aPortion;
|
|
}
|
|
|
|
// For negative values, try to extrapolate with tangent (p1 - p0) or,
|
|
// if p1 is coincident with p0, with (p2 - p0).
|
|
if (aPortion < 0.0) {
|
|
if (mTimingFunction.X1() > 0.0) {
|
|
return aPortion * mTimingFunction.Y1() / mTimingFunction.X1();
|
|
} else if (mTimingFunction.Y1() == 0 && mTimingFunction.X2() > 0.0) {
|
|
return aPortion * mTimingFunction.Y2() / mTimingFunction.X2();
|
|
}
|
|
// If we can't calculate a sensible tangent, don't extrapolate at all.
|
|
return 0.0;
|
|
}
|
|
|
|
// For values greater than 1, try to extrapolate with tangent (p2 - p3) or,
|
|
// if p2 is coincident with p3, with (p1 - p3).
|
|
if (aPortion > 1.0) {
|
|
if (mTimingFunction.X2() < 1.0) {
|
|
return 1.0 + (aPortion - 1.0) *
|
|
(mTimingFunction.Y2() - 1) / (mTimingFunction.X2() - 1);
|
|
} else if (mTimingFunction.Y2() == 1 && mTimingFunction.X1() < 1.0) {
|
|
return 1.0 + (aPortion - 1.0) *
|
|
(mTimingFunction.Y1() - 1) / (mTimingFunction.X1() - 1);
|
|
}
|
|
// If we can't calculate a sensible tangent, don't extrapolate at all.
|
|
return 1.0;
|
|
}
|
|
|
|
return mTimingFunction.GetSplineValue(aPortion);
|
|
}
|
|
|
|
// Since we use endpoint-exclusive timing, the output of a steps(start) timing
|
|
// function when aPortion = 0.0 is the top of the first step. When aPortion is
|
|
// negative, however, we should use the bottom of the first step. We handle
|
|
// negative values of aPortion specially here since once we clamp aPortion
|
|
// to [0,1] below we will no longer be able to distinguish to the two cases.
|
|
if (aPortion < 0.0) {
|
|
return 0.0;
|
|
}
|
|
|
|
// Clamp in case of steps(end) and steps(start) for values greater than 1.
|
|
aPortion = clamped(aPortion, 0.0, 1.0);
|
|
|
|
if (mType == nsTimingFunction::Type::StepStart) {
|
|
// There are diagrams in the spec that seem to suggest this check
|
|
// and the bounds point should not be symmetric with StepEnd, but
|
|
// should actually step up at rather than immediately after the
|
|
// fraction points. However, we rely on rounding negative values
|
|
// up to zero, so we can't do that. And it's not clear the spec
|
|
// really meant it.
|
|
return 1.0 - StepEnd(mSteps, 1.0 - aPortion);
|
|
}
|
|
MOZ_ASSERT(mType == nsTimingFunction::Type::StepEnd, "bad type");
|
|
return StepEnd(mSteps, aPortion);
|
|
}
|
|
|
|
int32_t
|
|
ComputedTimingFunction::Compare(const ComputedTimingFunction& aRhs) const
|
|
{
|
|
if (mType != aRhs.mType) {
|
|
return int32_t(mType) - int32_t(aRhs.mType);
|
|
}
|
|
|
|
if (mType == nsTimingFunction::Type::CubicBezier) {
|
|
int32_t order = mTimingFunction.Compare(aRhs.mTimingFunction);
|
|
if (order != 0) {
|
|
return order;
|
|
}
|
|
} else if (mType == nsTimingFunction::Type::StepStart ||
|
|
mType == nsTimingFunction::Type::StepEnd) {
|
|
if (mSteps != aRhs.mSteps) {
|
|
return int32_t(mSteps) - int32_t(aRhs.mSteps);
|
|
}
|
|
if (mStepSyntax != aRhs.mStepSyntax) {
|
|
return int32_t(mStepSyntax) - int32_t(aRhs.mStepSyntax);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void
|
|
ComputedTimingFunction::AppendToString(nsAString& aResult) const
|
|
{
|
|
switch (mType) {
|
|
case nsTimingFunction::Type::CubicBezier:
|
|
nsStyleUtil::AppendCubicBezierTimingFunction(mTimingFunction.X1(),
|
|
mTimingFunction.Y1(),
|
|
mTimingFunction.X2(),
|
|
mTimingFunction.Y2(),
|
|
aResult);
|
|
break;
|
|
case nsTimingFunction::Type::StepStart:
|
|
case nsTimingFunction::Type::StepEnd:
|
|
nsStyleUtil::AppendStepsTimingFunction(mType, mSteps, mStepSyntax,
|
|
aResult);
|
|
break;
|
|
default:
|
|
nsStyleUtil::AppendCubicBezierKeywordTimingFunction(mType, aResult);
|
|
break;
|
|
}
|
|
}
|
|
|
|
/* static */ int32_t
|
|
ComputedTimingFunction::Compare(const Maybe<ComputedTimingFunction>& aLhs,
|
|
const Maybe<ComputedTimingFunction>& aRhs)
|
|
{
|
|
// We can't use |operator<| for const Maybe<>& here because
|
|
// 'ease' is prior to 'linear' which is represented by Nothing().
|
|
// So we have to convert Nothing() as 'linear' and check it first.
|
|
nsTimingFunction::Type lhsType = aLhs.isNothing() ?
|
|
nsTimingFunction::Type::Linear : aLhs->GetType();
|
|
nsTimingFunction::Type rhsType = aRhs.isNothing() ?
|
|
nsTimingFunction::Type::Linear : aRhs->GetType();
|
|
|
|
if (lhsType != rhsType) {
|
|
return int32_t(lhsType) - int32_t(rhsType);
|
|
}
|
|
|
|
// Both of them are Nothing().
|
|
if (lhsType == nsTimingFunction::Type::Linear) {
|
|
return 0;
|
|
}
|
|
|
|
// Other types.
|
|
return aLhs->Compare(aRhs.value());
|
|
}
|
|
|
|
} // namespace mozilla
|