Bug 1469000: Fix image to layout transform for invalidation. r=aosmond

When computing image to layout transforms for invalidation, use the actual
intrinsic size of the source image, instead of the layout intrinsic size, which
may be scaled by ResponsiveImageSelector since bug 1149357.

I have absolutely no idea how to write a test for this, suggestions welcome.

MozReview-Commit-ID: LP6C9fSvMi2

--HG--
extra : rebase_source : c7c7b70dff3ba1c7514fceb58d0bb6f26374c8a8
This commit is contained in:
Emilio Cobos Álvarez 2018-06-19 17:51:53 +02:00
Родитель ac26190e4f
Коммит 4e021661e1
1 изменённых файлов: 12 добавлений и 15 удалений

Просмотреть файл

@ -384,25 +384,22 @@ nsImageFrame::GetSourceToDestTransform(nsTransform2D& aTransform)
// XXXbz does this introduce rounding errors because of the cast to
// float? Should we just manually add that stuff in every time
// instead?
aTransform.SetToTranslate(float(destRect.x),
float(destRect.y));
aTransform.SetToTranslate(float(destRect.x), float(destRect.y));
// Set the scale factors, based on destRect and intrinsic size.
if (mIntrinsicSize.width.GetUnit() == eStyleUnit_Coord &&
mIntrinsicSize.width.GetCoordValue() != 0 &&
mIntrinsicSize.height.GetUnit() == eStyleUnit_Coord &&
mIntrinsicSize.height.GetCoordValue() != 0 &&
mIntrinsicSize.width.GetCoordValue() != destRect.width &&
mIntrinsicSize.height.GetCoordValue() != destRect.height) {
aTransform.SetScale(float(destRect.width) /
float(mIntrinsicSize.width.GetCoordValue()),
float(destRect.height) /
float(mIntrinsicSize.height.GetCoordValue()));
return true;
// NOTE(emilio): This intrinsicSize is not the same as the layout intrinsic
// size (mIntrinsicSize), which can be scaled due to ResponsiveImageSelector,
// see ScaleIntrinsicSizeForDensity.
nsSize intrinsicSize;
if (!mImage ||
!NS_SUCCEEDED(mImage->GetIntrinsicSize(&intrinsicSize)) ||
intrinsicSize.IsEmpty()) {
return false;
}
return false;
aTransform.SetScale(float(destRect.width) / float(intrinsicSize.width),
float(destRect.height) / float(intrinsicSize.height));
return true;
}
// This function checks whether the given request is the current request for our