LCOV - code coverage report
Current view: directory - layout/generic - nsPlaceholderFrame.h (source / functions) Found Hit Coverage
Test: app.info Lines: 26 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                 : 
      38                 : /*
      39                 :  * rendering object for the point that anchors out-of-flow rendering
      40                 :  * objects such as floats and absolutely positioned elements
      41                 :  */
      42                 : 
      43                 : /*
      44                 :  * Destruction of a placeholder and its out-of-flow must observe the
      45                 :  * following constraints:
      46                 :  *
      47                 :  * - The mapping from the out-of-flow to the placeholder must be
      48                 :  *   removed from the frame manager before the placeholder is destroyed.
      49                 :  * - The mapping from the out-of-flow to the placeholder must be
      50                 :  *   removed from the frame manager before the out-of-flow is destroyed.
      51                 :  * - The placeholder must be removed from the frame tree, or have the
      52                 :  *   mapping from it to its out-of-flow cleared, before the out-of-flow
      53                 :  *   is destroyed (so that the placeholder will not point to a destroyed
      54                 :  *   frame while it's in the frame tree).
      55                 :  *
      56                 :  * Furthermore, some code assumes that placeholders point to something
      57                 :  * useful, so placeholders without an associated out-of-flow should not
      58                 :  * remain in the tree.
      59                 :  *
      60                 :  * The placeholder's Destroy() implementation handles the destruction of
      61                 :  * the placeholder and its out-of-flow. To avoid crashes, frame removal
      62                 :  * and destruction code that works with placeholders must not assume
      63                 :  * that the placeholder points to its out-of-flow.
      64                 :  */
      65                 : 
      66                 : #ifndef nsPlaceholderFrame_h___
      67                 : #define nsPlaceholderFrame_h___
      68                 : 
      69                 : #include "nsFrame.h"
      70                 : #include "nsGkAtoms.h"
      71                 : 
      72                 : nsIFrame* NS_NewPlaceholderFrame(nsIPresShell* aPresShell,
      73                 :                                  nsStyleContext* aContext,
      74                 :                                  nsFrameState aTypeBit);
      75                 : 
      76                 : // Frame state bits that are used to keep track of what this is a
      77                 : // placeholder for.
      78                 : #define PLACEHOLDER_FOR_FLOAT    NS_FRAME_STATE_BIT(20)
      79                 : #define PLACEHOLDER_FOR_ABSPOS   NS_FRAME_STATE_BIT(21)
      80                 : #define PLACEHOLDER_FOR_FIXEDPOS NS_FRAME_STATE_BIT(22)
      81                 : #define PLACEHOLDER_FOR_POPUP    NS_FRAME_STATE_BIT(23)
      82                 : #define PLACEHOLDER_TYPE_MASK    (PLACEHOLDER_FOR_FLOAT | \
      83                 :                                   PLACEHOLDER_FOR_ABSPOS | \
      84                 :                                   PLACEHOLDER_FOR_FIXEDPOS | \
      85                 :                                   PLACEHOLDER_FOR_POPUP)
      86                 : 
      87                 : /**
      88                 :  * Implementation of a frame that's used as a placeholder for a frame that
      89                 :  * has been moved out of the flow
      90                 :  */
      91                 : class nsPlaceholderFrame : public nsFrame {
      92                 : public:
      93                 :   NS_DECL_FRAMEARENA_HELPERS
      94                 : 
      95                 :   /**
      96                 :    * Create a new placeholder frame.  aTypeBit must be one of the
      97                 :    * PLACEHOLDER_FOR_* constants above.
      98                 :    */
      99                 :   friend nsIFrame* NS_NewPlaceholderFrame(nsIPresShell* aPresShell,
     100                 :                                           nsStyleContext* aContext,
     101                 :                                           nsFrameState aTypeBit);
     102               0 :   nsPlaceholderFrame(nsStyleContext* aContext, nsFrameState aTypeBit) :
     103               0 :     nsFrame(aContext)
     104                 :   {
     105               0 :     NS_PRECONDITION(aTypeBit == PLACEHOLDER_FOR_FLOAT ||
     106                 :                     aTypeBit == PLACEHOLDER_FOR_ABSPOS ||
     107                 :                     aTypeBit == PLACEHOLDER_FOR_FIXEDPOS ||
     108                 :                     aTypeBit == PLACEHOLDER_FOR_POPUP,
     109                 :                     "Unexpected type bit");
     110               0 :     AddStateBits(aTypeBit);
     111               0 :   }
     112                 :   virtual ~nsPlaceholderFrame();
     113                 : 
     114                 :   // Get/Set the associated out of flow frame
     115               0 :   nsIFrame*  GetOutOfFlowFrame() const {return mOutOfFlowFrame;}
     116               0 :   void       SetOutOfFlowFrame(nsIFrame* aFrame) {
     117               0 :                NS_ASSERTION(!aFrame || !aFrame->GetPrevContinuation(),
     118                 :                             "OOF must be first continuation");
     119               0 :                mOutOfFlowFrame = aFrame;
     120               0 :              }
     121                 : 
     122                 :   // nsIHTMLReflow overrides
     123                 :   // We need to override GetMinWidth and GetPrefWidth because XUL uses
     124                 :   // placeholders not within lines.
     125                 :   virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext);
     126                 :   virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext);
     127                 :   virtual void AddInlineMinWidth(nsRenderingContext *aRenderingContext,
     128                 :                                  InlineMinWidthData *aData);
     129                 :   virtual void AddInlinePrefWidth(nsRenderingContext *aRenderingContext,
     130                 :                                   InlinePrefWidthData *aData);
     131                 :   virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState);
     132                 :   virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState);
     133                 :   virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState);
     134                 :   NS_IMETHOD Reflow(nsPresContext* aPresContext,
     135                 :                     nsHTMLReflowMetrics& aDesiredSize,
     136                 :                     const nsHTMLReflowState& aReflowState,
     137                 :                     nsReflowStatus& aStatus);
     138                 : 
     139                 :   virtual void DestroyFrom(nsIFrame* aDestructRoot);
     140                 : 
     141                 :   // nsIFrame overrides
     142                 : #if defined(DEBUG) || (defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF))
     143                 :   NS_IMETHOD BuildDisplayList(nsDisplayListBuilder*   aBuilder,
     144                 :                               const nsRect&           aDirtyRect,
     145                 :                               const nsDisplayListSet& aLists);
     146                 : #endif // DEBUG || (MOZ_REFLOW_PERF_DSP && MOZ_REFLOW_PERF)
     147                 :   
     148                 : #ifdef DEBUG
     149                 :   NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
     150                 : #endif // DEBUG
     151                 : 
     152                 :   /**
     153                 :    * Get the "type" of the frame
     154                 :    *
     155                 :    * @see nsGkAtoms::placeholderFrame
     156                 :    */
     157                 :   virtual nsIAtom* GetType() const;
     158                 : 
     159                 : #ifdef DEBUG
     160                 :   NS_IMETHOD GetFrameName(nsAString& aResult) const;
     161                 : #endif
     162                 : 
     163               0 :   virtual bool IsEmpty() { return true; }
     164               0 :   virtual bool IsSelfEmpty() { return true; }
     165                 : 
     166                 :   virtual bool CanContinueTextRun() const;
     167                 : 
     168                 : #ifdef ACCESSIBILITY
     169               0 :   virtual already_AddRefed<nsAccessible> CreateAccessible()
     170                 :   {
     171               0 :     nsIFrame* realFrame = GetRealFrameForPlaceholder(this);
     172               0 :     return realFrame ? realFrame->CreateAccessible() :
     173               0 :                        nsFrame::CreateAccessible();
     174                 :   }
     175                 : #endif
     176                 : 
     177                 :   virtual nsIFrame* GetParentStyleContextFrame() const;
     178                 : 
     179                 :   /**
     180                 :    * @return the out-of-flow for aFrame if aFrame is a placeholder; otherwise
     181                 :    * aFrame
     182                 :    */
     183               0 :   static nsIFrame* GetRealFrameFor(nsIFrame* aFrame) {
     184               0 :     NS_PRECONDITION(aFrame, "Must have a frame to work with");
     185               0 :     if (aFrame->GetType() == nsGkAtoms::placeholderFrame) {
     186               0 :       return GetRealFrameForPlaceholder(aFrame);
     187                 :     }
     188               0 :     return aFrame;
     189                 :   }
     190                 : 
     191                 :   /**
     192                 :    * @return the out-of-flow for aFrame, which is known to be a placeholder
     193                 :    */
     194               0 :   static nsIFrame* GetRealFrameForPlaceholder(nsIFrame* aFrame) {
     195               0 :     NS_PRECONDITION(aFrame->GetType() == nsGkAtoms::placeholderFrame,
     196                 :                     "Must have placeholder frame as input");
     197                 :     nsIFrame* outOfFlow =
     198               0 :       static_cast<nsPlaceholderFrame*>(aFrame)->GetOutOfFlowFrame();
     199               0 :     NS_ASSERTION(outOfFlow, "Null out-of-flow for placeholder?");
     200               0 :     return outOfFlow;
     201                 :   }
     202                 : 
     203                 : protected:
     204                 :   nsIFrame* mOutOfFlowFrame;
     205                 : };
     206                 : 
     207                 : #endif /* nsPlaceholderFrame_h___ */

Generated by: LCOV version 1.7