зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1303235 - Part 2: Templatize CalculateCumulativeChangeHint. r=hiro
MozReview-Commit-ID: JHSn7FoRPpW --HG-- extra : rebase_source : f79dbf3b65bc20c13976e348cb9d192bd8b4bb4b
This commit is contained in:
Родитель
a43997fa7b
Коммит
80e5237e58
|
@ -1686,23 +1686,22 @@ KeyframeEffectReadOnly::RecordFrameSizeTelemetry(uint32_t aPixelArea) {
|
|||
}
|
||||
}
|
||||
|
||||
static already_AddRefed<GeckoStyleContext>
|
||||
CreateStyleContextForAnimationValue(nsCSSPropertyID aProperty,
|
||||
const StyleAnimationValue& aValue,
|
||||
GeckoStyleContext* aBaseStyleContext)
|
||||
already_AddRefed<nsStyleContext>
|
||||
KeyframeEffectReadOnly::CreateStyleContextForAnimationValue(
|
||||
nsCSSPropertyID aProperty,
|
||||
const AnimationValue& aValue,
|
||||
GeckoStyleContext* aBaseStyleContext)
|
||||
{
|
||||
MOZ_ASSERT(aBaseStyleContext,
|
||||
"CreateStyleContextForAnimationValue needs to be called "
|
||||
"with a valid nsStyleContext");
|
||||
"with a valid GeckoStyleContext");
|
||||
|
||||
RefPtr<AnimValuesStyleRule> styleRule = new AnimValuesStyleRule();
|
||||
styleRule->AddValue(aProperty, aValue);
|
||||
styleRule->AddValue(aProperty, aValue.mGecko);
|
||||
|
||||
nsCOMArray<nsIStyleRule> rules;
|
||||
rules.AppendObject(styleRule);
|
||||
|
||||
MOZ_ASSERT(aBaseStyleContext->PresContext()->StyleSet()->IsGecko(),
|
||||
"ServoStyleSet should not use StyleAnimationValue for animations");
|
||||
nsStyleSet* styleSet =
|
||||
aBaseStyleContext->PresContext()->StyleSet()->AsGecko();
|
||||
|
||||
|
@ -1716,17 +1715,33 @@ CreateStyleContextForAnimationValue(nsCSSPropertyID aProperty,
|
|||
return styleContext.forget();
|
||||
}
|
||||
|
||||
void
|
||||
KeyframeEffectReadOnly::CalculateCumulativeChangeHint(
|
||||
nsStyleContext* aStyleContext)
|
||||
already_AddRefed<nsStyleContext>
|
||||
KeyframeEffectReadOnly::CreateStyleContextForAnimationValue(
|
||||
nsCSSPropertyID aProperty,
|
||||
const AnimationValue& aValue,
|
||||
const ServoStyleContext* aBaseStyleContext)
|
||||
{
|
||||
MOZ_ASSERT(aBaseStyleContext,
|
||||
"CreateStyleContextForAnimationValue needs to be called "
|
||||
"with a valid ServoStyleContext");
|
||||
|
||||
ServoStyleSet* styleSet =
|
||||
aBaseStyleContext->PresContext()->StyleSet()->AsServo();
|
||||
Element* elementForResolve =
|
||||
EffectCompositor::GetElementToRestyle(mTarget->mElement,
|
||||
mTarget->mPseudoType);
|
||||
MOZ_ASSERT(elementForResolve, "The target element shouldn't be null");
|
||||
return styleSet->ResolveServoStyleByAddingAnimation(elementForResolve,
|
||||
aBaseStyleContext,
|
||||
aValue.mServo);
|
||||
}
|
||||
|
||||
template<typename StyleType>
|
||||
void
|
||||
KeyframeEffectReadOnly::CalculateCumulativeChangeHint(StyleType* aStyleContext)
|
||||
{
|
||||
if (mDocument->IsStyledByServo()) {
|
||||
// FIXME (bug 1303235): Do this for Servo too
|
||||
return;
|
||||
}
|
||||
mCumulativeChangeHint = nsChangeHint(0);
|
||||
|
||||
auto* geckoContext = aStyleContext ? aStyleContext->AsGecko() : nullptr;
|
||||
for (const AnimationProperty& property : mProperties) {
|
||||
for (const AnimationPropertySegment& segment : property.mSegments) {
|
||||
// In case composite operation is not 'replace' or value is null,
|
||||
|
@ -1737,15 +1752,23 @@ KeyframeEffectReadOnly::CalculateCumulativeChangeHint(
|
|||
mCumulativeChangeHint = ~nsChangeHint_Hints_CanIgnoreIfNotVisible;
|
||||
return;
|
||||
}
|
||||
RefPtr<GeckoStyleContext> fromContext =
|
||||
RefPtr<nsStyleContext> fromContext =
|
||||
CreateStyleContextForAnimationValue(property.mProperty,
|
||||
segment.mFromValue.mGecko,
|
||||
geckoContext);
|
||||
segment.mFromValue,
|
||||
aStyleContext);
|
||||
if (!fromContext) {
|
||||
mCumulativeChangeHint = ~nsChangeHint_Hints_CanIgnoreIfNotVisible;
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<GeckoStyleContext> toContext =
|
||||
RefPtr<nsStyleContext> toContext =
|
||||
CreateStyleContextForAnimationValue(property.mProperty,
|
||||
segment.mToValue.mGecko,
|
||||
geckoContext);
|
||||
segment.mToValue,
|
||||
aStyleContext);
|
||||
if (!toContext) {
|
||||
mCumulativeChangeHint = ~nsChangeHint_Hints_CanIgnoreIfNotVisible;
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t equalStructs = 0;
|
||||
uint32_t samePointerStructs = 0;
|
||||
|
|
|
@ -259,10 +259,8 @@ public:
|
|||
|
||||
// Cumulative change hint on each segment for each property.
|
||||
// This is used for deciding the animation is paint-only.
|
||||
void CalculateCumulativeChangeHint(nsStyleContext* aStyleContext);
|
||||
void CalculateCumulativeChangeHint(const ServoStyleContext* aComputedValues)
|
||||
{
|
||||
}
|
||||
template<typename StyleType>
|
||||
void CalculateCumulativeChangeHint(StyleType* aStyleContext);
|
||||
|
||||
// Returns true if all of animation properties' change hints
|
||||
// can ignore painting if the animation is not visible.
|
||||
|
@ -453,6 +451,16 @@ private:
|
|||
const AnimationPropertySegment& aSegment,
|
||||
const ComputedTiming& aComputedTiming);
|
||||
|
||||
already_AddRefed<nsStyleContext> CreateStyleContextForAnimationValue(
|
||||
nsCSSPropertyID aProperty,
|
||||
const AnimationValue& aValue,
|
||||
GeckoStyleContext* aBaseStyleContext);
|
||||
|
||||
already_AddRefed<nsStyleContext> CreateStyleContextForAnimationValue(
|
||||
nsCSSPropertyID aProperty,
|
||||
const AnimationValue& aValue,
|
||||
const ServoStyleContext* aBaseStyleContext);
|
||||
|
||||
nsIFrame* GetAnimationFrame() const;
|
||||
|
||||
bool CanThrottle() const;
|
||||
|
|
Загрузка…
Ссылка в новой задаче