Title: [111435] trunk/Source/WebCore
Revision
111435
Author
[email protected]
Date
2012-03-20 14:02:34 -0700 (Tue, 20 Mar 2012)

Log Message

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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (111434 => 111435)


--- trunk/Source/WebCore/ChangeLog	2012-03-20 20:56:39 UTC (rev 111434)
+++ trunk/Source/WebCore/ChangeLog	2012-03-20 21:02:34 UTC (rev 111435)
@@ -1,3 +1,29 @@
+2012-03-20  Julien Chaffraix  <[email protected]>
+
+        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.
+
 2012-03-20  Jacky Jiang  <[email protected]>
 
         [BlackBerry] Dijit crash WebCore::CookieManager::getRawCookies

Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (111434 => 111435)


--- trunk/Source/WebCore/rendering/RenderTable.cpp	2012-03-20 20:56:39 UTC (rev 111434)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp	2012-03-20 21:02:34 UTC (rev 111435)
@@ -306,7 +306,7 @@
 
     // FIXME: Distribute the extra logical height between all table sections instead of giving it all to the first one.
     if (RenderTableSection* section = topSection())
-        extraLogicalHeight = section->distributeExtraLogicalHeightToRows(extraLogicalHeight);
+        extraLogicalHeight -= section->distributeExtraLogicalHeightToRows(extraLogicalHeight);
 
     // FIXME: We really would like to enable this ASSERT to ensure that all the extra space has been distributed.
     // However our current distribution algorithm does not round properly and thus we can have some remaining height.

Modified: trunk/Source/WebCore/rendering/RenderTableSection.cpp (111434 => 111435)


--- trunk/Source/WebCore/rendering/RenderTableSection.cpp	2012-03-20 20:56:39 UTC (rev 111434)
+++ trunk/Source/WebCore/rendering/RenderTableSection.cpp	2012-03-20 21:02:34 UTC (rev 111435)
@@ -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()

Modified: trunk/Source/WebCore/rendering/RenderTableSection.h (111434 => 111435)


--- trunk/Source/WebCore/rendering/RenderTableSection.h	2012-03-20 20:56:39 UTC (rev 111434)
+++ trunk/Source/WebCore/rendering/RenderTableSection.h	2012-03-20 21:02:34 UTC (rev 111435)
@@ -158,7 +158,7 @@
     void setCachedCollapsedBorder(const RenderTableCell*, CollapsedBorderSide, CollapsedBorderValue);
     CollapsedBorderValue& cachedCollapsedBorder(const RenderTableCell*, CollapsedBorderSide);
 
-    // distributeExtraLogicalHeight* methods return the remaining extra logical height.
+    // distributeExtraLogicalHeightToRows methods return the *consumed* extra logical height.
     // FIXME: We may want to introduce a structure holding the in-flux layout information.
     int distributeExtraLogicalHeightToRows(int extraLogicalHeight);
 
@@ -189,9 +189,9 @@
 
     void ensureRows(unsigned);
 
-    int distributeExtraLogicalHeightToPercentRows(int extraLogicalHeight, int totalPercent);
-    int distributeExtraLogicalHeightToAutoRows(int extraLogicalHeight, unsigned autoRowsCount);
-    int distributeRemainingExtraLogicalHeight(int extraLogicalHeight);
+    void distributeExtraLogicalHeightToPercentRows(int& extraLogicalHeight, int totalPercent);
+    void distributeExtraLogicalHeightToAutoRows(int& extraLogicalHeight, unsigned autoRowsCount);
+    void distributeRemainingExtraLogicalHeight(int& extraLogicalHeight);
 
     bool hasOverflowingCell() const { return m_overflowingCells.size() || m_forceSlowPaintPathWithOverflowingCell; }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to