Bug 1254419 - Make always-set members of AnimationProperty(Value)Details required
At the same time we also make the 'warning' member of AnimationPropertyDetails
no longer nullable and simply use the absence of the member to indicate "no
warning" (which is what we were already doing -- we were never actually setting
it to null).
MozReview-Commit-ID: HdRDbqhCdmw
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -1801,51 +1801,49 @@ KeyframeEffectReadOnly::GetTarget(
static void
CreatePropertyValue(nsCSSProperty aProperty,
float aOffset,
const Maybe<ComputedTimingFunction>& aTimingFunction,
const StyleAnimationValue& aValue,
AnimationPropertyValueDetails& aResult)
{
- aResult.mOffset.Construct(aOffset);
+ aResult.mOffset = aOffset;
nsString stringValue;
StyleAnimationValue::UncomputeValue(aProperty, aValue, stringValue);
- aResult.mValue.Construct(stringValue);
+ aResult.mValue = stringValue;
if (aTimingFunction) {
aResult.mEasing.Construct();
aTimingFunction->AppendToString(aResult.mEasing.Value());
} else {
aResult.mEasing.Construct(NS_LITERAL_STRING("linear"));
}
- aResult.mComposite.Construct(CompositeOperation::Replace);
+ aResult.mComposite = CompositeOperation::Replace;
}
void
KeyframeEffectReadOnly::GetProperties(
nsTArray<AnimationPropertyDetails>& aProperties) const
{
for (const AnimationProperty& property : mProperties) {
AnimationPropertyDetails propertyDetails;
- propertyDetails.mProperty.Construct(
- NS_ConvertASCIItoUTF16(nsCSSProps::GetStringValue(property.mProperty)));
- propertyDetails.mRunningOnCompositor.Construct(
- property.mIsRunningOnCompositor);
+ propertyDetails.mProperty =
+ NS_ConvertASCIItoUTF16(nsCSSProps::GetStringValue(property.mProperty));
+ propertyDetails.mRunningOnCompositor = property.mIsRunningOnCompositor;
nsXPIDLString localizedString;
if (property.mPerformanceWarning &&
property.mPerformanceWarning->ToLocalizedString(localizedString)) {
propertyDetails.mWarning.Construct(localizedString);
}
- propertyDetails.mValues.Construct();
- if (!propertyDetails.mValues.Value().SetCapacity(
+ if (!propertyDetails.mValues.SetCapacity(
property.mSegments.Length(), mozilla::fallible)) {
MOZ_CRASH("Out of memory allocating values array");
}
for (size_t segmentIdx = 0, segmentLen = property.mSegments.Length();
segmentIdx < segmentLen;
segmentIdx++)
{
@@ -1857,35 +1855,33 @@ KeyframeEffectReadOnly::GetProperties(
fromValue);
// We don't apply timing functions for zero-length segments, so
// don't return one here.
if (segment.mFromKey == segment.mToKey) {
fromValue.mEasing.Reset();
}
// The following won't fail since we have already allocated the capacity
// above.
- propertyDetails.mValues.Value().AppendElement(fromValue,
- mozilla::fallible);
+ propertyDetails.mValues.AppendElement(fromValue, mozilla::fallible);
// Normally we can ignore the to-value for this segment since it is
// identical to the from-value from the next segment. However, we need
// to add it if either:
// a) this is the last segment, or
// b) the next segment's from-value differs.
if (segmentIdx == segmentLen - 1 ||
property.mSegments[segmentIdx + 1].mFromValue != segment.mToValue) {
binding_detail::FastAnimationPropertyValueDetails toValue;
CreatePropertyValue(property.mProperty, segment.mToKey,
Nothing(), segment.mToValue, toValue);
// It doesn't really make sense to have a timing function on the
// last property value or before a sudden jump so we just drop the
// easing property altogether.
toValue.mEasing.Reset();
- propertyDetails.mValues.Value().AppendElement(toValue,
- mozilla::fallible);
+ propertyDetails.mValues.AppendElement(toValue, mozilla::fallible);
}
}
aProperties.AppendElement(propertyDetails);
}
}
void
--- a/dom/webidl/KeyframeEffect.webidl
+++ b/dom/webidl/KeyframeEffect.webidl
@@ -42,27 +42,27 @@ interface KeyframeEffectReadOnly : Anima
// We use object instead of ComputedKeyframe so that we can put the
// property-value pairs on the object.
[Throws] sequence<object> getFrames();
};
// Non-standard extensions
dictionary AnimationPropertyValueDetails {
- double offset;
- DOMString value;
- DOMString easing;
- CompositeOperation composite;
+ required double offset;
+ required DOMString value;
+ DOMString easing;
+ required CompositeOperation composite;
};
dictionary AnimationPropertyDetails {
- DOMString property;
- boolean runningOnCompositor;
- DOMString? warning;
- sequence<AnimationPropertyValueDetails> values;
+ required DOMString property;
+ required boolean runningOnCompositor;
+ DOMString warning;
+ required sequence<AnimationPropertyValueDetails> values;
};
partial interface KeyframeEffectReadOnly {
[ChromeOnly] sequence<AnimationPropertyDetails> getProperties();
};
[Func="nsDocument::IsWebAnimationsEnabled",
Constructor ((Element or CSSPseudoElement)? target,