Title: [107038] trunk/Source/WebCore
Revision
107038
Author
e...@chromium.org
Date
2012-02-07 21:37:54 -0800 (Tue, 07 Feb 2012)

Log Message

Revert TableSection cell and border calculations to integers
https://bugs.webkit.org/show_bug.cgi?id=77918

Reviewed by Eric Seidel.

Change RenderTableSection cell width, row height and border calculations
back to use integers. Table layout is done on integer bounds to comply
with the specification and to ensure that columns given the same width,
including percentage widths, are rendered with identical widths. The same
applies to heights.

No new tests.

* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::setCellLogicalWidths):
(WebCore::RenderTableSection::calcRowLogicalHeight):
(WebCore::RenderTableSection::layoutRows):
(WebCore::RenderTableSection::calcOuterBorderBefore):
(WebCore::RenderTableSection::calcOuterBorderAfter):
(WebCore::RenderTableSection::calcOuterBorderStart):
(WebCore::RenderTableSection::calcOuterBorderEnd):
(WebCore::RenderTableSection::paintObject):
(WebCore::RenderTableSection::nodeAtPoint):
* rendering/RenderTableSection.h:
(RenderTableSection):
(WebCore::RenderTableSection::RowStruct::RowStruct):
(WebCore::RenderTableSection::outerBorderBefore):
(WebCore::RenderTableSection::outerBorderAfter):
(WebCore::RenderTableSection::outerBorderStart):
(WebCore::RenderTableSection::outerBorderEnd):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (107037 => 107038)


--- trunk/Source/WebCore/ChangeLog	2012-02-08 05:34:09 UTC (rev 107037)
+++ trunk/Source/WebCore/ChangeLog	2012-02-08 05:37:54 UTC (rev 107038)
@@ -1,3 +1,36 @@
+2012-02-07  Emil A Eklund  <e...@chromium.org>
+
+        Revert TableSection cell and border calculations to integers
+        https://bugs.webkit.org/show_bug.cgi?id=77918
+
+        Reviewed by Eric Seidel.
+
+        Change RenderTableSection cell width, row height and border calculations
+        back to use integers. Table layout is done on integer bounds to comply
+        with the specification and to ensure that columns given the same width,
+        including percentage widths, are rendered with identical widths. The same
+        applies to heights.
+
+        No new tests.
+
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::setCellLogicalWidths):
+        (WebCore::RenderTableSection::calcRowLogicalHeight):
+        (WebCore::RenderTableSection::layoutRows):
+        (WebCore::RenderTableSection::calcOuterBorderBefore):
+        (WebCore::RenderTableSection::calcOuterBorderAfter):
+        (WebCore::RenderTableSection::calcOuterBorderStart):
+        (WebCore::RenderTableSection::calcOuterBorderEnd):
+        (WebCore::RenderTableSection::paintObject):
+        (WebCore::RenderTableSection::nodeAtPoint):
+        * rendering/RenderTableSection.h:
+        (RenderTableSection):
+        (WebCore::RenderTableSection::RowStruct::RowStruct):
+        (WebCore::RenderTableSection::outerBorderBefore):
+        (WebCore::RenderTableSection::outerBorderAfter):
+        (WebCore::RenderTableSection::outerBorderStart):
+        (WebCore::RenderTableSection::outerBorderEnd):
+
 2012-02-07  Robert Kroeger  <rjkro...@chromium.org>
 
         [chromium] Remove the no longer necessary Chromium gesture recognizer.

Modified: trunk/Source/WebCore/rendering/RenderTableSection.cpp (107037 => 107038)


--- trunk/Source/WebCore/rendering/RenderTableSection.cpp	2012-02-08 05:34:09 UTC (rev 107037)
+++ trunk/Source/WebCore/rendering/RenderTableSection.cpp	2012-02-08 05:37:54 UTC (rev 107038)
@@ -277,7 +277,7 @@
 
 void RenderTableSection::setCellLogicalWidths()
 {
-    Vector<LayoutUnit>& columnPos = table()->columnPositions();
+    Vector<int>& columnPos = table()->columnPositions();
 
     LayoutStateMaintainer statePusher(view());
 
@@ -296,8 +296,8 @@
                 cspan -= table()->columns()[endCol].span;
                 endCol++;
             }
-            LayoutUnit w = columnPos[endCol] - columnPos[j] - table()->hBorderSpacing();
-            LayoutUnit oldLogicalWidth = cell->logicalWidth();
+            int w = columnPos[endCol] - columnPos[j] - table()->hBorderSpacing();
+            int oldLogicalWidth = cell->logicalWidth();
             if (w != oldLogicalWidth) {
                 cell->setNeedsLayout(true);
                 if (!table()->selfNeedsLayout() && cell->checkForRepaintDuringLayout()) {
@@ -316,7 +316,7 @@
     statePusher.pop(); // only pops if we pushed
 }
 
-LayoutUnit RenderTableSection::calcRowLogicalHeight()
+int RenderTableSection::calcRowLogicalHeight()
 {
 #ifndef NDEBUG
     setNeedsLayoutIsForbidden(true);
@@ -326,7 +326,7 @@
 
     RenderTableCell* cell;
 
-    LayoutUnit spacing = table()->vBorderSpacing();
+    int spacing = table()->vBorderSpacing();
 
     LayoutStateMaintainer statePusher(view());
 
@@ -337,9 +337,9 @@
         m_rowPos[r + 1] = 0;
         m_grid[r].baseline = 0;
         LayoutUnit baseline = 0;
-        LayoutUnit bdesc = 0;
-        LayoutUnit ch = m_grid[r].logicalHeight.calcMinValue(0);
-        LayoutUnit pos = m_rowPos[r] + ch + (m_grid[r].rowRenderer ? spacing : 0);
+        int bdesc = 0;
+        int ch = m_grid[r].logicalHeight.calcMinValue(0);
+        int pos = m_rowPos[r] + ch + (m_grid[r].rowRenderer ? spacing : 0);
 
         m_rowPos[r + 1] = max(m_rowPos[r + 1], pos);
 
@@ -370,7 +370,7 @@
                 cell->layoutIfNeeded();
             }
 
-            LayoutUnit adjustedLogicalHeight = cell->logicalHeight() - (cell->intrinsicPaddingBefore() + cell->intrinsicPaddingAfter());
+            int adjustedLogicalHeight = cell->logicalHeight() - (cell->intrinsicPaddingBefore() + cell->intrinsicPaddingAfter());
 
             ch = cell->style()->logicalHeight().calcValue(0);
             if (document()->inQuirksMode() || cell->style()->boxSizing() == BORDER_BOX) {
@@ -379,8 +379,8 @@
             } else {
                 // In strict mode, box-sizing: content-box do the right
                 // thing and actually add in the border and padding.
-                LayoutUnit adjustedPaddingBefore = cell->paddingBefore() - cell->intrinsicPaddingBefore();
-                LayoutUnit adjustedPaddingAfter = cell->paddingAfter() - cell->intrinsicPaddingAfter();
+                int adjustedPaddingBefore = cell->paddingBefore() - cell->intrinsicPaddingBefore();
+                int adjustedPaddingAfter = cell->paddingAfter() - cell->intrinsicPaddingAfter();
                 ch += adjustedPaddingBefore + adjustedPaddingAfter + cell->borderBefore() + cell->borderAfter();
             }
             ch = max(ch, adjustedLogicalHeight);
@@ -392,9 +392,9 @@
             // find out the baseline
             EVerticalAlign va = cell->style()->verticalAlign();
             if (va == BASELINE || va == TEXT_BOTTOM || va == TEXT_TOP || va == SUPER || va == SUB) {
-                LayoutUnit b = cell->cellBaselinePosition();
+                int b = cell->cellBaselinePosition();
                 if (b > cell->borderBefore() + cell->paddingBefore()) {
-                    baseline = max(baseline, b - cell->intrinsicPaddingBefore());
+                    baseline = max<LayoutUnit>(baseline, b - cell->intrinsicPaddingBefore());
                     bdesc = max(bdesc, m_rowPos[indx] + ch - (b - cell->intrinsicPaddingBefore()));
                 }
             }
@@ -436,7 +436,7 @@
     setNeedsLayout(false);
 }
 
-LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd)
+int RenderTableSection::layoutRows(int toAdd)
 {
 #ifndef NDEBUG
     setNeedsLayoutIsForbidden(true);
@@ -444,7 +444,7 @@
 
     ASSERT(!needsLayout());
 
-    LayoutUnit rHeight;
+    int rHeight;
     unsigned rindx;
     unsigned totalRows = m_grid.size();
 
@@ -455,9 +455,9 @@
     m_forceSlowPaintPathWithOverflowingCell = false;
 
     if (toAdd && totalRows && (m_rowPos[totalRows] || !nextSibling())) {
-        LayoutUnit totalHeight = m_rowPos[totalRows] + toAdd;
+        int totalHeight = m_rowPos[totalRows] + toAdd;
 
-        LayoutUnit dh = toAdd;
+        int dh = toAdd;
         int totalPercent = 0;
         int numAuto = 0;
         for (unsigned r = 0; r < totalRows; r++) {
@@ -468,15 +468,15 @@
         }
         if (totalPercent) {
             // try to satisfy percent
-            LayoutUnit add = 0;
+            int add = 0;
             totalPercent = min(totalPercent, 100);
-            LayoutUnit rh = m_rowPos[1] - m_rowPos[0];
+            int rh = m_rowPos[1] - m_rowPos[0];
             for (unsigned r = 0; r < totalRows; r++) {
                 if (totalPercent > 0 && m_grid[r].logicalHeight.isPercent()) {
-                    LayoutUnit toAdd = min<LayoutUnit>(dh, (totalHeight * m_grid[r].logicalHeight.percent() / 100) - rh);
+                    int toAdd = min<int>(dh, (totalHeight * m_grid[r].logicalHeight.percent() / 100) - rh);
                     // If toAdd is negative, then we don't want to shrink the row (this bug
                     // affected Outlook Web Access).
-                    toAdd = max<LayoutUnit>(0, toAdd);
+                    toAdd = max(0, toAdd);
                     add += toAdd;
                     dh -= toAdd;
                     totalPercent -= m_grid[r].logicalHeight.percent();
@@ -489,10 +489,10 @@
         }
         if (numAuto) {
             // distribute over variable cols
-            LayoutUnit add = 0;
+            int add = 0;
             for (unsigned r = 0; r < totalRows; r++) {
                 if (numAuto > 0 && m_grid[r].logicalHeight.isAuto()) {
-                    LayoutUnit toAdd = dh / numAuto;
+                    int toAdd = dh / numAuto;
                     add += toAdd;
                     dh -= toAdd;
                     numAuto--;
@@ -502,9 +502,9 @@
         }
         if (dh > 0 && m_rowPos[totalRows]) {
             // if some left overs, distribute equally.
-            LayoutUnit tot = m_rowPos[totalRows];
-            LayoutUnit add = 0;
-            LayoutUnit prev = m_rowPos[0];
+            int tot = m_rowPos[totalRows];
+            int add = 0;
+            int prev = m_rowPos[0];
             for (unsigned r = 0; r < totalRows; r++) {
                 // weight with the original height
                 add += dh * (m_rowPos[r + 1] - prev) / tot;
@@ -514,8 +514,8 @@
         }
     }
 
-    LayoutUnit hspacing = table()->hBorderSpacing();
-    LayoutUnit vspacing = table()->vBorderSpacing();
+    int hspacing = table()->hBorderSpacing();
+    int vspacing = table()->vBorderSpacing();
     unsigned nEffCols = table()->numEffCols();
 
     LayoutStateMaintainer statePusher(view(), this, LayoutSize(x(), y()), style()->isFlippedBlocksWritingMode());
@@ -603,18 +603,18 @@
                 }
             }
 
-            LayoutUnit oldIntrinsicPaddingBefore = cell->intrinsicPaddingBefore();
-            LayoutUnit oldIntrinsicPaddingAfter = cell->intrinsicPaddingAfter();
-            LayoutUnit logicalHeightWithoutIntrinsicPadding = cell->logicalHeight() - oldIntrinsicPaddingBefore - oldIntrinsicPaddingAfter;
+            int oldIntrinsicPaddingBefore = cell->intrinsicPaddingBefore();
+            int oldIntrinsicPaddingAfter = cell->intrinsicPaddingAfter();
+            int logicalHeightWithoutIntrinsicPadding = cell->logicalHeight() - oldIntrinsicPaddingBefore - oldIntrinsicPaddingAfter;
 
-            LayoutUnit intrinsicPaddingBefore = 0;
+            int intrinsicPaddingBefore = 0;
             switch (cell->style()->verticalAlign()) {
                 case SUB:
                 case SUPER:
                 case TEXT_TOP:
                 case TEXT_BOTTOM:
                 case BASELINE: {
-                    LayoutUnit b = cell->cellBaselinePosition();
+                    int b = cell->cellBaselinePosition();
                     if (b > cell->borderBefore() + cell->paddingBefore())
                         intrinsicPaddingBefore = getBaseline(r) - (b - oldIntrinsicPaddingBefore);
                     break;
@@ -631,7 +631,7 @@
                     break;
             }
             
-            LayoutUnit intrinsicPaddingAfter = rHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore;
+            int intrinsicPaddingAfter = rHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore;
             cell->setIntrinsicPaddingBefore(intrinsicPaddingBefore);
             cell->setIntrinsicPaddingAfter(intrinsicPaddingAfter);
 
@@ -715,7 +715,7 @@
     return height();
 }
 
-LayoutUnit RenderTableSection::calcOuterBorderBefore() const
+int RenderTableSection::calcOuterBorderBefore() const
 {
     unsigned totalCols = table()->numEffCols();
     if (!m_grid.size() || !totalCols)
@@ -766,7 +766,7 @@
     return borderWidth / 2;
 }
 
-LayoutUnit RenderTableSection::calcOuterBorderAfter() const
+int RenderTableSection::calcOuterBorderAfter() const
 {
     unsigned totalCols = table()->numEffCols();
     if (!m_grid.size() || !totalCols)
@@ -817,7 +817,7 @@
     return (borderWidth + 1) / 2;
 }
 
-LayoutUnit RenderTableSection::calcOuterBorderStart() const
+int RenderTableSection::calcOuterBorderStart() const
 {
     unsigned totalCols = table()->numEffCols();
     if (!m_grid.size() || !totalCols)
@@ -861,7 +861,7 @@
     return (borderWidth + (table()->style()->isLeftToRightDirection() ? 0 : 1)) / 2;
 }
 
-LayoutUnit RenderTableSection::calcOuterBorderEnd() const
+int RenderTableSection::calcOuterBorderEnd() const
 {
     unsigned totalCols = table()->numEffCols();
     if (!m_grid.size() || !totalCols)
@@ -1055,7 +1055,7 @@
     // FIXME: Implement RTL.
     if (!m_forceSlowPaintPathWithOverflowingCell && style()->isLeftToRightDirection()) {
         LayoutUnit start = (style()->isHorizontalWritingMode() ? localRepaintRect.x() : localRepaintRect.y()) - os;
-        Vector<LayoutUnit>& columnPos = table()->columnPositions();
+        Vector<int>& columnPos = table()->columnPositions();
         startcol = std::lower_bound(columnPos.begin(), columnPos.end(), start) - columnPos.begin();
         if ((startcol == columnPos.size()) || (startcol > 0 && (columnPos[startcol] > start)))
             --startcol;
@@ -1313,7 +1313,7 @@
     // Now set hitRow to the index of the hit row, or 0.
     unsigned hitRow = nextRow > 0 ? nextRow - 1 : 0;
 
-    Vector<LayoutUnit>& columnPos = table()->columnPositions();
+    Vector<int>& columnPos = table()->columnPositions();
     LayoutUnit offsetInRowDirection = style()->isHorizontalWritingMode() ? location.x() : location.y();
     if (!style()->isLeftToRightDirection())
         offsetInRowDirection = columnPos[columnPos.size() - 1] - offsetInRowDirection;

Modified: trunk/Source/WebCore/rendering/RenderTableSection.h (107037 => 107038)


--- trunk/Source/WebCore/rendering/RenderTableSection.h	2012-02-08 05:34:09 UTC (rev 107037)
+++ trunk/Source/WebCore/rendering/RenderTableSection.h	2012-02-08 05:37:54 UTC (rev 107038)
@@ -55,8 +55,8 @@
     void addCell(RenderTableCell*, RenderTableRow* row);
 
     void setCellLogicalWidths();
-    LayoutUnit calcRowLogicalHeight();
-    LayoutUnit layoutRows(LayoutUnit logicalHeight);
+    int calcRowLogicalHeight();
+    int layoutRows(int logicalHeight);
 
     RenderTable* table() const { return toRenderTable(parent()); }
 
@@ -87,7 +87,7 @@
     struct RowStruct {
         RowStruct()
             : rowRenderer(0)
-            , baseline(0)
+            , baseline()
         {
         }
 
@@ -108,16 +108,16 @@
     void appendColumn(unsigned pos);
     void splitColumn(unsigned pos, unsigned first);
 
-    LayoutUnit calcOuterBorderBefore() const;
-    LayoutUnit calcOuterBorderAfter() const;
-    LayoutUnit calcOuterBorderStart() const;
-    LayoutUnit calcOuterBorderEnd() const;
+    int calcOuterBorderBefore() const;
+    int calcOuterBorderAfter() const;
+    int calcOuterBorderStart() const;
+    int calcOuterBorderEnd() const;
     void recalcOuterBorder();
 
-    LayoutUnit outerBorderBefore() const { return m_outerBorderBefore; }
-    LayoutUnit outerBorderAfter() const { return m_outerBorderAfter; }
-    LayoutUnit outerBorderStart() const { return m_outerBorderStart; }
-    LayoutUnit outerBorderEnd() const { return m_outerBorderEnd; }
+    int outerBorderBefore() const { return m_outerBorderBefore; }
+    int outerBorderAfter() const { return m_outerBorderAfter; }
+    int outerBorderStart() const { return m_outerBorderStart; }
+    int outerBorderEnd() const { return m_outerBorderEnd; }
 
     unsigned numRows() const { return m_grid.size(); }
     unsigned numColumns() const;
@@ -173,16 +173,16 @@
     RenderObjectChildList m_children;
 
     Vector<RowStruct> m_grid;
-    Vector<LayoutUnit> m_rowPos;
+    Vector<int> m_rowPos;
 
     // the current insertion position
     unsigned m_cCol;
     unsigned m_cRow;
 
-    LayoutUnit m_outerBorderStart;
-    LayoutUnit m_outerBorderEnd;
-    LayoutUnit m_outerBorderBefore;
-    LayoutUnit m_outerBorderAfter;
+    int m_outerBorderStart;
+    int m_outerBorderEnd;
+    int m_outerBorderBefore;
+    int m_outerBorderAfter;
 
     bool m_needsCellRecalc;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to