Bug 1767126 - Change the return type of AnimationValue::GetScaleValue() to MatrixScales. r=botond

Differential Revision: https://phabricator.services.mozilla.com/D147575
This commit is contained in:
Razvan Cojocaru 2022-05-31 19:55:30 +00:00
parent d99cb01622
commit 5370a472bc
4 changed files with 18 additions and 17 deletions

View file

@ -1953,8 +1953,8 @@ bool KeyframeEffect::ContainsAnimatedScale(const nsIFrame* aFrame) const {
AnimationValue baseStyle = BaseStyle(prop.mProperty);
if (!baseStyle.IsNull()) {
gfx::Size size = baseStyle.GetScaleValue(aFrame);
if (size != gfx::Size(1.0f, 1.0f)) {
gfx::MatrixScales size = baseStyle.GetScaleValue(aFrame);
if (size != gfx::MatrixScales()) {
return true;
}
}
@ -1964,14 +1964,14 @@ bool KeyframeEffect::ContainsAnimatedScale(const nsIFrame* aFrame) const {
// really matter.
for (const AnimationPropertySegment& segment : prop.mSegments) {
if (!segment.mFromValue.IsNull()) {
gfx::Size from = segment.mFromValue.GetScaleValue(aFrame);
if (from != gfx::Size(1.0f, 1.0f)) {
gfx::MatrixScales from = segment.mFromValue.GetScaleValue(aFrame);
if (from != gfx::MatrixScales()) {
return true;
}
}
if (!segment.mToValue.IsNull()) {
gfx::Size to = segment.mToValue.GetScaleValue(aFrame);
if (to != gfx::Size(1.0f, 1.0f)) {
gfx::MatrixScales to = segment.mToValue.GetScaleValue(aFrame);
if (to != gfx::MatrixScales()) {
return true;
}
}

View file

@ -366,12 +366,12 @@ using MinAndMaxScale = std::pair<Size, Size>;
static inline void UpdateMinMaxScale(const nsIFrame* aFrame,
const AnimationValue& aValue,
MinAndMaxScale& aMinAndMaxScale) {
Size size = aValue.GetScaleValue(aFrame);
MatrixScales size = aValue.GetScaleValue(aFrame);
Size& minScale = aMinAndMaxScale.first;
Size& maxScale = aMinAndMaxScale.second;
minScale = Min(minScale, size);
maxScale = Max(maxScale, size);
minScale = Min(minScale, {size.xScale, size.yScale});
maxScale = Max(maxScale, {size.xScale, size.yScale});
}
// The final transform matrix is calculated by merging the final results of each

View file

@ -110,24 +110,25 @@ const mozilla::StylePositionOrAuto& AnimationValue::GetOffsetAnchorProperty()
return *Servo_AnimationValue_GetOffsetAnchor(mServo);
}
Size AnimationValue::GetScaleValue(const nsIFrame* aFrame) const {
MatrixScales AnimationValue::GetScaleValue(const nsIFrame* aFrame) const {
using namespace nsStyleTransformMatrix;
switch (Servo_AnimationValue_GetPropertyId(mServo)) {
case eCSSProperty_scale: {
const StyleScale& scale = GetScaleProperty();
return scale.IsNone() ? Size(1.0, 1.0)
: Size(scale.AsScale()._0, scale.AsScale()._1);
return scale.IsNone()
? MatrixScales()
: MatrixScales(scale.AsScale()._0, scale.AsScale()._1);
}
case eCSSProperty_rotate:
case eCSSProperty_translate:
return Size(1.0, 1.0);
return MatrixScales();
case eCSSProperty_transform:
break;
default:
MOZ_ASSERT_UNREACHABLE(
"Should only need to check in transform properties");
return Size(1.0, 1.0);
return MatrixScales();
}
TransformReferenceBox refBox(aFrame);
@ -138,9 +139,9 @@ Size AnimationValue::GetScaleValue(const nsIFrame* aFrame) const {
Matrix transform2d;
bool canDraw2D = t.CanDraw2D(&transform2d);
if (!canDraw2D) {
return Size();
return MatrixScales(0, 0);
}
return transform2d.ScaleFactors().ToSize();
return transform2d.ScaleFactors();
}
void AnimationValue::SerializeSpecifiedValue(nsCSSPropertyID aProperty,

View file

@ -83,7 +83,7 @@ struct AnimationValue {
const mozilla::StylePositionOrAuto& GetOffsetAnchorProperty() const;
// Return the scale for mServo, which is calculated with reference to aFrame.
mozilla::gfx::Size GetScaleValue(const nsIFrame* aFrame) const;
mozilla::gfx::MatrixScales GetScaleValue(const nsIFrame* aFrame) const;
// Uncompute this AnimationValue and then serialize it.
void SerializeSpecifiedValue(nsCSSPropertyID aProperty,