Bug 1334036 - Part 10: Return AnimationValue for BaseStyle.
We need to retrieve the correct base style for Servo backend, so change
the return value to AnimationValue and update
KeyframeEffectReadOnly::BaseStyle().
MozReview-Commit-ID: 9FL3h1DLoJt
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -422,17 +422,17 @@ KeyframeEffectReadOnly::GetUnderlyingSty
// If we have already composed style for the property, we use the style
// as the underlying style.
DebugOnly<bool> success = aAnimationRule->GetValue(aProperty, result);
MOZ_ASSERT(success, "AnimValuesStyleRule::GetValue should not fail");
} else {
// If we are composing with composite operation that is not 'replace'
// and we have not composed style for the property yet, we have to get
// the base style for the property.
- result = BaseStyle(aProperty);
+ result = BaseStyle(aProperty).mGecko;
}
return result;
}
StyleAnimationValue
KeyframeEffectReadOnly::CompositeValue(
nsCSSPropertyID aProperty,
@@ -1292,17 +1292,18 @@ KeyframeEffectReadOnly::GetKeyframes(JSC
// We use an uninitialized nsCSSValue to represent the
// "neutral value". We currently only do this for keyframes generated
// from CSS animations with missing 0%/100% keyframes. Furthermore,
// currently (at least until bug 1339334) keyframes generated from
// CSS animations only contain longhand properties so we only need to
// handle null nsCSSValues for longhand properties.
DebugOnly<bool> uncomputeResult =
StyleAnimationValue::UncomputeValue(
- propertyValue.mProperty, Move(BaseStyle(propertyValue.mProperty)),
+ propertyValue.mProperty,
+ Move(BaseStyle(propertyValue.mProperty).mGecko),
cssValue);
MOZ_ASSERT(uncomputeResult,
"Unable to get specified value from computed value");
MOZ_ASSERT(cssValue.GetUnit() != eCSSUnit_Null,
"Got null computed value");
}
cssValue.AppendToString(propertyValue.mProperty,
@@ -1843,17 +1844,17 @@ KeyframeEffectReadOnly::ContainsAnimated
return false;
}
for (const AnimationProperty& prop : mProperties) {
if (prop.mProperty != eCSSProperty_transform) {
continue;
}
- StyleAnimationValue baseStyle = BaseStyle(prop.mProperty);
+ AnimationValue baseStyle = BaseStyle(prop.mProperty);
if (baseStyle.IsNull()) {
// If we failed to get the base style, we consider it has scale value
// here just to be safe.
return true;
}
gfxSize size = baseStyle.GetScaleValue(aFrame);
if (size != gfxSize(1.0f, 1.0f)) {
return true;
--- a/dom/animation/KeyframeEffectReadOnly.h
+++ b/dom/animation/KeyframeEffectReadOnly.h
@@ -274,20 +274,28 @@ public:
// See nsChangeHint_Hints_CanIgnoreIfNotVisible in nsChangeHint.h
// in detail which change hint can be ignored.
bool CanIgnoreIfNotVisible() const;
// Returns true if the effect is current state and has scale animation.
// |aFrame| is used for calculation of scale values.
bool ContainsAnimatedScale(const nsIFrame* aFrame) const;
- StyleAnimationValue BaseStyle(nsCSSPropertyID aProperty) const
+ AnimationValue BaseStyle(nsCSSPropertyID aProperty) const
{
- StyleAnimationValue result;
- DebugOnly<bool> hasProperty = mBaseStyleValues.Get(aProperty, &result);
+ AnimationValue result;
+ bool hasProperty = false;
+ if (mDocument->IsStyledByServo()) {
+ // We cannot use getters_AddRefs on RawServoAnimationValue because it is
+ // an incomplete type, so Get() doesn't work. Instead, use GetWeak, and
+ // then assign the raw pointer to a RefPtr.
+ result.mServo = mBaseStyleValuesForServo.GetWeak(aProperty, &hasProperty);
+ } else {
+ hasProperty = mBaseStyleValues.Get(aProperty, &result.mGecko);
+ }
MOZ_ASSERT(hasProperty || result.IsNull());
return result;
}
protected:
KeyframeEffectReadOnly(nsIDocument* aDocument,
const Maybe<OwningAnimationTarget>& aTarget,
AnimationEffectTimingReadOnly* aTiming,
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -628,22 +628,19 @@ GetMinAndMaxScaleForAnimationProperty(co
for (size_t propIdx = effect->Properties().Length(); propIdx-- != 0; ) {
const AnimationProperty& prop = effect->Properties()[propIdx];
if (prop.mProperty != eCSSProperty_transform) {
continue;
}
// We need to factor in the scale of the base style if the base style
// will be used on the compositor.
- StyleAnimationValue baseStyle = effect->BaseStyle(prop.mProperty);
+ AnimationValue baseStyle = effect->BaseStyle(prop.mProperty);
if (!baseStyle.IsNull()) {
- // FIXME: Bug 1334036: We need to get the baseStyle for
- // RawServoAnimationValue.
- UpdateMinMaxScale(aFrame, AnimationValue(baseStyle),
- aMinScale, aMaxScale);
+ UpdateMinMaxScale(aFrame, baseStyle, aMinScale, aMaxScale);
}
for (const AnimationPropertySegment& segment : prop.mSegments) {
// In case of add or accumulate composite, StyleAnimationValue does
// not have a valid value.
if (segment.HasReplaceableFromValue()) {
UpdateMinMaxScale(aFrame, segment.mFromValue, aMinScale, aMaxScale);
}
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -561,23 +561,21 @@ AddAnimationForProperty(nsIFrame* aFrame
AsKeyframeEffect()->IterationComposite());
animation->isNotPlaying() = !aAnimation->IsPlaying();
TransformReferenceBox refBox(aFrame);
// If the animation is additive or accumulates, we need to pass its base value
// to the compositor.
- StyleAnimationValue baseStyle =
+ AnimationValue baseStyle =
aAnimation->GetEffect()->AsKeyframeEffect()->BaseStyle(aProperty.mProperty);
if (!baseStyle.IsNull()) {
- // FIXME: Bug 1334036: We need to get the baseValue for
- // RawServoAnimationValue.
SetAnimatable(aProperty.mProperty,
- AnimationValue(baseStyle),
+ baseStyle,
aFrame, refBox,
animation->baseStyle());
} else {
animation->baseStyle() = null_t();
}
for (uint32_t segIdx = 0; segIdx < aProperty.mSegments.Length(); segIdx++) {
const AnimationPropertySegment& segment = aProperty.mSegments[segIdx];