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, 2007, 2009 Apple Inc. All rights reserved.
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.
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.
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.
25 #ifndef RenderTableCell_h
26 #define RenderTableCell_h
28 #include "RenderTableSection.h"
32 class RenderTableCell : public RenderBlock {
34 explicit RenderTableCell(Node*);
36 // FIXME: need to implement cellIndex
37 int cellIndex() const { return 0; }
38 void setCellIndex(int) { }
40 int colSpan() const { return m_columnSpan; }
41 void setColSpan(int c) { m_columnSpan = c; }
43 int rowSpan() const { return m_rowSpan; }
44 void setRowSpan(int r) { m_rowSpan = r; }
46 int col() const { return m_column; }
47 void setCol(int col) { m_column = col; }
48 int row() const { return m_row; }
49 void setRow(int row) { m_row = row; }
51 RenderTableSection* section() const { return toRenderTableSection(parent()->parent()); }
52 RenderTable* table() const { return toRenderTable(parent()->parent()->parent()); }
54 Length styleOrColLogicalWidth() const;
56 virtual void computePreferredLogicalWidths();
58 void updateLogicalWidth(int);
60 virtual LayoutUnit borderLeft() const;
61 virtual LayoutUnit borderRight() const;
62 virtual LayoutUnit borderTop() const;
63 virtual LayoutUnit borderBottom() const;
64 virtual LayoutUnit borderStart() const;
65 virtual LayoutUnit borderEnd() const;
66 virtual LayoutUnit borderBefore() const;
67 virtual LayoutUnit borderAfter() const;
69 LayoutUnit borderHalfLeft(bool outer) const;
70 LayoutUnit borderHalfRight(bool outer) const;
71 LayoutUnit borderHalfTop(bool outer) const;
72 LayoutUnit borderHalfBottom(bool outer) const;
74 LayoutUnit borderHalfStart(bool outer) const;
75 LayoutUnit borderHalfEnd(bool outer) const;
76 LayoutUnit borderHalfBefore(bool outer) const;
77 LayoutUnit borderHalfAfter(bool outer) const;
79 CollapsedBorderValue collapsedStartBorder() const;
80 CollapsedBorderValue collapsedEndBorder() const;
81 CollapsedBorderValue collapsedBeforeBorder() const;
82 CollapsedBorderValue collapsedAfterBorder() const;
84 CollapsedBorderValue collapsedLeftBorder() const;
85 CollapsedBorderValue collapsedRightBorder() const;
86 CollapsedBorderValue collapsedTopBorder() const;
87 CollapsedBorderValue collapsedBottomBorder() const;
89 typedef Vector<CollapsedBorderValue, 100> CollapsedBorderStyles;
90 void collectBorderStyles(CollapsedBorderStyles&) const;
91 static void sortBorderStyles(CollapsedBorderStyles&);
93 virtual void updateFromElement();
95 virtual void layout();
97 virtual void paint(PaintInfo&, const LayoutPoint&);
99 void paintBackgroundsBehindCell(PaintInfo&, const LayoutPoint&, RenderObject* backgroundObject);
101 int cellBaselinePosition() const;
103 void setIntrinsicPaddingBefore(int p) { m_intrinsicPaddingBefore = p; }
104 void setIntrinsicPaddingAfter(int p) { m_intrinsicPaddingAfter = p; }
105 void setIntrinsicPadding(int before, int after) { setIntrinsicPaddingBefore(before); setIntrinsicPaddingAfter(after); }
106 void clearIntrinsicPadding() { setIntrinsicPadding(0, 0); }
108 int intrinsicPaddingBefore() const { return m_intrinsicPaddingBefore; }
109 int intrinsicPaddingAfter() const { return m_intrinsicPaddingAfter; }
111 virtual LayoutUnit paddingTop(bool includeIntrinsicPadding = true) const;
112 virtual LayoutUnit paddingBottom(bool includeIntrinsicPadding = true) const;
113 virtual LayoutUnit paddingLeft(bool includeIntrinsicPadding = true) const;
114 virtual LayoutUnit paddingRight(bool includeIntrinsicPadding = true) const;
116 // FIXME: For now we just assume the cell has the same block flow direction as the table. It's likely we'll
117 // create an extra anonymous RenderBlock to handle mixing directionality anyway, in which case we can lock
118 // the block flow directionality of the cells to the table's directionality.
119 virtual LayoutUnit paddingBefore(bool includeIntrinsicPadding = true) const;
120 virtual LayoutUnit paddingAfter(bool includeIntrinsicPadding = true) const;
122 void setOverrideHeightFromRowHeight(int);
124 bool hasVisualOverflow() const { return m_overflow && !borderBoxRect().contains(m_overflow->visualOverflowRect()); }
126 virtual void scrollbarsChanged(bool horizontalScrollbarChanged, bool verticalScrollbarChanged);
128 bool cellWidthChanged() const { return m_cellWidthChanged; }
129 void setCellWidthChanged(bool b = true) { m_cellWidthChanged = b; }
132 virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
133 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
136 virtual const char* renderName() const { return isAnonymous() ? "RenderTableCell (anonymous)" : "RenderTableCell"; }
138 virtual bool isTableCell() const { return true; }
140 virtual RenderBlock* containingBlock() const;
142 virtual void willBeDestroyed();
144 virtual void computeLogicalWidth();
146 virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&);
147 virtual void paintMask(PaintInfo&, const LayoutPoint&);
149 virtual LayoutSize offsetFromContainer(RenderObject*, const LayoutPoint&) const;
150 virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const;
151 virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false) const;
153 void paintCollapsedBorder(GraphicsContext*, const LayoutRect&);
158 int m_columnSpan : 31;
159 bool m_cellWidthChanged : 1;
160 int m_intrinsicPaddingBefore;
161 int m_intrinsicPaddingAfter;
164 inline RenderTableCell* toRenderTableCell(RenderObject* object)
166 ASSERT(!object || object->isTableCell());
167 return static_cast<RenderTableCell*>(object);
170 inline const RenderTableCell* toRenderTableCell(const RenderObject* object)
172 ASSERT(!object || object->isTableCell());
173 return static_cast<const RenderTableCell*>(object);
176 // This will catch anyone doing an unnecessary cast.
177 void toRenderTableCell(const RenderTableCell*);
179 } // namespace WebCore
181 #endif // RenderTableCell_h