Bug 1781140 - Remove nsTimingFunction and ComputedTimingFunction. r=dshin

They're simple wrappers of StyleComputedTimingFunction so we can remove
them.

Differential Revision: https://phabricator.services.mozilla.com/D152700
This commit is contained in:
Emilio Cobos Álvarez 2022-07-26 14:49:02 +00:00
parent f4f23a92a8
commit d98aff87e0
41 changed files with 180 additions and 312 deletions

View File

@ -258,12 +258,12 @@ ComputedTiming AnimationEffect::GetComputedTimingAt(
thisIterationReverse) ||
(result.mPhase == ComputedTiming::AnimationPhase::Before &&
!thisIterationReverse)) {
result.mBeforeFlag = StyleEasingBeforeFlag::Set;
result.mBeforeFlag = true;
}
// Apply the easing.
if (aTiming.TimingFunction()) {
progress = aTiming.TimingFunction()->GetValue(progress, result.mBeforeFlag);
if (const auto& fn = aTiming.TimingFunction()) {
progress = fn->At(progress, result.mBeforeFlag);
}
MOZ_ASSERT(IsFinite(progress), "Progress value should be finite");

View File

@ -7,7 +7,7 @@
#ifndef mozilla_dom_AnimationPropertySegment_h
#define mozilla_dom_AnimationPropertySegment_h
#include "mozilla/ComputedTimingFunction.h"
#include "mozilla/ServoStyleConsts.h"
#include "mozilla/Maybe.h"
#include "mozilla/StyleAnimationValue.h" // For AnimationValue
#include "mozilla/dom/BaseKeyframeTypesBinding.h" // For CompositeOperation
@ -20,7 +20,7 @@ struct AnimationPropertySegment {
// the unit of mFromValue or mToValue is eUnit_Null.
AnimationValue mFromValue, mToValue;
Maybe<ComputedTimingFunction> mTimingFunction;
Maybe<StyleComputedTimingFunction> mTimingFunction;
dom::CompositeOperation mFromComposite = dom::CompositeOperation::Replace;
dom::CompositeOperation mToComposite = dom::CompositeOperation::Replace;

View File

@ -19,7 +19,6 @@ struct JSContext;
namespace mozilla {
class ComputedTimingFunction;
class EffectSet;
namespace dom {

View File

@ -303,7 +303,7 @@ void CSSTransition::UpdateStartValueFromReplacedTransition() {
Animation::ProgressTimelinePosition::NotBoundary);
if (!computedTiming.mProgress.IsNull()) {
double valuePosition = ComputedTimingFunction::GetPortion(
double valuePosition = StyleComputedTimingFunction::GetPortion(
mReplacedTransition->mTimingFunction, computedTiming.mProgress.Value(),
computedTiming.mBeforeFlag);

View File

@ -130,7 +130,7 @@ class CSSTransition final : public Animation {
TimeDuration mStartTime;
double mPlaybackRate;
TimingParams mTiming;
Maybe<ComputedTimingFunction> mTimingFunction;
Maybe<StyleComputedTimingFunction> mTimingFunction;
AnimationValue mFromValue, mToValue;
};
void SetReplacedTransition(

View File

@ -9,7 +9,6 @@
#include "mozilla/dom/Nullable.h"
#include "mozilla/StickyTimeDuration.h"
#include "mozilla/ComputedTimingFunction.h"
#include "mozilla/dom/AnimationEffectBinding.h" // FillMode
@ -64,7 +63,7 @@ struct ComputedTiming {
};
AnimationPhase mPhase = AnimationPhase::Idle;
StyleEasingBeforeFlag mBeforeFlag = StyleEasingBeforeFlag::Unset;
bool mBeforeFlag = false;
};
} // namespace mozilla

View File

@ -1,41 +0,0 @@
/* -*- 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 "mozilla/Assertions.h"
#include "mozilla/ServoBindings.h"
#include "nsAlgorithm.h" // For clamped()
#include "mozilla/layers/LayersMessages.h"
namespace mozilla {
ComputedTimingFunction::ComputedTimingFunction(
const StyleComputedTimingFunction& aFunction)
: mFunction{aFunction} {}
ComputedTimingFunction::ComputedTimingFunction(
const nsTimingFunction& aFunction)
: ComputedTimingFunction{aFunction.mTiming} {}
double ComputedTimingFunction::GetValue(
double aPortion, StyleEasingBeforeFlag aBeforeFlag) const {
return Servo_EasingFunctionAt(&mFunction, aPortion, aBeforeFlag);
}
void ComputedTimingFunction::AppendToString(nsACString& aResult) const {
nsTimingFunction timing;
// This does not preserve the original input either - that is,
// linear(0 0% 50%, 1 50% 100%) -> linear(0 0%, 0 50%, 1 50%, 1 100%)
timing.mTiming = mFunction;
Servo_SerializeEasing(&timing, &aResult);
}
StyleComputedTimingFunction
ComputedTimingFunction::ToStyleComputedTimingFunction(
const ComputedTimingFunction& aComputedTimingFunction) {
return aComputedTimingFunction.mFunction;
}
} // namespace mozilla

View File

@ -1,68 +0,0 @@
/* -*- 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/. */
#ifndef mozilla_ComputedTimingFunction_h
#define mozilla_ComputedTimingFunction_h
#include "nsDebug.h"
#include "nsStringFwd.h"
#include "nsTimingFunction.h"
#include "mozilla/Assertions.h"
#include "mozilla/Maybe.h"
#include "mozilla/SMILKeySpline.h"
#include "mozilla/Variant.h"
namespace mozilla {
class ComputedTimingFunction {
public:
explicit ComputedTimingFunction(const nsTimingFunction& aFunction);
explicit ComputedTimingFunction(const StyleComputedTimingFunction& aFunction);
static StyleComputedTimingFunction ToStyleComputedTimingFunction(
const ComputedTimingFunction& aComputedTimingFunction);
double GetValue(double aPortion, StyleEasingBeforeFlag aBeforeFlag) const;
bool operator==(const ComputedTimingFunction& aOther) const {
return mFunction == aOther.mFunction;
}
bool operator!=(const ComputedTimingFunction& aOther) const {
return !(*this == aOther);
}
bool operator==(const nsTimingFunction& aOther) const {
return ToStyleComputedTimingFunction(*this) == aOther.mTiming;
}
bool operator!=(const nsTimingFunction& aOther) const {
return !(*this == aOther);
}
void AppendToString(nsACString& aResult) const;
static double GetPortion(const Maybe<ComputedTimingFunction>& aFunction,
double aPortion, StyleEasingBeforeFlag aBeforeFlag) {
return aFunction ? aFunction->GetValue(aPortion, aBeforeFlag) : aPortion;
}
private:
StyleComputedTimingFunction mFunction;
};
inline bool operator==(const Maybe<ComputedTimingFunction>& aLHS,
const nsTimingFunction& aRHS) {
if (aLHS.isNothing()) {
return aRHS.IsLinear();
}
return aLHS.value() == aRHS;
}
inline bool operator!=(const Maybe<ComputedTimingFunction>& aLHS,
const nsTimingFunction& aRHS) {
return !(aLHS == aRHS);
}
} // namespace mozilla
#endif // mozilla_ComputedTimingFunction_h

View File

@ -11,7 +11,7 @@
#include "nsCSSValue.h"
#include "nsTArray.h"
#include "mozilla/dom/BaseKeyframeTypesBinding.h" // CompositeOperationOrAuto
#include "mozilla/ComputedTimingFunction.h"
#include "mozilla/ServoStyleConsts.h"
#include "mozilla/Maybe.h"
#include "mozilla/RefPtr.h"
@ -71,8 +71,8 @@ struct Keyframe {
Maybe<double> mOffset;
static constexpr double kComputedOffsetNotSet = -1.0;
double mComputedOffset = kComputedOffsetNotSet;
Maybe<ComputedTimingFunction> mTimingFunction; // Nothing() here means
// "linear"
Maybe<StyleComputedTimingFunction> mTimingFunction; // Nothing() here means
// "linear"
dom::CompositeOperationOrAuto mComposite =
dom::CompositeOperationOrAuto::Auto;
CopyableTArray<PropertyValuePair> mPropertyValues;

View File

@ -1110,7 +1110,7 @@ void KeyframeEffect::SetPseudoElement(const nsAString& aPseudoElement,
static void CreatePropertyValue(
nsCSSPropertyID aProperty, float aOffset,
const Maybe<ComputedTimingFunction>& aTimingFunction,
const Maybe<StyleComputedTimingFunction>& aTimingFunction,
const AnimationValue& aValue, dom::CompositeOperation aComposite,
const RawServoStyleSet* aRawSet, AnimationPropertyValueDetails& aResult) {
aResult.mOffset = aOffset;

View File

@ -19,7 +19,6 @@
#include "mozilla/AnimationPropertySegment.h"
#include "mozilla/AnimationTarget.h"
#include "mozilla/Attributes.h"
#include "mozilla/ComputedTimingFunction.h"
#include "mozilla/EffectCompositor.h"
#include "mozilla/Keyframe.h"
#include "mozilla/KeyframeEffectParams.h"

View File

@ -97,7 +97,7 @@ struct KeyframeValueEntry {
AnimationValue mValue;
float mOffset;
Maybe<ComputedTimingFunction> mTimingFunction;
Maybe<StyleComputedTimingFunction> mTimingFunction;
dom::CompositeOperation mComposite;
struct PropertyOffsetComparator {
@ -1100,7 +1100,7 @@ static void GetKeyframeListFromPropertyIndexedKeyframe(
//
// This corresponds to step 5, "Otherwise," branch, substeps 7-11 of
// https://drafts.csswg.org/web-animations/#processing-a-keyframes-argument
FallibleTArray<Maybe<ComputedTimingFunction>> easings;
FallibleTArray<Maybe<StyleComputedTimingFunction>> easings;
auto parseAndAppendEasing = [&](const nsACString& easingString,
ErrorResult& aRv) {
auto easing = TimingParams::ParseEasing(easingString, aRv);

View File

@ -92,8 +92,8 @@ TimingParams TimingParams::FromEffectTiming(
if (aRv.Failed()) {
return result;
}
Maybe<ComputedTimingFunction> easing =
TimingParams::ParseEasing(aEffectTiming.mEasing, aRv);
Maybe<StyleComputedTimingFunction> easing =
ParseEasing(aEffectTiming.mEasing, aRv);
if (aRv.Failed()) {
return result;
}
@ -105,7 +105,7 @@ TimingParams TimingParams::FromEffectTiming(
result.mIterationStart = aEffectTiming.mIterationStart;
result.mDirection = aEffectTiming.mDirection;
result.mFill = aEffectTiming.mFill;
result.mFunction = easing;
result.mFunction = std::move(easing);
result.Update();
@ -146,9 +146,9 @@ TimingParams TimingParams::MergeOptionalEffectTiming(
}
}
Maybe<ComputedTimingFunction> easing;
Maybe<StyleComputedTimingFunction> easing;
if (aEffectTiming.mEasing.WasPassed()) {
easing = TimingParams::ParseEasing(aEffectTiming.mEasing.Value(), aRv);
easing = ParseEasing(aEffectTiming.mEasing.Value(), aRv);
if (aRv.Failed()) {
return result;
}
@ -189,19 +189,19 @@ TimingParams TimingParams::MergeOptionalEffectTiming(
}
/* static */
Maybe<ComputedTimingFunction> TimingParams::ParseEasing(
Maybe<StyleComputedTimingFunction> TimingParams::ParseEasing(
const nsACString& aEasing, ErrorResult& aRv) {
nsTimingFunction timingFunction;
StyleComputedTimingFunction timingFunction;
if (!ServoCSSParser::ParseEasing(aEasing, timingFunction)) {
aRv.ThrowTypeError<dom::MSG_INVALID_EASING_ERROR>(aEasing);
return Nothing();
}
if (timingFunction.IsLinear()) {
if (timingFunction.IsLinearKeyword()) {
return Nothing();
}
return Some(ComputedTimingFunction(timingFunction));
return Some(std::move(timingFunction));
}
bool TimingParams::operator==(const TimingParams& aOther) const {

View File

@ -13,10 +13,10 @@
#include "nsPrintfCString.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/UnionTypes.h" // For OwningUnrestrictedDoubleOrString
#include "mozilla/ComputedTimingFunction.h"
#include "mozilla/Maybe.h"
#include "mozilla/StickyTimeDuration.h"
#include "mozilla/TimeStamp.h" // for TimeDuration
#include "mozilla/ServoStyleConsts.h"
#include "mozilla/dom/AnimationEffectBinding.h" // for FillMode
// and PlaybackDirection
@ -43,7 +43,7 @@ struct TimingParams {
const TimeDuration& aEndDelay, float aIterations,
float aIterationStart, dom::PlaybackDirection aDirection,
dom::FillMode aFillMode,
Maybe<ComputedTimingFunction>&& aFunction)
const Maybe<StyleComputedTimingFunction>& aFunction)
: mDelay(aDelay),
mEndDelay(aEndDelay),
mIterations(aIterations),
@ -119,8 +119,8 @@ struct TimingParams {
}
}
static Maybe<ComputedTimingFunction> ParseEasing(const nsACString& aEasing,
ErrorResult& aRv);
static Maybe<StyleComputedTimingFunction> ParseEasing(const nsACString&,
ErrorResult&);
static StickyTimeDuration CalcActiveDuration(
const Maybe<StickyTimeDuration>& aDuration, double aIterations) {
@ -195,10 +195,10 @@ struct TimingParams {
void SetFill(dom::FillMode aFill) { mFill = aFill; }
dom::FillMode Fill() const { return mFill; }
void SetTimingFunction(Maybe<ComputedTimingFunction>&& aFunction) {
void SetTimingFunction(Maybe<StyleComputedTimingFunction>&& aFunction) {
mFunction = std::move(aFunction);
}
const Maybe<ComputedTimingFunction>& TimingFunction() const {
const Maybe<StyleComputedTimingFunction>& TimingFunction() const {
return mFunction;
}
@ -222,7 +222,7 @@ struct TimingParams {
double mIterationStart = 0.0;
dom::PlaybackDirection mDirection = dom::PlaybackDirection::Normal;
dom::FillMode mFill = dom::FillMode::Auto;
Maybe<ComputedTimingFunction> mFunction;
Maybe<StyleComputedTimingFunction> mFunction;
StickyTimeDuration mActiveDuration = StickyTimeDuration();
StickyTimeDuration mEndTime = StickyTimeDuration();
};

View File

@ -30,7 +30,6 @@ EXPORTS.mozilla += [
"AnimationTarget.h",
"AnimationUtils.h",
"ComputedTiming.h",
"ComputedTimingFunction.h",
"EffectCompositor.h",
"EffectSet.h",
"Keyframe.h",
@ -49,7 +48,6 @@ UNIFIED_SOURCES += [
"AnimationPerformanceWarning.cpp",
"AnimationTimeline.cpp",
"AnimationUtils.cpp",
"ComputedTimingFunction.cpp",
"CSSAnimation.cpp",
"CSSPseudoElement.cpp",
"CSSTransition.cpp",

View File

@ -6,13 +6,13 @@
#include "AnimationHelper.h"
#include "base/process_util.h"
#include "gfx2DGlue.h" // for ThebesRect
#include "gfxLineSegment.h" // for gfxLineSegment
#include "gfxPoint.h" // for gfxPoint
#include "gfxQuad.h" // for gfxQuad
#include "gfxRect.h" // for gfxRect
#include "gfxUtils.h" // for gfxUtils::TransformToQuad
#include "mozilla/ComputedTimingFunction.h" // for ComputedTimingFunction
#include "gfx2DGlue.h" // for ThebesRect
#include "gfxLineSegment.h" // for gfxLineSegment
#include "gfxPoint.h" // for gfxPoint
#include "gfxQuad.h" // for gfxQuad
#include "gfxRect.h" // for gfxRect
#include "gfxUtils.h" // for gfxUtils::TransformToQuad
#include "mozilla/ServoStyleConsts.h" // for StyleComputedTimingFunction
#include "mozilla/dom/AnimationEffectBinding.h" // for dom::FillMode
#include "mozilla/dom/KeyframeEffectBinding.h" // for dom::IterationComposite
#include "mozilla/dom/KeyframeEffect.h" // for dom::KeyFrameEffectReadOnly
@ -228,7 +228,7 @@ static AnimationHelper::SampleResult SampleAnimationForProperty(
(computedTiming.mProgress.Value() - segment->mStartPortion) /
(segment->mEndPortion - segment->mStartPortion);
double portion = ComputedTimingFunction::GetPortion(
double portion = StyleComputedTimingFunction::GetPortion(
segment->mFunction, positionInSegment, computedTiming.mBeforeFlag);
// Like above optimization, skip calculation if the target segment isn't
@ -472,10 +472,6 @@ AnimationStorageData AnimationHelper::ExtractAnimations(
PropertyAnimation* propertyAnimation =
currData->mAnimations.AppendElement();
Maybe<mozilla::ComputedTimingFunction> easingFunction;
if (animation.easingFunction().isSome()) {
easingFunction.emplace(*animation.easingFunction());
}
propertyAnimation->mOriginTime = animation.originTime();
propertyAnimation->mStartTime = animation.startTime();
@ -493,23 +489,19 @@ AnimationStorageData AnimationHelper::ExtractAnimations(
animation.iterationStart(),
static_cast<dom::PlaybackDirection>(animation.direction()),
GetAdjustedFillMode(animation),
std::move(easingFunction)};
animation.easingFunction()};
propertyAnimation->mScrollTimelineOptions =
animation.scrollTimelineOptions();
nsTArray<PropertyAnimation::SegmentData>& segmentData =
propertyAnimation->mSegments;
for (const AnimationSegment& segment : animation.segments()) {
Maybe<mozilla::ComputedTimingFunction> sampleFn;
if (segment.sampleFn().isSome()) {
sampleFn.emplace(*segment.sampleFn());
}
segmentData.AppendElement(PropertyAnimation::SegmentData{
AnimationValue::FromAnimatable(animation.property(),
segment.startState()),
AnimationValue::FromAnimatable(animation.property(),
segment.endState()),
std::move(sampleFn), segment.startPortion(), segment.endPortion(),
segment.sampleFn(), segment.startPortion(), segment.endPortion(),
static_cast<dom::CompositeOperation>(segment.startComposite()),
static_cast<dom::CompositeOperation>(segment.endComposite())});
}

View File

@ -8,7 +8,6 @@
#define mozilla_layers_AnimationHelper_h
#include "mozilla/dom/Nullable.h"
#include "mozilla/ComputedTimingFunction.h" // for ComputedTimingFunction
#include "mozilla/layers/AnimationStorageData.h"
#include "mozilla/layers/LayersMessages.h" // for TransformData, etc
#include "mozilla/webrender/WebRenderTypes.h" // for RenderRoot
@ -18,8 +17,7 @@
#include "X11UndefineNone.h"
#include <unordered_map>
namespace mozilla {
namespace layers {
namespace mozilla::layers {
class Animation;
class APZSampler;
class CompositorAnimationStorage;
@ -148,7 +146,6 @@ class AnimationHelper {
const ParentLayerRect& aClipRect);
};
} // namespace layers
} // namespace mozilla
} // namespace mozilla::layers
#endif // mozilla_layers_AnimationHelper_h

View File

@ -480,12 +480,7 @@ void AnimationInfo::AddAnimationForProperty(
? static_cast<float>(aAnimation->PlaybackRate())
: std::numeric_limits<float>::quiet_NaN();
animation->transformData() = aTransformData;
animation->easingFunction() = Nothing();
if (timing.TimingFunction().isSome()) {
animation->easingFunction().emplace(
ComputedTimingFunction::ToStyleComputedTimingFunction(
*timing.TimingFunction()));
}
animation->easingFunction() = timing.TimingFunction();
animation->iterationComposite() = static_cast<uint8_t>(
aAnimation->GetEffect()->AsKeyframeEffect()->IterationComposite());
animation->isNotPlaying() = !aAnimation->IsPlaying();
@ -522,12 +517,7 @@ void AnimationInfo::AddAnimationForProperty(
animSegment->startComposite() =
static_cast<uint8_t>(segment.mFromComposite);
animSegment->endComposite() = static_cast<uint8_t>(segment.mToComposite);
animSegment->sampleFn() = Nothing();
if (segment.mTimingFunction.isSome()) {
animSegment->sampleFn().emplace(
ComputedTimingFunction::ToStyleComputedTimingFunction(
*segment.mTimingFunction));
}
animSegment->sampleFn() = segment.mTimingFunction;
}
}

View File

@ -8,7 +8,7 @@
#define mozilla_layers_AnimationStorageData_h
#include "mozilla/dom/Nullable.h"
#include "mozilla/ComputedTimingFunction.h" // for ComputedTimingFunction
#include "mozilla/ServoStyleConsts.h" // for ComputedTimingFunction
#include "mozilla/layers/LayersMessages.h" // for TransformData, etc
#include "mozilla/layers/LayersTypes.h" // for LayersId
#include "mozilla/TimeStamp.h" // for TimeStamp
@ -28,7 +28,7 @@ struct PropertyAnimation {
struct SegmentData {
RefPtr<RawServoAnimationValue> mStartValue;
RefPtr<RawServoAnimationValue> mEndValue;
Maybe<mozilla::ComputedTimingFunction> mFunction;
Maybe<mozilla::StyleComputedTimingFunction> mFunction;
float mStartPortion;
float mEndPortion;
dom::CompositeOperation mStartComposite;

View File

@ -37,13 +37,13 @@
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/BasicEvents.h" // for Modifiers, MODIFIER_*
#include "mozilla/ClearOnShutdown.h" // for ClearOnShutdown
#include "mozilla/ComputedTimingFunction.h" // for ComputedTimingFunction
#include "mozilla/EventForwards.h" // for nsEventStatus_*
#include "mozilla/EventStateManager.h" // for EventStateManager
#include "mozilla/MouseEvents.h" // for WidgetWheelEvent
#include "mozilla/Preferences.h" // for Preferences
#include "mozilla/RecursiveMutex.h" // for RecursiveMutexAutoLock, etc
#include "mozilla/RefPtr.h" // for RefPtr
#include "mozilla/ServoStyleConsts.h" // for StyleComputedTimingFunction
#include "mozilla/EventForwards.h" // for nsEventStatus_*
#include "mozilla/EventStateManager.h" // for EventStateManager
#include "mozilla/MouseEvents.h" // for WidgetWheelEvent
#include "mozilla/Preferences.h" // for Preferences
#include "mozilla/RecursiveMutex.h" // for RecursiveMutexAutoLock, etc
#include "mozilla/RefPtr.h" // for RefPtr
#include "mozilla/ScrollTypes.h"
#include "mozilla/StaticPrefs_apz.h"
#include "mozilla/StaticPrefs_general.h"
@ -80,7 +80,6 @@
#include "nsMathUtils.h" // for NS_hypot
#include "nsPoint.h" // for nsIntPoint
#include "nsStyleConsts.h"
#include "nsTimingFunction.h"
#include "nsTArray.h" // for nsTArray, nsTArray_Impl, etc
#include "nsThreadUtils.h" // for NS_IsMainThread
#include "nsViewportInfo.h" // for kViewportMinScale, kViewportMaxScale
@ -505,12 +504,12 @@ typedef PlatformSpecificStateBase
/**
* Computed time function used for sampling frames of a zoom to animation.
*/
StaticAutoPtr<ComputedTimingFunction> gZoomAnimationFunction;
StaticAutoPtr<StyleComputedTimingFunction> gZoomAnimationFunction;
/**
* Computed time function used for curving up velocity when it gets high.
*/
StaticAutoPtr<ComputedTimingFunction> gVelocityCurveFunction;
StaticAutoPtr<StyleComputedTimingFunction> gVelocityCurveFunction;
/**
* The estimated duration of a paint for the purposes of calculating a new
@ -648,8 +647,8 @@ class ZoomAnimation : public AsyncPanZoomAnimation {
// Sample the zoom at the current time point. The sampled zoom
// will affect the final computed resolution.
float sampledPosition = gZoomAnimationFunction->GetValue(
animPosition, StyleEasingBeforeFlag::Unset);
float sampledPosition =
gZoomAnimationFunction->At(animPosition, /* aBeforeFlag = */ false);
// We scale the scrollOffset linearly with sampledPosition, so the zoom
// needs to scale inversely to match.
@ -699,14 +698,15 @@ void AsyncPanZoomController::InitializeGlobalState() {
MOZ_ASSERT(NS_IsMainThread());
gZoomAnimationFunction =
new ComputedTimingFunction(nsTimingFunction(StyleTimingKeyword::Ease));
gZoomAnimationFunction = new StyleComputedTimingFunction(
StyleComputedTimingFunction::Keyword(StyleTimingKeyword::Ease));
ClearOnShutdown(&gZoomAnimationFunction);
gVelocityCurveFunction = new ComputedTimingFunction(
nsTimingFunction(StaticPrefs::apz_fling_curve_function_x1_AtStartup(),
StaticPrefs::apz_fling_curve_function_y1_AtStartup(),
StaticPrefs::apz_fling_curve_function_x2_AtStartup(),
StaticPrefs::apz_fling_curve_function_y2_AtStartup()));
gVelocityCurveFunction =
new StyleComputedTimingFunction(StyleComputedTimingFunction::CubicBezier(
StaticPrefs::apz_fling_curve_function_x1_AtStartup(),
StaticPrefs::apz_fling_curve_function_y1_AtStartup(),
StaticPrefs::apz_fling_curve_function_x2_AtStartup(),
StaticPrefs::apz_fling_curve_function_y2_AtStartup()));
ClearOnShutdown(&gVelocityCurveFunction);
uint64_t sysmem = PR_GetPhysicalMemorySize();

View File

@ -6,7 +6,7 @@
#include "SimpleVelocityTracker.h"
#include "mozilla/ComputedTimingFunction.h" // for ComputedTimingFunction
#include "mozilla/ServoStyleConsts.h" // for StyleComputedTimingFunction
#include "mozilla/StaticPrefs_apz.h"
#include "mozilla/StaticPtr.h" // for StaticAutoPtr
@ -23,7 +23,7 @@ namespace layers {
// not recompute the velocity.
const TimeDuration MIN_VELOCITY_SAMPLE_TIME = TimeDuration::FromMilliseconds(5);
extern StaticAutoPtr<ComputedTimingFunction> gVelocityCurveFunction;
extern StaticAutoPtr<StyleComputedTimingFunction> gVelocityCurveFunction;
SimpleVelocityTracker::SimpleVelocityTracker(Axis* aAxis)
: mAxis(aAxis), mVelocitySamplePos(0) {}
@ -113,8 +113,8 @@ float SimpleVelocityTracker::ApplyFlingCurveToVelocity(float aVelocity) const {
// the curve
float scale = maxVelocity - curveThreshold;
float funcInput = (newVelocity - curveThreshold) / scale;
float funcOutput = gVelocityCurveFunction->GetValue(
funcInput, StyleEasingBeforeFlag::Unset);
float funcOutput =
gVelocityCurveFunction->At(funcInput, /* aBeforeFlag = */ false);
float curvedVelocity = (funcOutput * scale) + curveThreshold;
SVT_LOG("%p|%s curving up velocity from %f to %f\n",
mAxis->OpaqueApzcPointer(), mAxis->Name(), newVelocity,

View File

@ -640,8 +640,7 @@ double Gecko_GetProgressFromComputedTiming(const ComputedTiming* aTiming) {
}
double Gecko_GetPositionInSegment(const AnimationPropertySegment* aSegment,
double aProgress,
StyleEasingBeforeFlag aBeforeFlag) {
double aProgress, bool aBeforeFlag) {
MOZ_ASSERT(aSegment->mFromKey < aSegment->mToKey,
"The segment from key should be less than to key");
@ -651,8 +650,8 @@ double Gecko_GetPositionInSegment(const AnimationPropertySegment* aSegment,
// denominator using double precision.
(double(aSegment->mToKey) - aSegment->mFromKey);
return ComputedTimingFunction::GetPortion(aSegment->mTimingFunction,
positionInSegment, aBeforeFlag);
return StyleComputedTimingFunction::GetPortion(
aSegment->mTimingFunction, positionInSegment, aBeforeFlag);
}
const RawServoAnimationValue* Gecko_AnimationGetBaseStyle(
@ -1096,7 +1095,7 @@ enum class KeyframeInsertPosition {
static Keyframe* GetOrCreateKeyframe(
nsTArray<Keyframe>* aKeyframes, float aOffset,
const nsTimingFunction* aTimingFunction,
const StyleComputedTimingFunction* aTimingFunction,
const CompositeOperationOrAuto aComposition,
KeyframeSearchDirection aSearchDirection,
KeyframeInsertPosition aInsertPosition) {
@ -1127,7 +1126,7 @@ static Keyframe* GetOrCreateKeyframe(
Keyframe* keyframe = aKeyframes->InsertElementAt(
aInsertPosition == KeyframeInsertPosition::Prepend ? 0 : keyframeIndex);
keyframe->mOffset.emplace(aOffset);
if (!aTimingFunction->IsLinear()) {
if (!aTimingFunction->IsLinearKeyword()) {
keyframe->mTimingFunction.emplace(*aTimingFunction);
}
keyframe->mComposite = aComposition;
@ -1137,7 +1136,7 @@ static Keyframe* GetOrCreateKeyframe(
Keyframe* Gecko_GetOrCreateKeyframeAtStart(
nsTArray<Keyframe>* aKeyframes, float aOffset,
const nsTimingFunction* aTimingFunction,
const StyleComputedTimingFunction* aTimingFunction,
const CompositeOperationOrAuto aComposition) {
MOZ_ASSERT(aKeyframes->IsEmpty() ||
aKeyframes->ElementAt(0).mOffset.value() >= aOffset,
@ -1150,7 +1149,8 @@ Keyframe* Gecko_GetOrCreateKeyframeAtStart(
}
Keyframe* Gecko_GetOrCreateInitialKeyframe(
nsTArray<Keyframe>* aKeyframes, const nsTimingFunction* aTimingFunction,
nsTArray<Keyframe>* aKeyframes,
const StyleComputedTimingFunction* aTimingFunction,
const CompositeOperationOrAuto aComposition) {
return GetOrCreateKeyframe(aKeyframes, 0., aTimingFunction, aComposition,
KeyframeSearchDirection::Forwards,
@ -1158,7 +1158,8 @@ Keyframe* Gecko_GetOrCreateInitialKeyframe(
}
Keyframe* Gecko_GetOrCreateFinalKeyframe(
nsTArray<Keyframe>* aKeyframes, const nsTimingFunction* aTimingFunction,
nsTArray<Keyframe>* aKeyframes,
const StyleComputedTimingFunction* aTimingFunction,
const CompositeOperationOrAuto aComposition) {
return GetOrCreateKeyframe(aKeyframes, 1., aTimingFunction, aComposition,
KeyframeSearchDirection::Backwards,

View File

@ -17,7 +17,6 @@
#include "mozilla/css/SheetLoadData.h"
#include "mozilla/dom/Document.h"
#include "mozilla/EffectCompositor.h"
#include "mozilla/ComputedTimingFunction.h"
#include "mozilla/PreferenceSheet.h"
#include "nsStyleStruct.h"
@ -246,8 +245,7 @@ const RawServoAnimationValue* Gecko_ElementTransitions_EndValueAt(
double Gecko_GetProgressFromComputedTiming(const mozilla::ComputedTiming*);
double Gecko_GetPositionInSegment(const mozilla::AnimationPropertySegment*,
double aProgress,
mozilla::StyleEasingBeforeFlag aBeforeFlag);
double aProgress, bool aBeforeFlag);
// Get servo's AnimationValue for |aProperty| from the cached base style
// |aBaseStyles|.
@ -390,7 +388,7 @@ void Gecko_EnsureStyleTransitionArrayLength(void* array, size_t len);
// @returns The matching or created Keyframe.
mozilla::Keyframe* Gecko_GetOrCreateKeyframeAtStart(
nsTArray<mozilla::Keyframe>* keyframes, float offset,
const nsTimingFunction* timingFunction,
const mozilla::StyleComputedTimingFunction* timingFunction,
const mozilla::dom::CompositeOperationOrAuto composition);
// As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
@ -400,7 +398,7 @@ mozilla::Keyframe* Gecko_GetOrCreateKeyframeAtStart(
// inserted after the *last* Keyframe in |keyframes| with offset 0.0.
mozilla::Keyframe* Gecko_GetOrCreateInitialKeyframe(
nsTArray<mozilla::Keyframe>* keyframes,
const nsTimingFunction* timingFunction,
const mozilla::StyleComputedTimingFunction* timingFunction,
const mozilla::dom::CompositeOperationOrAuto composition);
// As with Gecko_GetOrCreateKeyframeAtStart except that this method will search
@ -409,7 +407,7 @@ mozilla::Keyframe* Gecko_GetOrCreateInitialKeyframe(
// Keyframe will be appended to the end of |keyframes|.
mozilla::Keyframe* Gecko_GetOrCreateFinalKeyframe(
nsTArray<mozilla::Keyframe>* keyframes,
const nsTimingFunction* timingFunction,
const mozilla::StyleComputedTimingFunction* timingFunction,
const mozilla::dom::CompositeOperationOrAuto composition);
// Appends and returns a new PropertyValuePair to |aProperties| initialized with

View File

@ -117,7 +117,6 @@ class nsCSSValue;
class nsINode;
class nsPresContext;
struct nsFontFaceRuleContainer;
struct nsTimingFunction;
namespace mozilla {
class ComputedStyle;

View File

@ -17,7 +17,6 @@ headers = [
"mozilla/ipc/ByteBuf.h",
"mozilla/AnimationPropertySegment.h",
"mozilla/ComputedTiming.h",
"mozilla/ComputedTimingFunction.h",
"mozilla/CORSMode.h",
"mozilla/Keyframe.h",
"mozilla/ServoElementSnapshot.h",
@ -204,7 +203,6 @@ allowlist-types = [
"mozilla::AnonymousCounterStyle",
"mozilla::AtomArray",
"mozilla::ComputedTiming",
"mozilla::ComputedTimingFunction",
"mozilla::Matrix4x4Components",
"mozilla::PreferenceSheet",
"mozilla::SeenPtrs",

View File

@ -44,7 +44,7 @@ already_AddRefed<RawServoDeclarationBlock> ServoCSSParser::ParseProperty(
/* static */
bool ServoCSSParser::ParseEasing(const nsACString& aValue,
nsTimingFunction& aResult) {
StyleComputedTimingFunction& aResult) {
return Servo_ParseEasing(&aValue, &aResult);
}

View File

@ -18,7 +18,6 @@
#include "nsStringFwd.h"
struct nsCSSRect;
struct nsTimingFunction;
struct RawServoDeclarationBlock;
template <class T>
class RefPtr;
@ -33,6 +32,12 @@ struct StyleFontWeight;
struct StyleFontStyle;
union StyleComputedFontStyleDescriptor;
template <typename Integer, typename Number, typename LinearStops>
struct StyleTimingFunction;
struct StylePiecewiseLinearFunction;
using StyleComputedTimingFunction =
StyleTimingFunction<int32_t, float, StylePiecewiseLinearFunction>;
namespace css {
class Loader;
}
@ -97,7 +102,8 @@ class ServoCSSParser {
* @param aResult The output timing function. (output)
* @return Whether the value was successfully parsed.
*/
static bool ParseEasing(const nsACString& aValue, nsTimingFunction& aResult);
static bool ParseEasing(const nsACString& aValue,
StyleComputedTimingFunction& aResult);
/**
* Parse a specified transform list into a gfx matrix.

View File

@ -45,7 +45,6 @@ class nsPresContext;
class nsSimpleContentList;
class imgRequestProxy;
struct nsCSSValueSharedList;
struct nsTimingFunction;
class gfxFontFeatureValueSet;
struct gfxFontFeature;

View File

@ -1080,6 +1080,27 @@ using FontStretch = StyleFontStretch;
using FontSlantStyle = StyleFontStyle;
using FontWeight = StyleFontWeight;
template <>
inline double StyleComputedTimingFunction::At(double aPortion,
bool aBeforeFlag) const {
return Servo_EasingFunctionAt(
this, aPortion,
aBeforeFlag ? StyleEasingBeforeFlag::Set : StyleEasingBeforeFlag::Unset);
}
template <>
inline void StyleComputedTimingFunction::AppendToString(
nsACString& aOut) const {
return Servo_SerializeEasing(this, &aOut);
}
template <>
inline double StyleComputedTimingFunction::GetPortion(
const Maybe<StyleComputedTimingFunction>& aFn, double aPortion,
bool aBeforeFlag) {
return aFn ? aFn->At(aPortion, aBeforeFlag) : aPortion;
}
} // namespace mozilla
#endif

View File

@ -1002,11 +1002,10 @@ void ServoStyleSet::AssertTreeIsClean() {
}
#endif
bool ServoStyleSet::GetKeyframesForName(const Element& aElement,
const ComputedStyle& aStyle,
nsAtom* aName,
const nsTimingFunction& aTimingFunction,
nsTArray<Keyframe>& aKeyframes) {
bool ServoStyleSet::GetKeyframesForName(
const Element& aElement, const ComputedStyle& aStyle, nsAtom* aName,
const StyleComputedTimingFunction& aTimingFunction,
nsTArray<Keyframe>& aKeyframes) {
MOZ_ASSERT(!StylistNeedsUpdate());
return Servo_StyleSet_GetKeyframesForName(
mRawSet.get(), &aElement, &aStyle, aName, &aTimingFunction, &aKeyframes);

View File

@ -30,6 +30,13 @@ namespace mozilla {
enum class MediaFeatureChangeReason : uint16_t;
enum class StylePageOrientation : uint8_t;
enum class StyleRuleChangeKind : uint32_t;
template <typename Integer, typename Number, typename LinearStops>
struct StyleTimingFunction;
struct StylePiecewiseLinearFunction;
using StyleComputedTimingFunction =
StyleTimingFunction<int32_t, float, StylePiecewiseLinearFunction>;
namespace css {
class Rule;
} // namespace css
@ -50,7 +57,6 @@ class nsIContent;
class nsPresContext;
class nsWindowSizes;
struct nsTimingFunction;
struct TreeMatchContext;
namespace mozilla {
@ -339,7 +345,7 @@ class ServoStyleSet {
bool GetKeyframesForName(const dom::Element&, const ComputedStyle&,
nsAtom* aName,
const nsTimingFunction& aTimingFunction,
const StyleComputedTimingFunction& aTimingFunction,
nsTArray<Keyframe>& aKeyframes);
nsTArray<ComputedKeyframeValues> GetComputedKeyframeValuesFor(

View File

@ -63,7 +63,6 @@ EXPORTS += [
"nsStyleStructList.h",
"nsStyleTransformMatrix.h",
"nsStyleUtil.h",
"nsTimingFunction.h",
]
EXPORTS.mozilla += [

View File

@ -75,7 +75,8 @@ class MOZ_STACK_CLASS ServoCSSAnimationBuilder final {
}
bool BuildKeyframes(const Element& aElement, nsPresContext* aPresContext,
nsAtom* aName, const nsTimingFunction& aTimingFunction,
nsAtom* aName,
const StyleComputedTimingFunction& aTimingFunction,
nsTArray<Keyframe>& aKeyframes) {
return aPresContext->StyleSet()->GetKeyframesForName(
aElement, *mComputedStyle, aName, aTimingFunction, aKeyframes);

View File

@ -61,10 +61,10 @@ class nsAnimationManager final
// first Keyframe with an offset differing to |aOffset| or, if the end
// of the iterator is reached, sets |aIndex| to the index after the last
// Keyframe.
template <class IterType, class TimingFunctionType>
template <class IterType>
static bool FindMatchingKeyframe(
IterType&& aIter, double aOffset,
const TimingFunctionType& aTimingFunctionToMatch,
const mozilla::StyleComputedTimingFunction& aTimingFunctionToMatch,
mozilla::dom::CompositeOperationOrAuto aCompositionToMatch,
size_t& aIndex) {
aIndex = 0;
@ -72,8 +72,15 @@ class nsAnimationManager final
if (keyframe.mOffset.value() != aOffset) {
break;
}
if (keyframe.mTimingFunction == aTimingFunctionToMatch &&
keyframe.mComposite == aCompositionToMatch) {
const bool matches = [&] {
if (keyframe.mComposite != aCompositionToMatch) {
return false;
}
return keyframe.mTimingFunction
? *keyframe.mTimingFunction == aTimingFunctionToMatch
: aTimingFunctionToMatch.IsLinearKeyword();
}();
if (matches) {
return true;
}
++aIndex;

View File

@ -2145,7 +2145,8 @@ bool nsStyleBackground::IsTransparent(const ComputedStyle* aStyle) const {
StyleTransition::StyleTransition(const StyleTransition& aCopy) = default;
void StyleTransition::SetInitialValues() {
mTimingFunction = nsTimingFunction(StyleTimingKeyword::Ease);
mTimingFunction =
StyleComputedTimingFunction::Keyword(StyleTimingKeyword::Ease);
mDuration = 0.0;
mDelay = 0.0;
mProperty = eCSSPropertyExtra_all_properties;
@ -2162,7 +2163,8 @@ bool StyleTransition::operator==(const StyleTransition& aOther) const {
StyleAnimation::StyleAnimation(const StyleAnimation& aCopy) = default;
void StyleAnimation::SetInitialValues() {
mTimingFunction = nsTimingFunction(StyleTimingKeyword::Ease);
mTimingFunction =
StyleComputedTimingFunction::Keyword(StyleTimingKeyword::Ease);
mDuration = 0.0;
mDelay = 0.0;
mName = nsGkAtoms::_empty;

View File

@ -25,7 +25,6 @@
#include "nsStyleAutoArray.h"
#include "nsStyleConsts.h"
#include "nsChangeHint.h"
#include "nsTimingFunction.h"
#include "nsTArray.h"
#include "imgIContainer.h"
#include "imgRequestProxy.h"
@ -1153,7 +1152,9 @@ struct StyleTransition {
// Delay and Duration are in milliseconds
const nsTimingFunction& GetTimingFunction() const { return mTimingFunction; }
const StyleComputedTimingFunction& GetTimingFunction() const {
return mTimingFunction;
}
float GetDelay() const { return mDelay; }
float GetDuration() const { return mDuration; }
nsCSSPropertyID GetProperty() const { return mProperty; }
@ -1165,7 +1166,7 @@ struct StyleTransition {
}
private:
nsTimingFunction mTimingFunction;
StyleComputedTimingFunction mTimingFunction;
float mDuration;
float mDelay;
nsCSSPropertyID mProperty;
@ -1183,7 +1184,9 @@ struct StyleAnimation {
// Delay and Duration are in milliseconds
const nsTimingFunction& GetTimingFunction() const { return mTimingFunction; }
const StyleComputedTimingFunction& GetTimingFunction() const {
return mTimingFunction;
}
float GetDelay() const { return mDelay; }
float GetDuration() const { return mDuration; }
nsAtom* GetName() const { return mName; }
@ -1203,7 +1206,7 @@ struct StyleAnimation {
}
private:
nsTimingFunction mTimingFunction;
StyleComputedTimingFunction mTimingFunction;
float mDuration;
float mDelay;
RefPtr<nsAtom> mName; // nsGkAtoms::_empty for 'none'
@ -1790,7 +1793,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUIReset {
float GetTransitionDuration(uint32_t aIndex) const {
return mTransitions[aIndex % mTransitionDurationCount].GetDuration();
}
const nsTimingFunction& GetTransitionTimingFunction(uint32_t aIndex) const {
const mozilla::StyleComputedTimingFunction& GetTransitionTimingFunction(
uint32_t aIndex) const {
return mTransitions[aIndex % mTransitionTimingFunctionCount]
.GetTimingFunction();
}
@ -1825,7 +1829,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUIReset {
return mAnimations[aIndex % mAnimationIterationCountCount]
.GetIterationCount();
}
const nsTimingFunction& GetAnimationTimingFunction(uint32_t aIndex) const {
const mozilla::StyleComputedTimingFunction& GetAnimationTimingFunction(
uint32_t aIndex) const {
return mAnimations[aIndex % mAnimationTimingFunctionCount]
.GetTimingFunction();
}

View File

@ -1,37 +0,0 @@
/* -*- 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/. */
#ifndef nsTimingFunction_h
#define nsTimingFunction_h
#include "mozilla/ServoStyleConsts.h"
struct nsTimingFunction {
mozilla::StyleComputedTimingFunction mTiming;
explicit nsTimingFunction(
mozilla::StyleTimingKeyword aKeyword = mozilla::StyleTimingKeyword::Ease)
: mTiming(mozilla::StyleComputedTimingFunction::Keyword(aKeyword)) {}
nsTimingFunction(float x1, float y1, float x2, float y2)
: mTiming(mozilla::StyleComputedTimingFunction::CubicBezier(x1, y1, x2,
y2)) {}
bool IsLinear() const {
return mTiming.IsKeyword() &&
mTiming.AsKeyword() == mozilla::StyleTimingKeyword::Linear;
}
bool operator==(const nsTimingFunction& aOther) const {
return mTiming == aOther.mTiming;
}
bool operator!=(const nsTimingFunction& aOther) const {
return !(*this == aOther);
}
};
#endif // nsTimingFunction_h

View File

@ -442,10 +442,10 @@ bool nsTransitionManager::ConsiderInitiatingTransition(
duration, delay, 1.0 /* iteration count */,
dom::PlaybackDirection::Normal, dom::FillMode::Backwards);
const nsTimingFunction& tf =
const StyleComputedTimingFunction& tf =
aStyle.GetTransitionTimingFunction(transitionIdx);
if (!tf.IsLinear()) {
timing.SetTimingFunction(Some(ComputedTimingFunction(tf)));
if (!tf.IsLinearKeyword()) {
timing.SetTimingFunction(Some(tf));
}
KeyframeEffectParams effectOptions;

View File

@ -984,7 +984,7 @@ fn static_assert() {
${impl_simple_copy('_moz_min_font_size_ratio', 'mMinFontSizeRatio')}
</%self:impl_trait>
<%def name="impl_copy_animation_or_transition_value(type, ident, gecko_ffi_name, member=None)">
<%def name="impl_copy_animation_or_transition_value(type, ident, gecko_ffi_name)">
#[allow(non_snake_case)]
pub fn copy_${type}_${ident}_from(&mut self, other: &Self) {
self.gecko.m${type.capitalize()}s.ensure_len(other.gecko.m${type.capitalize()}s.len());
@ -997,11 +997,7 @@ fn static_assert() {
);
for (ours, others) in iter {
% if member:
ours.m${gecko_ffi_name}.${member} = others.m${gecko_ffi_name}.${member}.clone();
% else:
ours.m${gecko_ffi_name} = others.m${gecko_ffi_name}.clone();
% endif
}
}
@ -1056,14 +1052,14 @@ fn static_assert() {
self.gecko.m${type.capitalize()}TimingFunctionCount = input_len as u32;
for (gecko, servo) in self.gecko.m${type.capitalize()}s.iter_mut().take(input_len as usize).zip(v) {
gecko.mTimingFunction.mTiming = servo;
gecko.mTimingFunction = servo;
}
}
${impl_animation_or_transition_count(type, 'timing_function', 'TimingFunction')}
${impl_copy_animation_or_transition_value(type, 'timing_function', "TimingFunction", "mTiming")}
${impl_copy_animation_or_transition_value(type, 'timing_function', "TimingFunction")}
pub fn ${type}_timing_function_at(&self, index: usize)
-> longhands::${type}_timing_function::computed_value::SingleComputedValue {
self.gecko.m${type.capitalize()}s[index].mTimingFunction.mTiming.clone()
self.gecko.m${type.capitalize()}s[index].mTimingFunction.clone()
}
</%def>

View File

@ -297,7 +297,6 @@ renaming_overrides_prefixing = true
"Keyframe" = "Keyframe"
"nsChangeHint" = "nsChangeHint"
"ServoElementSnapshotTable" = "ServoElementSnapshotTable"
"nsTimingFunction" = "nsTimingFunction"
"Keyframe" = "Keyframe"
"ComputedKeyframeValues" = "ComputedKeyframeValues"
"OriginFlags" = "OriginFlags"
@ -816,6 +815,13 @@ renaming_overrides_prefixing = true
public:
// The implementation of IPC LayersMessages needs this to be public.
StyleTimingFunction() : tag(Tag::Keyword) { ::new (&keyword._0) (StyleTimingKeyword) (StyleTimingKeyword::Linear); }
bool IsLinearKeyword() const { return IsKeyword() && AsKeyword() == StyleTimingKeyword::Linear; }
inline double At(double, bool aBeforeFlag) const;
inline void AppendToString(nsACString&) const;
inline static double GetPortion(const Maybe<StyleTimingFunction>&, double, bool aBeforeFlag);
"""
"GenericImage" = """

View File

@ -57,7 +57,6 @@ use style::gecko_bindings::structs::nsChangeHint;
use style::gecko_bindings::structs::nsCompatibility;
use style::gecko_bindings::structs::nsStyleTransformMatrix::MatrixTransformOperator;
use style::gecko_bindings::structs::nsTArray;
use style::gecko_bindings::structs::nsTimingFunction;
use style::gecko_bindings::structs::nsresult;
use style::gecko_bindings::structs::CallerType;
use style::gecko_bindings::structs::CompositeOperation;
@ -139,6 +138,7 @@ use style::values::animated::color::AnimatedRGBA;
use style::values::generics::color::ColorInterpolationMethod;
use style::values::generics::easing::BeforeFlag;
use style::values::computed::font::{FontFamily, FontFamilyList, GenericFontFamily, FontWeight, FontStyle, FontStretch};
use style::values::computed::easing::ComputedTimingFunction;
use style::values::computed::{self, Context, ToComputedValue};
use style::values::distance::ComputeSquaredDistance;
use style::values::specified::gecko::IntersectionObserverRootMargin;
@ -1089,7 +1089,7 @@ impl_basic_serde_funcs!(
impl_basic_serde_funcs!(
Servo_StyleComputedTimingFunction_Serialize,
Servo_StyleComputedTimingFunction_Deserialize,
computed::easing::ComputedTimingFunction
ComputedTimingFunction
);
#[no_mangle]
@ -4385,7 +4385,7 @@ pub unsafe extern "C" fn Servo_ParseProperty(
}
#[no_mangle]
pub extern "C" fn Servo_ParseEasing(easing: &nsACString, output: &mut nsTimingFunction) -> bool {
pub extern "C" fn Servo_ParseEasing(easing: &nsACString, output: &mut ComputedTimingFunction) -> bool {
use style::properties::longhands::transition_timing_function;
let context = ParserContext::new(
@ -4404,8 +4404,7 @@ pub extern "C" fn Servo_ParseEasing(easing: &nsACString, output: &mut nsTimingFu
parser.parse_entirely(|p| transition_timing_function::single_value::parse(&context, p));
match result {
Ok(parsed_easing) => {
// We store as computed value in nsTimingFunction.
(*output).mTiming = parsed_easing.to_computed_value_without_context();
*output = parsed_easing.to_computed_value_without_context();
true
},
Err(_) => false,
@ -4413,8 +4412,8 @@ pub extern "C" fn Servo_ParseEasing(easing: &nsACString, output: &mut nsTimingFu
}
#[no_mangle]
pub extern "C" fn Servo_SerializeEasing(easing: &nsTimingFunction, output: &mut nsACString) {
easing.mTiming.to_css(&mut CssWriter::new(output)).unwrap();
pub extern "C" fn Servo_SerializeEasing(easing: &ComputedTimingFunction, output: &mut nsACString) {
easing.to_css(&mut CssWriter::new(output)).unwrap();
}
#[no_mangle]
@ -6224,7 +6223,7 @@ enum Offset {
fn fill_in_missing_keyframe_values(
all_properties: &LonghandIdSet,
timing_function: &nsTimingFunction,
timing_function: &ComputedTimingFunction,
longhands_at_offset: &LonghandIdSet,
offset: Offset,
keyframes: &mut nsTArray<structs::Keyframe>,
@ -6268,7 +6267,7 @@ pub unsafe extern "C" fn Servo_StyleSet_GetKeyframesForName(
element: &RawGeckoElement,
style: &ComputedValues,
name: *mut nsAtom,
inherited_timing_function: &nsTimingFunction,
inherited_timing_function: &ComputedTimingFunction,
keyframes: &mut nsTArray<structs::Keyframe>,
) -> bool {
use style::gecko_bindings::structs::CompositeOperationOrAuto;
@ -6307,11 +6306,9 @@ pub unsafe extern "C" fn Servo_StyleSet_GetKeyframesForName(
}
// Override timing_function if the keyframe has an animation-timing-function.
let timing_function = nsTimingFunction {
mTiming: match step.get_animation_timing_function(&guard) {
Some(val) => val.to_computed_value_without_context(),
None => (*inherited_timing_function).mTiming.clone(),
},
let timing_function = match step.get_animation_timing_function(&guard) {
Some(val) => val.to_computed_value_without_context(),
None => (*inherited_timing_function).clone(),
};
// Override composite operation if the keyframe has an animation-composition.
@ -7544,7 +7541,7 @@ pub extern "C" fn Servo_InterpolateColor(
#[no_mangle]
pub extern "C" fn Servo_EasingFunctionAt(
easing_function: &computed::easing::ComputedTimingFunction,
easing_function: &ComputedTimingFunction,
progress: f64,
before_flag: BeforeFlag
) -> f64 {