Skip to content


Browse files Browse the repository at this point in the history
[Multicolumn] Avoid floating point when calculating the actual column…
… count

Reviewed by Alan Baradlay.


This patch get rid of 'floating point' calculation for column count,
which can be error-prone.

The test is already imported:

* Source/WebCore/rendering/RenderMultiColumnSet.cpp:

Canonical link:
  • Loading branch information
Ahmad-S792 authored and Ahmad Saleem committed May 30, 2023
1 parent a9ba148 commit 2b08248
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Source/WebCore/rendering/RenderMultiColumnSet.cpp
Expand Up @@ -456,7 +456,10 @@ unsigned RenderMultiColumnSet::columnCount() const
if (logicalHeightInColumns <= 0)
return 1;

unsigned count = ceilf(static_cast<float>(logicalHeightInColumns) / computedColumnHeight);
unsigned count = (logicalHeightInColumns / computedColumnHeight).floor();
// logicalHeightInColumns may be saturated, so detect the remainder manually.
if (count * computedColumnHeight < logicalHeightInColumns)
ASSERT(count >= 1);
return count;
Expand Down

0 comments on commit 2b08248

Please sign in to comment.