Make distributeExtraLogicalHeightToRows return the consumed logical height
https://bugs.webkit.org/show_bug.cgi?id=81678
Reviewed by Tony Chang.
Small refactoring, no change in behavior.
* rendering/RenderTable.cpp:
(WebCore::RenderTable::distributeExtraLogicalHeight):
Remove the consumed logical height from the available height.
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::distributeExtraLogicalHeightToPercentRows):
(WebCore::RenderTableSection::distributeExtraLogicalHeightToAutoRows):
(WebCore::RenderTableSection::distributeRemainingExtraLogicalHeight):
Changed those method to not return anything but remove from the available width.
(WebCore::RenderTableSection::distributeExtraLogicalHeightToRows):
Return the consumed logical height.
* rendering/RenderTableSection.h:
Updated the previous distribute functions signature and the comment about
the returned value from distributeExtraLogicalHeightToRows.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@111435 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/rendering/RenderTableSection.cpp b/Source/WebCore/rendering/RenderTableSection.cpp
index 0d799cb..e85e80b 100644
--- a/Source/WebCore/rendering/RenderTableSection.cpp
+++ b/Source/WebCore/rendering/RenderTableSection.cpp
@@ -424,14 +424,14 @@
setNeedsLayout(false);
}
-int RenderTableSection::distributeExtraLogicalHeightToPercentRows(int extraLogicalHeight, int totalPercent)
+void RenderTableSection::distributeExtraLogicalHeightToPercentRows(int& extraLogicalHeight, int totalPercent)
{
if (!totalPercent)
- return extraLogicalHeight;
+ return;
unsigned totalRows = m_grid.size();
int totalHeight = m_rowPos[totalRows] + extraLogicalHeight;
- int add = 0;
+ int totalLogicalHeightAdded = 0;
totalPercent = min(totalPercent, 100);
int rowHeight = m_rowPos[1] - m_rowPos[0];
for (unsigned r = 0; r < totalRows; ++r) {
@@ -440,56 +440,54 @@
// If toAdd is negative, then we don't want to shrink the row (this bug
// affected Outlook Web Access).
toAdd = max(0, toAdd);
- add += toAdd;
+ totalLogicalHeightAdded += toAdd;
extraLogicalHeight -= toAdd;
totalPercent -= m_grid[r].logicalHeight.percent();
}
ASSERT(totalRows >= 1);
if (r < totalRows - 1)
rowHeight = m_rowPos[r + 2] - m_rowPos[r + 1];
- m_rowPos[r + 1] += add;
+ m_rowPos[r + 1] += totalLogicalHeightAdded;
}
- return extraLogicalHeight;
}
-int RenderTableSection::distributeExtraLogicalHeightToAutoRows(int extraLogicalHeight, unsigned autoRowsCount)
+void RenderTableSection::distributeExtraLogicalHeightToAutoRows(int& extraLogicalHeight, unsigned autoRowsCount)
{
if (!autoRowsCount)
- return extraLogicalHeight;
+ return;
- int add = 0;
+ int totalLogicalHeightAdded = 0;
for (unsigned r = 0; r < m_grid.size(); ++r) {
if (autoRowsCount > 0 && m_grid[r].logicalHeight.isAuto()) {
// Recomputing |extraLogicalHeightForRow| guarantees that we properly ditribute round |extraLogicalHeight|.
int extraLogicalHeightForRow = extraLogicalHeight / autoRowsCount;
- add += extraLogicalHeightForRow;
+ totalLogicalHeightAdded += extraLogicalHeightForRow;
extraLogicalHeight -= extraLogicalHeightForRow;
--autoRowsCount;
}
- m_rowPos[r + 1] += add;
+ m_rowPos[r + 1] += totalLogicalHeightAdded;
}
- return extraLogicalHeight;
}
-int RenderTableSection::distributeRemainingExtraLogicalHeight(int extraLogicalHeight)
+void RenderTableSection::distributeRemainingExtraLogicalHeight(int& extraLogicalHeight)
{
unsigned totalRows = m_grid.size();
if (extraLogicalHeight <= 0 || !m_rowPos[totalRows])
- return extraLogicalHeight;
+ return;
// FIXME: m_rowPos[totalRows] - m_rowPos[0] is the total rows' size.
int totalRowSize = m_rowPos[totalRows];
- int add = 0;
+ int totalLogicalHeightAdded = 0;
int previousRowPosition = m_rowPos[0];
for (unsigned r = 0; r < totalRows; r++) {
// weight with the original height
- add += extraLogicalHeight * (m_rowPos[r + 1] - previousRowPosition) / totalRowSize;
+ totalLogicalHeightAdded += extraLogicalHeight * (m_rowPos[r + 1] - previousRowPosition) / totalRowSize;
previousRowPosition = m_rowPos[r + 1];
- m_rowPos[r + 1] += add;
+ m_rowPos[r + 1] += totalLogicalHeightAdded;
}
- return extraLogicalHeight;
+ extraLogicalHeight -= totalLogicalHeightAdded;
}
int RenderTableSection::distributeExtraLogicalHeightToRows(int extraLogicalHeight)
@@ -514,10 +512,10 @@
}
int remainingExtraLogicalHeight = extraLogicalHeight;
- remainingExtraLogicalHeight = distributeExtraLogicalHeightToPercentRows(remainingExtraLogicalHeight, totalPercent);
- remainingExtraLogicalHeight = distributeExtraLogicalHeightToAutoRows(remainingExtraLogicalHeight, autoRowsCount);
- remainingExtraLogicalHeight = distributeRemainingExtraLogicalHeight(remainingExtraLogicalHeight);
- return remainingExtraLogicalHeight;
+ distributeExtraLogicalHeightToPercentRows(remainingExtraLogicalHeight, totalPercent);
+ distributeExtraLogicalHeightToAutoRows(remainingExtraLogicalHeight, autoRowsCount);
+ distributeRemainingExtraLogicalHeight(remainingExtraLogicalHeight);
+ return extraLogicalHeight - remainingExtraLogicalHeight;
}
void RenderTableSection::layoutRows()