Home | History | Annotate | Download | only in rendering
      1 /*
      2  * Copyright (C) 2002 Lars Knoll (knoll (at) kde.org)
      3  *           (C) 2002 Dirk Mueller (mueller (at) kde.org)
      4  *
      5  * This library is free software; you can redistribute it and/or
      6  * modify it under the terms of the GNU Library General Public
      7  * License as published by the Free Software Foundation; either
      8  * version 2 of the License.
      9  *
     10  * This library is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13  * Library General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU Library General Public License
     16  * along with this library; see the file COPYING.LIB.  If not, write to
     17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     18  * Boston, MA 02110-1301, USA.
     19  */
     20 
     21 #ifndef AutoTableLayout_h
     22 #define AutoTableLayout_h
     23 
     24 #include "Length.h"
     25 #include "TableLayout.h"
     26 #include <wtf/Vector.h>
     27 
     28 namespace WebCore {
     29 
     30 class RenderTable;
     31 class RenderTableCell;
     32 
     33 class AutoTableLayout : public TableLayout {
     34 public:
     35     AutoTableLayout(RenderTable*);
     36     ~AutoTableLayout();
     37 
     38     virtual void calcPrefWidths(int& minWidth, int& maxWidth);
     39     virtual void layout();
     40 
     41 protected:
     42     void fullRecalc();
     43     void recalcColumn(int effCol);
     44 
     45     void calcPercentages() const;
     46     int totalPercent() const
     47     {
     48         if (m_percentagesDirty)
     49             calcPercentages();
     50         return m_totalPercent;
     51     }
     52 
     53     int calcEffectiveWidth();
     54 
     55     void insertSpanCell(RenderTableCell*);
     56 
     57     struct Layout {
     58         Layout()
     59             : minWidth(0)
     60             , maxWidth(0)
     61             , effMinWidth(0)
     62             , effMaxWidth(0)
     63             , calcWidth(0)
     64             , emptyCellsOnly(true) {}
     65         Length width;
     66         Length effWidth;
     67         int minWidth;
     68         int maxWidth;
     69         int effMinWidth;
     70         int effMaxWidth;
     71         int calcWidth;
     72         bool emptyCellsOnly;
     73     };
     74 
     75     Vector<Layout, 4> m_layoutStruct;
     76     Vector<RenderTableCell*, 4> m_spanCells;
     77     bool m_hasPercent : 1;
     78     mutable bool m_percentagesDirty : 1;
     79     mutable bool m_effWidthDirty : 1;
     80     mutable unsigned short m_totalPercent;
     81 };
     82 
     83 } // namespace WebCore
     84 
     85 #endif // AutoTableLayout_h
     86