Move the extra logical height distribution into RenderTable as a new step in our layout algorithm
https://bugs.webkit.org/show_bug.cgi?id=81548
Reviewed by Tony Chang.
Refactoring, no expected change in behavior.
Moving the distribution step into RenderTable is needed to implement a better distribution algorithm that would
span several RenderTableSection (which is what IE and FF are doing right now).
* rendering/RenderTable.cpp:
(WebCore::RenderTable::distributeExtraLogicalHeight):
(WebCore::RenderTable::layout):
Moved the distribution step into distributeExtraLogicalHeight. While at it, changed the code to make use of the helper
methods to iterate over the sections and explicitly floor the LayoutUnit before calling distributeExtraLogicalHeight.
* rendering/RenderTable.h:
Added distributeExtraLogicalHeight.
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::layoutRows):
Changed the method signature as it doesn't handle the distribution step anymore.
* rendering/RenderTableSection.h:
Updated layoutRows signature and exposed distributeExtraLogicalHeightToRows for RenderTable use.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@111353 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 37b7ebf..c1142e7 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,31 @@
+2012-03-19 Julien Chaffraix <jchaffraix@webkit.org>
+
+ Move the extra logical height distribution into RenderTable as a new step in our layout algorithm
+ https://bugs.webkit.org/show_bug.cgi?id=81548
+
+ Reviewed by Tony Chang.
+
+ Refactoring, no expected change in behavior.
+
+ Moving the distribution step into RenderTable is needed to implement a better distribution algorithm that would
+ span several RenderTableSection (which is what IE and FF are doing right now).
+
+ * rendering/RenderTable.cpp:
+ (WebCore::RenderTable::distributeExtraLogicalHeight):
+ (WebCore::RenderTable::layout):
+ Moved the distribution step into distributeExtraLogicalHeight. While at it, changed the code to make use of the helper
+ methods to iterate over the sections and explicitly floor the LayoutUnit before calling distributeExtraLogicalHeight.
+
+ * rendering/RenderTable.h:
+ Added distributeExtraLogicalHeight.
+
+ * rendering/RenderTableSection.cpp:
+ (WebCore::RenderTableSection::layoutRows):
+ Changed the method signature as it doesn't handle the distribution step anymore.
+
+ * rendering/RenderTableSection.h:
+ Updated layoutRows signature and exposed distributeExtraLogicalHeightToRows for RenderTable use.
+
2012-03-19 Anders Carlsson <andersca@apple.com>
Another attempt at fixing the Windows build.
diff --git a/Source/WebCore/rendering/RenderTable.cpp b/Source/WebCore/rendering/RenderTable.cpp
index a5305fa..a2e25fc 100644
--- a/Source/WebCore/rendering/RenderTable.cpp
+++ b/Source/WebCore/rendering/RenderTable.cpp
@@ -299,6 +299,20 @@
setLogicalHeight(logicalHeight() + caption->logicalHeight() + caption->marginBefore() + caption->marginAfter());
}
+void RenderTable::distributeExtraLogicalHeight(int extraLogicalHeight)
+{
+ if (extraLogicalHeight <= 0)
+ return;
+
+ // FIXME: Distribute the extra logical height between all table sections instead of giving it all to the first one.
+ if (RenderTableSection* section = topSection())
+ extraLogicalHeight = section->distributeExtraLogicalHeightToRows(extraLogicalHeight);
+
+ // FIXME: We really would like to enable this ASSERT to ensure that all the extra space has been distributed.
+ // However our current distribution algorithm does not round properly and thus we can have some remaining height.
+ // ASSERT(!topSection() || !extraLogicalHeight);
+}
+
void RenderTable::layout()
{
ASSERT(needsLayout());
@@ -390,11 +404,10 @@
computedLogicalHeight = computePercentageLogicalHeight(logicalHeightLength);
computedLogicalHeight = max<LayoutUnit>(0, computedLogicalHeight);
- for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
- if (child->isTableSection())
- // FIXME: Distribute the extra logical height between all table sections instead of giving it all to the first one.
- toRenderTableSection(child)->layoutRows(child == topSection() ? max<LayoutUnit>(0, computedLogicalHeight - totalSectionLogicalHeight) : 0);
- }
+ distributeExtraLogicalHeight(floorToInt(computedLogicalHeight - totalSectionLogicalHeight));
+
+ for (RenderTableSection* section = topSection(); section; section = sectionBelow(section))
+ section->layoutRows();
if (!topSection() && computedLogicalHeight > totalSectionLogicalHeight && !document()->inQuirksMode()) {
// Completely empty tables (with no sections or anything) should at least honor specified height
diff --git a/Source/WebCore/rendering/RenderTable.h b/Source/WebCore/rendering/RenderTable.h
index d4e4fca..5fda200 100644
--- a/Source/WebCore/rendering/RenderTable.h
+++ b/Source/WebCore/rendering/RenderTable.h
@@ -252,6 +252,8 @@
void recalcSections() const;
void layoutCaption(RenderTableCaption*);
+ void distributeExtraLogicalHeight(int extraLogicalHeight);
+
mutable Vector<LayoutUnit> m_columnPos;
mutable Vector<ColumnStruct> m_columns;
mutable Vector<RenderTableCaption*> m_captions;
diff --git a/Source/WebCore/rendering/RenderTableSection.cpp b/Source/WebCore/rendering/RenderTableSection.cpp
index 8d7dc65..0d799cb 100644
--- a/Source/WebCore/rendering/RenderTableSection.cpp
+++ b/Source/WebCore/rendering/RenderTableSection.cpp
@@ -520,7 +520,7 @@
return remainingExtraLogicalHeight;
}
-int RenderTableSection::layoutRows(int extraLogicalHeight)
+void RenderTableSection::layoutRows()
{
#ifndef NDEBUG
setNeedsLayoutIsForbidden(true);
@@ -538,8 +538,6 @@
m_overflowingCells.clear();
m_forceSlowPaintPathWithOverflowingCell = false;
- extraLogicalHeight = distributeExtraLogicalHeightToRows(extraLogicalHeight);
-
int hspacing = table()->hBorderSpacing();
int vspacing = table()->vBorderSpacing();
unsigned nEffCols = table()->numEffCols();
@@ -738,7 +736,6 @@
ASSERT(hasOverflowingCell == this->hasOverflowingCell());
statePusher.pop();
- return height();
}
int RenderTableSection::calcOuterBorderBefore() const
diff --git a/Source/WebCore/rendering/RenderTableSection.h b/Source/WebCore/rendering/RenderTableSection.h
index 8df74f0..ea9eaa7 100644
--- a/Source/WebCore/rendering/RenderTableSection.h
+++ b/Source/WebCore/rendering/RenderTableSection.h
@@ -73,7 +73,7 @@
void setCellLogicalWidths();
int calcRowLogicalHeight();
- int layoutRows(int logicalHeight);
+ void layoutRows();
RenderTable* table() const { return toRenderTable(parent()); }
@@ -158,6 +158,10 @@
void setCachedCollapsedBorder(const RenderTableCell*, CollapsedBorderSide, CollapsedBorderValue);
CollapsedBorderValue& cachedCollapsedBorder(const RenderTableCell*, CollapsedBorderSide);
+ // distributeExtraLogicalHeight* methods return the remaining extra logical height.
+ // FIXME: We may want to introduce a structure holding the in-flux layout information.
+ int distributeExtraLogicalHeightToRows(int extraLogicalHeight);
+
protected:
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
@@ -185,9 +189,6 @@
void ensureRows(unsigned);
- // Those methods return the remaining extra logical height.
- // FIXME: We may want to introduce a structure holding the in-flux layout information.
- int distributeExtraLogicalHeightToRows(int extraLogicalHeight);
int distributeExtraLogicalHeightToPercentRows(int extraLogicalHeight, int totalPercent);
int distributeExtraLogicalHeightToAutoRows(int extraLogicalHeight, unsigned autoRowsCount);
int distributeRemainingExtraLogicalHeight(int extraLogicalHeight);