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, 2009, 2013 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 RenderTableRow_h
26 #define RenderTableRow_h
27
28 #include "core/rendering/RenderTableSection.h"
29
30 namespace WebCore {
31
32 static const unsigned unsetRowIndex = 0x7FFFFFFF;
33 static const unsigned maxRowIndex = 0x7FFFFFFE; // 2,147,483,646
34
35 class RenderTableRow FINAL : public RenderBox {
36 public:
37 explicit RenderTableRow(Element*);
38
39 RenderTableCell* firstCell() const;
40 RenderTableCell* lastCell() const;
41
42 RenderTableRow* previousRow() const;
43 RenderTableRow* nextRow() const;
44
children()45 const RenderObjectChildList* children() const { return &m_children; }
children()46 RenderObjectChildList* children() { return &m_children; }
47
section()48 RenderTableSection* section() const { return toRenderTableSection(parent()); }
table()49 RenderTable* table() const { return toRenderTable(parent()->parent()); }
50
51 void paintOutlineForRowIfNeeded(PaintInfo&, const LayoutPoint&);
52
53 static RenderTableRow* createAnonymous(Document*);
54 static RenderTableRow* createAnonymousWithParentRenderer(const RenderObject*);
createAnonymousBoxWithSameTypeAs(const RenderObject * parent)55 virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const OVERRIDE
56 {
57 return createAnonymousWithParentRenderer(parent);
58 }
59
setRowIndex(unsigned rowIndex)60 void setRowIndex(unsigned rowIndex)
61 {
62 if (UNLIKELY(rowIndex > maxRowIndex))
63 CRASH();
64
65 m_rowIndex = rowIndex;
66 }
67
rowIndexWasSet()68 bool rowIndexWasSet() const { return m_rowIndex != unsetRowIndex; }
rowIndex()69 unsigned rowIndex() const
70 {
71 ASSERT(rowIndexWasSet());
72 return m_rowIndex;
73 }
74
borderAdjoiningTableStart()75 const BorderValue& borderAdjoiningTableStart() const
76 {
77 if (section()->hasSameDirectionAs(table()))
78 return style()->borderStart();
79
80 return style()->borderEnd();
81 }
82
borderAdjoiningTableEnd()83 const BorderValue& borderAdjoiningTableEnd() const
84 {
85 if (section()->hasSameDirectionAs(table()))
86 return style()->borderEnd();
87
88 return style()->borderStart();
89 }
90
91 const BorderValue& borderAdjoiningStartCell(const RenderTableCell*) const;
92 const BorderValue& borderAdjoiningEndCell(const RenderTableCell*) const;
93
94 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
95
96 private:
virtualChildren()97 virtual RenderObjectChildList* virtualChildren() OVERRIDE { return children(); }
virtualChildren()98 virtual const RenderObjectChildList* virtualChildren() const OVERRIDE { return children(); }
99
renderName()100 virtual const char* renderName() const OVERRIDE { return (isAnonymous() || isPseudoElement()) ? "RenderTableRow (anonymous)" : "RenderTableRow"; }
101
isTableRow()102 virtual bool isTableRow() const OVERRIDE { return true; }
103
104 virtual void willBeRemovedFromTree() OVERRIDE;
105
106 virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) OVERRIDE;
107 virtual void layout() OVERRIDE;
108
layerTypeRequired()109 virtual LayerType layerTypeRequired() const OVERRIDE
110 {
111 if (hasTransform() || hasHiddenBackface() || hasClipPath() || createsGroup() || isStickyPositioned() || style()->shouldCompositeForCurrentAnimations())
112 return NormalLayer;
113
114 if (hasOverflowClip())
115 return OverflowClipLayer;
116
117 return NoLayer;
118 }
119
120 virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
121
122 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) OVERRIDE;
123
124 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
125
126 void nextSibling() const WTF_DELETED_FUNCTION;
127 void previousSibling() const WTF_DELETED_FUNCTION;
128
129 RenderObjectChildList m_children;
130 unsigned m_rowIndex : 31;
131 };
132
133 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderTableRow, isTableRow());
134
previousRow()135 inline RenderTableRow* RenderTableRow::previousRow() const
136 {
137 return toRenderTableRow(RenderObject::previousSibling());
138 }
139
nextRow()140 inline RenderTableRow* RenderTableRow::nextRow() const
141 {
142 return toRenderTableRow(RenderObject::nextSibling());
143 }
144
firstRow()145 inline RenderTableRow* RenderTableSection::firstRow() const
146 {
147 ASSERT(children() == virtualChildren());
148 return toRenderTableRow(children()->firstChild());
149 }
150
lastRow()151 inline RenderTableRow* RenderTableSection::lastRow() const
152 {
153 ASSERT(children() == virtualChildren());
154 return toRenderTableRow(children()->lastChild());
155 }
156
157 } // namespace WebCore
158
159 #endif // RenderTableRow_h
160