Commit 8cdbcc91 authored by ojan@chromium.org's avatar ojan@chromium.org

Table layout does not need to explicitly call computePreferredLogicalWidths

https://bugs.webkit.org/show_bug.cgi?id=106931

Reviewed by Julien Chaffraix.

Code shouldn't need to explicitly call computePreferredLogicalWidths.
It should only get called as a by-product of calling minPreferredLogicalWidth
or maxPreferredLogicalWidth.

Instead, make it clear that the calling code is just trying to clear
preferred width dirty bits.

* rendering/AutoTableLayout.cpp:
(WebCore::AutoTableLayout::recalcColumn):
The computePreferredLogicalWidths call on the table cell is redundant
with the minPreferredLogicalWidth call on the next line.

* rendering/FixedTableLayout.cpp:
(WebCore::FixedTableLayout::calcWidthArray):
We only need to clear the dirty bit here. Table cells don't use
their preferred widths in fixed table layout calculations.

* rendering/RenderTableCell.h:
* rendering/RenderTableCol.cpp:
(WebCore::RenderTableCol::clearPreferredLogicalWidthsDirtyBits):
* rendering/RenderTableCol.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@140047 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a44c86b2
2013-01-17 Ojan Vafai <ojan@chromium.org>
Table layout does not need to explicitly call computePreferredLogicalWidths
https://bugs.webkit.org/show_bug.cgi?id=106931
Reviewed by Julien Chaffraix.
Code shouldn't need to explicitly call computePreferredLogicalWidths.
It should only get called as a by-product of calling minPreferredLogicalWidth
or maxPreferredLogicalWidth.
Instead, make it clear that the calling code is just trying to clear
preferred width dirty bits.
* rendering/AutoTableLayout.cpp:
(WebCore::AutoTableLayout::recalcColumn):
The computePreferredLogicalWidths call on the table cell is redundant
with the minPreferredLogicalWidth call on the next line.
* rendering/FixedTableLayout.cpp:
(WebCore::FixedTableLayout::calcWidthArray):
We only need to clear the dirty bit here. Table cells don't use
their preferred widths in fixed table layout calculations.
* rendering/RenderTableCell.h:
* rendering/RenderTableCol.cpp:
(WebCore::RenderTableCol::clearPreferredLogicalWidthsDirtyBits):
* rendering/RenderTableCol.h:
2013-01-17 Julien Chaffraix <jchaffraix@webkit.org>
[CSS Grid Layout] Updating -webkit-grid-rows or -webkit-grid-columns doesn't work as expected
......@@ -50,9 +50,12 @@ void AutoTableLayout::recalcColumn(unsigned effCol)
RenderTableCell* maxContributor = 0;
for (RenderObject* child = m_table->children()->firstChild(); child; child = child->nextSibling()) {
if (child->isRenderTableCol())
toRenderTableCol(child)->computePreferredLogicalWidths();
else if (child->isTableSection()) {
if (child->isRenderTableCol()){
// RenderTableCols don't have the concept of preferred logical width, but we need to clear their dirty bits
// so that if we call setPreferredWidthsDirty(true) on a col or one of its descendants, we'll mark it's
// ancestors as dirty.
toRenderTableCol(child)->clearPreferredLogicalWidthsDirtyBits();
} else if (child->isTableSection()) {
RenderTableSection* section = toRenderTableSection(child);
unsigned numRows = section->numRows();
for (unsigned i = 0; i < numRows; i++) {
......@@ -72,8 +75,6 @@ void AutoTableLayout::recalcColumn(unsigned effCol)
columnLayout.maxLogicalWidth = max<int>(columnLayout.maxLogicalWidth, 1);
if (cell->colSpan() == 1) {
if (cell->preferredLogicalWidthsDirty())
cell->computePreferredLogicalWidths();
columnLayout.minLogicalWidth = max<int>(cell->minPreferredLogicalWidth(), columnLayout.minLogicalWidth);
if (cell->maxPreferredLogicalWidth() > columnLayout.maxLogicalWidth) {
columnLayout.maxLogicalWidth = cell->maxPreferredLogicalWidth();
......
......@@ -88,7 +88,10 @@ int FixedTableLayout::calcWidthArray(int)
unsigned currentEffectiveColumn = 0;
for (RenderTableCol* col = m_table->firstColumn(); col; col = col->nextColumn()) {
col->computePreferredLogicalWidths();
// RenderTableCols don't have the concept of preferred logical width, but we need to clear their dirty bits
// so that if we call setPreferredWidthsDirty(true) on a col or one of its descendants, we'll mark it's
// ancestors as dirty.
col->clearPreferredLogicalWidthsDirtyBits();
// Width specified by column-groups that have column child does not affect column width in fixed layout tables
if (col->isTableColumnGroupWithColumnChildren())
......@@ -138,12 +141,12 @@ int FixedTableLayout::calcWidthArray(int)
continue;
RenderTableCell* cell = toRenderTableCell(child);
if (cell->preferredLogicalWidthsDirty())
cell->computePreferredLogicalWidths();
Length logicalWidth = cell->styleOrColLogicalWidth();
unsigned span = cell->colSpan();
int fixedBorderBoxLogicalWidth = 0;
// FIXME: Support other length types. If the width is non-auto, it should probably just use
// RenderBox::computeLogicalWidthInRegionUsing to compute the width.
if (logicalWidth.isFixed() && logicalWidth.isPositive()) {
fixedBorderBoxLogicalWidth = cell->adjustBorderBoxLogicalWidthForBoxSizing(logicalWidth.value());
logicalWidth.setValue(fixedBorderBoxLogicalWidth);
......@@ -161,6 +164,12 @@ int FixedTableLayout::calcWidthArray(int)
usedSpan += eSpan;
++currentColumn;
}
// FixedTableLayout doesn't use min/maxPreferredLogicalWidths, but we need to clear the
// dirty bit on the cell so that we'll correctly mark its ancestors dirty
// in case we later call setPreferredLogicalWidthsDirty(true) on it later.
if (cell->preferredLogicalWidthsDirty())
cell->setPreferredLogicalWidthsDirty(false);
}
return usedWidth;
......
......@@ -102,7 +102,6 @@ public:
return max(styleLogicalHeight, adjustedLogicalHeight);
}
virtual void computePreferredLogicalWidths();
void setCellLogicalWidth(int constrainedLogicalWidth);
......@@ -207,6 +206,7 @@ public:
#endif
protected:
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
virtual void computePreferredLogicalWidths();
private:
virtual const char* renderName() const { return (isAnonymous() || isPseudoElement()) ? "RenderTableCell (anonymous)" : "RenderTableCell"; }
......
......@@ -115,7 +115,7 @@ void RenderTableCol::imageChanged(WrappedImagePtr, const IntRect*)
repaint();
}
void RenderTableCol::computePreferredLogicalWidths()
void RenderTableCol::clearPreferredLogicalWidthsDirtyBits()
{
setPreferredLogicalWidthsDirty(false);
......
......@@ -43,7 +43,7 @@ public:
const RenderObjectChildList* children() const { return &m_children; }
RenderObjectChildList* children() { return &m_children; }
virtual void computePreferredLogicalWidths();
void clearPreferredLogicalWidthsDirtyBits();
unsigned span() const { return m_span; }
void setSpan(unsigned span) { m_span = span; }
......@@ -85,6 +85,7 @@ private:
virtual const char* renderName() const { return "RenderTableCol"; }
virtual bool isRenderTableCol() const OVERRIDE { return true; }
virtual void updateFromElement();
virtual void computePreferredLogicalWidths() OVERRIDE { ASSERT_NOT_REACHED(); }
virtual void insertedIntoTree() OVERRIDE;
virtual void willBeRemovedFromTree() OVERRIDE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment