Bug 1331704 - Part 2: Resolve base styles during UpdateProprties. r=birtles a=abillings

EnsureBaseStyle() requires an already resolved nsStyleContext
and resolves the base style by ResolveStyleByRemovingAnimation().

MozReview-Commit-ID: BHqJiBJspQY
This commit is contained in:
Hiroyuki Ikezoe 2017-02-11 19:11:45 +09:00
Родитель e7c1543f3e
Коммит 14613aa3a3
2 изменённых файлов: 14 добавлений и 45 удалений

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

@ -286,6 +286,10 @@ KeyframeEffectReadOnly::UpdateProperties(nsStyleContext* aStyleContext)
nsTArray<AnimationProperty> properties = BuildProperties(aStyleContext);
// We need to update base styles even if any properties are not changed at all
// since base styles might have been changed due to parent style changes, etc.
EnsureBaseStyles(aStyleContext, properties);
if (mProperties == properties) {
return;
}
@ -393,9 +397,7 @@ KeyframeEffectReadOnly::GetUnderlyingStyle(
// 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.
RefPtr<nsStyleContext> styleContext =
GetTargetStyleContextWithoutAnimation();
result = ResolveBaseStyle(aProperty, styleContext);
result = BaseStyle(aProperty);
}
return result;
@ -437,38 +439,24 @@ KeyframeEffectReadOnly::CompositeValue(
}
void
KeyframeEffectReadOnly::EnsureBaseStylesForCompositor(
const nsCSSPropertyIDSet& aPropertiesToSkip)
KeyframeEffectReadOnly::EnsureBaseStyles(
nsStyleContext* aStyleContext,
const nsTArray<AnimationProperty>& aProperties)
{
if (!mTarget) {
return;
}
RefPtr<nsStyleContext> styleContext;
for (const AnimationProperty& property : mProperties) {
if (!nsCSSProps::PropHasFlags(property.mProperty,
CSS_PROPERTY_CAN_ANIMATE_ON_COMPOSITOR)) {
continue;
}
if (aPropertiesToSkip.HasProperty(property.mProperty)) {
continue;
}
mBaseStyleValues.Clear();
for (const AnimationProperty& property : aProperties) {
for (const AnimationPropertySegment& segment : property.mSegments) {
if (segment.mFromComposite == dom::CompositeOperation::Replace &&
segment.mToComposite == dom::CompositeOperation::Replace) {
continue;
}
if (!styleContext) {
styleContext = GetTargetStyleContextWithoutAnimation();
}
MOZ_RELEASE_ASSERT(styleContext);
StyleAnimationValue result =
ResolveBaseStyle(property.mProperty, styleContext);
Unused << ResolveBaseStyle(property.mProperty, aStyleContext);
break;
}
}
@ -495,16 +483,6 @@ KeyframeEffectReadOnly::ComposeStyle(
// If the progress is null, we don't have fill data for the current
// time so we shouldn't animate.
if (computedTiming.mProgress.IsNull()) {
// If we are not in-effect, this effect might still be sent to the
// compositor and later become in-effect (e.g. if it is in the delay phase,
// or, if it is in the end delay phase but with a negative playback rate).
// In that case, we might need the base style in order to perform
// additive/accumulative animation on the compositor.
// Note, however, that we don't actually send animations with a negative
// playback rate in their end delay phase to the compositor at this stage
// (bug 1330498).
EnsureBaseStylesForCompositor(aPropertiesToSkip);
return;
}
@ -674,14 +652,6 @@ KeyframeEffectReadOnly::ComposeStyle(
}
}
}
// For properties that can be run on the compositor, we may need to prepare
// base styles to send to the compositor even if the current processing
// segment for properties does not have either an additive or accumulative
// composite mode, and even if the animation is not in-effect. That's because
// the animation may later progress to a segment which has an additive or
// accumulative composite on the compositor mode.
EnsureBaseStylesForCompositor(aPropertiesToSkip);
}
bool

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

@ -386,10 +386,9 @@ protected:
nsCSSPropertyID aProperty,
const RefPtr<AnimValuesStyleRule>& aAnimationRule);
// Ensure the base styles is available for any properties that can be run on
// the compositor and which are not includes in |aPropertiesToSkip|.
void EnsureBaseStylesForCompositor(
const nsCSSPropertyIDSet& aPropertiesToSkip);
// Ensure the base styles is available for any properties in |aProperties|.
void EnsureBaseStyles(nsStyleContext* aStyleContext,
const nsTArray<AnimationProperty>& aProperties);
// Returns the base style resolved by |aStyleContext| for |aProperty|.
StyleAnimationValue ResolveBaseStyle(nsCSSPropertyID aProperty,