The result of adding any percentage factor to a size that is zero should also be zero

master
Fedor 2019-05-20 09:01:12 +03:00
parent 8fe1fdda57
commit 01b53534c3
1 changed files with 5 additions and 4 deletions

View File

@ -1439,13 +1439,14 @@ public:
/** /**
* This function increases an initial intrinsic size, 'aCurrent', according * This function increases an initial intrinsic size, 'aCurrent', according
* to the given 'aPercent', such that the size-increase makes up exactly * to the given 'aPercent', such that the size-increase makes up exactly
* 'aPercent' percent of the returned value. If 'aPercent' is less than * 'aPercent' percent of the returned value. If 'aPercent' or 'aCurrent' are
* or equal to zero the original 'aCurrent' value is returned. If 'aPercent' * less than or equal to zero the original 'aCurrent' value is returned.
* is greater than or equal to 1.0 the value nscoord_MAX 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) 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 return MOZ_UNLIKELY(aPercent >= 1.0f) ? nscoord_MAX
: NSToCoordRound(float(aCurrent) / (1.0f - aPercent)); : NSToCoordRound(float(aCurrent) / (1.0f - aPercent));
} }