Bug 1338108 - The result of adding any percentage factor to a size that is zero should also be zero. r=dholbert

MozReview-Commit-ID: OzOCjvcz0A
This commit is contained in:
Mats Palmgren 2017-04-06 20:17:34 +02:00
Родитель 9178a1fa06
Коммит 14f1a284bb
1 изменённых файлов: 5 добавлений и 4 удалений

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

@ -1450,13 +1450,14 @@ public:
/**
* This function increases an initial intrinsic size, 'aCurrent', according
* to the given 'aPercent', such that the size-increase makes up exactly
* 'aPercent' percent of the returned value. If 'aPercent' is less than
* or equal to zero the original 'aCurrent' value is returned. If 'aPercent'
* is greater than or equal to 1.0 the value nscoord_MAX is returned.
* 'aPercent' percent of the returned value. If 'aPercent' or 'aCurrent' are
* less than or equal to zero the original 'aCurrent' value is returned.
* If 'aPercent' is greater than or equal to 1.0 the value nscoord_MAX is
* returned.
*/
static nscoord AddPercents(nscoord aCurrent, float aPercent)
{
if (aPercent > 0.0f) {
if (aPercent > 0.0f && aCurrent > 0) {
return MOZ_UNLIKELY(aPercent >= 1.0f) ? nscoord_MAX
: NSToCoordRound(float(aCurrent) / (1.0f - aPercent));
}