Bug 1259285 - Part1 - Move CSS/Web Animations-specific visibility handling. r=birtles

MozReview-Commit-ID: 5ZYUhvI1cqV

--HG--
extra : transplant_source : %85%01%5C%91%EB%C2%F9%F5a%82%5C%FCZKz%F7%2B%27%F7%9C
This commit is contained in:
Mantaroh Yoshinaga 2016-04-20 09:05:29 +09:00
parent d8c748eec4
commit 1a3a4d293d
7 changed files with 40 additions and 29 deletions

View File

@ -505,19 +505,6 @@ KeyframeUtils::GetAnimationPropertiesFromKeyframes(
MOZ_ASSERT(values.Length() == 1,
"Longhand properties should produce a single"
" StyleAnimationValue");
// 'visibility' requires special handling that is unique to CSS
// Transitions/CSS Animations/Web Animations (i.e. not SMIL) so we
// apply that here.
//
// Bug 1259285 - Move this code to StyleAnimationValue
if (pair.mProperty == eCSSProperty_visibility) {
MOZ_ASSERT(values[0].mValue.GetUnit() ==
StyleAnimationValue::eUnit_Enumerated,
"unexpected unit");
values[0].mValue.SetIntValue(values[0].mValue.GetIntValue(),
StyleAnimationValue::eUnit_Visibility);
}
}
for (auto& value : values) {

View File

@ -2261,15 +2261,6 @@ ComputeAnimationValue(nsCSSProperty aProperty,
aInput, false, aOutput)) {
return false;
}
// This matches TransExtractComputedValue in nsTransitionManager.cpp.
if (aProperty == eCSSProperty_visibility) {
MOZ_ASSERT(aOutput.GetUnit() == StyleAnimationValue::eUnit_Enumerated,
"unexpected unit");
aOutput.SetIntValue(aOutput.GetIntValue(),
StyleAnimationValue::eUnit_Visibility);
}
return true;
}

View File

@ -9,6 +9,7 @@
#include "mozilla/dom/SVGAnimationElement.h"
#include "mozilla/Move.h"
#include "nsISMILAttr.h"
#include "nsSMILCSSValueType.h"
#include "nsSMILParserUtils.h"
#include "nsSMILNullType.h"
#include "nsSMILTimedElement.h"
@ -384,6 +385,15 @@ nsSMILAnimationFunction::InterpolateResult(const nsSMILValueArray& aValues,
nsresult rv = NS_OK;
nsSMILCalcMode calcMode = GetCalcMode();
// Force discrete calcMode for visibility since StyleAnimationValue will
// try to interpolate it using the special clamping behavior defined for
// CSS.
if (nsSMILCSSValueType::PropertyFromValue(aValues[0])
== eCSSProperty_visibility) {
calcMode = CALC_DISCRETE;
}
if (calcMode != CALC_DISCRETE) {
// Get the normalised progress between adjacent values
const nsSMILValue* from = nullptr;

View File

@ -428,3 +428,19 @@ nsSMILCSSValueType::ValueToString(const nsSMILValue& aValue,
StyleAnimationValue::UncomputeValue(wrapper->mPropID,
wrapper->mCSSValue, aString);
}
// static
nsCSSProperty
nsSMILCSSValueType::PropertyFromValue(const nsSMILValue& aValue)
{
if (aValue.mType != &nsSMILCSSValueType::sSingleton) {
return eCSSProperty_UNKNOWN;
}
const ValueWrapper* wrapper = ExtractValueWrapper(aValue);
if (!wrapper) {
return eCSSProperty_UNKNOWN;
}
return wrapper->mPropID;
}

View File

@ -98,6 +98,16 @@ public:
*/
static bool ValueToString(const nsSMILValue& aValue, nsAString& aString);
/**
* Return the CSS property animated by the specified value.
*
* @param aValue The nsSMILValue to examine.
* @return The nsCSSProperty enum value of the property animated
* by |aValue|, or eCSSProperty_UNKNOWN if the type of
* |aValue| is not nsSMILCSSValueType.
*/
static nsCSSProperty PropertyFromValue(const nsSMILValue& aValue);
private:
// Private constructor: prevent instances beyond my singleton.
MOZ_CONSTEXPR nsSMILCSSValueType() {}

View File

@ -89,13 +89,6 @@ CommonAnimationManager<AnimationType>::ExtractComputedValueForTransition(
bool result = StyleAnimationValue::ExtractComputedValue(aProperty,
aStyleContext,
aComputedValue);
if (aProperty == eCSSProperty_visibility) {
MOZ_ASSERT(aComputedValue.GetUnit() ==
StyleAnimationValue::eUnit_Enumerated,
"unexpected unit");
aComputedValue.SetIntValue(aComputedValue.GetIntValue(),
StyleAnimationValue::eUnit_Visibility);
}
return result;
}

View File

@ -4012,6 +4012,10 @@ StyleAnimationValue::ExtractComputedValue(nsCSSProperty aProperty,
case eStyleAnimType_EnumU8:
aComputedValue.SetIntValue(*static_cast<const uint8_t*>(
StyleDataAtOffset(styleStruct, ssOffset)), eUnit_Enumerated);
if (aProperty == eCSSProperty_visibility) {
aComputedValue.SetIntValue(aComputedValue.GetIntValue(),
eUnit_Visibility);
}
return true;
case eStyleAnimType_float:
aComputedValue.SetFloatValue(*static_cast<const float*>(