• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 1997 Martin Jones (mjones@kde.org)
3  *           (C) 1997 Torben Weis (weis@kde.org)
4  *           (C) 1998 Waldo Bastian (bastian@kde.org)
5  *           (C) 1999 Lars Knoll (knoll@kde.org)
6  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
7  * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public License
20  * along with this library; see the file COPYING.LIB.  If not, write to
21  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  */
24 
25 #ifndef RenderTableSection_h
26 #define RenderTableSection_h
27 
28 #include "RenderTable.h"
29 #include <wtf/Vector.h>
30 
31 namespace WebCore {
32 
33 class RenderTableCell;
34 class RenderTableRow;
35 
36 class RenderTableSection : public RenderBox {
37 public:
38     RenderTableSection(Node*);
39     virtual ~RenderTableSection();
40 
children()41     const RenderObjectChildList* children() const { return &m_children; }
children()42     RenderObjectChildList* children() { return &m_children; }
43 
44     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
45 
46     virtual int firstLineBoxBaseline() const;
47 
48     void addCell(RenderTableCell*, RenderTableRow* row);
49 
50     void setCellWidths();
51     int calcRowHeight();
52     int layoutRows(int height);
53 
table()54     RenderTable* table() const { return toRenderTable(parent()); }
55 
56     struct CellStruct {
57         RenderTableCell* cell;
58         bool inColSpan; // true for columns after the first in a colspan
59     };
60 
61     typedef Vector<CellStruct> Row;
62 
63     struct RowStruct {
64         Row* row;
65         RenderTableRow* rowRenderer;
66         int baseline;
67         Length height;
68     };
69 
cellAt(int row,int col)70     CellStruct& cellAt(int row,  int col) { return (*m_grid[row].row)[col]; }
cellAt(int row,int col)71     const CellStruct& cellAt(int row, int col) const { return (*m_grid[row].row)[col]; }
72 
73     void appendColumn(int pos);
74     void splitColumn(int pos, int newSize);
75 
76     virtual int overflowWidth(bool includeInterior = true) const { return (!includeInterior && hasOverflowClip()) ? width() : m_overflowWidth; }
77     virtual int overflowLeft(bool includeInterior = true) const { return (!includeInterior && hasOverflowClip()) ? 0 : m_overflowLeft; }
78     virtual int overflowHeight(bool includeInterior = true) const { return (!includeInterior && hasOverflowClip()) ? height() : m_overflowHeight; }
79     virtual int overflowTop(bool includeInterior = true) const { return (!includeInterior && hasOverflowClip()) ? 0 : m_overflowTop; }
80 
81     int calcOuterBorderTop() const;
82     int calcOuterBorderBottom() const;
83     int calcOuterBorderLeft(bool rtl) const;
84     int calcOuterBorderRight(bool rtl) const;
85     void recalcOuterBorder();
86 
outerBorderTop()87     int outerBorderTop() const { return m_outerBorderTop; }
outerBorderBottom()88     int outerBorderBottom() const { return m_outerBorderBottom; }
outerBorderLeft()89     int outerBorderLeft() const { return m_outerBorderLeft; }
outerBorderRight()90     int outerBorderRight() const { return m_outerBorderRight; }
91 
numRows()92     int numRows() const { return m_gridRows; }
93     int numColumns() const;
94     void recalcCells();
recalcCellsIfNeeded()95     void recalcCellsIfNeeded()
96     {
97         if (m_needsCellRecalc)
98             recalcCells();
99     }
100 
needsCellRecalc()101     bool needsCellRecalc() const { return m_needsCellRecalc; }
setNeedsCellRecalc()102     void setNeedsCellRecalc()
103     {
104         m_needsCellRecalc = true;
105         table()->setNeedsSectionRecalc();
106     }
107 
getBaseline(int row)108     int getBaseline(int row) { return m_grid[row].baseline; }
109 
110 private:
virtualChildren()111     virtual RenderObjectChildList* virtualChildren() { return children(); }
virtualChildren()112     virtual const RenderObjectChildList* virtualChildren() const { return children(); }
113 
renderName()114     virtual const char* renderName() const { return isAnonymous() ? "RenderTableSection (anonymous)" : "RenderTableSection"; }
115 
isTableSection()116     virtual bool isTableSection() const { return true; }
117 
118     virtual void destroy();
119 
120     virtual void layout();
121 
122     virtual void removeChild(RenderObject* oldChild);
123 
124     virtual int lowestPosition(bool includeOverflowInterior, bool includeSelf) const;
125     virtual int rightmostPosition(bool includeOverflowInterior, bool includeSelf) const;
126     virtual int leftmostPosition(bool includeOverflowInterior, bool includeSelf) const;
127 
128     virtual void paint(PaintInfo&, int tx, int ty);
129     virtual void paintObject(PaintInfo&, int tx, int ty);
130 
131     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
132 
133     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
134 
lineHeight(bool,bool)135     virtual int lineHeight(bool, bool) const { return 0; }
136 
137     bool ensureRows(int);
138     void clearGrid();
139 
140     RenderObjectChildList m_children;
141 
142     Vector<RowStruct> m_grid;
143     Vector<int> m_rowPos;
144 
145     int m_gridRows;
146 
147     // the current insertion position
148     int m_cCol;
149     int m_cRow;
150 
151     int m_outerBorderLeft;
152     int m_outerBorderRight;
153     int m_outerBorderTop;
154     int m_outerBorderBottom;
155     int m_overflowLeft;
156     int m_overflowWidth;
157     int m_overflowTop;
158     int m_overflowHeight;
159 
160     bool m_needsCellRecalc;
161     bool m_hasOverflowingCell;
162 };
163 
toRenderTableSection(RenderObject * object)164 inline RenderTableSection* toRenderTableSection(RenderObject* object)
165 {
166     ASSERT(!object || object->isTableSection());
167     return static_cast<RenderTableSection*>(object);
168 }
169 
toRenderTableSection(const RenderObject * object)170 inline const RenderTableSection* toRenderTableSection(const RenderObject* object)
171 {
172     ASSERT(!object || object->isTableSection());
173     return static_cast<const RenderTableSection*>(object);
174 }
175 
176 // This will catch anyone doing an unnecessary cast.
177 void toRenderTableSection(const RenderTableSection*);
178 
179 } // namespace WebCore
180 
181 #endif // RenderTableSection_h
182