RenderElement::style() should return a reference.
<https://webkit.org/b/123414>
Now that renderers always have style, go ahead and make style()
return a RenderStyle&.
There are countless opportunities for further cleanup enabled by
this change. I'm simply passing &style() in many cases where we
can really do something nicer instead.
Reviewed by Anders Carlsson.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158163 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/rendering/RenderTableSection.cpp b/Source/WebCore/rendering/RenderTableSection.cpp
index c9de8e0..a1055a6 100644
--- a/Source/WebCore/rendering/RenderTableSection.cpp
+++ b/Source/WebCore/rendering/RenderTableSection.cpp
@@ -51,7 +51,7 @@
static inline void setRowLogicalHeightToRowStyleLogicalHeightIfNotRelative(RenderTableSection::RowStruct& row)
{
ASSERT(row.rowRenderer);
- row.logicalHeight = row.rowRenderer->style()->logicalHeight();
+ row.logicalHeight = row.rowRenderer->style().logicalHeight();
if (row.logicalHeight.isRelative())
row.logicalHeight = Length();
}
@@ -62,7 +62,7 @@
if (cell->rowSpan() != 1)
return;
- Length logicalHeight = cell->style()->logicalHeight();
+ Length logicalHeight = cell->style().logicalHeight();
if (logicalHeight.isPositive() || (logicalHeight.isRelative() && logicalHeight.value() >= 0)) {
Length cRowLogicalHeight = row.logicalHeight;
switch (logicalHeight.type()) {
@@ -122,7 +122,7 @@
// If border was changed, notify table.
RenderTable* table = this->table();
- if (table && !table->selfNeedsLayout() && !table->normalChildNeedsLayout() && oldStyle && oldStyle->border() != style()->border())
+ if (table && !table->selfNeedsLayout() && !table->normalChildNeedsLayout() && oldStyle && oldStyle->border() != style().border())
table->invalidateCollapsedBorders();
}
@@ -387,7 +387,7 @@
// can be called in a loop (e.g during parsing). Doing it now ensures we have a stable-enough structure.
m_grid.shrinkToFit();
- LayoutStateMaintainer statePusher(&view(), this, locationOffset(), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode());
+ LayoutStateMaintainer statePusher(&view(), this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
const Vector<int>& columnPos = table()->columnPositions();
@@ -532,7 +532,7 @@
int vspacing = table()->vBorderSpacing();
unsigned nEffCols = table()->numEffCols();
- LayoutStateMaintainer statePusher(&view(), this, locationOffset(), hasTransform() || style()->isFlippedBlocksWritingMode());
+ LayoutStateMaintainer statePusher(&view(), this, locationOffset(), hasTransform() || style().isFlippedBlocksWritingMode());
for (unsigned r = 0; r < totalRows; r++) {
// Set the row's x/y position and width/height.
@@ -571,11 +571,11 @@
// match the behavior perfectly, but we'll continue to refine it as we discover new
// bugs. :)
bool cellChildrenFlex = false;
- bool flexAllChildren = cell->style()->logicalHeight().isFixed()
- || (!table()->style()->logicalHeight().isAuto() && rHeight != cell->logicalHeight());
+ bool flexAllChildren = cell->style().logicalHeight().isFixed()
+ || (!table()->style().logicalHeight().isAuto() && rHeight != cell->logicalHeight());
for (RenderObject* o = cell->firstChild(); o; o = o->nextSibling()) {
- if (!o->isText() && o->style()->logicalHeight().isPercent() && (flexAllChildren || ((o->isReplaced() || (o->isBox() && toRenderBox(o)->scrollsOverflow())) && !o->isTextControl()))) {
+ if (!o->isText() && o->style().logicalHeight().isPercent() && (flexAllChildren || ((o->isReplaced() || (o->isBox() && toRenderBox(o)->scrollsOverflow())) && !o->isTextControl()))) {
// Tables with no sections do not flex.
if (!o->isTable() || toRenderTable(o)->hasSections()) {
o->setNeedsLayout(MarkOnlyThis);
@@ -725,13 +725,13 @@
unsigned borderWidth = 0;
- const BorderValue& sb = style()->borderBefore();
+ const BorderValue& sb = style().borderBefore();
if (sb.style() == BHIDDEN)
return -1;
if (sb.style() > BHIDDEN)
borderWidth = sb.width();
- const BorderValue& rb = firstRow()->style()->borderBefore();
+ const BorderValue& rb = firstRow()->style().borderBefore();
if (rb.style() == BHIDDEN)
return -1;
if (rb.style() > BHIDDEN && rb.width() > borderWidth)
@@ -742,11 +742,11 @@
const CellStruct& current = cellAt(0, c);
if (current.inColSpan || !current.hasCells())
continue;
- const BorderValue& cb = current.primaryCell()->style()->borderBefore(); // FIXME: Make this work with perpendicular and flipped cells.
+ const BorderValue& cb = current.primaryCell()->style().borderBefore(); // FIXME: Make this work with perpendicular and flipped cells.
// FIXME: Don't repeat for the same col group
RenderTableCol* colGroup = table()->colElement(c);
if (colGroup) {
- const BorderValue& gb = colGroup->style()->borderBefore();
+ const BorderValue& gb = colGroup->style().borderBefore();
if (gb.style() == BHIDDEN || cb.style() == BHIDDEN)
continue;
allHidden = false;
@@ -776,13 +776,13 @@
unsigned borderWidth = 0;
- const BorderValue& sb = style()->borderAfter();
+ const BorderValue& sb = style().borderAfter();
if (sb.style() == BHIDDEN)
return -1;
if (sb.style() > BHIDDEN)
borderWidth = sb.width();
- const BorderValue& rb = lastRow()->style()->borderAfter();
+ const BorderValue& rb = lastRow()->style().borderAfter();
if (rb.style() == BHIDDEN)
return -1;
if (rb.style() > BHIDDEN && rb.width() > borderWidth)
@@ -793,11 +793,11 @@
const CellStruct& current = cellAt(m_grid.size() - 1, c);
if (current.inColSpan || !current.hasCells())
continue;
- const BorderValue& cb = current.primaryCell()->style()->borderAfter(); // FIXME: Make this work with perpendicular and flipped cells.
+ const BorderValue& cb = current.primaryCell()->style().borderAfter(); // FIXME: Make this work with perpendicular and flipped cells.
// FIXME: Don't repeat for the same col group
RenderTableCol* colGroup = table()->colElement(c);
if (colGroup) {
- const BorderValue& gb = colGroup->style()->borderAfter();
+ const BorderValue& gb = colGroup->style().borderAfter();
if (gb.style() == BHIDDEN || cb.style() == BHIDDEN)
continue;
allHidden = false;
@@ -827,14 +827,14 @@
unsigned borderWidth = 0;
- const BorderValue& sb = style()->borderStart();
+ const BorderValue& sb = style().borderStart();
if (sb.style() == BHIDDEN)
return -1;
if (sb.style() > BHIDDEN)
borderWidth = sb.width();
if (RenderTableCol* colGroup = table()->colElement(0)) {
- const BorderValue& gb = colGroup->style()->borderStart();
+ const BorderValue& gb = colGroup->style().borderStart();
if (gb.style() == BHIDDEN)
return -1;
if (gb.style() > BHIDDEN && gb.width() > borderWidth)
@@ -847,8 +847,8 @@
if (!current.hasCells())
continue;
// FIXME: Don't repeat for the same cell
- const BorderValue& cb = current.primaryCell()->style()->borderStart(); // FIXME: Make this work with perpendicular and flipped cells.
- const BorderValue& rb = current.primaryCell()->parent()->style()->borderStart();
+ const BorderValue& cb = current.primaryCell()->style().borderStart(); // FIXME: Make this work with perpendicular and flipped cells.
+ const BorderValue& rb = current.primaryCell()->parent()->style().borderStart();
if (cb.style() == BHIDDEN || rb.style() == BHIDDEN)
continue;
allHidden = false;
@@ -860,7 +860,7 @@
if (allHidden)
return -1;
- return (borderWidth + (table()->style()->isLeftToRightDirection() ? 0 : 1)) / 2;
+ return (borderWidth + (table()->style().isLeftToRightDirection() ? 0 : 1)) / 2;
}
int RenderTableSection::calcOuterBorderEnd() const
@@ -871,14 +871,14 @@
unsigned borderWidth = 0;
- const BorderValue& sb = style()->borderEnd();
+ const BorderValue& sb = style().borderEnd();
if (sb.style() == BHIDDEN)
return -1;
if (sb.style() > BHIDDEN)
borderWidth = sb.width();
if (RenderTableCol* colGroup = table()->colElement(totalCols - 1)) {
- const BorderValue& gb = colGroup->style()->borderEnd();
+ const BorderValue& gb = colGroup->style().borderEnd();
if (gb.style() == BHIDDEN)
return -1;
if (gb.style() > BHIDDEN && gb.width() > borderWidth)
@@ -891,8 +891,8 @@
if (!current.hasCells())
continue;
// FIXME: Don't repeat for the same cell
- const BorderValue& cb = current.primaryCell()->style()->borderEnd(); // FIXME: Make this work with perpendicular and flipped cells.
- const BorderValue& rb = current.primaryCell()->parent()->style()->borderEnd();
+ const BorderValue& cb = current.primaryCell()->style().borderEnd(); // FIXME: Make this work with perpendicular and flipped cells.
+ const BorderValue& rb = current.primaryCell()->parent()->style().borderEnd();
if (cb.style() == BHIDDEN || rb.style() == BHIDDEN)
continue;
allHidden = false;
@@ -904,7 +904,7 @@
if (allHidden)
return -1;
- return (borderWidth + (table()->style()->isLeftToRightDirection() ? 1 : 0)) / 2;
+ return (borderWidth + (table()->style().isLeftToRightDirection() ? 1 : 0)) / 2;
}
void RenderTableSection::recalcOuterBorder()
@@ -959,7 +959,7 @@
if (pushedClip)
popContentsClip(paintInfo, phase, adjustedPaintOffset);
- if ((phase == PaintPhaseOutline || phase == PaintPhaseSelfOutline) && style()->visibility() == VISIBLE)
+ if ((phase == PaintPhaseOutline || phase == PaintPhaseSelfOutline) && style().visibility() == VISIBLE)
paintOutline(paintInfo, LayoutRect(adjustedPaintOffset, size()));
}
@@ -1016,12 +1016,12 @@
flipForWritingMode(tableAlignedRect);
- if (!style()->isHorizontalWritingMode())
+ if (!style().isHorizontalWritingMode())
tableAlignedRect = tableAlignedRect.transposedRect();
const Vector<int>& columnPos = table()->columnPositions();
// FIXME: The table's direction should determine our row's direction, not the section's (see bug 96691).
- if (!style()->isLeftToRightDirection())
+ if (!style().isLeftToRightDirection())
tableAlignedRect.setX(columnPos[columnPos.size() - 1] - tableAlignedRect.maxX());
return tableAlignedRect;
@@ -1121,49 +1121,49 @@
rect.intersect(paintInfo.rect);
if (rect.isEmpty())
return;
- drawLineForBoxSide(paintInfo.context, rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height(), side, style()->visitedDependentColor(borderColor), borderStyle, 0, 0, antialias);
+ drawLineForBoxSide(paintInfo.context, rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height(), side, style().visitedDependentColor(borderColor), borderStyle, 0, 0, antialias);
}
int RenderTableSection::offsetLeftForRowGroupBorder(RenderTableCell* cell, const LayoutRect& rowGroupRect, unsigned row)
{
- if (style()->isHorizontalWritingMode()) {
- if (style()->isLeftToRightDirection())
+ if (style().isHorizontalWritingMode()) {
+ if (style().isLeftToRightDirection())
return cell ? cell->x().toInt() + cell->width().toInt() : 0;
- return -outerBorderLeft(style());
+ return -outerBorderLeft(&style());
}
bool isLastRow = row + 1 == m_grid.size();
- return rowGroupRect.width().toInt() - m_rowPos[row + 1] + (isLastRow ? -outerBorderLeft(style()) : 0);
+ return rowGroupRect.width().toInt() - m_rowPos[row + 1] + (isLastRow ? -outerBorderLeft(&style()) : 0);
}
int RenderTableSection::offsetTopForRowGroupBorder(RenderTableCell* cell, BoxSide borderSide, unsigned row)
{
bool isLastRow = row + 1 == m_grid.size();
- if (style()->isHorizontalWritingMode())
- return m_rowPos[row] + (!row && borderSide == BSRight ? -outerBorderTop(style()) : isLastRow && borderSide == BSLeft ? outerBorderTop(style()) : 0);
- if (style()->isLeftToRightDirection())
- return (cell ? cell->y().toInt() + cell->height().toInt() : 0) + (borderSide == BSLeft ? outerBorderTop(style()) : 0);
- return borderSide == BSRight ? -outerBorderTop(style()) : 0;
+ if (style().isHorizontalWritingMode())
+ return m_rowPos[row] + (!row && borderSide == BSRight ? -outerBorderTop(&style()) : isLastRow && borderSide == BSLeft ? outerBorderTop(&style()) : 0);
+ if (style().isLeftToRightDirection())
+ return (cell ? cell->y().toInt() + cell->height().toInt() : 0) + (borderSide == BSLeft ? outerBorderTop(&style()) : 0);
+ return borderSide == BSRight ? -outerBorderTop(&style()) : 0;
}
int RenderTableSection::verticalRowGroupBorderHeight(RenderTableCell* cell, const LayoutRect& rowGroupRect, unsigned row)
{
bool isLastRow = row + 1 == m_grid.size();
- if (style()->isHorizontalWritingMode())
- return m_rowPos[row + 1] - m_rowPos[row] + (!row ? outerBorderTop(style()) : isLastRow ? outerBorderBottom(style()) : 0);
- if (style()->isLeftToRightDirection())
- return rowGroupRect.height().toInt() - (cell ? cell->y().toInt() + cell->height().toInt() : 0) + outerBorderBottom(style());
+ if (style().isHorizontalWritingMode())
+ return m_rowPos[row + 1] - m_rowPos[row] + (!row ? outerBorderTop(&style()) : isLastRow ? outerBorderBottom(&style()) : 0);
+ if (style().isLeftToRightDirection())
+ return rowGroupRect.height().toInt() - (cell ? cell->y().toInt() + cell->height().toInt() : 0) + outerBorderBottom(&style());
return cell ? rowGroupRect.height().toInt() - (cell->y().toInt() - cell->height().toInt()) : 0;
}
int RenderTableSection::horizontalRowGroupBorderWidth(RenderTableCell* cell, const LayoutRect& rowGroupRect, unsigned row, unsigned column)
{
- if (style()->isHorizontalWritingMode()) {
- if (style()->isLeftToRightDirection())
- return rowGroupRect.width().toInt() - (cell ? cell->x().toInt() + cell->width().toInt() : 0) + (!column ? outerBorderLeft(style()) : column == table()->numEffCols() ? outerBorderRight(style()) : 0);
+ if (style().isHorizontalWritingMode()) {
+ if (style().isLeftToRightDirection())
+ return rowGroupRect.width().toInt() - (cell ? cell->x().toInt() + cell->width().toInt() : 0) + (!column ? outerBorderLeft(&style()) : column == table()->numEffCols() ? outerBorderRight(&style()) : 0);
return cell ? rowGroupRect.width().toInt() - (cell->x().toInt() - cell->width().toInt()) : 0;
}
bool isLastRow = row + 1 == m_grid.size();
- return m_rowPos[row + 1] - m_rowPos[row] + (isLastRow ? outerBorderLeft(style()) : !row ? outerBorderRight(style()) : 0);
+ return m_rowPos[row + 1] - m_rowPos[row] + (isLastRow ? outerBorderLeft(&style()) : !row ? outerBorderRight(&style()) : 0);
}
void RenderTableSection::paintRowGroupBorderIfRequired(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, unsigned row, unsigned column, BoxSide borderSide, RenderTableCell* cell)
@@ -1173,27 +1173,27 @@
if (paintInfo.context->paintingDisabled())
return;
- RenderStyle* style = this->style();
+ const RenderStyle& style = this->style();
bool antialias = shouldAntialiasLines(paintInfo.context);
LayoutRect rowGroupRect = LayoutRect(paintOffset, size());
- rowGroupRect.moveBy(-LayoutPoint(outerBorderLeft(style), (borderSide == BSRight) ? 0 : outerBorderTop(style)));
+ rowGroupRect.moveBy(-LayoutPoint(outerBorderLeft(&style), (borderSide == BSRight) ? 0 : outerBorderTop(&style)));
switch (borderSide) {
case BSTop:
paintRowGroupBorder(paintInfo, antialias, LayoutRect(paintOffset.x() + offsetLeftForRowGroupBorder(cell, rowGroupRect, row), rowGroupRect.y(),
- horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), style->borderTop().width()), BSTop, CSSPropertyBorderTopColor, style->borderTopStyle(), table()->style()->borderTopStyle());
+ horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), style.borderTop().width()), BSTop, CSSPropertyBorderTopColor, style.borderTopStyle(), table()->style().borderTopStyle());
break;
case BSBottom:
paintRowGroupBorder(paintInfo, antialias, LayoutRect(paintOffset.x() + offsetLeftForRowGroupBorder(cell, rowGroupRect, row), rowGroupRect.y() + rowGroupRect.height(),
- horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), style->borderBottom().width()), BSBottom, CSSPropertyBorderBottomColor, style->borderBottomStyle(), table()->style()->borderBottomStyle());
+ horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), style.borderBottom().width()), BSBottom, CSSPropertyBorderBottomColor, style.borderBottomStyle(), table()->style().borderBottomStyle());
break;
case BSLeft:
- paintRowGroupBorder(paintInfo, antialias, LayoutRect(rowGroupRect.x(), rowGroupRect.y() + offsetTopForRowGroupBorder(cell, borderSide, row), style->borderLeft().width(),
- verticalRowGroupBorderHeight(cell, rowGroupRect, row)), BSLeft, CSSPropertyBorderLeftColor, style->borderLeftStyle(), table()->style()->borderLeftStyle());
+ paintRowGroupBorder(paintInfo, antialias, LayoutRect(rowGroupRect.x(), rowGroupRect.y() + offsetTopForRowGroupBorder(cell, borderSide, row), style.borderLeft().width(),
+ verticalRowGroupBorderHeight(cell, rowGroupRect, row)), BSLeft, CSSPropertyBorderLeftColor, style.borderLeftStyle(), table()->style().borderLeftStyle());
break;
case BSRight:
- paintRowGroupBorder(paintInfo, antialias, LayoutRect(rowGroupRect.x() + rowGroupRect.width(), rowGroupRect.y() + offsetTopForRowGroupBorder(cell, borderSide, row), style->borderRight().width(),
- verticalRowGroupBorderHeight(cell, rowGroupRect, row)), BSRight, CSSPropertyBorderRightColor, style->borderRightStyle(), table()->style()->borderRightStyle());
+ paintRowGroupBorder(paintInfo, antialias, LayoutRect(rowGroupRect.x() + rowGroupRect.width(), rowGroupRect.y() + offsetTopForRowGroupBorder(cell, borderSide, row), style.borderRight().width(),
+ verticalRowGroupBorderHeight(cell, rowGroupRect, row)), BSRight, CSSPropertyBorderRightColor, style.borderRightStyle(), table()->style().borderRightStyle());
break;
default:
break;
@@ -1256,9 +1256,9 @@
RenderTableCell* cell = current.primaryCell();
if (!cell) {
if (!c)
- paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(style(), CBSStart));
+ paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(&style(), CBSStart));
else if (c == table()->numEffCols())
- paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(style(), CBSEnd));
+ paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(&style(), CBSEnd));
shouldPaintRowGroupBorder = true;
continue;
}
@@ -1269,9 +1269,9 @@
// this will only happen once within a row as the null cells will always be clustered together on one end of the row.
if (shouldPaintRowGroupBorder) {
if (r == m_grid.size())
- paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(style(), CBSAfter), cell);
+ paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(&style(), CBSAfter), cell);
else if (!row && !table()->sectionAbove(this))
- paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(style(), CBSBefore), cell);
+ paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(&style(), CBSBefore), cell);
shouldPaintRowGroupBorder = false;
}
@@ -1422,13 +1422,13 @@
const BorderValue& RenderTableSection::borderAdjoiningStartCell(const RenderTableCell* cell) const
{
ASSERT(cell->isFirstOrLastCellInRow());
- return hasSameDirectionAs(cell) ? style()->borderStart() : style()->borderEnd();
+ return hasSameDirectionAs(cell) ? style().borderStart() : style().borderEnd();
}
const BorderValue& RenderTableSection::borderAdjoiningEndCell(const RenderTableCell* cell) const
{
ASSERT(cell->isFirstOrLastCellInRow());
- return hasSameDirectionAs(cell) ? style()->borderEnd() : style()->borderStart();
+ return hasSameDirectionAs(cell) ? style().borderEnd() : style().borderStart();
}
const RenderTableCell* RenderTableSection::firstRowCellAdjoiningTableStart() const
@@ -1569,7 +1569,7 @@
RenderTableSection* RenderTableSection::createAnonymousWithParentRenderer(const RenderObject* parent)
{
- auto section = new RenderTableSection(parent->document(), RenderStyle::createAnonymousStyleWithDisplay(parent->style(), TABLE_ROW_GROUP));
+ auto section = new RenderTableSection(parent->document(), RenderStyle::createAnonymousStyleWithDisplay(&parent->style(), TABLE_ROW_GROUP));
section->initializeStyle();
return section;
}
@@ -1582,7 +1582,7 @@
int horizontalBorderSpacing = table()->hBorderSpacing();
// FIXME: The table's direction should determine our row's direction, not the section's (see bug 96691).
- if (!style()->isLeftToRightDirection())
+ if (!style().isLeftToRightDirection())
cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - table()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing);
else
cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizontalBorderSpacing);