LCOV - code coverage report
Current view: directory - layout/tables - nsTableColGroupFrame.h (source / functions) Found Hit Coverage
Test: app.info Lines: 16 0 0.0 %
Date: 2012-06-02 Functions: 8 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 mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      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 of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or 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                 : #ifndef nsTableColGroupFrame_h__
      38                 : #define nsTableColGroupFrame_h__
      39                 : 
      40                 : #include "nscore.h"
      41                 : #include "nsContainerFrame.h"
      42                 : #include "nsTableColFrame.h"
      43                 : #include "nsTablePainter.h"
      44                 : 
      45                 : class nsTableColFrame;
      46                 : 
      47                 : enum nsTableColGroupType {
      48                 :   eColGroupContent            = 0, // there is real col group content associated   
      49                 :   eColGroupAnonymousCol       = 1, // the result of a col
      50                 :   eColGroupAnonymousCell      = 2  // the result of a cell alone
      51                 : };
      52                 : 
      53                 : /**
      54                 :  * nsTableColGroupFrame
      55                 :  * data structure to maintain information about a single table cell's frame
      56                 :  *
      57                 :  * @author  sclark
      58                 :  */
      59                 : class nsTableColGroupFrame : public nsContainerFrame
      60               0 : {
      61                 : public:
      62                 :   NS_DECL_FRAMEARENA_HELPERS
      63                 : 
      64                 :   // default constructor supplied by the compiler
      65                 : 
      66                 :   /** instantiate a new instance of nsTableRowFrame.
      67                 :     * @param aPresShell the pres shell for this frame
      68                 :     *
      69                 :     * @return           the frame that was created
      70                 :     */
      71                 :   friend nsIFrame* NS_NewTableColGroupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
      72                 : 
      73                 :   /** Initialize the colgroup frame with a set of children.
      74                 :     * @see nsIFrame::SetInitialChildList
      75                 :     */
      76                 :   NS_IMETHOD SetInitialChildList(ChildListID     aListID,
      77                 :                                  nsFrameList&    aChildList);
      78                 : 
      79                 :   /**
      80                 :    * ColGroups never paint anything, nor receive events.
      81                 :    */
      82               0 :   NS_IMETHOD BuildDisplayList(nsDisplayListBuilder*   aBuilder,
      83                 :                               const nsRect&           aDirtyRect,
      84               0 :                               const nsDisplayListSet& aLists) { return NS_OK; }
      85                 : 
      86                 :   /** A colgroup can be caused by three things:
      87                 :     * 1)        An element with table-column-group display
      88                 :     * 2)        An element with a table-column display without a
      89                 :            *    table-column-group parent
      90                 :     * 3)        Cells that are not in a column (and hence get an anonymous
      91                 :            *    column and colgroup).
      92                 :     * @return colgroup type
      93                 :     */
      94                 :   nsTableColGroupType GetColType() const;
      95                 : 
      96                 :   /** Set the colgroup type based on the creation cause
      97                 :     * @param aType - the reason why this colgroup is needed
      98                 :     */
      99                 :   void SetColType(nsTableColGroupType aType);
     100                 :   
     101                 :   /** Real in this context are colgroups that come from an element
     102                 :     * with table-column-group display or wrap around columns that
     103                 :     * come from an element with table-column display. Colgroups
     104                 :     * that are the result of wrapping cells in an anonymous
     105                 :     * column and colgroup are not considered real here.
     106                 :     * @param aTableFrame - the table parent of the colgroups
     107                 :     * @return the last real colgroup
     108                 :     */
     109                 :   static nsTableColGroupFrame* GetLastRealColGroup(nsTableFrame* aTableFrame);
     110                 : 
     111                 :   /** @see nsIFrame::DidSetStyleContext */
     112                 :   virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
     113                 : 
     114                 :   /** @see nsIFrame::AppendFrames, InsertFrames, RemoveFrame
     115                 :     */
     116                 :   NS_IMETHOD AppendFrames(ChildListID     aListID,
     117                 :                           nsFrameList&    aFrameList);
     118                 :   NS_IMETHOD InsertFrames(ChildListID     aListID,
     119                 :                           nsIFrame*       aPrevFrame,
     120                 :                           nsFrameList&    aFrameList);
     121                 :   NS_IMETHOD RemoveFrame(ChildListID     aListID,
     122                 :                          nsIFrame*       aOldFrame);
     123                 : 
     124                 :   /** remove the column aChild from the column group, if requested renumber
     125                 :     * the subsequent columns in this column group and all following column
     126                 :     * groups. see also ResetColIndices for this
     127                 :     * @param aChild       - the column frame that needs to be removed
     128                 :     * @param aResetSubsequentColIndices - if true the columns that follow
     129                 :     *                                     after aChild will be reenumerated
     130                 :     */
     131                 :   void RemoveChild(nsTableColFrame& aChild,
     132                 :                    bool             aResetSubsequentColIndices);
     133                 : 
     134                 :   /** reflow of a column group is a trivial matter of reflowing
     135                 :     * the col group's children (columns), and setting this frame
     136                 :     * to 0-size.  Since tables are row-centric, column group frames
     137                 :     * don't play directly in the rendering game.  They do however
     138                 :     * maintain important state that effects table and cell layout.
     139                 :     */
     140                 :   NS_IMETHOD Reflow(nsPresContext*          aPresContext,
     141                 :                     nsHTMLReflowMetrics&     aDesiredSize,
     142                 :                     const nsHTMLReflowState& aReflowState,
     143                 :                     nsReflowStatus&          aStatus);
     144                 : 
     145                 :   /**
     146                 :    * Get the "type" of the frame
     147                 :    *
     148                 :    * @see nsGkAtoms::tableColGroupFrame
     149                 :    */
     150                 :   virtual nsIAtom* GetType() const;
     151                 : 
     152                 :   /** Add column frames to the table storages: colframe cache and cellmap
     153                 :     * this doesn't change the mFrames of the colgroup frame.
     154                 :     * @param aFirstColIndex - the index at which aFirstFrame should be inserted
     155                 :     *                         into the colframe cache.
     156                 :     * @param aResetSubsequentColIndices - the indices of the col frames
     157                 :     *                                     after the insertion might need
     158                 :     *                                     an update
     159                 :     * @param aCols - an iterator that can be used to iterate over the col
     160                 :     *                frames to be added.  Once this is done, the frames on the
     161                 :     *                sbling chain of its .get() at that point will still need
     162                 :     *                their col indices updated.
     163                 :     * @result            - if there is no table frame or the table frame is not
     164                 :     *                      the first in flow it will return an error
     165                 :     */
     166                 :   nsresult AddColsToTable(PRInt32                   aFirstColIndex,
     167                 :                           bool                      aResetSubsequentColIndices,
     168                 :                           const nsFrameList::Slice& aCols);
     169                 : 
     170                 : #ifdef DEBUG
     171                 :   NS_IMETHOD GetFrameName(nsAString& aResult) const;
     172                 :   void Dump(PRInt32 aIndent);
     173                 : #endif
     174                 : 
     175                 :   /** returns the number of columns represented by this group.
     176                 :     * if there are col children, count them (taking into account the span of each)
     177                 :     * else, check my own span attribute.
     178                 :     */
     179                 :   virtual PRInt32 GetColCount() const;
     180                 : 
     181                 :   /** first column on the child list */
     182                 :   nsTableColFrame * GetFirstColumn();
     183                 :   /** next sibling to aChildFrame that is a column frame, first column frame
     184                 :     * in the column group if aChildFrame is null
     185                 :     */
     186                 :   nsTableColFrame * GetNextColumn(nsIFrame *aChildFrame);
     187                 : 
     188                 :   /** @return - the position of the first column in this colgroup in the table
     189                 :     * colframe cache.
     190                 :     */
     191                 :   PRInt32 GetStartColumnIndex();
     192                 :   
     193                 :   /** set the position of the first column in this colgroup in the table
     194                 :     * colframe cache.
     195                 :     */
     196                 :   void SetStartColumnIndex(PRInt32 aIndex);
     197                 : 
     198                 :   /** helper method to get the span attribute for this colgroup */
     199                 :   PRInt32 GetSpan();
     200                 : 
     201                 :   /** provide access to the mFrames list
     202                 :     */
     203                 :   nsFrameList& GetWritableChildList();
     204                 : 
     205                 :   /** set the column index for all frames starting at aStartColFrame, it
     206                 :     * will also reset the column indices in all subsequent colgroups
     207                 :     * @param aFirstColGroup - start the reset operation inside this colgroup
     208                 :     * @param aFirstColIndex - first column that is reset should get this index
     209                 :     * @param aStartColFrame - if specified the reset starts with this column
     210                 :     *                         inside the colgroup; if not specified, the reset
     211                 :     *                         starts with the first column
     212                 :     */
     213                 :   static void ResetColIndices(nsIFrame*       aFirstColGroup,
     214                 :                               PRInt32         aFirstColIndex,
     215                 :                               nsIFrame*       aStartColFrame = nsnull);
     216                 : 
     217                 :   /**
     218                 :    * Gets inner border widths before collapsing with cell borders
     219                 :    * Caller must get left border from previous column
     220                 :    * GetContinuousBCBorderWidth will not overwrite aBorder.left
     221                 :    * see nsTablePainter about continuous borders
     222                 :    */
     223                 :   void GetContinuousBCBorderWidth(nsMargin& aBorder);
     224                 :   /**
     225                 :    * Set full border widths before collapsing with cell borders
     226                 :    * @param aForSide - side to set; only accepts top and bottom
     227                 :    */
     228                 :   void SetContinuousBCBorderWidth(PRUint8     aForSide,
     229                 :                                   BCPixelSize aPixelValue);
     230                 : protected:
     231                 :   nsTableColGroupFrame(nsStyleContext* aContext);
     232                 : 
     233                 :   void InsertColsReflow(PRInt32                   aColIndex,
     234                 :                         const nsFrameList::Slice& aCols);
     235                 : 
     236                 :   /** implement abstract method on nsContainerFrame */
     237                 :   virtual PRIntn GetSkipSides() const;
     238                 : 
     239                 :   // data members
     240                 :   PRInt32 mColCount;
     241                 :   // the starting column index this col group represents. Must be >= 0. 
     242                 :   PRInt32 mStartColIndex;
     243                 : 
     244                 :   // border width in pixels
     245                 :   BCPixelSize mTopContBorderWidth;
     246                 :   BCPixelSize mBottomContBorderWidth;
     247                 : };
     248                 : 
     249               0 : inline nsTableColGroupFrame::nsTableColGroupFrame(nsStyleContext *aContext)
     250               0 : : nsContainerFrame(aContext), mColCount(0), mStartColIndex(0)
     251                 : { 
     252               0 :   SetColType(eColGroupContent);
     253               0 : }
     254                 :   
     255               0 : inline PRInt32 nsTableColGroupFrame::GetStartColumnIndex()
     256                 : {  
     257               0 :   return mStartColIndex;
     258                 : }
     259                 : 
     260               0 : inline void nsTableColGroupFrame::SetStartColumnIndex (PRInt32 aIndex)
     261                 : {
     262               0 :   mStartColIndex = aIndex;
     263               0 : }
     264                 : 
     265               0 : inline PRInt32 nsTableColGroupFrame::GetColCount() const
     266                 : {  
     267               0 :   return mColCount;
     268                 : }
     269                 : 
     270               0 : inline nsFrameList& nsTableColGroupFrame::GetWritableChildList()
     271                 : {  
     272               0 :   return mFrames;
     273                 : }
     274                 : 
     275                 : #endif
     276                 : 

Generated by: LCOV version 1.7