- Revision
- 112752
- Author
- [email protected]
- Date
- 2012-03-30 17:13:20 -0700 (Fri, 30 Mar 2012)
Log Message
Fix usage of LayoutUnits in table code.
https://bugs.webkit.org/show_bug.cgi?id=82765
Reviewed by Eric Seidel.
Clean up usage of ints and LayoutUnits in table code in preparation for
turning on subpixel layout.
No new tests, no change in functionality.
* rendering/AutoTableLayout.cpp:
(WebCore::AutoTableLayout::computePreferredLogicalWidths):
Cast maxWidth to int as all table layout is done on int bounds.
* rendering/RenderTable.cpp:
(WebCore::RenderTable::convertStyleLogicalWidthToComputedWidth):
Change borders to LayoutUnit as paddings can have subpixel precision.
* rendering/RenderTable.h:
(WebCore::RenderTable::getColumnPos):
(WebCore::RenderTable::columnPositions):
Change getColumnPos and columnPositions to ints as the values are always
on pixel bounds.
(WebCore::RenderTable::bordersPaddingAndSpacingInRowDirection):
* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::styleOrColLogicalWidth):
Remove unnecessary cast.
(WebCore::RenderTableCell::clippedOverflowRectForRepaint):
Use LayoutPoint instead of left/top.
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::calcRowLogicalHeight):
(WebCore::RenderTableSection::layoutRows):
* rendering/RenderTableSection.h:
Change baseline and baselineDescent to int to avoid unnecessary type
conversion.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (112751 => 112752)
--- trunk/Source/WebCore/ChangeLog 2012-03-31 00:10:50 UTC (rev 112751)
+++ trunk/Source/WebCore/ChangeLog 2012-03-31 00:13:20 UTC (rev 112752)
@@ -1,3 +1,44 @@
+2012-03-30 Emil A Eklund <[email protected]>
+
+ Fix usage of LayoutUnits in table code.
+ https://bugs.webkit.org/show_bug.cgi?id=82765
+
+ Reviewed by Eric Seidel.
+
+ Clean up usage of ints and LayoutUnits in table code in preparation for
+ turning on subpixel layout.
+
+ No new tests, no change in functionality.
+
+ * rendering/AutoTableLayout.cpp:
+ (WebCore::AutoTableLayout::computePreferredLogicalWidths):
+ Cast maxWidth to int as all table layout is done on int bounds.
+
+ * rendering/RenderTable.cpp:
+ (WebCore::RenderTable::convertStyleLogicalWidthToComputedWidth):
+ Change borders to LayoutUnit as paddings can have subpixel precision.
+
+ * rendering/RenderTable.h:
+ (WebCore::RenderTable::getColumnPos):
+ (WebCore::RenderTable::columnPositions):
+ Change getColumnPos and columnPositions to ints as the values are always
+ on pixel bounds.
+
+ (WebCore::RenderTable::bordersPaddingAndSpacingInRowDirection):
+ * rendering/RenderTableCell.cpp:
+ (WebCore::RenderTableCell::styleOrColLogicalWidth):
+ Remove unnecessary cast.
+
+ (WebCore::RenderTableCell::clippedOverflowRectForRepaint):
+ Use LayoutPoint instead of left/top.
+
+ * rendering/RenderTableSection.cpp:
+ (WebCore::RenderTableSection::calcRowLogicalHeight):
+ (WebCore::RenderTableSection::layoutRows):
+ * rendering/RenderTableSection.h:
+ Change baseline and baselineDescent to int to avoid unnecessary type
+ conversion.
+
2012-03-30 Joe Thomas <[email protected]>
Spec renamed Viewport-relative lengths to Viewport-percentage lengths
Modified: trunk/Source/WebCore/rendering/AutoTableLayout.cpp (112751 => 112752)
--- trunk/Source/WebCore/rendering/AutoTableLayout.cpp 2012-03-31 00:10:50 UTC (rev 112751)
+++ trunk/Source/WebCore/rendering/AutoTableLayout.cpp 2012-03-31 00:13:20 UTC (rev 112752)
@@ -251,8 +251,8 @@
if (scaleColumns) {
maxNonPercent = maxNonPercent * 100 / max(remainingPercent, epsilon);
- maxWidth = max(maxWidth, static_cast<int>(min(maxNonPercent, numeric_limits<LayoutUnit>::max() / 2.0f)));
- maxWidth = max(maxWidth, static_cast<int>(min(maxPercent, numeric_limits<LayoutUnit>::max() / 2.0f)));
+ maxWidth = max<int>(maxWidth, static_cast<int>(min(maxNonPercent, numeric_limits<LayoutUnit>::max() / 2.0f)));
+ maxWidth = max<int>(maxWidth, static_cast<int>(min(maxPercent, numeric_limits<LayoutUnit>::max() / 2.0f)));
}
maxWidth = max<int>(maxWidth, spanMaxLogicalWidth);
Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (112751 => 112752)
--- trunk/Source/WebCore/rendering/RenderTable.cpp 2012-03-31 00:10:50 UTC (rev 112751)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp 2012-03-31 00:13:20 UTC (rev 112752)
@@ -271,11 +271,11 @@
LayoutUnit RenderTable::convertStyleLogicalWidthToComputedWidth(const Length& styleLogicalWidth, LayoutUnit availableWidth)
{
// HTML tables' width styles already include borders and paddings, but CSS tables' width styles do not.
- int borders = 0;
+ LayoutUnit borders = 0;
bool isCSSTable = !node() || !node()->hasTagName(tableTag);
if (isCSSTable && styleLogicalWidth.isFixed() && styleLogicalWidth.isPositive()) {
recalcBordersInRowDirection();
- borders = borderStart() + borderEnd() + (collapseBorders() ? 0 : paddingStart() + paddingEnd());
+ borders = borderStart() + borderEnd() + (collapseBorders() ? zeroLayoutUnit : paddingStart() + paddingEnd());
}
return minimumValueForLength(styleLogicalWidth, availableWidth, view()) + borders;
}
Modified: trunk/Source/WebCore/rendering/RenderTable.h (112751 => 112752)
--- trunk/Source/WebCore/rendering/RenderTable.h 2012-03-31 00:10:50 UTC (rev 112751)
+++ trunk/Source/WebCore/rendering/RenderTable.h 2012-03-31 00:13:20 UTC (rev 112752)
@@ -45,7 +45,7 @@
explicit RenderTable(Node*);
virtual ~RenderTable();
- LayoutUnit getColumnPos(unsigned col) const { return m_columnPos[col]; }
+ int getColumnPos(unsigned col) const { return m_columnPos[col]; }
int hBorderSpacing() const { return m_hSpacing; }
int vBorderSpacing() const { return m_vSpacing; }
@@ -136,7 +136,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; }
@@ -172,7 +172,7 @@
LayoutUnit bordersPaddingAndSpacingInRowDirection() const
{
return borderStart() + borderEnd() +
- (collapseBorders() ? zeroLayoutUnit : (paddingStart() + paddingEnd() + (numEffCols() + 1) * hBorderSpacing()));
+ (collapseBorders() ? zeroLayoutUnit : (paddingStart() + paddingEnd() + static_cast<LayoutUnit>(numEffCols() + 1) * hBorderSpacing()));
}
RenderTableCol* colElement(unsigned col, bool* startEdge = 0, bool* endEdge = 0) const;
@@ -254,7 +254,7 @@
void distributeExtraLogicalHeight(int extraLogicalHeight);
- mutable Vector<LayoutUnit> m_columnPos;
+ mutable Vector<int> m_columnPos;
mutable Vector<ColumnStruct> m_columns;
mutable Vector<RenderTableCaption*> m_captions;
Modified: trunk/Source/WebCore/rendering/RenderTableCell.cpp (112751 => 112752)
--- trunk/Source/WebCore/rendering/RenderTableCell.cpp 2012-03-31 00:10:50 UTC (rev 112751)
+++ trunk/Source/WebCore/rendering/RenderTableCell.cpp 2012-03-31 00:13:20 UTC (rev 112752)
@@ -143,7 +143,7 @@
// Percentages don't need to be handled since they're always treated this way (even when specified on the cells).
// See Bugzilla bug 8126 for details.
if (colWidthSum.isFixed() && colWidthSum.value() > 0)
- colWidthSum = Length(max<LayoutUnit>(0, colWidthSum.value() - borderAndPaddingLogicalWidth()), Fixed);
+ colWidthSum = Length(max(0, colWidthSum.value() - borderAndPaddingLogicalWidth()), Fixed);
return colWidthSum;
}
@@ -296,9 +296,8 @@
right = max(right, below->borderHalfRight(true));
}
}
- left = max(left, -minXVisualOverflow());
- top = max(top, -minYVisualOverflow());
- LayoutRect r(-left, - top, left + max(width() + right, maxXVisualOverflow()), top + max(height() + bottom, maxYVisualOverflow()));
+ LayoutPoint location(max<LayoutUnit>(left, -minXVisualOverflow()), max<LayoutUnit>(top, -minYVisualOverflow()));
+ LayoutRect r(-location.x(), -location.y(), location.x() + max(width() + right, maxXVisualOverflow()), location.y() + max(height() + bottom, maxYVisualOverflow()));
if (RenderView* v = view()) {
// FIXME: layoutDelta needs to be applied in parts before/after transforms and
Modified: trunk/Source/WebCore/rendering/RenderTableSection.cpp (112751 => 112752)
--- trunk/Source/WebCore/rendering/RenderTableSection.cpp 2012-03-31 00:10:50 UTC (rev 112751)
+++ trunk/Source/WebCore/rendering/RenderTableSection.cpp 2012-03-31 00:13:20 UTC (rev 112752)
@@ -336,7 +336,7 @@
for (unsigned r = 0; r < m_grid.size(); r++) {
m_grid[r].baseline = 0;
- LayoutUnit baselineDescent = 0;
+ int baselineDescent = 0;
// Our base size is the biggest logical height from our cells' styles (excluding row spanning cells).
m_rowPos[r + 1] = max(m_rowPos[r] + minimumValueForLength(m_grid[r].logicalHeight, 0, viewRenderer), 0);
@@ -620,7 +620,7 @@
// If the baseline moved, we may have to update the data for our row. Find out the new baseline.
EVerticalAlign va = cell->style()->verticalAlign();
if (va == BASELINE || va == TEXT_BOTTOM || va == TEXT_TOP || va == SUPER || va == SUB) {
- LayoutUnit baseline = cell->cellBaselinePosition();
+ int baseline = cell->cellBaselinePosition();
if (baseline > cell->borderBefore() + cell->paddingBefore())
m_grid[r].baseline = max(m_grid[r].baseline, baseline);
}
Modified: trunk/Source/WebCore/rendering/RenderTableSection.h (112751 => 112752)
--- trunk/Source/WebCore/rendering/RenderTableSection.h 2012-03-31 00:10:50 UTC (rev 112751)
+++ trunk/Source/WebCore/rendering/RenderTableSection.h 2012-03-31 00:13:20 UTC (rev 112752)
@@ -110,7 +110,7 @@
Row row;
RenderTableRow* rowRenderer;
- LayoutUnit baseline;
+ int baseline;
Length logicalHeight;
};