Bug 1766041: Part 3: Migrate C++ `BeforeFlag` to that of Rust's. r=boris

Differential Revision: https://phabricator.services.mozilla.com/D150567
This commit is contained in:
David Shin 2022-07-07 22:52:58 +00:00
Родитель 0c20ef85f5
Коммит 07b055639d
10 изменённых файлов: 19 добавлений и 22 удалений

Просмотреть файл

@ -258,7 +258,7 @@ ComputedTiming AnimationEffect::GetComputedTimingAt(
thisIterationReverse) ||
(result.mPhase == ComputedTiming::AnimationPhase::Before &&
!thisIterationReverse)) {
result.mBeforeFlag = ComputedTimingFunction::BeforeFlag::Set;
result.mBeforeFlag = StyleEasingBeforeFlag::Set;
}
// Apply the easing.

Просмотреть файл

@ -64,8 +64,7 @@ struct ComputedTiming {
};
AnimationPhase mPhase = AnimationPhase::Idle;
ComputedTimingFunction::BeforeFlag mBeforeFlag =
ComputedTimingFunction::BeforeFlag::Unset;
StyleEasingBeforeFlag mBeforeFlag = StyleEasingBeforeFlag::Unset;
};
} // namespace mozilla

Просмотреть файл

@ -65,7 +65,7 @@ ComputedTimingFunction::ComputedTimingFunction(
double ComputedTimingFunction::StepTiming(
const ComputedTimingFunction::StepFunc& aStepFunc, double aPortion,
ComputedTimingFunction::BeforeFlag aBeforeFlag) {
StyleEasingBeforeFlag aBeforeFlag) {
// Use the algorithm defined in the spec:
// https://drafts.csswg.org/css-easing-1/#step-timing-function-algo
@ -85,7 +85,7 @@ double ComputedTimingFunction::StepTiming(
// If the "before flag" is set and we are at a transition point,
// drop back a step
if (aBeforeFlag == ComputedTimingFunction::BeforeFlag::Set &&
if (aBeforeFlag == StyleEasingBeforeFlag::Set &&
fmod(aPortion * aStepFunc.mSteps, 1) == 0) {
--checkedCurrentStep;
}
@ -171,7 +171,7 @@ static inline double GetSplineValue(double aPortion,
}
double ComputedTimingFunction::GetValue(
double aPortion, ComputedTimingFunction::BeforeFlag aBeforeFlag) const {
double aPortion, StyleEasingBeforeFlag aBeforeFlag) const {
return mFunction.match(
[aPortion](const KeywordFunction& aFunction) {
return GetSplineValue(aPortion, aFunction.mFunction);

Просмотреть файл

@ -26,10 +26,7 @@ class ComputedTimingFunction {
static StyleComputedTimingFunction ToStyleComputedTimingFunction(
const ComputedTimingFunction& aComputedTimingFunction);
// BeforeFlag is used in step timing function.
// https://drafts.csswg.org/css-easing/#before-flag
enum class BeforeFlag { Unset, Set };
double GetValue(double aPortion, BeforeFlag aBeforeFlag) const;
double GetValue(double aPortion, StyleEasingBeforeFlag aBeforeFlag) const;
bool operator==(const ComputedTimingFunction& aOther) const {
return mFunction == aOther.mFunction;
}
@ -45,7 +42,7 @@ class ComputedTimingFunction {
void AppendToString(nsACString& aResult) const;
static double GetPortion(const Maybe<ComputedTimingFunction>& aFunction,
double aPortion, BeforeFlag aBeforeFlag) {
double aPortion, StyleEasingBeforeFlag aBeforeFlag) {
return aFunction ? aFunction->GetValue(aPortion, aBeforeFlag) : aPortion;
}
@ -85,7 +82,7 @@ class ComputedTimingFunction {
explicit ComputedTimingFunction(StylePiecewiseLinearFunction aFunction)
: mFunction{AsVariant(std::move(aFunction))} {}
static double StepTiming(const StepFunc& aStepFunc, double aPortion,
BeforeFlag aBeforeFlag);
StyleEasingBeforeFlag aBeforeFlag);
Function mFunction;
};

Просмотреть файл

@ -649,7 +649,7 @@ 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, ComputedTimingFunction::BeforeFlag::Unset);
animPosition, StyleEasingBeforeFlag::Unset);
// We scale the scrollOffset linearly with sampledPosition, so the zoom
// needs to scale inversely to match.

Просмотреть файл

@ -114,7 +114,7 @@ float SimpleVelocityTracker::ApplyFlingCurveToVelocity(float aVelocity) const {
float scale = maxVelocity - curveThreshold;
float funcInput = (newVelocity - curveThreshold) / scale;
float funcOutput = gVelocityCurveFunction->GetValue(
funcInput, ComputedTimingFunction::BeforeFlag::Unset);
funcInput, StyleEasingBeforeFlag::Unset);
float curvedVelocity = (funcOutput * scale) + curveThreshold;
SVT_LOG("%p|%s curving up velocity from %f to %f\n",
mAxis->OpaqueApzcPointer(), mAxis->Name(), newVelocity,

Просмотреть файл

@ -639,9 +639,9 @@ double Gecko_GetProgressFromComputedTiming(const ComputedTiming* aTiming) {
return aTiming->mProgress.Value();
}
double Gecko_GetPositionInSegment(
const AnimationPropertySegment* aSegment, double aProgress,
ComputedTimingFunction::BeforeFlag aBeforeFlag) {
double Gecko_GetPositionInSegment(const AnimationPropertySegment* aSegment,
double aProgress,
StyleEasingBeforeFlag aBeforeFlag) {
MOZ_ASSERT(aSegment->mFromKey < aSegment->mToKey,
"The segment from key should be less than to key");

Просмотреть файл

@ -242,9 +242,9 @@ const RawServoAnimationValue* Gecko_ElementTransitions_EndValueAt(
double Gecko_GetProgressFromComputedTiming(const mozilla::ComputedTiming*);
double Gecko_GetPositionInSegment(
const mozilla::AnimationPropertySegment*, double aProgress,
mozilla::ComputedTimingFunction::BeforeFlag aBeforeFlag);
double Gecko_GetPositionInSegment(const mozilla::AnimationPropertySegment*,
double aProgress,
mozilla::StyleEasingBeforeFlag aBeforeFlag);
// Get servo's AnimationValue for |aProperty| from the cached base style
// |aBaseStyles|.

Просмотреть файл

@ -204,7 +204,6 @@ allowlist-types = [
"mozilla::AtomArray",
"mozilla::ComputedTiming",
"mozilla::ComputedTimingFunction",
"mozilla::ComputedTimingFunction::BeforeFlag",
"mozilla::Matrix4x4Components",
"mozilla::PreferenceSheet",
"mozilla::SeenPtrs",

Просмотреть файл

@ -247,7 +247,8 @@ include = [
"ScrollDirection",
"HyphenateCharacter",
"ComputedLinearStop",
"PiecewiseLinearFunction"
"PiecewiseLinearFunction",
"BeforeFlag"
]
item_types = ["enums", "structs", "unions", "typedefs", "functions", "constants"]
renaming_overrides_prefixing = true
@ -302,6 +303,7 @@ renaming_overrides_prefixing = true
"OriginFlags" = "OriginFlags"
"ServoTraversalFlags" = "ServoTraversalFlags"
"ServoStyleSetSizes" = "ServoStyleSetSizes"
"BeforeFlag" = "StyleEasingBeforeFlag"
[export.body]
"CSSPixelLength" = """