| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
#ifndef RenderTable_h |
|---|
| 28 |
#define RenderTable_h |
|---|
| 29 |
|
|---|
| 30 |
#include "RenderBlock.h" |
|---|
| 31 |
#include <wtf/Vector.h> |
|---|
| 32 |
|
|---|
| 33 |
namespace WebCore { |
|---|
| 34 |
|
|---|
| 35 |
class RenderTableCol; |
|---|
| 36 |
class RenderTableCell; |
|---|
| 37 |
class RenderTableSection; |
|---|
| 38 |
class TableLayout; |
|---|
| 39 |
|
|---|
| 40 |
class RenderTable : public RenderBlock { |
|---|
| 41 |
public: |
|---|
| 42 |
enum Rules { |
|---|
| 43 |
None = 0x00, |
|---|
| 44 |
RGroups = 0x01, |
|---|
| 45 |
CGroups = 0x02, |
|---|
| 46 |
Groups = 0x03, |
|---|
| 47 |
Rows = 0x05, |
|---|
| 48 |
Cols = 0x0a, |
|---|
| 49 |
All = 0x0f |
|---|
| 50 |
}; |
|---|
| 51 |
enum Frame { |
|---|
| 52 |
Void = 0x00, |
|---|
| 53 |
Above = 0x01, |
|---|
| 54 |
Below = 0x02, |
|---|
| 55 |
Lhs = 0x04, |
|---|
| 56 |
Rhs = 0x08, |
|---|
| 57 |
Hsides = 0x03, |
|---|
| 58 |
Vsides = 0x0c, |
|---|
| 59 |
Box = 0x0f |
|---|
| 60 |
}; |
|---|
| 61 |
|
|---|
| 62 |
RenderTable(Node*); |
|---|
| 63 |
~RenderTable(); |
|---|
| 64 |
|
|---|
| 65 |
virtual const char* renderName() const { return "RenderTable"; } |
|---|
| 66 |
|
|---|
| 67 |
virtual bool isTable() const { return true; } |
|---|
| 68 |
|
|---|
| 69 |
virtual void setStyle(RenderStyle*); |
|---|
| 70 |
|
|---|
| 71 |
virtual bool avoidsFloats() const { return true; } |
|---|
| 72 |
|
|---|
| 73 |
int getColumnPos(int col) const { return m_columnPos[col]; } |
|---|
| 74 |
|
|---|
| 75 |
int hBorderSpacing() const { return m_hSpacing; } |
|---|
| 76 |
int vBorderSpacing() const { return m_vSpacing; } |
|---|
| 77 |
|
|---|
| 78 |
bool collapseBorders() const { return style()->borderCollapse(); } |
|---|
| 79 |
int borderLeft() const { return m_borderLeft; } |
|---|
| 80 |
int borderRight() const { return m_borderRight; } |
|---|
| 81 |
int borderTop() const; |
|---|
| 82 |
int borderBottom() const; |
|---|
| 83 |
|
|---|
| 84 |
Rules getRules() const { return static_cast<Rules>(m_rules); } |
|---|
| 85 |
|
|---|
| 86 |
const Color& bgColor() const { return style()->backgroundColor(); } |
|---|
| 87 |
|
|---|
| 88 |
int outerBorderTop() const; |
|---|
| 89 |
int outerBorderBottom() const; |
|---|
| 90 |
int outerBorderLeft() const; |
|---|
| 91 |
int outerBorderRight() const; |
|---|
| 92 |
|
|---|
| 93 |
int calcBorderLeft() const; |
|---|
| 94 |
int calcBorderRight() const; |
|---|
| 95 |
void recalcHorizontalBorders(); |
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); |
|---|
| 99 |
virtual void paint(PaintInfo&, int tx, int ty); |
|---|
| 100 |
virtual void paintBoxDecorations(PaintInfo&, int tx, int ty); |
|---|
| 101 |
virtual void paintMask(PaintInfo& paintInfo, int tx, int ty); |
|---|
| 102 |
virtual void layout(); |
|---|
| 103 |
virtual void calcPrefWidths(); |
|---|
| 104 |
|
|---|
| 105 |
virtual RenderBlock* firstLineBlock() const; |
|---|
| 106 |
virtual void updateFirstLetter(); |
|---|
| 107 |
|
|---|
| 108 |
virtual void setCellWidths(); |
|---|
| 109 |
|
|---|
| 110 |
virtual void calcWidth(); |
|---|
| 111 |
|
|---|
| 112 |
struct ColumnStruct { |
|---|
| 113 |
enum { |
|---|
| 114 |
WidthUndefined = 0xffff |
|---|
| 115 |
}; |
|---|
| 116 |
|
|---|
| 117 |
ColumnStruct() |
|---|
| 118 |
: span(1) |
|---|
| 119 |
, width(WidthUndefined) |
|---|
| 120 |
{ |
|---|
| 121 |
} |
|---|
| 122 |
|
|---|
| 123 |
unsigned short span; |
|---|
| 124 |
unsigned width; |
|---|
| 125 |
}; |
|---|
| 126 |
|
|---|
| 127 |
Vector<ColumnStruct>& columns() { return m_columns; } |
|---|
| 128 |
Vector<int>& columnPositions() { return m_columnPos; } |
|---|
| 129 |
RenderTableSection* header() const { return m_head; } |
|---|
| 130 |
RenderTableSection* footer() const { return m_foot; } |
|---|
| 131 |
RenderTableSection* firstBody() const { return m_firstBody; } |
|---|
| 132 |
|
|---|
| 133 |
void splitColumn(int pos, int firstSpan); |
|---|
| 134 |
void appendColumn(int span); |
|---|
| 135 |
int numEffCols() const { return m_columns.size(); } |
|---|
| 136 |
int spanOfEffCol(int effCol) const { return m_columns[effCol].span; } |
|---|
| 137 |
|
|---|
| 138 |
int colToEffCol(int col) const |
|---|
| 139 |
{ |
|---|
| 140 |
int i = 0; |
|---|
| 141 |
int effCol = numEffCols(); |
|---|
| 142 |
for (int c = 0; c < col && i < effCol; ++i) |
|---|
| 143 |
c += m_columns[i].span; |
|---|
| 144 |
return i; |
|---|
| 145 |
} |
|---|
| 146 |
|
|---|
| 147 |
int effColToCol(int effCol) const |
|---|
| 148 |
{ |
|---|
| 149 |
int c = 0; |
|---|
| 150 |
for (int i = 0; i < effCol; i++) |
|---|
| 151 |
c += m_columns[i].span; |
|---|
| 152 |
return c; |
|---|
| 153 |
} |
|---|
| 154 |
|
|---|
| 155 |
int bordersPaddingAndSpacing() const |
|---|
| 156 |
{ |
|---|
| 157 |
return borderLeft() + borderRight() + |
|---|
| 158 |
(collapseBorders() ? 0 : (paddingLeft() + paddingRight() + (numEffCols() + 1) * hBorderSpacing())); |
|---|
| 159 |
} |
|---|
| 160 |
|
|---|
| 161 |
RenderTableCol* colElement(int col, bool* startEdge = 0, bool* endEdge = 0) const; |
|---|
| 162 |
|
|---|
| 163 |
bool needsSectionRecalc() const { return m_needsSectionRecalc; } |
|---|
| 164 |
void setNeedsSectionRecalc() |
|---|
| 165 |
{ |
|---|
| 166 |
if (documentBeingDestroyed()) |
|---|
| 167 |
return; |
|---|
| 168 |
m_needsSectionRecalc = true; |
|---|
| 169 |
setNeedsLayout(true); |
|---|
| 170 |
} |
|---|
| 171 |
|
|---|
| 172 |
virtual RenderObject* removeChildNode(RenderObject*, bool fullRemove = true); |
|---|
| 173 |
|
|---|
| 174 |
RenderTableSection* sectionAbove(const RenderTableSection*, bool skipEmptySections = false) const; |
|---|
| 175 |
RenderTableSection* sectionBelow(const RenderTableSection*, bool skipEmptySections = false) const; |
|---|
| 176 |
|
|---|
| 177 |
RenderTableCell* cellAbove(const RenderTableCell*) const; |
|---|
| 178 |
RenderTableCell* cellBelow(const RenderTableCell*) const; |
|---|
| 179 |
RenderTableCell* cellBefore(const RenderTableCell*) const; |
|---|
| 180 |
RenderTableCell* cellAfter(const RenderTableCell*) const; |
|---|
| 181 |
|
|---|
| 182 |
const CollapsedBorderValue* currentBorderStyle() const { return m_currentBorder; } |
|---|
| 183 |
|
|---|
| 184 |
bool hasSections() const { return m_head || m_foot || m_firstBody; } |
|---|
| 185 |
|
|---|
| 186 |
virtual IntRect getOverflowClipRect(int tx, int ty); |
|---|
| 187 |
|
|---|
| 188 |
void recalcSectionsIfNeeded() const |
|---|
| 189 |
{ |
|---|
| 190 |
if (m_needsSectionRecalc) |
|---|
| 191 |
recalcSections(); |
|---|
| 192 |
} |
|---|
| 193 |
|
|---|
| 194 |
private: |
|---|
| 195 |
void recalcSections() const; |
|---|
| 196 |
|
|---|
| 197 |
mutable Vector<int> m_columnPos; |
|---|
| 198 |
mutable Vector<ColumnStruct> m_columns; |
|---|
| 199 |
|
|---|
| 200 |
mutable RenderBlock* m_caption; |
|---|
| 201 |
mutable RenderTableSection* m_head; |
|---|
| 202 |
mutable RenderTableSection* m_foot; |
|---|
| 203 |
mutable RenderTableSection* m_firstBody; |
|---|
| 204 |
|
|---|
| 205 |
TableLayout* m_tableLayout; |
|---|
| 206 |
|
|---|
| 207 |
const CollapsedBorderValue* m_currentBorder; |
|---|
| 208 |
|
|---|
| 209 |
unsigned m_frame : 4; |
|---|
| 210 |
unsigned m_rules : 4; |
|---|
| 211 |
|
|---|
| 212 |
mutable bool m_hasColElements : 1; |
|---|
| 213 |
mutable bool m_needsSectionRecalc : 1; |
|---|
| 214 |
|
|---|
| 215 |
short m_hSpacing; |
|---|
| 216 |
short m_vSpacing; |
|---|
| 217 |
int m_borderLeft; |
|---|
| 218 |
int m_borderRight; |
|---|
| 219 |
}; |
|---|
| 220 |
|
|---|
| 221 |
} |
|---|
| 222 |
|
|---|
| 223 |
#endif |
|---|
| 224 |
|
|---|