• 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, 2007, 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 RenderTableCell_h
26 #define RenderTableCell_h
27 
28 #include "RenderTableSection.h"
29 
30 namespace WebCore {
31 
32 class RenderTableCell : public RenderBlock {
33 public:
34     explicit RenderTableCell(Node*);
35 
36     // FIXME: need to implement cellIndex
cellIndex()37     int cellIndex() const { return 0; }
setCellIndex(int)38     void setCellIndex(int) { }
39 
colSpan()40     int colSpan() const { return m_columnSpan; }
setColSpan(int c)41     void setColSpan(int c) { m_columnSpan = c; }
42 
rowSpan()43     int rowSpan() const { return m_rowSpan; }
setRowSpan(int r)44     void setRowSpan(int r) { m_rowSpan = r; }
45 
col()46     int col() const { return m_column; }
setCol(int col)47     void setCol(int col) { m_column = col; }
row()48     int row() const { return m_row; }
setRow(int row)49     void setRow(int row) { m_row = row; }
50 
section()51     RenderTableSection* section() const { return toRenderTableSection(parent()->parent()); }
table()52     RenderTable* table() const { return toRenderTable(parent()->parent()->parent()); }
53 
54     Length styleOrColLogicalWidth() const;
55 
56     virtual void computePreferredLogicalWidths();
57 
58     void updateLogicalWidth(int);
59 
60     virtual int borderLeft() const;
61     virtual int borderRight() const;
62     virtual int borderTop() const;
63     virtual int borderBottom() const;
64     virtual int borderStart() const;
65     virtual int borderEnd() const;
66     virtual int borderBefore() const;
67     virtual int borderAfter() const;
68 
69     int borderHalfLeft(bool outer) const;
70     int borderHalfRight(bool outer) const;
71     int borderHalfTop(bool outer) const;
72     int borderHalfBottom(bool outer) const;
73 
74     int borderHalfStart(bool outer) const;
75     int borderHalfEnd(bool outer) const;
76     int borderHalfBefore(bool outer) const;
77     int borderHalfAfter(bool outer) const;
78 
79     CollapsedBorderValue collapsedStartBorder() const;
80     CollapsedBorderValue collapsedEndBorder() const;
81     CollapsedBorderValue collapsedBeforeBorder() const;
82     CollapsedBorderValue collapsedAfterBorder() const;
83 
84     CollapsedBorderValue collapsedLeftBorder() const;
85     CollapsedBorderValue collapsedRightBorder() const;
86     CollapsedBorderValue collapsedTopBorder() const;
87     CollapsedBorderValue collapsedBottomBorder() const;
88 
89     typedef Vector<CollapsedBorderValue, 100> CollapsedBorderStyles;
90     void collectBorderStyles(CollapsedBorderStyles&) const;
91     static void sortBorderStyles(CollapsedBorderStyles&);
92 
93     virtual void updateFromElement();
94 
95     virtual void layout();
96 
97     virtual void paint(PaintInfo&, int tx, int ty);
98 
99     void paintBackgroundsBehindCell(PaintInfo&, int tx, int ty, RenderObject* backgroundObject);
100 
101     int cellBaselinePosition() const;
102 
setIntrinsicPaddingBefore(int p)103     void setIntrinsicPaddingBefore(int p) { m_intrinsicPaddingBefore = p; }
setIntrinsicPaddingAfter(int p)104     void setIntrinsicPaddingAfter(int p) { m_intrinsicPaddingAfter = p; }
setIntrinsicPadding(int before,int after)105     void setIntrinsicPadding(int before, int after) { setIntrinsicPaddingBefore(before); setIntrinsicPaddingAfter(after); }
clearIntrinsicPadding()106     void clearIntrinsicPadding() { setIntrinsicPadding(0, 0); }
107 
intrinsicPaddingBefore()108     int intrinsicPaddingBefore() const { return m_intrinsicPaddingBefore; }
intrinsicPaddingAfter()109     int intrinsicPaddingAfter() const { return m_intrinsicPaddingAfter; }
110 
111     virtual int paddingTop(bool includeIntrinsicPadding = true) const;
112     virtual int paddingBottom(bool includeIntrinsicPadding = true) const;
113     virtual int paddingLeft(bool includeIntrinsicPadding = true) const;
114     virtual int paddingRight(bool includeIntrinsicPadding = true) const;
115 
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 int paddingBefore(bool includeIntrinsicPadding = true) const;
120     virtual int paddingAfter(bool includeIntrinsicPadding = true) const;
121 
122     virtual void setOverrideSize(int);
123     void setOverrideSizeFromRowHeight(int);
124 
hasVisualOverflow()125     bool hasVisualOverflow() const { return m_overflow && !borderBoxRect().contains(m_overflow->visualOverflowRect()); }
126 
127     virtual void scrollbarsChanged(bool horizontalScrollbarChanged, bool verticalScrollbarChanged);
128 
cellWidthChanged()129     bool cellWidthChanged() const { return m_cellWidthChanged; }
130     void setCellWidthChanged(bool b = true) { m_cellWidthChanged = b; }
131 
132 protected:
133     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
134     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
135 
136 private:
renderName()137     virtual const char* renderName() const { return isAnonymous() ? "RenderTableCell (anonymous)" : "RenderTableCell"; }
138 
isTableCell()139     virtual bool isTableCell() const { return true; }
140 
141     virtual void destroy();
142 
143     virtual void computeLogicalWidth();
144 
145     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
146     virtual void paintMask(PaintInfo&, int tx, int ty);
147 
148     virtual IntSize offsetFromContainer(RenderObject*, const IntPoint&) const;
149     virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
150     virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false);
151 
152     void paintCollapsedBorder(GraphicsContext*, int x, int y, int w, int h);
153 
154     int m_row;
155     int m_column;
156     int m_rowSpan;
157     int m_columnSpan : 31;
158     bool m_cellWidthChanged : 1;
159     int m_intrinsicPaddingBefore;
160     int m_intrinsicPaddingAfter;
161 };
162 
toRenderTableCell(RenderObject * object)163 inline RenderTableCell* toRenderTableCell(RenderObject* object)
164 {
165     ASSERT(!object || object->isTableCell());
166     return static_cast<RenderTableCell*>(object);
167 }
168 
toRenderTableCell(const RenderObject * object)169 inline const RenderTableCell* toRenderTableCell(const RenderObject* object)
170 {
171     ASSERT(!object || object->isTableCell());
172     return static_cast<const RenderTableCell*>(object);
173 }
174 
175 // This will catch anyone doing an unnecessary cast.
176 void toRenderTableCell(const RenderTableCell*);
177 
178 } // namespace WebCore
179 
180 #endif // RenderTableCell_h
181