Commit 440ac8c4 authored by mitz@apple.com's avatar mitz@apple.com
Browse files

WebCore:

        Reviewed by Darin Adler.

        - fix <rdar://problem/5843719> Excessive repainting of cells in tables with non-auto height

        Test: fast/repaint/table-two-pass-layout-overpaint.html

        * rendering/RenderTable.cpp:
        (WebCore::RenderTable::layout): Changed the first pass over the sections
        to only call calcRowHeight() and recalcOuterBorder() but not
        layoutRows(), because the section's final height is unknown yet.
        Removed caching of m_height before the call to calcHeight(), because
        for non-positioned tables, calcHeight() only calculates the vertical
        margins and does not change m_height.
        Added a second pass over the sections, after the table height is known,
        to call layoutRows() on each section, with additional height if needed.
        Did minimal cleanup including caching the value of collapseBorders() in
        a local variable and changing a while loop into a for loop.
        * rendering/RenderTableSection.cpp:
        (WebCore::RenderTableSection::calcRowHeight): Changed to return the
        height of the section based on row height calculations.
        (WebCore::RenderTableSection::layoutRows): Removed a call to
        recalcOuterBorder(), which is now done by RenderTable::layout().
        * rendering/RenderTableSection.h: Changed calcRowHeight() to have a
        return value.

LayoutTests:

        Reviewed by Darin Adler.

        - repaint test for <rdar://problem/5843719> Excessive repainting of cells in tables with non-auto height

        * fast/repaint/table-two-pass-layout-overpaint.html: Added.
        * platform/mac/fast/repaint/table-two-pass-layout-overpaint-expected.checksum: Added.
        * platform/mac/fast/repaint/table-two-pass-layout-overpaint-expected.png: Added.
        * platform/mac/fast/repaint/table-two-pass-layout-overpaint-expected.txt: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31663 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6e2533da
2008-04-05 Dan Bernstein <mitz@apple.com>
Reviewed by Darin Adler.
- repaint test for <rdar://problem/5843719> Excessive repainting of cells in tables with non-auto height
* fast/repaint/table-two-pass-layout-overpaint.html: Added.
* platform/mac/fast/repaint/table-two-pass-layout-overpaint-expected.checksum: Added.
* platform/mac/fast/repaint/table-two-pass-layout-overpaint-expected.png: Added.
* platform/mac/fast/repaint/table-two-pass-layout-overpaint-expected.txt: Added.
2008-04-03 Oliver Hunt <oliver@apple.com>
 
Reviewed by NOBODY (Rollout).
<html>
<head>
<style>
table { background-color: lightblue; height: 100px; }
td { width: 100px; height: 50px; }
div#target { height: 25px; background-color: lightgreen; }
</style>
<script src="repaint.js"></script>
<script>
function repaintTest()
{
document.getElementById("target").style.width = "50px";
}
</script>
</head>
<body onload="runRepaintTest()">
<table>
<tr>
<td>
<div id="target"></div>
</td>
</tr>
</table>
</body>
</html>
c7240d897db7ff15e630e4f1630dc5db
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderTable {TABLE} at (0,0) size 106x98 [bgcolor=#ADD8E6]
RenderTableSection {TBODY} at (0,0) size 106x98
RenderTableRow {TR} at (0,2) size 106x94
RenderTableCell {TD} at (2,35) size 102x27 [r=0 c=0 rs=1 cs=1]
RenderBlock {DIV} at (1,1) size 50x25 [bgcolor=#90EE90]
2008-04-05 Dan Bernstein <mitz@apple.com>
Reviewed by Darin Adler.
- fix <rdar://problem/5843719> Excessive repainting of cells in tables with non-auto height
Test: fast/repaint/table-two-pass-layout-overpaint.html
* rendering/RenderTable.cpp:
(WebCore::RenderTable::layout): Changed the first pass over the sections
to only call calcRowHeight() and recalcOuterBorder() but not
layoutRows(), because the section's final height is unknown yet.
Removed caching of m_height before the call to calcHeight(), because
for non-positioned tables, calcHeight() only calculates the vertical
margins and does not change m_height.
Added a second pass over the sections, after the table height is known,
to call layoutRows() on each section, with additional height if needed.
Did minimal cleanup including caching the value of collapseBorders() in
a local variable and changing a while loop into a for loop.
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::calcRowHeight): Changed to return the
height of the section based on row height calculations.
(WebCore::RenderTableSection::layoutRows): Removed a call to
recalcOuterBorder(), which is now done by RenderTable::layout().
* rendering/RenderTableSection.h: Changed calcRowHeight() to have a
return value.
2008-04-05 Simon Hausmann <shausman@trolltech.com>
 
Reviewed by Holger.
......@@ -290,20 +290,22 @@ void RenderTable::layout()
int calculatedHeight = 0;
int oldTableTop = m_caption ? m_caption->height() + m_caption->marginTop() + m_caption->marginBottom() : 0;
RenderObject* child = firstChild();
while (child) {
bool collapsing = collapseBorders();
for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
// FIXME: What about a form that has a display value that makes it a table section?
if (child->needsLayout() && !(child->element() && child->element()->hasTagName(formTag)))
child->layout();
if (child->isTableSection()) {
static_cast<RenderTableSection*>(child)->calcRowHeight();
calculatedHeight += static_cast<RenderTableSection*>(child)->layoutRows(0);
RenderTableSection* section = static_cast<RenderTableSection*>(child);
calculatedHeight += section->calcRowHeight();
if (collapsing)
section->recalcOuterBorder();
}
child = child->nextSibling();
}
m_overflowWidth = m_width + (collapseBorders() ? outerBorderRight() - borderRight() : 0);
m_overflowLeft = collapseBorders() ? borderLeft() - outerBorderLeft() : 0;
m_overflowWidth = m_width + (collapsing ? outerBorderRight() - borderRight() : 0);
m_overflowLeft = collapsing ? borderLeft() - outerBorderLeft() : 0;
// If any table section moved vertically, we will just repaint everything from that
// section down (it is quite unlikely that any of the following sections
......@@ -331,15 +333,13 @@ void RenderTable::layout()
}
}
int bpTop = borderTop() + (collapseBorders() ? 0 : paddingTop());
int bpBottom = borderBottom() + (collapseBorders() ? 0 : paddingBottom());
int bpTop = borderTop() + (collapsing ? 0 : paddingTop());
int bpBottom = borderBottom() + (collapsing ? 0 : paddingBottom());
m_height += bpTop;
int oldHeight = m_height;
if (!isPositioned())
calcHeight();
m_height = oldHeight;
Length h = style()->height();
int th = 0;
......@@ -350,23 +350,21 @@ void RenderTable::layout()
th = calcPercentageHeight(h);
th = max(0, th);
// layout rows
if (th > calculatedHeight) {
// we have to redistribute that height to get the constraint correctly
// just force the first body to the height needed
// FIXME: This should take height constraints on all table sections into account and distribute
// accordingly. For now this should be good enough.
if (m_firstBody) {
m_firstBody->calcRowHeight();
m_firstBody->layoutRows(th - calculatedHeight);
} else if (!style()->htmlHacks())
// Completely empty tables (with no sections or anything) should at least honor specified height
// in strict mode.
m_height += th;
for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
if (!child->isTableSection())
continue;
// FIXME: Distribute extra height between all table body sections instead of giving it all to the first one.
static_cast<RenderTableSection*>(child)->layoutRows(child == m_firstBody ? max(0, th - calculatedHeight) : 0);
}
if (!m_firstBody && th > calculatedHeight && !style()->htmlHacks()) {
// Completely empty tables (with no sections or anything) should at least honor specified height
// in strict mode.
m_height += th;
}
int bl = borderLeft();
if (!collapseBorders())
if (!collapsing)
bl += paddingLeft();
// position the table sections
......
......@@ -307,7 +307,7 @@ void RenderTableSection::setCellWidths()
view()->popLayoutState();
}
void RenderTableSection::calcRowHeight()
int RenderTableSection::calcRowHeight()
{
RenderTableCell* cell;
......@@ -386,6 +386,8 @@ void RenderTableSection::calcRowHeight()
if (pushedLayoutState)
view()->popLayoutState();
return m_rowPos[m_gridRows];
}
int RenderTableSection::layoutRows(int toAdd)
......@@ -402,9 +404,6 @@ int RenderTableSection::layoutRows(int toAdd)
m_overflowHeight = 0;
m_hasOverflowingCell = false;
if (table()->collapseBorders())
recalcOuterBorder();
if (toAdd && totalRows && (m_rowPos[totalRows] || !nextSibling())) {
int totalHeight = m_rowPos[totalRows] + toAdd;
......
......@@ -55,7 +55,7 @@ public:
void addCell(RenderTableCell*, RenderObject* row);
void setCellWidths();
void calcRowHeight();
int calcRowHeight();
int layoutRows(int height);
RenderTable* table() const { return static_cast<RenderTable*>(parent()); }
......
Supports Markdown
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