]>
git.saurik.com Git - iphone-api.git/blob - WebCore/RenderTable.h
2 * This file is part of the DOM implementation for KDE.
4 * Copyright (C) 1997 Martin Jones (mjones@kde.org)
5 * (C) 1997 Torben Weis (weis@kde.org)
6 * (C) 1998 Waldo Bastian (bastian@kde.org)
7 * (C) 1999 Lars Knoll (knoll@kde.org)
8 * (C) 1999 Antti Koivisto (koivisto@kde.org)
9 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
30 #include "RenderBlock.h"
31 #include <wtf/Vector.h>
36 class RenderTableCell
;
37 class RenderTableSection
;
40 class RenderTable
: public RenderBlock
{
65 virtual const char* renderName() const { return "RenderTable"; }
67 virtual bool isTable() const { return true; }
69 virtual bool avoidsFloats() const { return true; }
71 int getColumnPos(int col
) const { return m_columnPos
[col
]; }
73 int hBorderSpacing() const { return m_hSpacing
; }
74 int vBorderSpacing() const { return m_vSpacing
; }
76 bool collapseBorders() const { return style()->borderCollapse(); }
77 int borderLeft() const { return m_borderLeft
; }
78 int borderRight() const { return m_borderRight
; }
79 int borderTop() const;
80 int borderBottom() const;
82 Rules
getRules() const { return static_cast<Rules
>(m_rules
); }
84 const Color
& bgColor() const { return style()->backgroundColor(); }
86 int outerBorderTop() const;
87 int outerBorderBottom() const;
88 int outerBorderLeft() const;
89 int outerBorderRight() const;
91 int calcBorderLeft() const;
92 int calcBorderRight() const;
93 void recalcHorizontalBorders();
96 virtual void addChild(RenderObject
* child
, RenderObject
* beforeChild
= 0);
97 virtual void paint(PaintInfo
&, int tx
, int ty
);
98 virtual void paintObject(PaintInfo
&, int tx
, int ty
);
99 virtual void paintBoxDecorations(PaintInfo
&, int tx
, int ty
);
100 virtual void paintMask(PaintInfo
& paintInfo
, int tx
, int ty
);
101 virtual void layout();
102 virtual void calcPrefWidths();
103 virtual bool nodeAtPoint(const HitTestRequest
&, HitTestResult
&, int xPos
, int yPos
, int tx
, int ty
, HitTestAction
);
105 virtual int getBaselineOfFirstLineBox() const;
107 virtual RenderBlock
* firstLineBlock() const;
108 virtual void updateFirstLetter();
110 virtual void setCellWidths();
112 virtual void calcWidth();
114 struct ColumnStruct
{
116 WidthUndefined
= 0xffff
121 , width(WidthUndefined
)
126 unsigned width
; // the calculated position of the column
129 Vector
<ColumnStruct
>& columns() { return m_columns
; }
130 Vector
<int>& columnPositions() { return m_columnPos
; }
131 RenderTableSection
* header() const { return m_head
; }
132 RenderTableSection
* footer() const { return m_foot
; }
133 RenderTableSection
* firstBody() const { return m_firstBody
; }
135 void splitColumn(int pos
, int firstSpan
);
136 void appendColumn(int span
);
137 int numEffCols() const { return m_columns
.size(); }
138 int spanOfEffCol(int effCol
) const { return m_columns
[effCol
].span
; }
140 int colToEffCol(int col
) const
143 int effCol
= numEffCols();
144 for (int c
= 0; c
< col
&& i
< effCol
; ++i
)
145 c
+= m_columns
[i
].span
;
149 int effColToCol(int effCol
) const
152 for (int i
= 0; i
< effCol
; i
++)
153 c
+= m_columns
[i
].span
;
157 int bordersPaddingAndSpacing() const
159 return borderLeft() + borderRight() +
160 (collapseBorders() ? 0 : (paddingLeft() + paddingRight() + (numEffCols() + 1) * hBorderSpacing()));
163 RenderTableCol
* colElement(int col
, bool* startEdge
= 0, bool* endEdge
= 0) const;
165 bool needsSectionRecalc() const { return m_needsSectionRecalc
; }
166 void setNeedsSectionRecalc()
168 if (documentBeingDestroyed())
170 m_needsSectionRecalc
= true;
171 setNeedsLayout(true);
174 virtual RenderObject
* removeChildNode(RenderObject
*, bool fullRemove
= true);
176 RenderTableSection
* sectionAbove(const RenderTableSection
*, bool skipEmptySections
= false) const;
177 RenderTableSection
* sectionBelow(const RenderTableSection
*, bool skipEmptySections
= false) const;
179 RenderTableCell
* cellAbove(const RenderTableCell
*) const;
180 RenderTableCell
* cellBelow(const RenderTableCell
*) const;
181 RenderTableCell
* cellBefore(const RenderTableCell
*) const;
182 RenderTableCell
* cellAfter(const RenderTableCell
*) const;
184 const CollapsedBorderValue
* currentBorderStyle() const { return m_currentBorder
; }
186 bool hasSections() const { return m_head
|| m_foot
|| m_firstBody
; }
188 virtual IntRect
getOverflowClipRect(int tx
, int ty
);
190 void recalcSectionsIfNeeded() const
192 if (m_needsSectionRecalc
)
197 virtual void styleDidChange(StyleDifference
, const RenderStyle
* oldStyle
);
200 void recalcSections() const;
202 mutable Vector
<int> m_columnPos
;
203 mutable Vector
<ColumnStruct
> m_columns
;
205 mutable RenderBlock
* m_caption
;
206 mutable RenderTableSection
* m_head
;
207 mutable RenderTableSection
* m_foot
;
208 mutable RenderTableSection
* m_firstBody
;
210 TableLayout
* m_tableLayout
;
212 const CollapsedBorderValue
* m_currentBorder
;
214 unsigned m_frame
: 4; // Frame
215 unsigned m_rules
: 4; // Rules
217 mutable bool m_hasColElements
: 1;
218 mutable bool m_needsSectionRecalc
: 1;
226 } // namespace WebCore
228 #endif // RenderTable_h