Fix for various table regressions (malumovies.com and cityofheroes.gameamp.com)...
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Jul 2004 19:49:48 +0000 (19:49 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Jul 2004 19:49:48 +0000 (19:49 +0000)
percentage heights.

        Reviewed by kocienda

        * khtml/rendering/render_box.cpp:
        (RenderBox::calcPercentageHeight):
        (RenderBox::availableHeightUsing):
        * khtml/rendering/render_table.cpp:
        (RenderTable::layout):
        (RenderTableSection::calcRowHeight):
        (RenderTableSection::layoutRows):
        (RenderTableCell::updateFromElement):
        * khtml/rendering/render_table.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7024 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/khtml/rendering/render_box.cpp
WebCore/khtml/rendering/render_table.cpp
WebCore/khtml/rendering/render_table.h

index a5ce0f4..ebc9101 100644 (file)
@@ -1,3 +1,20 @@
+2004-07-14  David Hyatt  <hyatt@apple.com>
+
+       Fix for various table regressions (malumovies.com and cityofheroes.gameamp.com) involving bungling of
+       percentage heights.
+       
+        Reviewed by kocienda
+
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::calcPercentageHeight):
+        (RenderBox::availableHeightUsing):
+        * khtml/rendering/render_table.cpp:
+        (RenderTable::layout):
+        (RenderTableSection::calcRowHeight):
+        (RenderTableSection::layoutRows):
+        (RenderTableCell::updateFromElement):
+        * khtml/rendering/render_table.h:
+
 2004-07-14  Ken Kocienda  <kocienda@apple.com>
 
         Reviewed by John
index 155596c..d0b6564 100644 (file)
@@ -1000,8 +1000,8 @@ int RenderBox::calcPercentageHeight(const Length& height)
     // don't care if the cell specified a height or not.  We just always make ourselves
     // be a percentage of the cell's current content height.
     if (cb->isTableCell()) {
-        result = static_cast<RenderTableCell*>(cb)->getCellPercentageHeight();
-        if (result == 0)
+        result = cb->overrideSize();
+        if (result == -1)
             return -1;
         // It is necessary to use the border-box to match WinIE's broken
         // box model.  This is essential for sizing inside
@@ -1123,8 +1123,7 @@ int RenderBox::availableHeightUsing(const Length& h) const
     // artificially.  We're going to rely on this cell getting expanded to some new
     // height, and then when we lay out again we'll use the calculation below.
     if (isTableCell() && (h.isVariable() || h.isPercent())) {
-        const RenderTableCell* tableCell = static_cast<const RenderTableCell*>(this);
-        return tableCell->getCellPercentageHeight() - (borderLeft()+borderRight()+paddingLeft()+paddingRight());
+        return overrideSize() - (borderLeft()+borderRight()+paddingLeft()+paddingRight());
     }
     
     if (h.isPercent())
index 0cbf9ad..4b9ab22 100644 (file)
@@ -286,7 +286,6 @@ void RenderTable::layout()
     int newHeight = m_height;
     m_height = oldHeight;
 
-    // html tables with percent height are relative to view
     Length h = style()->height();
     int th = -(bpTop + bpBottom); // Tables size as though CSS height includes border/padding.
     if (isPositioned())
@@ -307,17 +306,16 @@ void RenderTable::layout()
         }
 
         if (c->isTableCell()) {
-            RenderTableCell* cell = static_cast<RenderTableCell*>(c);
-            int cellHeight = cell->getCellPercentageHeight();
-            if (cellHeight)
+            int cellHeight = c->overrideSize();
+            if (cellHeight != -1)
                 th += h.width(cellHeight);
         }
         else  {
             Length ch = c->style()->height();
             if (ch.isFixed())
                 th += h.width(ch.value);
-            else
-                // FIXME: Investigate this.  Seems wrong to always expand to fill the viewRect.
+            else if (style()->htmlHacks())
+                // In quirks mode, we always expand to fill the viewRect.
                 // We need to substract out the margins of this block. -dwh
                 th += h.width(viewRect().height() - c->marginBottom() - c->marginTop());
         }
@@ -1134,8 +1132,8 @@ void RenderTableSection::calcRowHeight()
            if ( ( indx = r - cell->rowSpan() + 1 ) < 0 )
                indx = 0;
 
-            if (cell->getCellPercentageHeight()) {
-                cell->setCellPercentageHeight(0);
+            if (cell->overrideSize() != -1) {
+                cell->setOverrideSize(-1);
                 cell->setChildNeedsLayout(true, false);
                 cell->layoutIfNeeded();
             }
@@ -1280,26 +1278,32 @@ int RenderTableSection::layoutRows( int toAdd )
             
             // Force percent height children to lay themselves out again.
             // This will cause, e.g., textareas to grow to
-            // fill the area.  FIXME: <div>s and blocks still don't
-            // work right.  We'll need to have an efficient way of
-            // invalidating all percent height objects in a render subtree.
-            // For now, we just handle immediate children. -dwh
+            // fill the area.
             bool cellChildrenFlex = false;
-            RenderObject* o = cell->firstChild();
-            while (o) {
-                if (!o->isText() && o->style()->height().isPercent()) {
-                    o->setNeedsLayout(true, false);
-                    cell->setChildNeedsLayout(true, false);
-                    cellChildrenFlex = true;
+            if (cell->style()->height().isFixed() || 
+                (!table()->style()->height().isVariable() && rHeight != cell->height())) {
+                // FIXME: There is still more work to do here to fully match WinIE (should
+                // it become necessary to do so).  In quirks mode, WinIE behaves like we
+                // do, but it will clip the cells that spill out of the table section.  In
+                // strict mode, Mozilla and WinIE both regrow the table to accommodate the
+                // new height of the cell (thus letting the percentages cause growth one
+                // time only).  We may also not be handling row-spanning cells correctly.
+                RenderObject* o = cell->firstChild();
+                while (o) {
+                    if (!o->isText() && o->style()->height().isPercent()) {
+                        o->setNeedsLayout(true, false);
+                        cell->setChildNeedsLayout(true, false);
+                        cellChildrenFlex = true;
+                    }
+                    o = o->nextSibling();
                 }
-                o = o->nextSibling();
             }
             if (cellChildrenFlex) {
-                cell->setCellPercentageHeight(kMax(0, 
-                                                   rHeight - cell->borderTop() - cell->paddingTop() - 
-                                                   cell->borderBottom() - cell->paddingBottom()));
+                cell->setOverrideSize(kMax(0, 
+                                           rHeight - cell->borderTop() - cell->paddingTop() - 
+                                                     cell->borderBottom() - cell->paddingBottom()));
                 cell->layoutIfNeeded();
-           
+
                 // Alignment within a cell is based off the calculated
                 // height, which becomes irrelevant once the cell has
                 // been resized based off its percentage. -dwh
@@ -1634,16 +1638,6 @@ void RenderTableCell::updateFromElement()
       cSpan = rSpan = 1;
   }
 }
-
-int RenderTableCell::getCellPercentageHeight() const
-{
-    return m_percentageHeight;
-}
-
-void RenderTableCell::setCellPercentageHeight(int h)
-{
-    m_percentageHeight = h;
-}
     
 void RenderTableCell::calcMinMaxWidth()
 {
index 961d902..6202aae 100644 (file)
@@ -359,9 +359,6 @@ public:
     void setCellTopExtra(int p) { _topExtra = p; }
     void setCellBottomExtra(int p) { _bottomExtra = p; }
 
-    int getCellPercentageHeight() const;
-    void setCellPercentageHeight(int h);
-    
     virtual void paint(PaintInfo& i, int tx, int ty);
 
     void paintCollapsedBorder(QPainter* p, int x, int y, int w, int h);