mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 972703 - Clamp massive transformed overflow areas to the middle of the representable range instead of the start. r=roc
This commit is contained in:
parent
b5987bbf40
commit
d41ee4ab21
@ -1639,7 +1639,7 @@ nsLayoutUtils::ChangeMatrixBasis(const gfxPoint3D &aOrigin,
|
||||
*
|
||||
* @param aVal The value to constrain (in/out)
|
||||
*/
|
||||
static void ConstrainToCoordValues(gfxFloat &aVal)
|
||||
static void ConstrainToCoordValues(gfxFloat& aVal)
|
||||
{
|
||||
if (aVal <= nscoord_MIN)
|
||||
aVal = nscoord_MIN;
|
||||
@ -1647,6 +1647,32 @@ static void ConstrainToCoordValues(gfxFloat &aVal)
|
||||
aVal = nscoord_MAX;
|
||||
}
|
||||
|
||||
static void ConstrainToCoordValues(gfxFloat& aStart, gfxFloat& aSize)
|
||||
{
|
||||
gfxFloat max = aStart + aSize;
|
||||
|
||||
// Clamp the end points to within nscoord range
|
||||
ConstrainToCoordValues(aStart);
|
||||
ConstrainToCoordValues(max);
|
||||
|
||||
aSize = max - aStart;
|
||||
// If the width if still greater than the max nscoord, then bring both
|
||||
// endpoints in by the same amount until it fits.
|
||||
if (aSize > nscoord_MAX) {
|
||||
gfxFloat excess = aSize - nscoord_MAX;
|
||||
excess /= 2;
|
||||
|
||||
aStart += excess;
|
||||
aSize = nscoord_MAX;
|
||||
} else if (aSize < nscoord_MIN) {
|
||||
gfxFloat excess = aSize - nscoord_MIN;
|
||||
excess /= 2;
|
||||
|
||||
aStart -= excess;
|
||||
aSize = nscoord_MIN;
|
||||
}
|
||||
}
|
||||
|
||||
nsRect
|
||||
nsLayoutUtils::RoundGfxRectToAppRect(const gfxRect &aRect, float aFactor)
|
||||
{
|
||||
@ -1655,10 +1681,8 @@ nsLayoutUtils::RoundGfxRectToAppRect(const gfxRect &aRect, float aFactor)
|
||||
scaledRect.ScaleRoundOut(aFactor);
|
||||
|
||||
/* We now need to constrain our results to the max and min values for coords. */
|
||||
ConstrainToCoordValues(scaledRect.x);
|
||||
ConstrainToCoordValues(scaledRect.y);
|
||||
ConstrainToCoordValues(scaledRect.width);
|
||||
ConstrainToCoordValues(scaledRect.height);
|
||||
ConstrainToCoordValues(scaledRect.x, scaledRect.width);
|
||||
ConstrainToCoordValues(scaledRect.y, scaledRect.height);
|
||||
|
||||
/* Now typecast everything back. This is guaranteed to be safe. */
|
||||
return nsRect(nscoord(scaledRect.X()), nscoord(scaledRect.Y()),
|
||||
|
Loading…
Reference in New Issue
Block a user