Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / RenderTableRow.h
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 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     RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
40     RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
41
42     const RenderObjectChildList* children() const { return &m_children; }
43     RenderObjectChildList* children() { return &m_children; }
44
45     RenderTableSection* section() const { return toRenderTableSection(parent()); }
46     RenderTable* table() const { return toRenderTable(parent()->parent()); }
47
48     void paintOutlineForRowIfNeeded(PaintInfo&, const LayoutPoint&);
49
50     static RenderTableRow* createAnonymous(Document*);
51     static RenderTableRow* createAnonymousWithParentRenderer(const RenderObject*);
52     virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const OVERRIDE
53     {
54         return createAnonymousWithParentRenderer(parent);
55     }
56
57     void setRowIndex(unsigned rowIndex)
58     {
59         if (UNLIKELY(rowIndex > maxRowIndex))
60             CRASH();
61
62         m_rowIndex = rowIndex;
63     }
64
65     bool rowIndexWasSet() const { return m_rowIndex != unsetRowIndex; }
66     unsigned rowIndex() const
67     {
68         ASSERT(rowIndexWasSet());
69         return m_rowIndex;
70     }
71
72     const BorderValue& borderAdjoiningTableStart() const
73     {
74         if (section()->hasSameDirectionAs(table()))
75             return style()->borderStart();
76
77         return style()->borderEnd();
78     }
79
80     const BorderValue& borderAdjoiningTableEnd() const
81     {
82         if (section()->hasSameDirectionAs(table()))
83             return style()->borderEnd();
84
85         return style()->borderStart();
86     }
87
88     const BorderValue& borderAdjoiningStartCell(const RenderTableCell*) const;
89     const BorderValue& borderAdjoiningEndCell(const RenderTableCell*) const;
90
91 private:
92     virtual RenderObjectChildList* virtualChildren() OVERRIDE { return children(); }
93     virtual const RenderObjectChildList* virtualChildren() const OVERRIDE { return children(); }
94
95     virtual const char* renderName() const OVERRIDE { return (isAnonymous() || isPseudoElement()) ? "RenderTableRow (anonymous)" : "RenderTableRow"; }
96
97     virtual bool isTableRow() const OVERRIDE { return true; }
98
99     virtual void willBeRemovedFromTree() OVERRIDE;
100
101     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) OVERRIDE;
102     virtual void layout() OVERRIDE;
103     virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const OVERRIDE;
104     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
105
106     virtual LayerType layerTypeRequired() const OVERRIDE
107     {
108         if (hasTransform() || hasHiddenBackface() || hasClipPath() || createsGroup() || isStickyPositioned())
109             return NormalLayer;
110
111         if (hasOverflowClip())
112             return OverflowClipLayer;
113
114         return NoLayer;
115     }
116
117     virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
118
119     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) OVERRIDE;
120
121     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
122
123     RenderObjectChildList m_children;
124     unsigned m_rowIndex : 31;
125 };
126
127 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderTableRow, isTableRow());
128
129 } // namespace WebCore
130
131 #endif // RenderTableRow_h