Title: [100372] branches/subpixellayout/Source/WebCore/rendering
Revision
100372
Author
le...@chromium.org
Date
2011-11-15 17:03:36 -0800 (Tue, 15 Nov 2011)

Log Message

Converting table row height calculations back to ints and avoiding enclosingIntRect when outputting test expectations for table parts.

Modified Paths

Diff

Modified: branches/subpixellayout/Source/WebCore/rendering/RenderTable.cpp (100371 => 100372)


--- branches/subpixellayout/Source/WebCore/rendering/RenderTable.cpp	2011-11-16 01:03:33 UTC (rev 100371)
+++ branches/subpixellayout/Source/WebCore/rendering/RenderTable.cpp	2011-11-16 01:03:36 UTC (rev 100372)
@@ -318,7 +318,7 @@
 
     setCellLogicalWidths();
 
-    LayoutUnit totalSectionLogicalHeight = 0;
+    int totalSectionLogicalHeight = 0;
     LayoutUnit oldTableLogicalTop = m_caption ? m_caption->logicalHeight() + m_caption->marginBefore() + m_caption->marginAfter() : LayoutUnit(0);
 
     bool collapsing = collapseBorders();
@@ -356,8 +356,8 @@
         }
     }
 
-    LayoutUnit borderAndPaddingBefore = borderBefore() + (collapsing ? LayoutUnit(0) : paddingBefore());
-    LayoutUnit borderAndPaddingAfter = borderAfter() + (collapsing ? LayoutUnit(0) : paddingAfter());
+    LayoutUnit borderAndPaddingBefore = borderBefore() + (collapsing ? LayoutUnit() : paddingBefore());
+    LayoutUnit borderAndPaddingAfter = borderAfter() + (collapsing ? LayoutUnit() : paddingAfter());
 
     setLogicalHeight(logicalHeight() + borderAndPaddingBefore);
 
@@ -365,7 +365,7 @@
         computeLogicalHeight();
 
     Length logicalHeightLength = style()->logicalHeight();
-    LayoutUnit computedLogicalHeight = 0;
+    LayoutUnit computedLogicalHeight;
     if (logicalHeightLength.isFixed()) {
         // HTML tables size as though CSS height includes border/padding, CSS tables do not.
         LayoutUnit borders = node() && node()->hasTagName(tableTag) ? (borderAndPaddingBefore + borderAndPaddingAfter) : LayoutUnit(0);
@@ -374,10 +374,12 @@
         computedLogicalHeight = computePercentageLogicalHeight(logicalHeightLength);
     computedLogicalHeight = max<LayoutUnit>(0, computedLogicalHeight);
 
+    int pixelSnappedLogicalHeight = (logicalTop() + computedLogicalHeight).round() - logicalTop().round();
+
     for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
         if (child->isTableSection())
             // FIXME: Distribute extra height between all table body sections instead of giving it all to the first one.
-            toRenderTableSection(child)->layoutRows(child == m_firstBody ? max<LayoutUnit>(0, computedLogicalHeight - totalSectionLogicalHeight) : LayoutUnit(0));
+            toRenderTableSection(child)->layoutRows(child == m_firstBody ? max(0, pixelSnappedLogicalHeight - totalSectionLogicalHeight) : 0);
     }
 
     if (!m_firstBody && computedLogicalHeight > totalSectionLogicalHeight && !document()->inQuirksMode()) {

Modified: branches/subpixellayout/Source/WebCore/rendering/RenderTable.h (100371 => 100372)


--- branches/subpixellayout/Source/WebCore/rendering/RenderTable.h	2011-11-16 01:03:33 UTC (rev 100371)
+++ branches/subpixellayout/Source/WebCore/rendering/RenderTable.h	2011-11-16 01:03:36 UTC (rev 100372)
@@ -44,7 +44,7 @@
     explicit RenderTable(Node*);
     virtual ~RenderTable();
 
-    LayoutUnit getColumnPos(int col) const { return m_columnPos[col]; }
+    int getColumnPos(int col) const { return m_columnPos[col]; }
 
     int hBorderSpacing() const { return m_hSpacing; }
     int vBorderSpacing() const { return m_vSpacing; }
@@ -135,7 +135,7 @@
     };
 
     Vector<ColumnStruct>& columns() { return m_columns; }
-    Vector<LayoutUnit>& columnPositions() { return m_columnPos; }
+    Vector<int>& columnPositions() { return m_columnPos; }
     RenderTableSection* header() const { return m_head; }
     RenderTableSection* footer() const { return m_foot; }
     RenderTableSection* firstBody() const { return m_firstBody; }
@@ -250,7 +250,7 @@
     void recalcSections() const;
     void adjustLogicalHeightForCaption();
 
-    mutable Vector<LayoutUnit> m_columnPos;
+    mutable Vector<int> m_columnPos;
     mutable Vector<ColumnStruct> m_columns;
 
     mutable RenderBlock* m_caption;

Modified: branches/subpixellayout/Source/WebCore/rendering/RenderTableSection.cpp (100371 => 100372)


--- branches/subpixellayout/Source/WebCore/rendering/RenderTableSection.cpp	2011-11-16 01:03:33 UTC (rev 100371)
+++ branches/subpixellayout/Source/WebCore/rendering/RenderTableSection.cpp	2011-11-16 01:03:36 UTC (rev 100372)
@@ -264,7 +264,7 @@
 
 void RenderTableSection::setCellLogicalWidths()
 {
-    Vector<LayoutUnit>& columnPos = table()->columnPositions();
+    Vector<int>& columnPos = table()->columnPositions();
 
     LayoutStateMaintainer statePusher(view());
 
@@ -283,8 +283,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()) {
@@ -303,7 +303,7 @@
     statePusher.pop(); // only pops if we pushed
 }
 
-LayoutUnit RenderTableSection::calcRowLogicalHeight()
+int RenderTableSection::calcRowLogicalHeight()
 {
 #ifndef NDEBUG
     setNeedsLayoutIsForbidden(true);
@@ -313,7 +313,7 @@
 
     RenderTableCell* cell;
 
-    LayoutUnit spacing = table()->vBorderSpacing();
+    int spacing = table()->vBorderSpacing();
 
     LayoutStateMaintainer statePusher(view());
 
@@ -324,9 +324,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 : LayoutUnit(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);
 
@@ -357,7 +357,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) {
@@ -366,22 +366,22 @@
             } 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();
-                ch += adjustedPaddingBefore + adjustedPaddingAfter + cell->borderBefore() + cell->borderAfter();
+                int adjustedPaddingBefore = cell->paddingBefore() - cell->intrinsicPaddingBefore();
+                int adjustedPaddingAfter = cell->paddingAfter() - cell->intrinsicPaddingAfter();
+                ch += adjustedPaddingBefore + adjustedPaddingAfter + cell->borderBefore().floor() + cell->borderAfter().floor();
             }
             ch = max(ch, adjustedLogicalHeight);
 
-            pos = m_rowPos[indx] + ch + (m_grid[r].rowRenderer ? spacing : LayoutUnit(0));
+            pos = m_rowPos[indx] + ch + (m_grid[r].rowRenderer ? spacing : 0);
 
             m_rowPos[r + 1] = max(m_rowPos[r + 1], pos);
 
             // 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()));
                 }
             }
@@ -390,7 +390,7 @@
         // do we have baseline aligned elements?
         if (baseline) {
             // increase rowheight if baseline requires
-            m_rowPos[r + 1] = max(m_rowPos[r + 1], baseline + bdesc + (m_grid[r].rowRenderer ? spacing : LayoutUnit(0)));
+            m_rowPos[r + 1] = max(m_rowPos[r + 1], baseline.round() + bdesc + (m_grid[r].rowRenderer ? spacing : 0));
             m_grid[r].baseline = baseline;
         }
 
@@ -423,7 +423,7 @@
     setNeedsLayout(false);
 }
 
-LayoutUnit RenderTableSection::layoutRows(LayoutUnit toAdd)
+int RenderTableSection::layoutRows(int toAdd)
 {
 #ifndef NDEBUG
     setNeedsLayoutIsForbidden(true);
@@ -431,7 +431,7 @@
 
     ASSERT(!needsLayout());
 
-    LayoutUnit rHeight;
+    int rHeight;
     int rindx;
     unsigned totalRows = m_grid.size();
 
@@ -442,9 +442,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++) {
@@ -455,15 +455,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();
@@ -476,10 +476,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--;
@@ -489,9 +489,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;
@@ -501,9 +501,9 @@
         }
     }
 
-    LayoutUnit hspacing = table()->hBorderSpacing();
-    LayoutUnit vspacing = table()->vBorderSpacing();
-    LayoutUnit nEffCols = table()->numEffCols();
+    int hspacing = table()->hBorderSpacing();
+    int vspacing = table()->vBorderSpacing();
+    int nEffCols = table()->numEffCols();
 
     LayoutStateMaintainer statePusher(view(), this, LayoutSize(x(), y()), style()->isFlippedBlocksWritingMode());
 
@@ -590,18 +590,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;
@@ -618,7 +618,7 @@
                     break;
             }
             
-            LayoutUnit intrinsicPaddingAfter = rHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore;
+            int intrinsicPaddingAfter = rHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore;
             cell->setIntrinsicPaddingBefore(intrinsicPaddingBefore);
             cell->setIntrinsicPaddingAfter(intrinsicPaddingAfter);
 
@@ -702,7 +702,7 @@
     return height();
 }
 
-LayoutUnit RenderTableSection::calcOuterBorderBefore() const
+int RenderTableSection::calcOuterBorderBefore() const
 {
     int totalCols = table()->numEffCols();
     if (!m_grid.size() || !totalCols)
@@ -753,7 +753,7 @@
     return borderWidth / 2;
 }
 
-LayoutUnit RenderTableSection::calcOuterBorderAfter() const
+int RenderTableSection::calcOuterBorderAfter() const
 {
     int totalCols = table()->numEffCols();
     if (!m_grid.size() || !totalCols)
@@ -804,7 +804,7 @@
     return (borderWidth + 1) / 2;
 }
 
-LayoutUnit RenderTableSection::calcOuterBorderStart() const
+int RenderTableSection::calcOuterBorderStart() const
 {
     int totalCols = table()->numEffCols();
     if (!m_grid.size() || !totalCols)
@@ -848,7 +848,7 @@
     return (borderWidth + (table()->style()->isLeftToRightDirection() ? 0 : 1)) / 2;
 }
 
-LayoutUnit RenderTableSection::calcOuterBorderEnd() const
+int RenderTableSection::calcOuterBorderEnd() const
 {
     int totalCols = table()->numEffCols();
     if (!m_grid.size() || !totalCols)
@@ -1039,7 +1039,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;
@@ -1250,7 +1250,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: branches/subpixellayout/Source/WebCore/rendering/RenderTableSection.h (100371 => 100372)


--- branches/subpixellayout/Source/WebCore/rendering/RenderTableSection.h	2011-11-16 01:03:33 UTC (rev 100371)
+++ branches/subpixellayout/Source/WebCore/rendering/RenderTableSection.h	2011-11-16 01:03:36 UTC (rev 100372)
@@ -48,8 +48,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()); }
 
@@ -80,7 +80,7 @@
     struct RowStruct {
         RowStruct()
             : rowRenderer(0)
-            , baseline(0)
+            , baseline()
         {
         }
 
@@ -101,16 +101,16 @@
     void appendColumn(int pos);
     void splitColumn(unsigned pos, int 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;
@@ -162,16 +162,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;
 

Modified: branches/subpixellayout/Source/WebCore/rendering/RenderTreeAsText.cpp (100371 => 100372)


--- branches/subpixellayout/Source/WebCore/rendering/RenderTreeAsText.cpp	2011-11-16 01:03:33 UTC (rev 100371)
+++ branches/subpixellayout/Source/WebCore/rendering/RenderTreeAsText.cpp	2011-11-16 01:03:36 UTC (rev 100372)
@@ -283,8 +283,13 @@
         r.move(0, -toRenderTableCell(o.containingBlock())->intrinsicPaddingBefore());
 
     // FIXME: Convert layout test results to report sub-pixel values, in the meantime using enclosingIntRect
-    // for consistency with old results.
-    r = enclosingIntRect(r);
+    // for consistency with old results. This doesn't apply to tables, which are still laid out on integer bounds.
+    if (!o.isTable() && !o.isTableCell() && !o.isTableCol() && !o.isTableRow() && !o.isTableSection())
+        r = enclosingIntRect(r);
+    else
+        r = IntRect(r);
+
+
     ts << " " << r;
 
     if (!(o.isText() && !o.isBR())) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to