From 731ab384394a2179872d6c97024953545da9a650 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Wed, 10 May 2017 11:06:19 +0800 Subject: [PATCH] Bug 1334036 - Part 10: Return AnimationValue for BaseStyle. r=hiro 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 --HG-- extra : rebase_source : 42284c5fe8b8135910cde44b0815eb475ca2f1cc --- dom/animation/KeyframeEffectReadOnly.cpp | 7 ++++--- dom/animation/KeyframeEffectReadOnly.h | 14 +++++++++++--- layout/base/nsLayoutUtils.cpp | 7 ++----- layout/painting/nsDisplayList.cpp | 6 ++---- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/dom/animation/KeyframeEffectReadOnly.cpp b/dom/animation/KeyframeEffectReadOnly.cpp index 1db386eec592..fceb60ce8779 100644 --- a/dom/animation/KeyframeEffectReadOnly.cpp +++ b/dom/animation/KeyframeEffectReadOnly.cpp @@ -427,7 +427,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. - result = BaseStyle(aProperty); + result = BaseStyle(aProperty).mGecko; } return result; @@ -1297,7 +1297,8 @@ KeyframeEffectReadOnly::GetKeyframes(JSContext*& aCx, // handle null nsCSSValues for longhand properties. DebugOnly uncomputeResult = StyleAnimationValue::UncomputeValue( - propertyValue.mProperty, Move(BaseStyle(propertyValue.mProperty)), + propertyValue.mProperty, + Move(BaseStyle(propertyValue.mProperty).mGecko), cssValue); MOZ_ASSERT(uncomputeResult, @@ -1848,7 +1849,7 @@ KeyframeEffectReadOnly::ContainsAnimatedScale(const nsIFrame* aFrame) const 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. diff --git a/dom/animation/KeyframeEffectReadOnly.h b/dom/animation/KeyframeEffectReadOnly.h index fbc294ed7763..edf21c862f04 100644 --- a/dom/animation/KeyframeEffectReadOnly.h +++ b/dom/animation/KeyframeEffectReadOnly.h @@ -279,10 +279,18 @@ public: // |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 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; } diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 0586ef8da02b..31b6d9339e9d 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -633,12 +633,9 @@ GetMinAndMaxScaleForAnimationProperty(const nsIFrame* aFrame, // 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) { diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 28b8c36cfba9..71a515a29a77 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -566,13 +566,11 @@ AddAnimationForProperty(nsIFrame* aFrame, const AnimationProperty& aProperty, // 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 {