mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1055285 part 3: Implement animation for 'object-position' property. r=heycam
This commit is contained in:
parent
e1c8e93f24
commit
cdaccd881b
@ -558,6 +558,15 @@ StyleAnimationValue::ComputeDistance(nsCSSProperty aProperty,
|
|||||||
aDistance = sqrt(difflen * difflen + diffpct * diffpct);
|
aDistance = sqrt(difflen * difflen + diffpct * diffpct);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case eUnit_ObjectPosition: {
|
||||||
|
const nsCSSValue* position1 = aStartValue.GetCSSValueValue();
|
||||||
|
const nsCSSValue* position2 = aEndValue.GetCSSValueValue();
|
||||||
|
double squareDistance =
|
||||||
|
CalcPositionSquareDistance(*position1,
|
||||||
|
*position2);
|
||||||
|
aDistance = sqrt(squareDistance);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
case eUnit_CSSValuePair: {
|
case eUnit_CSSValuePair: {
|
||||||
const nsCSSValuePair *pair1 = aStartValue.GetCSSValuePairValue();
|
const nsCSSValuePair *pair1 = aStartValue.GetCSSValuePairValue();
|
||||||
const nsCSSValuePair *pair2 = aEndValue.GetCSSValuePairValue();
|
const nsCSSValuePair *pair2 = aEndValue.GetCSSValuePairValue();
|
||||||
@ -2067,6 +2076,18 @@ StyleAnimationValue::AddWeighted(nsCSSProperty aProperty,
|
|||||||
aResultValue.SetAndAdoptCSSValueValue(val, eUnit_Calc);
|
aResultValue.SetAndAdoptCSSValueValue(val, eUnit_Calc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case eUnit_ObjectPosition: {
|
||||||
|
const nsCSSValue* position1 = aValue1.GetCSSValueValue();
|
||||||
|
const nsCSSValue* position2 = aValue2.GetCSSValueValue();
|
||||||
|
|
||||||
|
nsAutoPtr<nsCSSValue> result(new nsCSSValue);
|
||||||
|
AddPositions(aCoeff1, *position1,
|
||||||
|
aCoeff2, *position2, *result);
|
||||||
|
|
||||||
|
aResultValue.SetAndAdoptCSSValueValue(result.forget(),
|
||||||
|
eUnit_ObjectPosition);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
case eUnit_CSSValuePair: {
|
case eUnit_CSSValuePair: {
|
||||||
const nsCSSValuePair *pair1 = aValue1.GetCSSValuePairValue();
|
const nsCSSValuePair *pair1 = aValue1.GetCSSValuePairValue();
|
||||||
const nsCSSValuePair *pair2 = aValue2.GetCSSValuePairValue();
|
const nsCSSValuePair *pair2 = aValue2.GetCSSValuePairValue();
|
||||||
@ -2609,7 +2630,8 @@ StyleAnimationValue::UncomputeValue(nsCSSProperty aProperty,
|
|||||||
const StyleAnimationValue& aComputedValue,
|
const StyleAnimationValue& aComputedValue,
|
||||||
nsCSSValue& aSpecifiedValue)
|
nsCSSValue& aSpecifiedValue)
|
||||||
{
|
{
|
||||||
switch (aComputedValue.GetUnit()) {
|
Unit unit = aComputedValue.GetUnit();
|
||||||
|
switch (unit) {
|
||||||
case eUnit_Normal:
|
case eUnit_Normal:
|
||||||
aSpecifiedValue.SetNormalValue();
|
aSpecifiedValue.SetNormalValue();
|
||||||
break;
|
break;
|
||||||
@ -2642,9 +2664,15 @@ StyleAnimationValue::UncomputeValue(nsCSSProperty aProperty,
|
|||||||
// colors can be alone, or part of a paint server
|
// colors can be alone, or part of a paint server
|
||||||
aSpecifiedValue.SetColorValue(aComputedValue.GetColorValue());
|
aSpecifiedValue.SetColorValue(aComputedValue.GetColorValue());
|
||||||
break;
|
break;
|
||||||
case eUnit_Calc: {
|
case eUnit_Calc:
|
||||||
|
case eUnit_ObjectPosition: {
|
||||||
nsCSSValue* val = aComputedValue.GetCSSValueValue();
|
nsCSSValue* val = aComputedValue.GetCSSValueValue();
|
||||||
NS_ABORT_IF_FALSE(val->GetUnit() == eCSSUnit_Calc, "unexpected unit");
|
// Sanity-check that the underlying unit in the nsCSSValue is what we
|
||||||
|
// expect for our StyleAnimationValue::Unit:
|
||||||
|
MOZ_ASSERT((unit == eUnit_Calc && val->GetUnit() == eCSSUnit_Calc) ||
|
||||||
|
(unit == eUnit_ObjectPosition &&
|
||||||
|
val->GetUnit() == eCSSUnit_Array),
|
||||||
|
"unexpected unit");
|
||||||
aSpecifiedValue = *val;
|
aSpecifiedValue = *val;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3180,6 +3208,18 @@ StyleAnimationValue::ExtractComputedValue(nsCSSProperty aProperty,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case eCSSProperty_object_position: {
|
||||||
|
const nsStylePosition* stylePos =
|
||||||
|
static_cast<const nsStylePosition*>(styleStruct);
|
||||||
|
|
||||||
|
nsAutoPtr<nsCSSValue> val(new nsCSSValue);
|
||||||
|
SetPositionValue(stylePos->mObjectPosition, *val);
|
||||||
|
|
||||||
|
aComputedValue.SetAndAdoptCSSValueValue(val.forget(),
|
||||||
|
eUnit_ObjectPosition);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case eCSSProperty_background_position: {
|
case eCSSProperty_background_position: {
|
||||||
const nsStyleBackground *bg =
|
const nsStyleBackground *bg =
|
||||||
static_cast<const nsStyleBackground*>(styleStruct);
|
static_cast<const nsStyleBackground*>(styleStruct);
|
||||||
@ -3574,6 +3614,9 @@ StyleAnimationValue::operator=(const StyleAnimationValue& aOther)
|
|||||||
mValue.mColor = aOther.mValue.mColor;
|
mValue.mColor = aOther.mValue.mColor;
|
||||||
break;
|
break;
|
||||||
case eUnit_Calc:
|
case eUnit_Calc:
|
||||||
|
case eUnit_ObjectPosition:
|
||||||
|
NS_ABORT_IF_FALSE(IsCSSValueUnit(mUnit),
|
||||||
|
"This clause is for handling nsCSSValue-backed units");
|
||||||
NS_ABORT_IF_FALSE(aOther.mValue.mCSSValue, "values may not be null");
|
NS_ABORT_IF_FALSE(aOther.mValue.mCSSValue, "values may not be null");
|
||||||
mValue.mCSSValue = new nsCSSValue(*aOther.mValue.mCSSValue);
|
mValue.mCSSValue = new nsCSSValue(*aOther.mValue.mCSSValue);
|
||||||
if (!mValue.mCSSValue) {
|
if (!mValue.mCSSValue) {
|
||||||
@ -3836,6 +3879,9 @@ StyleAnimationValue::operator==(const StyleAnimationValue& aOther) const
|
|||||||
case eUnit_Color:
|
case eUnit_Color:
|
||||||
return mValue.mColor == aOther.mValue.mColor;
|
return mValue.mColor == aOther.mValue.mColor;
|
||||||
case eUnit_Calc:
|
case eUnit_Calc:
|
||||||
|
case eUnit_ObjectPosition:
|
||||||
|
NS_ABORT_IF_FALSE(IsCSSValueUnit(mUnit),
|
||||||
|
"This clause is for handling nsCSSValue-backed units");
|
||||||
return *mValue.mCSSValue == *aOther.mValue.mCSSValue;
|
return *mValue.mCSSValue == *aOther.mValue.mCSSValue;
|
||||||
case eUnit_CSSValuePair:
|
case eUnit_CSSValuePair:
|
||||||
return *mValue.mCSSValuePair == *aOther.mValue.mCSSValuePair;
|
return *mValue.mCSSValuePair == *aOther.mValue.mCSSValuePair;
|
||||||
|
@ -214,6 +214,8 @@ public:
|
|||||||
eUnit_Color,
|
eUnit_Color,
|
||||||
eUnit_Calc, // nsCSSValue* (never null), always with a single
|
eUnit_Calc, // nsCSSValue* (never null), always with a single
|
||||||
// calc() expression that's either length or length+percent
|
// calc() expression that's either length or length+percent
|
||||||
|
eUnit_ObjectPosition, // nsCSSValue* (never null), always with a
|
||||||
|
// 4-entry nsCSSValue::Array
|
||||||
eUnit_CSSValuePair, // nsCSSValuePair* (never null)
|
eUnit_CSSValuePair, // nsCSSValuePair* (never null)
|
||||||
eUnit_CSSValueTriplet, // nsCSSValueTriplet* (never null)
|
eUnit_CSSValueTriplet, // nsCSSValueTriplet* (never null)
|
||||||
eUnit_CSSRect, // nsCSSRect* (never null)
|
eUnit_CSSRect, // nsCSSRect* (never null)
|
||||||
@ -374,7 +376,8 @@ private:
|
|||||||
aUnit == eUnit_Integer;
|
aUnit == eUnit_Integer;
|
||||||
}
|
}
|
||||||
static bool IsCSSValueUnit(Unit aUnit) {
|
static bool IsCSSValueUnit(Unit aUnit) {
|
||||||
return aUnit == eUnit_Calc;
|
return aUnit == eUnit_Calc ||
|
||||||
|
aUnit == eUnit_ObjectPosition;
|
||||||
}
|
}
|
||||||
static bool IsCSSValuePairUnit(Unit aUnit) {
|
static bool IsCSSValuePairUnit(Unit aUnit) {
|
||||||
return aUnit == eUnit_CSSValuePair;
|
return aUnit == eUnit_CSSValuePair;
|
||||||
|
@ -2540,8 +2540,8 @@ CSS_PROP_POSITION(
|
|||||||
"layout.css.object-fit-and-position.enabled",
|
"layout.css.object-fit-and-position.enabled",
|
||||||
0,
|
0,
|
||||||
kBackgroundPositionKTable,
|
kBackgroundPositionKTable,
|
||||||
CSS_PROP_NO_OFFSET,
|
offsetof(nsStylePosition, mObjectPosition),
|
||||||
eStyleAnimType_None) // XXXdholbert Use "_Custom", and implement animation
|
eStyleAnimType_Custom)
|
||||||
CSS_PROP_DISPLAY(
|
CSS_PROP_DISPLAY(
|
||||||
opacity,
|
opacity,
|
||||||
opacity,
|
opacity,
|
||||||
|
@ -182,6 +182,7 @@ var supported_properties = {
|
|||||||
"min-width": [ test_length_transition, test_percent_transition,
|
"min-width": [ test_length_transition, test_percent_transition,
|
||||||
test_length_percent_calc_transition,
|
test_length_percent_calc_transition,
|
||||||
test_length_clamped, test_percent_clamped ],
|
test_length_clamped, test_percent_clamped ],
|
||||||
|
"object-position": [ test_background_position_transition ],
|
||||||
"opacity" : [ test_float_zeroToOne_transition,
|
"opacity" : [ test_float_zeroToOne_transition,
|
||||||
// opacity is clamped in computed style
|
// opacity is clamped in computed style
|
||||||
// (not parsing/interpolation)
|
// (not parsing/interpolation)
|
||||||
@ -1813,7 +1814,7 @@ function test_background_size_transition(prop) {
|
|||||||
div.style.setProperty(prop, "contain", "");
|
div.style.setProperty(prop, "contain", "");
|
||||||
is(cs.getPropertyValue(prop), "contain",
|
is(cs.getPropertyValue(prop), "contain",
|
||||||
"property " + prop + ": can't interpolate 'contain'");
|
"property " + prop + ": can't interpolate 'contain'");
|
||||||
test_background_position_size_common(prop);
|
test_background_position_size_common(prop, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_background_position_transition(prop) {
|
function test_background_position_transition(prop) {
|
||||||
@ -1826,10 +1827,24 @@ function test_background_position_transition(prop) {
|
|||||||
is(cs.getPropertyValue(prop), "62.5% 85%",
|
is(cs.getPropertyValue(prop), "62.5% 85%",
|
||||||
"property " + prop + ": interpolation of percents");
|
"property " + prop + ": interpolation of percents");
|
||||||
check_distance(prop, "center 80%", "62.5% 85%", "bottom right");
|
check_distance(prop, "center 80%", "62.5% 85%", "bottom right");
|
||||||
test_background_position_size_common(prop);
|
|
||||||
|
var doesPropTakeListValues = (prop == "background-position");
|
||||||
|
|
||||||
|
test_background_position_size_common(prop, doesPropTakeListValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_background_position_size_common(prop) {
|
/**
|
||||||
|
* Common tests for 'background-position', 'background-size', and other
|
||||||
|
* properties that take CSS value-type 'position' or 'bg-size'.
|
||||||
|
*
|
||||||
|
* @arg prop The name of the property
|
||||||
|
* @arg doesPropTakeListValues
|
||||||
|
* If false, the property is assumed to just take a single 'position' or
|
||||||
|
* 'bg-size' value. If true, the property is assumed to also accept
|
||||||
|
* comma-separated list of such values.
|
||||||
|
*/
|
||||||
|
function test_background_position_size_common(prop, doesPropTakeListValues) {
|
||||||
|
// Test non-list values
|
||||||
div.style.setProperty("transition-property", "none", "");
|
div.style.setProperty("transition-property", "none", "");
|
||||||
div.style.setProperty(prop, "40% 0%", "");
|
div.style.setProperty(prop, "40% 0%", "");
|
||||||
is(cs.getPropertyValue(prop), "40% 0%",
|
is(cs.getPropertyValue(prop), "40% 0%",
|
||||||
@ -1859,6 +1874,9 @@ function test_background_position_size_common(prop) {
|
|||||||
is(cs.getPropertyValue(prop), "20px 30px",
|
is(cs.getPropertyValue(prop), "20px 30px",
|
||||||
"property " + prop + ": interpolation of lengths");
|
"property " + prop + ": interpolation of lengths");
|
||||||
check_distance(prop, "10px 40px", "20px 30px", "50px 0");
|
check_distance(prop, "10px 40px", "20px 30px", "50px 0");
|
||||||
|
|
||||||
|
// Test list values, if appropriate
|
||||||
|
if (doesPropTakeListValues) {
|
||||||
div.style.setProperty(prop, "10px 40px, 50px 50px, 30px 20px", "");
|
div.style.setProperty(prop, "10px 40px, 50px 50px, 30px 20px", "");
|
||||||
is(cs.getPropertyValue(prop), "10px 40px, 50px 50px, 30px 20px",
|
is(cs.getPropertyValue(prop), "10px 40px, 50px 50px, 30px 20px",
|
||||||
"property " + prop + ": computed value before transition");
|
"property " + prop + ": computed value before transition");
|
||||||
@ -1896,6 +1914,7 @@ function test_background_position_size_common(prop) {
|
|||||||
"calc(33px + 15%) calc(30px + 35%), calc(6px + 5%) calc(4px + 24%), calc(17px + 14%) calc(28px + 10%)",
|
"calc(33px + 15%) calc(30px + 35%), calc(6px + 5%) calc(4px + 24%), calc(17px + 14%) calc(28px + 10%)",
|
||||||
"12px 20%, calc(20%) calc(16px + 60%), calc(8px + 20%) calc(40px + 16%)");
|
"12px 20%, calc(20%) calc(16px + 60%), calc(8px + 20%) calc(40px + 16%)");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function test_transform_transition(prop) {
|
function test_transform_transition(prop) {
|
||||||
is(prop, "transform", "Unexpected transform property! Test needs to be fixed");
|
is(prop, "transform", "Unexpected transform property! Test needs to be fixed");
|
||||||
|
Loading…
Reference in New Issue
Block a user