RenderTableRow.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. #ifndef RenderTableRow_h
  25. #define RenderTableRow_h
  26. #include "RenderTableSection.h"
  27. namespace WebCore {
  28. static const unsigned unsetRowIndex = 0x7FFFFFFF;
  29. static const unsigned maxRowIndex = 0x7FFFFFFE; // 2,147,483,646
  30. class RenderTableRow : public RenderBox {
  31. public:
  32. explicit RenderTableRow(Element*);
  33. RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
  34. RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
  35. const RenderObjectChildList* children() const { return &m_children; }
  36. RenderObjectChildList* children() { return &m_children; }
  37. RenderTableSection* section() const { return toRenderTableSection(parent()); }
  38. RenderTable* table() const { return toRenderTable(parent()->parent()); }
  39. void paintOutlineForRowIfNeeded(PaintInfo&, const LayoutPoint&);
  40. static RenderTableRow* createAnonymous(Document*);
  41. static RenderTableRow* createAnonymousWithParentRenderer(const RenderObject*);
  42. virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const OVERRIDE
  43. {
  44. return createAnonymousWithParentRenderer(parent);
  45. }
  46. void setRowIndex(unsigned rowIndex)
  47. {
  48. if (UNLIKELY(rowIndex > maxRowIndex))
  49. CRASH();
  50. m_rowIndex = rowIndex;
  51. }
  52. bool rowIndexWasSet() const { return m_rowIndex != unsetRowIndex; }
  53. unsigned rowIndex() const
  54. {
  55. ASSERT(rowIndexWasSet());
  56. return m_rowIndex;
  57. }
  58. const BorderValue& borderAdjoiningTableStart() const
  59. {
  60. if (section()->hasSameDirectionAs(table()))
  61. return style()->borderStart();
  62. return style()->borderEnd();
  63. }
  64. const BorderValue& borderAdjoiningTableEnd() const
  65. {
  66. if (section()->hasSameDirectionAs(table()))
  67. return style()->borderEnd();
  68. return style()->borderStart();
  69. }
  70. const BorderValue& borderAdjoiningStartCell(const RenderTableCell*) const;
  71. const BorderValue& borderAdjoiningEndCell(const RenderTableCell*) const;
  72. private:
  73. virtual RenderObjectChildList* virtualChildren() { return children(); }
  74. virtual const RenderObjectChildList* virtualChildren() const { return children(); }
  75. virtual const char* renderName() const { return (isAnonymous() || isPseudoElement()) ? "RenderTableRow (anonymous)" : "RenderTableRow"; }
  76. virtual bool isTableRow() const { return true; }
  77. virtual void willBeRemovedFromTree() OVERRIDE;
  78. virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
  79. virtual void layout();
  80. virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const;
  81. virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
  82. virtual bool requiresLayer() const OVERRIDE { return hasOverflowClip() || hasTransform() || hasHiddenBackface() || hasClipPath() || createsGroup(); }
  83. virtual void paint(PaintInfo&, const LayoutPoint&);
  84. virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
  85. virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
  86. RenderObjectChildList m_children;
  87. unsigned m_rowIndex : 31;
  88. };
  89. inline RenderTableRow* toRenderTableRow(RenderObject* object)
  90. {
  91. ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isTableRow());
  92. return static_cast<RenderTableRow*>(object);
  93. }
  94. inline const RenderTableRow* toRenderTableRow(const RenderObject* object)
  95. {
  96. ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isTableRow());
  97. return static_cast<const RenderTableRow*>(object);
  98. }
  99. // This will catch anyone doing an unnecessary cast.
  100. void toRenderTableRow(const RenderTableRow*);
  101. } // namespace WebCore
  102. #endif // RenderTableRow_h