LCOV - code coverage report
Current view: directory - layout/generic - nsLeafFrame.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 44 0 0.0 %
Date: 2012-06-02 Functions: 12 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                 : 
      38                 : /* base class for rendering objects that do not have child lists */
      39                 : 
      40                 : #include "nsCOMPtr.h"
      41                 : #include "nsLeafFrame.h"
      42                 : #include "nsContainerFrame.h"
      43                 : #include "nsHTMLParts.h"
      44                 : #include "nsPresContext.h"
      45                 : 
      46               0 : nsLeafFrame::~nsLeafFrame()
      47                 : {
      48               0 : }
      49                 : 
      50               0 : NS_IMPL_FRAMEARENA_HELPERS(nsLeafFrame)
      51                 : 
      52                 : /* virtual */ nscoord
      53               0 : nsLeafFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
      54                 : {
      55                 :   nscoord result;
      56               0 :   DISPLAY_MIN_WIDTH(this, result);
      57                 : 
      58               0 :   result = GetIntrinsicWidth();
      59               0 :   return result;
      60                 : }
      61                 : 
      62                 : /* virtual */ nscoord
      63               0 : nsLeafFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
      64                 : {
      65                 :   nscoord result;
      66               0 :   DISPLAY_PREF_WIDTH(this, result);
      67               0 :   result = GetIntrinsicWidth();
      68               0 :   return result;
      69                 : }
      70                 : 
      71                 : /* virtual */ nsSize
      72               0 : nsLeafFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
      73                 :                              nsSize aCBSize, nscoord aAvailableWidth,
      74                 :                              nsSize aMargin, nsSize aBorder,
      75                 :                              nsSize aPadding, bool aShrinkWrap)
      76                 : {
      77               0 :   return nsSize(GetIntrinsicWidth(), GetIntrinsicHeight());
      78                 : }
      79                 : 
      80                 : NS_IMETHODIMP
      81               0 : nsLeafFrame::Reflow(nsPresContext* aPresContext,
      82                 :                     nsHTMLReflowMetrics& aMetrics,
      83                 :                     const nsHTMLReflowState& aReflowState,
      84                 :                     nsReflowStatus& aStatus)
      85                 : {
      86               0 :   DO_GLOBAL_REFLOW_COUNT("nsLeafFrame");
      87               0 :   NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
      88                 :                  ("enter nsLeafFrame::Reflow: aMaxSize=%d,%d",
      89                 :                   aReflowState.availableWidth, aReflowState.availableHeight));
      90                 : 
      91               0 :   NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
      92                 : 
      93               0 :   DoReflow(aPresContext, aMetrics, aReflowState, aStatus);
      94                 : 
      95               0 :   FinishAndStoreOverflow(&aMetrics);
      96               0 :   return NS_OK;
      97                 : }
      98                 : 
      99                 : NS_IMETHODIMP
     100               0 : nsLeafFrame::DoReflow(nsPresContext* aPresContext,
     101                 :                       nsHTMLReflowMetrics& aMetrics,
     102                 :                       const nsHTMLReflowState& aReflowState,
     103                 :                       nsReflowStatus& aStatus)
     104                 : {
     105               0 :   NS_ASSERTION(aReflowState.ComputedWidth() != NS_UNCONSTRAINEDSIZE,
     106                 :                "Shouldn't have unconstrained stuff here "
     107                 :                "Thanks to the rules of reflow");
     108               0 :   NS_ASSERTION(NS_INTRINSICSIZE != aReflowState.ComputedHeight(),
     109                 :                "Shouldn't have unconstrained stuff here "
     110                 :                "thanks to ComputeAutoSize");  
     111                 : 
     112               0 :   aMetrics.width = aReflowState.ComputedWidth();
     113               0 :   aMetrics.height = aReflowState.ComputedHeight();
     114                 :   
     115               0 :   AddBordersAndPadding(aReflowState, aMetrics);
     116               0 :   aStatus = NS_FRAME_COMPLETE;
     117                 : 
     118               0 :   NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
     119                 :                  ("exit nsLeafFrame::DoReflow: size=%d,%d",
     120                 :                   aMetrics.width, aMetrics.height));
     121               0 :   NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
     122                 : 
     123               0 :   aMetrics.SetOverflowAreasToDesiredBounds();
     124                 : 
     125               0 :   return NS_OK;
     126                 : }
     127                 : 
     128                 : nscoord
     129               0 : nsLeafFrame::GetIntrinsicHeight()
     130                 : {
     131               0 :   NS_NOTREACHED("Someone didn't override Reflow or ComputeAutoSize");
     132               0 :   return 0;
     133                 : }
     134                 : 
     135                 : // XXX how should border&padding effect baseline alignment?
     136                 : // => descent = borderPadding.bottom for example
     137                 : void
     138               0 : nsLeafFrame::AddBordersAndPadding(const nsHTMLReflowState& aReflowState,
     139                 :                                   nsHTMLReflowMetrics& aMetrics)
     140                 : {
     141               0 :   aMetrics.width += aReflowState.mComputedBorderPadding.LeftRight();
     142               0 :   aMetrics.height += aReflowState.mComputedBorderPadding.TopBottom();
     143               0 : }
     144                 : 
     145                 : void
     146               0 : nsLeafFrame::SizeToAvailSize(const nsHTMLReflowState& aReflowState,
     147                 :                              nsHTMLReflowMetrics& aDesiredSize)
     148                 : {
     149               0 :   aDesiredSize.width  = aReflowState.availableWidth; // FRAME
     150               0 :   aDesiredSize.height = aReflowState.availableHeight;
     151               0 :   aDesiredSize.SetOverflowAreasToDesiredBounds();
     152               0 :   FinishAndStoreOverflow(&aDesiredSize);  
     153               0 : }

Generated by: LCOV version 1.7