LCOV - app.info - layout/tables/nsTablePainter.h

LCOV - code coverage report
| Current view: | directory - layout/tables - nsTablePainter.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 9 | 0 | 0.0 %
| Date: | 2012-04-21 | Functions: | 5 | 0 | 0.0 %

           1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
           2                 : /* ***** BEGIN LICENSE BLOCK *****
           3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           4                 :  *
           5                 :  * The contents of this file are subject to the Mozilla Public License Version
           6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           7                 :  * the License. You may obtain a copy of the License at
           8                 :  * http://www.mozilla.org/MPL/
           9                 :  *
          10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          12                 :  * for the specific language governing rights and limitations under the
          13                 :  * License.
          14                 :  *
          15                 :  * The Original Code is TableBackgroundPainter interface.
          16                 :  *
          17                 :  * The Initial Developer of the Original Code is
          18                 :  * Elika J. Etemad ("fantasai") <fantasai@inkedblade.net>.
          19                 :  * Portions created by the Initial Developer are Copyright (C) 2004
          20                 :  * the Initial Developer. All Rights Reserved.
          21                 :  *
          22                 :  * Contributor(s):
          23                 :  *
          24                 :  * Alternatively, the contents of this file may be used under the terms of
          25                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
          26                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          28                 :  * of those above. If you wish to allow use of your version of this file only
          29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          30                 :  * use your version of this file under the terms of the MPL, indicate your
          31                 :  * decision by deleting the provisions above and replace them with the notice
          32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          33                 :  * the provisions above, a recipient may use your version of this file under
          34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          35                 :  *
          36                 :  * ***** END LICENSE BLOCK ***** */
          37                 :
          38                 : #ifndef nsTablePainter_h__
          39                 : #define nsTablePainter_h__
          40                 :
          41                 : #include "celldata.h"
          42                 :
          43                 : // flags for Paint, PaintChild, PaintChildren are currently only used by tables.
          44                 : //Table-based paint call; not a direct call as with views
          45                 : #define NS_PAINT_FLAG_TABLE_BG_PAINT      0x00000001
          46                 : //Cells should paint their backgrounds only, no children
          47                 : #define NS_PAINT_FLAG_TABLE_CELL_BG_PASS  0x00000002
          48                 :
          49                 : #include "nsIFrame.h"
          50                 : class nsTableFrame;
          51                 : class nsTableRowGroupFrame;
          52                 : class nsTableRowFrame;
          53                 : class nsTableCellFrame;
          54                 :
          55                 : class TableBackgroundPainter
          56                 : {
          57                 :   /*
          58                 :    * Helper class for painting table backgrounds
          59                 :    *
          60                 :    */
          61                 :
          62                 :   public:
          63                 :
          64                 :     enum Origin { eOrigin_Table, eOrigin_TableRowGroup, eOrigin_TableRow };
          65                 :
          66                 :     /** Public constructor
          67                 :       * @param aTableFrame       - the table's table frame
          68                 :       * @param aOrigin           - what type of table frame is creating this instance
          69                 :       * @param aPresContext      - the presentation context
          70                 :       * @param aRenderingContext - the rendering context
          71                 :       * @param aDirtyRect        - the area that needs to be painted,
          72                 :       * relative to aRenderingContext
          73                 :       * @param aPt               - offset of the table frame relative to
          74                 :       * aRenderingContext
          75                 :       * @param aBGPaintFlags - Flags of the nsCSSRendering::PAINTBG_* variety
          76                 :       */
          77                 :     TableBackgroundPainter(nsTableFrame*        aTableFrame,
          78                 :                            Origin               aOrigin,
          79                 :                            nsPresContext*       aPresContext,
          80                 :                            nsRenderingContext& aRenderingContext,
          81                 :                            const nsRect&        aDirtyRect,
          82                 :                            const nsPoint&       aPt,
          83                 :                            PRUint32             aBGPaintFlags);
          84                 :
          85                 :     /** Destructor */
          86                 :     ~TableBackgroundPainter();
          87                 :
          88                 :     /* ~*~ The Border Collapse Painting Issue ~*~
          89                 :
          90                 :        In border-collapse, the *table* paints the cells' borders,
          91                 :        so we need to make sure the backgrounds get painted first
          92                 :        (underneath) by doing a cell-background-only painting pass.
          93                 :     */
          94                 :
          95                 :     /* ~*~ Using nsTablePainter Background Painting ~*~
          96                 :
          97                 :        A call to PaintTable will normally paint all of the table's
          98                 :        elements (except for the table background, if aPaintTableBackground
          99                 :        is false).
         100                 :        Elements with views however, will be skipped and must create their
         101                 :        own painter to call the appropriate paint function in their ::Paint
         102                 :        method (e.g. painter.PaintRow in nsTableRow::Paint)
         103                 :     */
         104                 :
         105                 :     /** Paint background for the table frame (if requested) and its children
         106                 :       * down through cells.
         107                 :       * (Cells themselves will only be painted in border collapse)
         108                 :       * Table must do a flagged TABLE_BG_PAINT ::Paint call on its
         109                 :       * children afterwards
         110                 :       * @param aTableFrame - the table frame
         111                 :       * @param aDeflate    - deflation needed to bring table's mRect
         112                 :       *                      to the outer grid lines in border-collapse
         113                 :       * @param aPaintTableBackground - if true, the table background
         114                 :       * is included, otherwise it isn't
         115                 :       */
         116                 :     nsresult PaintTable(nsTableFrame* aTableFrame, const nsMargin& aDeflate,
         117                 :                         bool aPaintTableBackground);
         118                 :
         119                 :     /** Paint background for the row group and its children down through cells
         120                 :       * (Cells themselves will only be painted in border collapse)
         121                 :       * Standards mode only
         122                 :       * Table Row Group must do a flagged TABLE_BG_PAINT ::Paint call on its
         123                 :       * children afterwards
         124                 :       * @param aFrame - the table row group frame
         125                 :       */
         126               0 :     nsresult PaintRowGroup(nsTableRowGroupFrame* aFrame)
         127               0 :     { return PaintRowGroup(aFrame, false); }
         128                 :
         129                 :     /** Paint background for the row and its children down through cells
         130                 :       * (Cells themselves will only be painted in border collapse)
         131                 :       * Standards mode only
         132                 :       * Table Row must do a flagged TABLE_BG_PAINT ::Paint call on its
         133                 :       * children afterwards
         134                 :       * @param aFrame - the table row frame
         135                 :       */
         136               0 :     nsresult PaintRow(nsTableRowFrame* aFrame)
         137               0 :     { return PaintRow(aFrame, false); }
         138                 :
         139                 :   private:
         140                 :
         141                 :     /** Paint table frame's background
         142                 :       * @param aTableFrame     - the table frame
         143                 :       * @param aFirstRowGroup  - the first (in layout order) row group
         144                 :       *                          may be null
         145                 :       * @param aLastRowGroup   - the last (in layout order) row group
         146                 :       *                          may be null
         147                 :       * @param aDeflate        - adjustment to frame's rect (used for quirks BC)
         148                 :       *                          may be null
         149                 :       */
         150                 :     nsresult PaintTableFrame(nsTableFrame*         aTableFrame,
         151                 :                              nsTableRowGroupFrame* aFirstRowGroup,
         152                 :                              nsTableRowGroupFrame* aLastRowGroup,
         153                 :                              const nsMargin&       aDeflate);
         154                 :
         155                 :     /* aPassThrough params indicate whether to paint the element or to just
         156                 :      * pass through and paint underlying layers only
         157                 :      * See Public versions for function descriptions
         158                 :      */
         159                 :     nsresult PaintRowGroup(nsTableRowGroupFrame* aFrame,
         160                 :                            bool                  aPassThrough);
         161                 :     nsresult PaintRow(nsTableRowFrame* aFrame,
         162                 :                       bool             aPassThrough);
         163                 :
         164                 :     /** Paint table background layers for this cell space
         165                 :       * Also paints cell's own background in border-collapse mode
         166                 :       * @param aFrame      - the cell
         167                 :       * @param aPassSelf   - pass this cell; i.e. paint only underlying layers
         168                 :       */
         169                 :     nsresult PaintCell(nsTableCellFrame* aFrame,
         170                 :                        bool              aPassSelf);
         171                 :
         172                 :     /** Translate mRenderingContext, mDirtyRect, and mCols' column and
         173                 :       * colgroup coords
         174                 :       * @param aDX - origin's x-coord change
         175                 :       * @param aDY - origin's y-coord change
         176                 :       */
         177                 :     void TranslateContext(nscoord aDX,
         178                 :                           nscoord aDY);
         179                 :
         180                 :     struct TableBackgroundData;
         181                 :     friend struct TableBackgroundData;
         182                 :     struct TableBackgroundData {
         183                 :       nsIFrame*                 mFrame;
         184                 :       /** mRect is the rect of mFrame in the current coordinate system */
         185                 :       nsRect                    mRect;
         186                 :       bool                      mVisible;
         187                 :       const nsStyleBorder*      mBorder;
         188                 :
         189                 :       /** Data is valid & frame is visible */
         190               0 :       bool IsVisible() const { return mVisible; }
         191                 :
         192                 :       /** Constructor */
         193                 :       TableBackgroundData();
         194                 :       /** Destructor */
         195                 :       ~TableBackgroundData();
         196                 :       /** Destroys synthesized data. MUST be called before destructor
         197                 :        *  @param aPresContext - the pres context
         198                 :        */
         199                 :       void Destroy(nsPresContext* aPresContext);
         200                 :
         201                 :
         202                 :       /** Clear background data */
         203                 :       void Clear();
         204                 :
         205                 :       /** Calculate and set all data values to represent aFrame */
         206                 :       void SetFull(nsIFrame* aFrame);
         207                 :
         208                 :       /** Set frame data (mFrame, mRect) but leave style data empty */
         209                 :       void SetFrame(nsIFrame* aFrame);
         210                 :
         211                 :       /** Calculate the style data for mFrame */
         212                 :       void SetData();
         213                 :
         214                 :       /** True if need to set border-collapse border; must call SetFull beforehand */
         215                 :       bool ShouldSetBCBorder();
         216                 :
         217                 :       /** Set border-collapse border with aBorderWidth as widths */
         218                 :       nsresult SetBCBorder(nsMargin&               aBorderWidth,
         219                 :                            TableBackgroundPainter* aPainter);
         220                 :
         221                 :       private:
         222                 :       nsStyleBorder* mSynthBorder;
         223                 :     };
         224                 :
         225                 :     struct ColData;
         226                 :     friend struct ColData;
         227               0 :     struct ColData {
         228                 :       TableBackgroundData  mCol;
         229                 :       TableBackgroundData* mColGroup; //link to col's parent colgroup's data (owned by painter)
         230               0 :       ColData() {
         231               0 :         mColGroup = nsnull;
         232               0 :       }
         233                 :     };
         234                 :
         235                 :     nsPresContext*      mPresContext;
         236                 :     nsRenderingContext& mRenderingContext;
         237                 :     nsPoint              mRenderPt;
         238                 :     nsRect               mDirtyRect;
         239                 : #ifdef DEBUG
         240                 :     nsCompatibility      mCompatMode;
         241                 : #endif
         242                 :     bool                 mIsBorderCollapse;
         243                 :     Origin               mOrigin; //user's table frame type
         244                 :
         245                 :     ColData*             mCols;  //array of columns' ColData
         246                 :     PRUint32             mNumCols;
         247                 :     TableBackgroundData  mRowGroup; //current row group
         248                 :     TableBackgroundData  mRow;      //current row
         249                 :     nsRect               mCellRect; //current cell's rect
         250                 :
         251                 :     nsStyleBorder        mZeroBorder;  //cached zero-width border
         252                 :     PRUint32             mBGPaintFlags;
         253                 : };
         254                 :
         255                 : #endif

Generated by: LCOV version 1.7