WebCore/rendering/RenderTableCell.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     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     RenderTableCell(Node*);
       
    35 
       
    36     // FIXME: need to implement cellIndex
       
    37     int cellIndex() const { return 0; }
       
    38     void setCellIndex(int) { }
       
    39 
       
    40     int colSpan() const { return m_columnSpan; }
       
    41     void setColSpan(int c) { m_columnSpan = c; }
       
    42 
       
    43     int rowSpan() const { return m_rowSpan; }
       
    44     void setRowSpan(int r) { m_rowSpan = r; }
       
    45 
       
    46     int col() const { return m_column; }
       
    47     void setCol(int col) { m_column = col; }
       
    48     int row() const { return m_row; }
       
    49     void setRow(int row) { m_row = row; }
       
    50 
       
    51     RenderTableSection* section() const { return toRenderTableSection(parent()->parent()); }
       
    52     RenderTable* table() const { return toRenderTable(parent()->parent()->parent()); }
       
    53 
       
    54     Length styleOrColWidth() const;
       
    55 
       
    56     virtual void calcPrefWidths();
       
    57 
       
    58     void updateWidth(int);
       
    59 
       
    60     int borderLeft() const;
       
    61     int borderRight() const;
       
    62     int borderTop() const;
       
    63     int borderBottom() const;
       
    64 
       
    65     int borderHalfLeft(bool outer) const;
       
    66     int borderHalfRight(bool outer) const;
       
    67     int borderHalfTop(bool outer) const;
       
    68     int borderHalfBottom(bool outer) const;
       
    69 
       
    70     CollapsedBorderValue collapsedLeftBorder(bool rtl) const;
       
    71     CollapsedBorderValue collapsedRightBorder(bool rtl) const;
       
    72     CollapsedBorderValue collapsedTopBorder() const;
       
    73     CollapsedBorderValue collapsedBottomBorder() const;
       
    74 
       
    75     typedef Vector<CollapsedBorderValue, 100> CollapsedBorderStyles;
       
    76     void collectBorderStyles(CollapsedBorderStyles&) const;
       
    77     static void sortBorderStyles(CollapsedBorderStyles&);
       
    78 
       
    79     virtual void updateFromElement();
       
    80 
       
    81     virtual void layout();
       
    82 
       
    83     virtual void paint(PaintInfo&, int tx, int ty);
       
    84 
       
    85     void paintBackgroundsBehindCell(PaintInfo&, int tx, int ty, RenderObject* backgroundObject);
       
    86 
       
    87     virtual int baselinePosition(bool firstLine = false, bool isRootLineBox = false) const;
       
    88 
       
    89     void setIntrinsicPaddingTop(int p) { m_intrinsicPaddingTop = p; }
       
    90     void setIntrinsicPaddingBottom(int p) { m_intrinsicPaddingBottom = p; }
       
    91     void setIntrinsicPadding(int top, int bottom) { setIntrinsicPaddingTop(top); setIntrinsicPaddingBottom(bottom); }
       
    92     void clearIntrinsicPadding() { setIntrinsicPadding(0, 0); }
       
    93 
       
    94     int intrinsicPaddingTop() const { return m_intrinsicPaddingTop; }
       
    95     int intrinsicPaddingBottom() const { return m_intrinsicPaddingBottom; }
       
    96 
       
    97     virtual int paddingTop(bool includeIntrinsicPadding = true) const;
       
    98     virtual int paddingBottom(bool includeIntrinsicPadding = true) const;
       
    99 
       
   100     virtual void setOverrideSize(int);
       
   101 
       
   102     bool hasVisibleOverflow() const { return m_overflow; }
       
   103 
       
   104 protected:
       
   105     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
       
   106     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
       
   107 
       
   108 private:
       
   109     virtual const char* renderName() const { return isAnonymous() ? "RenderTableCell (anonymous)" : "RenderTableCell"; }
       
   110 
       
   111     virtual bool isTableCell() const { return true; }
       
   112 
       
   113     virtual void destroy();
       
   114 
       
   115     virtual bool requiresLayer() const { return isPositioned() || isTransparent() || hasOverflowClip() || hasTransform() || hasMask() || hasReflection(); }
       
   116 
       
   117     virtual void calcWidth();
       
   118 
       
   119     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
       
   120     virtual void paintMask(PaintInfo&, int tx, int ty);
       
   121 
       
   122     virtual IntSize offsetFromContainer(RenderObject*, const IntPoint&) const;
       
   123     virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
       
   124     virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false);
       
   125 
       
   126     void paintCollapsedBorder(GraphicsContext*, int x, int y, int w, int h);
       
   127 
       
   128     int m_row;
       
   129     int m_column;
       
   130     int m_rowSpan;
       
   131     int m_columnSpan;
       
   132     int m_intrinsicPaddingTop;
       
   133     int m_intrinsicPaddingBottom;
       
   134     int m_percentageHeight;
       
   135 };
       
   136 
       
   137 inline RenderTableCell* toRenderTableCell(RenderObject* object)
       
   138 {
       
   139     ASSERT(!object || object->isTableCell());
       
   140     return static_cast<RenderTableCell*>(object);
       
   141 }
       
   142 
       
   143 inline const RenderTableCell* toRenderTableCell(const RenderObject* object)
       
   144 {
       
   145     ASSERT(!object || object->isTableCell());
       
   146     return static_cast<const RenderTableCell*>(object);
       
   147 }
       
   148 
       
   149 // This will catch anyone doing an unnecessary cast.
       
   150 void toRenderTableCell(const RenderTableCell*);
       
   151 
       
   152 } // namespace WebCore
       
   153 
       
   154 #endif // RenderTableCell_h