зеркало из https://github.com/mozilla/gecko-dev.git
Bug 665597 - Use saturating calculations when adding the margin to the scrollable overflow rect. part=4/5 r=roc
This commit is contained in:
Родитель
c883373e7b
Коммит
554bbb0b27
|
@ -81,6 +81,44 @@ struct NS_GFX nsRect :
|
|||
}
|
||||
#endif
|
||||
|
||||
// A version of Inflate that caps the values to the nscoord range.
|
||||
// x & y is capped at the minimum value nscoord_MIN and
|
||||
// width & height is capped at the maximum value nscoord_MAX.
|
||||
void SaturatingInflate(const nsMargin& aMargin)
|
||||
{
|
||||
#ifdef NS_COORD_IS_FLOAT
|
||||
Inflate(aMargin);
|
||||
#else
|
||||
PRInt64 nx = PRInt64(x) - aMargin.left;
|
||||
if (nx < nscoord_MIN) {
|
||||
NS_WARNING("Underflowed nscoord_MIN in conversion to nscoord x");
|
||||
nx = nscoord_MIN;
|
||||
}
|
||||
x = nscoord(nx);
|
||||
|
||||
PRInt64 ny = PRInt64(y) - aMargin.top;
|
||||
if (ny < nscoord_MIN) {
|
||||
NS_WARNING("Underflowed nscoord_MIN in conversion to nscoord y");
|
||||
ny = nscoord_MIN;
|
||||
}
|
||||
y = nscoord(ny);
|
||||
|
||||
PRInt64 w = PRInt64(width) + PRInt64(aMargin.left) + aMargin.right;
|
||||
if (w > nscoord_MAX) {
|
||||
NS_WARNING("Overflowed nscoord_MAX in conversion to nscoord width");
|
||||
w = nscoord_MAX;
|
||||
}
|
||||
width = nscoord(w);
|
||||
|
||||
PRInt64 h = PRInt64(height) + PRInt64(aMargin.top) + aMargin.bottom;
|
||||
if (h > nscoord_MAX) {
|
||||
NS_WARNING("Overflowed nscoord_MAX in conversion to nscoord height");
|
||||
h = nscoord_MAX;
|
||||
}
|
||||
height = nscoord(h);
|
||||
#endif
|
||||
}
|
||||
|
||||
// We have saturating versions of all the Union methods. These avoid
|
||||
// overflowing nscoord values in the 'width' and 'height' fields by
|
||||
// clamping the width and height values to nscoord_MAX if necessary.
|
||||
|
|
|
@ -6605,9 +6605,9 @@ nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas,
|
|||
nsRect marginBounds(bounds);
|
||||
nsMargin margin = GetUsedMargin();
|
||||
ApplySkipSides(margin);
|
||||
marginBounds.Inflate(margin);
|
||||
marginBounds.SaturatingInflate(margin);
|
||||
nsRect& so = aOverflowAreas.ScrollableOverflow();
|
||||
so.UnionRectEdges(so, marginBounds);
|
||||
so.SaturatingUnionRectEdges(so, marginBounds);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче