Attack of the expanding tables

David Hyatt hyatt at apple.com
Tue Sep 30 12:33:29 CEST 2003


The cellpercentageheight variable I was using to flex percentage height 
children in table cells needs to be cleared or the table will expand 
every time it gets a layout.

+++ khtml/rendering/render_table.cpp    2003/09/30 18:30:18
@@ -1399,13 +1399,20 @@ void RenderTableRow::layout()

      RenderObject *child = firstChild();
      while( child ) {
-       if ( child->isTableCell() && child->needsLayout() ) {
-           RenderTableCell *cell = static_cast<RenderTableCell 
*>(child);
-           cell->calcVerticalMargins();
-           cell->layout();
-           cell->setCellTopExtra(0);
-           cell->setCellBottomExtra(0);
-       }
+        if (child->isTableCell()) {
+            RenderTableCell *cell = static_cast<RenderTableCell 
*>(child);
+            if (cell->getCellPercentageHeight()) {
+                cell->setCellPercentageHeight(0);
+                if (!cell->needsLayout())
+                    cell->setChildNeedsLayout(true);
+            }
+            if (child->needsLayout()) {
+                cell->calcVerticalMargins();
+                cell->layout();
+                cell->setCellTopExtra(0);
+                cell->setCellBottomExtra(0);
+            }
+        }
         child = child->nextSibling();
      }
      setNeedsLayout(false);


Here is a test case that demonstrates the problem:

<HTML><BODY>
<TABLE>
<TR><TD id="foo" width="0" height="300" style="background-color:blue">
<table height="100%" border=2><tr><td></td></tr></table>
</TD></TR>
</TABLE>
<script>
var width = 0;
var foo = document.getElementById('foo');
function increaseFoo()
{
     if (width > 600)
       return;
     foo.style.width = width;
     width += 20;
     setTimeout("increaseFoo()", 100);
}

increaseFoo();
</script>
</BODY></HTML>



More information about the Khtml-devel mailing list