LCOV - code coverage report
Current view: directory - layout/tables - nsTableColFrame.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 84 0 0.0 %
Date: 2012-06-02 Functions: 17 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                 : #include "nsCOMPtr.h"
      38                 : #include "nsTableColFrame.h"
      39                 : #include "nsTableFrame.h"
      40                 : #include "nsContainerFrame.h"
      41                 : #include "nsStyleContext.h"
      42                 : #include "nsStyleConsts.h"
      43                 : #include "nsPresContext.h"
      44                 : #include "nsGkAtoms.h"
      45                 : #include "nsCSSRendering.h"
      46                 : #include "nsIContent.h"
      47                 : #include "nsIDOMHTMLTableColElement.h"
      48                 : 
      49                 : #define COL_TYPE_BITS                 (NS_FRAME_STATE_BIT(28) | \
      50                 :                                        NS_FRAME_STATE_BIT(29) | \
      51                 :                                        NS_FRAME_STATE_BIT(30) | \
      52                 :                                        NS_FRAME_STATE_BIT(31))
      53                 : #define COL_TYPE_OFFSET               28
      54                 : 
      55               0 : nsTableColFrame::nsTableColFrame(nsStyleContext* aContext) :
      56               0 :   nsSplittableFrame(aContext)
      57                 : {
      58               0 :   SetColType(eColContent);
      59               0 :   ResetIntrinsics();
      60               0 :   ResetSpanIntrinsics();
      61               0 :   ResetFinalWidth();
      62               0 : }
      63                 : 
      64               0 : nsTableColFrame::~nsTableColFrame()
      65                 : {
      66               0 : }
      67                 : 
      68                 : nsTableColType 
      69               0 : nsTableColFrame::GetColType() const 
      70                 : {
      71               0 :   return (nsTableColType)((mState & COL_TYPE_BITS) >> COL_TYPE_OFFSET);
      72                 : }
      73                 : 
      74                 : void 
      75               0 : nsTableColFrame::SetColType(nsTableColType aType) 
      76                 : {
      77               0 :   NS_ASSERTION(aType != eColAnonymousCol ||
      78                 :                (GetPrevContinuation() &&
      79                 :                 GetPrevContinuation()->GetNextContinuation() == this &&
      80                 :                 GetPrevContinuation()->GetNextSibling() == this),
      81                 :                "spanned content cols must be continuations");
      82               0 :   PRUint32 type = aType - eColContent;
      83               0 :   mState |= (type << COL_TYPE_OFFSET);
      84               0 : }
      85                 : 
      86                 : /* virtual */ void
      87               0 : nsTableColFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
      88                 : {
      89               0 :   if (!aOldStyleContext) //avoid this on init
      90               0 :     return;
      91                 :      
      92               0 :   nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
      93               0 :   if (tableFrame->IsBorderCollapse() &&
      94               0 :       tableFrame->BCRecalcNeeded(aOldStyleContext, GetStyleContext())) {
      95               0 :     nsIntRect damageArea(GetColIndex(), 0, 1, tableFrame->GetRowCount());
      96               0 :     tableFrame->AddBCDamageArea(damageArea);
      97                 :   }
      98                 : }
      99                 : 
     100               0 : void nsTableColFrame::SetContinuousBCBorderWidth(PRUint8     aForSide,
     101                 :                                                  BCPixelSize aPixelValue)
     102                 : {
     103               0 :   switch (aForSide) {
     104                 :     case NS_SIDE_TOP:
     105               0 :       mTopContBorderWidth = aPixelValue;
     106               0 :       return;
     107                 :     case NS_SIDE_RIGHT:
     108               0 :       mRightContBorderWidth = aPixelValue;
     109               0 :       return;
     110                 :     case NS_SIDE_BOTTOM:
     111               0 :       mBottomContBorderWidth = aPixelValue;
     112               0 :       return;
     113                 :     default:
     114               0 :       NS_ERROR("invalid side arg");
     115                 :   }
     116                 : }
     117                 : 
     118               0 : NS_METHOD nsTableColFrame::Reflow(nsPresContext*          aPresContext,
     119                 :                                   nsHTMLReflowMetrics&     aDesiredSize,
     120                 :                                   const nsHTMLReflowState& aReflowState,
     121                 :                                   nsReflowStatus&          aStatus)
     122                 : {
     123               0 :   DO_GLOBAL_REFLOW_COUNT("nsTableColFrame");
     124               0 :   DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
     125               0 :   aDesiredSize.width=0;
     126               0 :   aDesiredSize.height=0;
     127               0 :   const nsStyleVisibility* colVis = GetStyleVisibility();
     128               0 :   bool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
     129               0 :   if (collapseCol) {
     130               0 :     nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
     131               0 :     tableFrame->SetNeedToCollapse(true);
     132                 :   }
     133               0 :   aStatus = NS_FRAME_COMPLETE;
     134               0 :   NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
     135               0 :   return NS_OK;
     136                 : }
     137                 : 
     138               0 : PRInt32 nsTableColFrame::GetSpan()
     139                 : {
     140               0 :   return GetStyleTable()->mSpan;
     141                 : }
     142                 : 
     143                 : #ifdef DEBUG
     144               0 : void nsTableColFrame::Dump(PRInt32 aIndent)
     145                 : {
     146               0 :   char* indent = new char[aIndent + 1];
     147               0 :   if (!indent) return;
     148               0 :   for (PRInt32 i = 0; i < aIndent + 1; i++) {
     149               0 :     indent[i] = ' ';
     150                 :   }
     151               0 :   indent[aIndent] = 0;
     152                 : 
     153                 :   printf("%s**START COL DUMP**\n%s colIndex=%d coltype=",
     154               0 :     indent, indent, mColIndex);
     155               0 :   nsTableColType colType = GetColType();
     156               0 :   switch (colType) {
     157                 :   case eColContent:
     158               0 :     printf(" content ");
     159               0 :     break;
     160                 :   case eColAnonymousCol: 
     161               0 :     printf(" anonymous-column ");
     162               0 :     break;
     163                 :   case eColAnonymousColGroup:
     164               0 :     printf(" anonymous-colgroup ");
     165               0 :     break;
     166                 :   case eColAnonymousCell: 
     167               0 :     printf(" anonymous-cell ");
     168               0 :     break;
     169                 :   }
     170                 :   printf("\nm:%d c:%d(%c) p:%f sm:%d sc:%d sp:%f f:%d",
     171                 :          PRInt32(mMinCoord), PRInt32(mPrefCoord),
     172                 :          mHasSpecifiedCoord ? 's' : 'u', mPrefPercent,
     173                 :          PRInt32(mSpanMinCoord), PRInt32(mSpanPrefCoord),
     174                 :          mSpanPrefPercent,
     175               0 :          PRInt32(GetFinalWidth()));
     176               0 :   printf("\n%s**END COL DUMP** ", indent);
     177               0 :   delete [] indent;
     178                 : }
     179                 : #endif
     180                 : /* ----- global methods ----- */
     181                 : 
     182                 : nsTableColFrame* 
     183               0 : NS_NewTableColFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
     184                 : {
     185               0 :   return new (aPresShell) nsTableColFrame(aContext);
     186                 : }
     187                 : 
     188               0 : NS_IMPL_FRAMEARENA_HELPERS(nsTableColFrame)
     189                 : 
     190                 : nsTableColFrame*  
     191               0 : nsTableColFrame::GetNextCol() const
     192                 : {
     193               0 :   nsIFrame* childFrame = GetNextSibling();
     194               0 :   while (childFrame) {
     195               0 :     if (nsGkAtoms::tableColFrame == childFrame->GetType()) {
     196               0 :       return (nsTableColFrame*)childFrame;
     197                 :     }
     198               0 :     childFrame = childFrame->GetNextSibling();
     199                 :   }
     200               0 :   return nsnull;
     201                 : }
     202                 : 
     203                 : nsIAtom*
     204               0 : nsTableColFrame::GetType() const
     205                 : {
     206               0 :   return nsGkAtoms::tableColFrame;
     207                 : }
     208                 : 
     209                 : #ifdef DEBUG
     210                 : NS_IMETHODIMP
     211               0 : nsTableColFrame::GetFrameName(nsAString& aResult) const
     212                 : {
     213               0 :   return MakeFrameName(NS_LITERAL_STRING("TableCol"), aResult);
     214                 : }
     215                 : #endif
     216                 : 
     217                 : nsSplittableType
     218               0 : nsTableColFrame::GetSplittableType() const
     219                 : {
     220               0 :   return NS_FRAME_NOT_SPLITTABLE;
     221                 : }
     222                 : 

Generated by: LCOV version 1.7