Skip to content

Commit

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

https://bugs.webkit.org/show_bug.cgi?id=257030

Reviewed by Alan Baradlay.

Merge: https://chromium.googlesource.com/chromium/src.git/+/4a931c534e4b27b809b67d0207c7dc0d8a28faf0

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

The test is already imported:
imported/blink/fast/pagination/short-pages-tall-content.html

* Source/WebCore/rendering/RenderMultiColumnSet.cpp:
(RenderMultiColumnSet::columnCount):

Canonical link: https://commits.webkit.org/264667@main
  • 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)
++count;
ASSERT(count >= 1);
return count;
}
Expand Down

0 comments on commit 2b08248

Please sign in to comment.