LCOV - app.info - layout/generic/nsPageContentFrame.cpp

LCOV - code coverage report
| Current view: | directory - layout/generic - nsPageContentFrame.cpp (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 47 | 0 | 0.0 %
| Date: | 2012-07-07 | Functions: | 7 | 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 "nsPageContentFrame.h"
          38                 : #include "nsPageFrame.h"
          39                 : #include "nsPlaceholderFrame.h"
          40                 : #include "nsCSSFrameConstructor.h"
          41                 : #include "nsContainerFrame.h"
          42                 : #include "nsHTMLParts.h"
          43                 : #include "nsIContent.h"
          44                 : #include "nsPresContext.h"
          45                 : #include "nsGkAtoms.h"
          46                 : #include "nsIPresShell.h"
          47                 : #include "nsReadableUtils.h"
          48                 : #include "nsSimplePageSequence.h"
          49                 : #include "nsDisplayList.h"
          50                 :
          51                 : nsIFrame*
          52               0 : NS_NewPageContentFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
          53                 : {
          54               0 :   return new (aPresShell) nsPageContentFrame(aContext);
          55                 : }
          56                 :
          57               0 : NS_IMPL_FRAMEARENA_HELPERS(nsPageContentFrame)
          58                 :
          59                 : /* virtual */ nsSize
          60               0 : nsPageContentFrame::ComputeSize(nsRenderingContext *aRenderingContext,
          61                 :                                 nsSize aCBSize, nscoord aAvailableWidth,
          62                 :                                 nsSize aMargin, nsSize aBorder, nsSize aPadding,
          63                 :                                 bool aShrinkWrap)
          64                 : {
          65               0 :   NS_ASSERTION(mPD, "Pages are supposed to have page data");
          66               0 :   nscoord height = (!mPD || mPD->mReflowSize.height == NS_UNCONSTRAINEDSIZE)
          67                 :                    ? NS_UNCONSTRAINEDSIZE
          68               0 :                    : (mPD->mReflowSize.height - mPD->mReflowMargin.TopBottom());
          69               0 :   return nsSize(aAvailableWidth, height);
          70                 : }
          71                 :
          72                 : NS_IMETHODIMP
          73               0 : nsPageContentFrame::Reflow(nsPresContext*           aPresContext,
          74                 :                            nsHTMLReflowMetrics&     aDesiredSize,
          75                 :                            const nsHTMLReflowState& aReflowState,
          76                 :                            nsReflowStatus&          aStatus)
          77                 : {
          78               0 :   DO_GLOBAL_REFLOW_COUNT("nsPageContentFrame");
          79               0 :   DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
          80               0 :   aStatus = NS_FRAME_COMPLETE;  // initialize out parameter
          81               0 :   nsresult rv = NS_OK;
          82                 :
          83               0 :   if (GetPrevInFlow() && (GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
          84                 :     nsresult rv = aPresContext->PresShell()->FrameConstructor()
          85               0 :                     ->ReplicateFixedFrames(this);
          86               0 :     NS_ENSURE_SUCCESS(rv, rv);
          87                 :   }
          88                 :
          89                 :   // Set our size up front, since some parts of reflow depend on it
          90                 :   // being already set.  Note that the computed height may be
          91                 :   // unconstrained; that's ok.  Consumers should watch out for that.
          92               0 :   SetSize(nsSize(aReflowState.availableWidth, aReflowState.availableHeight));
          93                 :
          94                 :   // A PageContentFrame must always have one child: the canvas frame.
          95                 :   // Resize our frame allowing it only to be as big as we are
          96                 :   // XXX Pay attention to the page's border and padding...
          97               0 :   if (mFrames.NotEmpty()) {
          98               0 :     nsIFrame* frame = mFrames.FirstChild();
          99               0 :     nsSize  maxSize(aReflowState.availableWidth, aReflowState.availableHeight);
         100               0 :     nsHTMLReflowState kidReflowState(aPresContext, aReflowState, frame, maxSize);
         101               0 :     kidReflowState.SetComputedHeight(aReflowState.availableHeight);
         102                 :
         103               0 :     mPD->mPageContentSize  = aReflowState.availableWidth;
         104                 :
         105                 :     // Reflow the page content area
         106               0 :     rv = ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, 0, 0, 0, aStatus);
         107               0 :     NS_ENSURE_SUCCESS(rv, rv);
         108                 :
         109                 :     // The document element's background should cover the entire canvas, so
         110                 :     // take into account the combined area and any space taken up by
         111                 :     // absolutely positioned elements
         112               0 :     nsMargin padding(0,0,0,0);
         113                 :
         114                 :     // XXXbz this screws up percentage padding (sets padding to zero
         115                 :     // in the percentage padding case)
         116               0 :     kidReflowState.mStylePadding->GetPadding(padding);
         117                 :
         118                 :     // This is for shrink-to-fit, and therefore we want to use the
         119                 :     // scrollable overflow, since the purpose of shrink to fit is to
         120                 :     // make the content that ought to be reachable (represented by the
         121                 :     // scrollable overflow) fit in the page.
         122               0 :     if (frame->HasOverflowAreas()) {
         123                 :       // The background covers the content area and padding area, so check
         124                 :       // for children sticking outside the child frame's padding edge
         125               0 :       nscoord xmost = aDesiredSize.ScrollableOverflow().XMost();
         126               0 :       if (xmost > aDesiredSize.width) {
         127                 :         mPD->mPageContentXMost =
         128                 :           xmost +
         129               0 :           kidReflowState.mStyleBorder->GetActualBorderWidth(NS_SIDE_RIGHT) +
         130               0 :           padding.right;
         131                 :       }
         132                 :     }
         133                 :
         134                 :     // Place and size the child
         135               0 :     FinishReflowChild(frame, aPresContext, &kidReflowState, aDesiredSize, 0, 0, 0);
         136                 :
         137               0 :     NS_ASSERTION(aPresContext->IsDynamic() || !NS_FRAME_IS_FULLY_COMPLETE(aStatus) ||
         138                 :                   !frame->GetNextInFlow(), "bad child flow list");
         139                 :   }
         140                 :
         141                 :   // Reflow our fixed frames
         142               0 :   nsReflowStatus fixedStatus = NS_FRAME_COMPLETE;
         143               0 :   ReflowAbsoluteFrames(aPresContext, aDesiredSize, aReflowState, fixedStatus);
         144               0 :   NS_ASSERTION(NS_FRAME_IS_COMPLETE(fixedStatus), "fixed frames can be truncated, but not incomplete");
         145                 :
         146                 :   // Return our desired size
         147               0 :   aDesiredSize.width = aReflowState.availableWidth;
         148               0 :   if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) {
         149               0 :     aDesiredSize.height = aReflowState.availableHeight;
         150                 :   }
         151                 :
         152               0 :   FinishAndStoreOverflow(&aDesiredSize);
         153                 :
         154               0 :   NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
         155               0 :   return NS_OK;
         156                 : }
         157                 :
         158                 : nsIAtom*
         159               0 : nsPageContentFrame::GetType() const
         160                 : {
         161               0 :   return nsGkAtoms::pageContentFrame;
         162                 : }
         163                 :
         164                 : #ifdef DEBUG
         165                 : NS_IMETHODIMP
         166               0 : nsPageContentFrame::GetFrameName(nsAString& aResult) const
         167                 : {
         168               0 :   return MakeFrameName(NS_LITERAL_STRING("PageContent"), aResult);
         169                 : }
         170                 : #endif

Generated by: LCOV version 1.7