2017-01-29 06:58:23 +03:00
|
|
|
/* -*- 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_dom_Keyframe_h
|
|
|
|
#define mozilla_dom_Keyframe_h
|
|
|
|
|
|
|
|
#include "nsCSSPropertyID.h"
|
|
|
|
#include "nsCSSValue.h"
|
|
|
|
#include "nsTArray.h"
|
2018-08-16 19:24:52 +03:00
|
|
|
#include "mozilla/dom/BaseKeyframeTypesBinding.h" // CompositeOperationOrAuto
|
2017-01-29 06:58:23 +03:00
|
|
|
#include "mozilla/ComputedTimingFunction.h"
|
|
|
|
#include "mozilla/Maybe.h"
|
|
|
|
#include "mozilla/RefPtr.h"
|
|
|
|
|
|
|
|
struct RawServoDeclarationBlock;
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A property-value pair specified on a keyframe.
|
|
|
|
*/
|
|
|
|
struct PropertyValuePair {
|
2017-07-20 08:38:54 +03:00
|
|
|
explicit PropertyValuePair(nsCSSPropertyID aProperty)
|
|
|
|
: mProperty(aProperty) {}
|
2017-06-14 06:43:47 +03:00
|
|
|
PropertyValuePair(nsCSSPropertyID aProperty,
|
|
|
|
RefPtr<RawServoDeclarationBlock>&& aValue)
|
2018-05-30 22:15:35 +03:00
|
|
|
: mProperty(aProperty), mServoDeclarationBlock(std::move(aValue)) {
|
2017-06-14 06:43:47 +03:00
|
|
|
MOZ_ASSERT(mServoDeclarationBlock, "Should be valid property value");
|
|
|
|
}
|
|
|
|
|
2017-01-29 06:58:23 +03:00
|
|
|
nsCSSPropertyID mProperty;
|
|
|
|
|
2017-03-30 05:08:47 +03:00
|
|
|
// The specified value when using the Servo backend.
|
2017-01-29 06:58:23 +03:00
|
|
|
RefPtr<RawServoDeclarationBlock> mServoDeclarationBlock;
|
|
|
|
|
2017-05-30 11:24:08 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
// Flag to indicate that when we call StyleAnimationValue::ComputeValues on
|
|
|
|
// this value we should behave as if that function had failed.
|
2017-06-14 06:43:47 +03:00
|
|
|
bool mSimulateComputeValuesFailure = false;
|
2017-05-30 11:24:08 +03:00
|
|
|
#endif
|
|
|
|
|
2017-01-29 06:58:23 +03:00
|
|
|
bool operator==(const PropertyValuePair&) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A single keyframe.
|
|
|
|
*
|
|
|
|
* This is the canonical form in which keyframe effects are stored and
|
|
|
|
* corresponds closely to the type of objects returned via the getKeyframes()
|
|
|
|
* API.
|
|
|
|
*
|
|
|
|
* Before computing an output animation value, however, we flatten these frames
|
|
|
|
* down to a series of per-property value arrays where we also resolve any
|
|
|
|
* overlapping shorthands/longhands, convert specified CSS values to computed
|
|
|
|
* values, etc.
|
|
|
|
*
|
2018-03-23 16:49:21 +03:00
|
|
|
* When the target element or computed style changes, however, we rebuild these
|
2017-01-29 06:58:23 +03:00
|
|
|
* per-property arrays from the original list of keyframes objects. As a result,
|
|
|
|
* these objects represent the master definition of the effect's values.
|
|
|
|
*/
|
|
|
|
struct Keyframe {
|
|
|
|
Keyframe() = default;
|
|
|
|
Keyframe(const Keyframe& aOther) = default;
|
|
|
|
Keyframe(Keyframe&& aOther) { *this = std::move(aOther); }
|
|
|
|
|
|
|
|
Keyframe& operator=(const Keyframe& aOther) = default;
|
|
|
|
Keyframe& operator=(Keyframe&& aOther) {
|
|
|
|
mOffset = aOther.mOffset;
|
|
|
|
mComputedOffset = aOther.mComputedOffset;
|
2018-05-30 22:15:35 +03:00
|
|
|
mTimingFunction = std::move(aOther.mTimingFunction);
|
|
|
|
mComposite = std::move(aOther.mComposite);
|
|
|
|
mPropertyValues = std::move(aOther.mPropertyValues);
|
2017-01-29 06:58:23 +03:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
Maybe<double> mOffset;
|
|
|
|
static constexpr double kComputedOffsetNotSet = -1.0;
|
|
|
|
double mComputedOffset = kComputedOffsetNotSet;
|
|
|
|
Maybe<ComputedTimingFunction> mTimingFunction; // Nothing() here means
|
|
|
|
// "linear"
|
2018-08-16 19:24:52 +03:00
|
|
|
dom::CompositeOperationOrAuto mComposite =
|
|
|
|
dom::CompositeOperationOrAuto::Auto;
|
2017-01-29 06:58:23 +03:00
|
|
|
nsTArray<PropertyValuePair> mPropertyValues;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_Keyframe_h
|