LCOV - code coverage report
Current view: directory - layout/xul/base/src - nsBoxFrame.h (source / functions) Found Hit Coverage
Test: app.info Lines: 7 0 0.0 %
Date: 2012-06-02 Functions: 6 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 Communicator client 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                 : 
      40                 :   Eric D Vaughan
      41                 :   nsBoxFrame is a frame that can lay its children out either vertically or horizontally.
      42                 :   It lays them out according to a min max or preferred size.
      43                 :  
      44                 : **/
      45                 : 
      46                 : #ifndef nsBoxFrame_h___
      47                 : #define nsBoxFrame_h___
      48                 : 
      49                 : #include "nsCOMPtr.h"
      50                 : #include "nsContainerFrame.h"
      51                 : #include "nsBoxLayout.h"
      52                 : 
      53                 : class nsBoxLayoutState;
      54                 : 
      55                 : // flags from box
      56                 : #define NS_STATE_BOX_CHILD_RESERVED      NS_FRAME_STATE_BIT(20)
      57                 : #define NS_STATE_STACK_NOT_POSITIONED    NS_FRAME_STATE_BIT(21)
      58                 : //#define NS_STATE_IS_HORIZONTAL           NS_FRAME_STATE_BIT(22)  moved to nsIFrame.h
      59                 : #define NS_STATE_AUTO_STRETCH            NS_FRAME_STATE_BIT(23)
      60                 : //#define NS_STATE_IS_ROOT                 NS_FRAME_STATE_BIT(24)  moved to nsBox.h
      61                 : #define NS_STATE_CURRENTLY_IN_DEBUG      NS_FRAME_STATE_BIT(25)
      62                 : //#define NS_STATE_SET_TO_DEBUG            NS_FRAME_STATE_BIT(26)  moved to nsBox.h
      63                 : //#define NS_STATE_DEBUG_WAS_SET           NS_FRAME_STATE_BIT(27)  moved to nsBox.h
      64                 : #define NS_STATE_MENU_HAS_POPUP_LIST       NS_FRAME_STATE_BIT(28) /* used on nsMenuFrame */
      65                 : #define NS_STATE_BOX_WRAPS_KIDS_IN_BLOCK NS_FRAME_STATE_BIT(29)
      66                 : #define NS_STATE_EQUAL_SIZE              NS_FRAME_STATE_BIT(30)
      67                 : //#define NS_STATE_IS_DIRECTION_NORMAL     NS_FRAME_STATE_BIT(31)  moved to nsIFrame.h
      68                 : #define NS_FRAME_MOUSE_THROUGH_ALWAYS    NS_FRAME_STATE_BIT(60)
      69                 : #define NS_FRAME_MOUSE_THROUGH_NEVER     NS_FRAME_STATE_BIT(61)
      70                 : 
      71                 : nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
      72                 :                          nsStyleContext* aContext,
      73                 :                          bool aIsRoot,
      74                 :                          nsBoxLayout* aLayoutManager);
      75                 : nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
      76                 :                          nsStyleContext* aContext);
      77                 : 
      78                 : class nsBoxFrame : public nsContainerFrame
      79                 : {
      80                 : public:
      81                 :   NS_DECL_FRAMEARENA_HELPERS
      82                 : 
      83                 :   friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell, 
      84                 :                                   nsStyleContext* aContext,
      85                 :                                   bool aIsRoot,
      86                 :                                   nsBoxLayout* aLayoutManager);
      87                 :   friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
      88                 :                                   nsStyleContext* aContext);
      89                 : 
      90                 :   // gets the rect inside our border and debug border. If you wish to paint inside a box
      91                 :   // call this method to get the rect so you don't draw on the debug border or outer border.
      92                 : 
      93                 :   // ------ nsIBox -------------
      94               0 :   virtual void SetLayoutManager(nsBoxLayout* aLayout) { mLayoutManager = aLayout; }
      95               0 :   virtual nsBoxLayout* GetLayoutManager() { return mLayoutManager; }
      96                 : 
      97                 :   NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild);
      98                 : 
      99                 :   virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState);
     100                 :   virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState);
     101                 :   virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState);
     102                 :   virtual nscoord GetFlex(nsBoxLayoutState& aBoxLayoutState);
     103                 :   virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState);
     104                 : #ifdef DEBUG_LAYOUT
     105                 :   NS_IMETHOD SetDebug(nsBoxLayoutState& aBoxLayoutState, bool aDebug);
     106                 :   NS_IMETHOD GetDebug(bool& aDebug);
     107                 : #endif
     108               0 :   virtual Valignment GetVAlign() const { return mValign; }
     109               0 :   virtual Halignment GetHAlign() const { return mHalign; }
     110                 :   NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
     111                 : 
     112               0 :   virtual bool ComputesOwnOverflowArea() { return false; }
     113                 : 
     114                 :   // ----- child and sibling operations ---
     115                 : 
     116                 :   // ----- public methods -------
     117                 :   
     118                 :   NS_IMETHOD  Init(nsIContent*      aContent,
     119                 :                    nsIFrame*        aParent,
     120                 :                    nsIFrame*        asPrevInFlow);
     121                 : 
     122                 :  
     123                 :   NS_IMETHOD AttributeChanged(PRInt32         aNameSpaceID,
     124                 :                               nsIAtom*        aAttribute,
     125                 :                               PRInt32         aModType);
     126                 : 
     127                 :   virtual void MarkIntrinsicWidthsDirty();
     128                 :   virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext);
     129                 :   virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext);
     130                 : 
     131                 :   NS_IMETHOD Reflow(nsPresContext*          aPresContext,
     132                 :                     nsHTMLReflowMetrics&     aDesiredSize,
     133                 :                     const nsHTMLReflowState& aReflowState,
     134                 :                     nsReflowStatus&          aStatus);
     135                 : 
     136                 :   NS_IMETHOD  AppendFrames(ChildListID     aListID,
     137                 :                            nsFrameList&    aFrameList);
     138                 : 
     139                 :   NS_IMETHOD  InsertFrames(ChildListID     aListID,
     140                 :                            nsIFrame*       aPrevFrame,
     141                 :                            nsFrameList&    aFrameList);
     142                 : 
     143                 :   NS_IMETHOD  RemoveFrame(ChildListID     aListID,
     144                 :                           nsIFrame*       aOldFrame);
     145                 : 
     146                 :   virtual nsIFrame* GetContentInsertionFrame();
     147                 : 
     148                 :   NS_IMETHOD  SetInitialChildList(ChildListID     aListID,
     149                 :                                   nsFrameList&    aChildList);
     150                 : 
     151                 :   virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
     152                 : 
     153                 :   virtual nsIAtom* GetType() const;
     154                 : 
     155               0 :   virtual bool IsFrameOfType(PRUint32 aFlags) const
     156                 :   {
     157                 :     // record that children that are ignorable whitespace should be excluded 
     158                 :     // (When content was loaded via the XUL content sink, it's already
     159                 :     // been excluded, but we need this for when the XUL namespace is used
     160                 :     // in other MIME types or when the XUL CSS display types are used with
     161                 :     // non-XUL elements.)
     162                 : 
     163                 :     // This is bogus, but it's what we've always done.
     164                 :     // (Given that we're replaced, we need to say we're a replaced element
     165                 :     // that contains a block so nsHTMLReflowState doesn't tell us to be
     166                 :     // NS_INTRINSICSIZE wide.)
     167                 :     return nsContainerFrame::IsFrameOfType(aFlags &
     168                 :       ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock | eXULBox |
     169               0 :         nsIFrame::eExcludesIgnorableWhitespace));
     170                 :   }
     171                 : 
     172                 : #ifdef DEBUG
     173                 :   NS_IMETHOD GetFrameName(nsAString& aResult) const;
     174                 : #endif
     175                 : 
     176                 :   NS_IMETHOD DidReflow(nsPresContext*           aPresContext,
     177                 :                        const nsHTMLReflowState*  aReflowState,
     178                 :                        nsDidReflowStatus         aStatus);
     179                 : 
     180                 :   virtual bool HonorPrintBackgroundSettings();
     181                 : 
     182                 :   virtual ~nsBoxFrame();
     183                 :   
     184                 :   nsBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, bool aIsRoot = false, nsBoxLayout* aLayoutManager = nsnull);
     185                 : 
     186                 :   // virtual so nsStackFrame, nsButtonBoxFrame, nsSliderFrame and nsMenuFrame
     187                 :   // can override it
     188                 :   NS_IMETHOD BuildDisplayListForChildren(nsDisplayListBuilder*   aBuilder,
     189                 :                                          const nsRect&           aDirtyRect,
     190                 :                                          const nsDisplayListSet& aLists);
     191                 : 
     192                 :   NS_IMETHOD BuildDisplayList(nsDisplayListBuilder*   aBuilder,
     193                 :                               const nsRect&           aDirtyRect,
     194                 :                               const nsDisplayListSet& aLists);
     195                 :   
     196                 : #ifdef DEBUG_LAYOUT
     197                 :     virtual void SetDebugOnChildList(nsBoxLayoutState& aState, nsIBox* aChild, bool aDebug);
     198                 :     nsresult DisplayDebugInfoFor(nsIBox*  aBox, 
     199                 :                                  nsPoint& aPoint);
     200                 : #endif
     201                 : 
     202                 :   static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIBox* aBox, const nsRect& aRect);
     203                 : 
     204                 :   /**
     205                 :    * Utility method to redirect events on descendants to this frame.
     206                 :    * Supports 'allowevents' attribute on descendant elements to allow those
     207                 :    * elements and their descendants to receive events.
     208                 :    */
     209                 :   nsresult WrapListsInRedirector(nsDisplayListBuilder*   aBuilder,
     210                 :                                  const nsDisplayListSet& aIn,
     211                 :                                  const nsDisplayListSet& aOut);
     212                 : 
     213                 :   /**
     214                 :    * This defaults to true, but some box frames (nsListBoxBodyFrame for
     215                 :    * example) don't support ordinals in their children.
     216                 :    */
     217                 :   virtual bool SupportsOrdinalsInChildren();
     218                 : 
     219                 : protected:
     220                 : #ifdef DEBUG_LAYOUT
     221                 :     virtual void GetBoxName(nsAutoString& aName);
     222                 :     void PaintXULDebugBackground(nsRenderingContext& aRenderingContext,
     223                 :                                  nsPoint aPt);
     224                 :     void PaintXULDebugOverlay(nsRenderingContext& aRenderingContext,
     225                 :                               nsPoint aPt);
     226                 : #endif
     227                 : 
     228                 :     virtual bool GetInitialEqualSize(bool& aEqualSize); 
     229                 :     virtual void GetInitialOrientation(bool& aIsHorizontal);
     230                 :     virtual void GetInitialDirection(bool& aIsNormal);
     231                 :     virtual bool GetInitialHAlignment(Halignment& aHalign); 
     232                 :     virtual bool GetInitialVAlignment(Valignment& aValign); 
     233                 :     virtual bool GetInitialAutoStretch(bool& aStretch); 
     234                 :   
     235                 :     virtual void DestroyFrom(nsIFrame* aDestructRoot);
     236                 : 
     237                 :     nsSize mPrefSize;
     238                 :     nsSize mMinSize;
     239                 :     nsSize mMaxSize;
     240                 :     nscoord mFlex;
     241                 :     nscoord mAscent;
     242                 : 
     243                 :     nsCOMPtr<nsBoxLayout> mLayoutManager;
     244                 : 
     245                 : protected:
     246                 :     nsresult RegUnregAccessKey(bool aDoReg);
     247                 : 
     248                 :   NS_HIDDEN_(void) CheckBoxOrder(nsBoxLayoutState& aState);
     249                 : 
     250                 : private: 
     251                 : 
     252                 : #ifdef DEBUG_LAYOUT
     253                 :     nsresult SetDebug(nsPresContext* aPresContext, bool aDebug);
     254                 :     bool GetInitialDebug(bool& aDebug);
     255                 :     void GetDebugPref(nsPresContext* aPresContext);
     256                 : 
     257                 :     void GetDebugBorder(nsMargin& aInset);
     258                 :     void GetDebugPadding(nsMargin& aInset);
     259                 :     void GetDebugMargin(nsMargin& aInset);
     260                 : 
     261                 :     nsresult GetFrameSizeWithMargin(nsIBox* aBox, nsSize& aSize);
     262                 : 
     263                 :     void PixelMarginToTwips(nsPresContext* aPresContext, nsMargin& aMarginPixels);
     264                 : 
     265                 :     void GetValue(nsPresContext* aPresContext, const nsSize& a, const nsSize& b, char* value);
     266                 :     void GetValue(nsPresContext* aPresContext, PRInt32 a, PRInt32 b, char* value);
     267                 :     void DrawSpacer(nsPresContext* aPresContext, nsRenderingContext& aRenderingContext, bool aHorizontal, PRInt32 flex, nscoord x, nscoord y, nscoord size, nscoord spacerSize);
     268                 :     void DrawLine(nsRenderingContext& aRenderingContext,  bool aHorizontal, nscoord x1, nscoord y1, nscoord x2, nscoord y2);
     269                 :     void FillRect(nsRenderingContext& aRenderingContext,  bool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height);
     270                 : #endif
     271                 :     virtual void UpdateMouseThrough();
     272                 : 
     273                 :     void CacheAttributes();
     274                 : 
     275                 :     // instance variables.
     276                 :     Halignment mHalign;
     277                 :     Valignment mValign;
     278                 : 
     279                 : #ifdef DEBUG_LAYOUT
     280                 :     static bool gDebug;
     281                 :     static nsIBox* mDebugChild;
     282                 : #endif
     283                 : 
     284                 : }; // class nsBoxFrame
     285                 : 
     286                 : #endif
     287                 : 

Generated by: LCOV version 1.7