summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@wolfbeast.com>2019-03-23 08:15:18 +0100
committerGitHub <noreply@github.com>2019-03-23 08:15:18 +0100
commitf33a272de2175d3b631e2f9acd24f63fcae38d2b (patch)
treee5f063168e8d948c0e2d0684fa48e826db98b1b7
parentcda6937fc2072c46f0a43e693987ba3607e94977 (diff)
parent96dfb2e6dfe677c3b79d6fc5710057a848007db1 (diff)
downloadUXP-f33a272de2175d3b631e2f9acd24f63fcae38d2b.tar
UXP-f33a272de2175d3b631e2f9acd24f63fcae38d2b.tar.gz
UXP-f33a272de2175d3b631e2f9acd24f63fcae38d2b.tar.lz
UXP-f33a272de2175d3b631e2f9acd24f63fcae38d2b.tar.xz
UXP-f33a272de2175d3b631e2f9acd24f63fcae38d2b.zip
Merge pull request #1019 from JustOff/PR_nsLayoutUtils_AddPercents
The result of adding any percentage factor to a size that is zero should also be zero
-rw-r--r--layout/base/nsLayoutUtils.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h
index 63253fd10..0a82dbf6a 100644
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -1439,13 +1439,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));
}