• 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 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     RenderTableCell(Node*);
35 
renderName()36     virtual const char* renderName() const { return isAnonymous() ? "RenderTableCell (anonymous)" : "RenderTableCell"; }
37 
isTableCell()38     virtual bool isTableCell() const { return true; }
39 
40     virtual void destroy();
41 
42     // FIXME: need to implement cellIndex
cellIndex()43     int cellIndex() const { return 0; }
setCellIndex(int)44     void setCellIndex(int) { }
45 
colSpan()46     int colSpan() const { return m_columnSpan; }
setColSpan(int c)47     void setColSpan(int c) { m_columnSpan = c; }
48 
rowSpan()49     int rowSpan() const { return m_rowSpan; }
setRowSpan(int r)50     void setRowSpan(int r) { m_rowSpan = r; }
51 
col()52     int col() const { return m_column; }
setCol(int col)53     void setCol(int col) { m_column = col; }
row()54     int row() const { return m_row; }
setRow(int row)55     void setRow(int row) { m_row = row; }
56 
section()57     RenderTableSection* section() const { return static_cast<RenderTableSection*>(parent()->parent()); }
table()58     RenderTable* table() const { return static_cast<RenderTable*>(parent()->parent()->parent()); }
59 
60     Length styleOrColWidth() const;
61 
requiresLayer()62     virtual bool requiresLayer() const { return isPositioned() || isTransparent() || hasOverflowClip() || hasTransform() || hasMask() || hasReflection(); }
63 
64     virtual void calcPrefWidths();
65     virtual void calcWidth();
66 #ifdef ANDROID_LAYOUT
67     // RenderTableSection needs to access this in setCellWidths()
getVisibleWidth()68     int getVisibleWidth() { return m_visibleWidth; }
69 #endif
70 
71     void updateWidth(int);
72 
73     int borderLeft() const;
74     int borderRight() const;
75     int borderTop() const;
76     int borderBottom() const;
77 
78     int borderHalfLeft(bool outer) const;
79     int borderHalfRight(bool outer) const;
80     int borderHalfTop(bool outer) const;
81     int borderHalfBottom(bool outer) const;
82 
83     CollapsedBorderValue collapsedLeftBorder(bool rtl) const;
84     CollapsedBorderValue collapsedRightBorder(bool rtl) const;
85     CollapsedBorderValue collapsedTopBorder() const;
86     CollapsedBorderValue collapsedBottomBorder() const;
87 
88     typedef Vector<CollapsedBorderValue, 100> CollapsedBorderStyles;
89     void collectBorderStyles(CollapsedBorderStyles&) const;
90     static void sortBorderStyles(CollapsedBorderStyles&);
91 
92     virtual void updateFromElement();
93 
94     virtual void layout();
95 
96     virtual void paint(PaintInfo&, int tx, int ty);
97     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
98     virtual void paintMask(PaintInfo& paintInfo, int tx, int ty);
99     void paintCollapsedBorder(GraphicsContext*, int x, int y, int w, int h);
100     void paintBackgroundsBehindCell(PaintInfo&, int tx, int ty, RenderObject* backgroundObject);
101 
102     virtual IntRect clippedOverflowRectForRepaint(RenderBox* repaintContainer);
103     virtual void computeRectForRepaint(IntRect&, RenderBox* repaintContainer, bool fixed = false);
104     virtual FloatPoint localToAbsolute(FloatPoint localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
105     virtual FloatPoint absoluteToLocal(FloatPoint containerPoint, bool fixed = false, bool useTransforms = false) const;
106 
107     virtual int baselinePosition(bool firstLine = false, bool isRootLineBox = false) const;
108 
setIntrinsicPaddingTop(int p)109     void setIntrinsicPaddingTop(int p) { m_intrinsicPaddingTop = p; }
setIntrinsicPaddingBottom(int p)110     void setIntrinsicPaddingBottom(int p) { m_intrinsicPaddingBottom = p; }
setIntrinsicPadding(int top,int bottom)111     void setIntrinsicPadding(int top, int bottom) { setIntrinsicPaddingTop(top); setIntrinsicPaddingBottom(bottom); }
clearIntrinsicPadding()112     void clearIntrinsicPadding() { setIntrinsicPadding(0, 0); }
113 
intrinsicPaddingTop()114     int intrinsicPaddingTop() const { return m_intrinsicPaddingTop; }
intrinsicPaddingBottom()115     int intrinsicPaddingBottom() const { return m_intrinsicPaddingBottom; }
116 
117     virtual int paddingTop(bool includeIntrinsicPadding = true) const;
118     virtual int paddingBottom(bool includeIntrinsicPadding = true) const;
119 
120     virtual void setOverrideSize(int);
121 
122 protected:
123     virtual void styleWillChange(RenderStyle::Diff, const RenderStyle* newStyle);
124     virtual void styleDidChange(RenderStyle::Diff, const RenderStyle* oldStyle);
125 
126     virtual FloatQuad localToContainerQuad(const FloatQuad&, RenderBox* repaintContainer, bool fixed = false) const;
127 
128 private:
129     int m_row;
130     int m_column;
131     int m_rowSpan;
132     int m_columnSpan;
133     int m_intrinsicPaddingTop;
134     int m_intrinsicPaddingBottom;
135     int m_percentageHeight;
136 };
137 
138 } // namespace WebCore
139 
140 #endif // RenderTableCell_h
141