Back to index

lightning-sunbird  0.9+nobinonly
nsContainerFrame.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 #ifndef nsContainerFrame_h___
00038 #define nsContainerFrame_h___
00039 
00040 #include "nsSplittableFrame.h"
00041 #include "nsFrameList.h"
00042 
00043 // Option flags for ReflowChild() and FinishReflowChild()
00044 // member functions
00045 #define NS_FRAME_NO_MOVE_VIEW         0x0001
00046 #define NS_FRAME_NO_MOVE_FRAME        (0x0002 | NS_FRAME_NO_MOVE_VIEW)
00047 #define NS_FRAME_NO_SIZE_VIEW         0x0004
00048 #define NS_FRAME_NO_VISIBILITY        0x0008
00049 
00053 class nsContainerFrame : public nsSplittableFrame
00054 {
00055 public:
00056   // nsIFrame overrides
00057   NS_IMETHOD Init(nsPresContext*  aPresContext,
00058                   nsIContent*      aContent,
00059                   nsIFrame*        aParent,
00060                   nsStyleContext*  aContext,
00061                   nsIFrame*        aPrevInFlow);
00062   NS_IMETHOD SetInitialChildList(nsPresContext* aPresContext,
00063                                  nsIAtom*        aListName,
00064                                  nsIFrame*       aChildList);
00065   virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
00066   virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
00067   NS_IMETHOD Destroy(nsPresContext* aPresContext);
00068   NS_IMETHOD Paint(nsPresContext*      aPresContext,
00069                    nsIRenderingContext& aRenderingContext,
00070                    const nsRect&        aDirtyRect,
00071                    nsFramePaintLayer    aWhichLayer,
00072                    PRUint32             aFlags = 0);
00073   NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, 
00074                               nsFramePaintLayer aWhichLayer,
00075                               nsIFrame**     aFrame);
00076   NS_IMETHOD ReplaceFrame(nsIAtom*        aListName,
00077                           nsIFrame*       aOldFrame,
00078                           nsIFrame*       aNewFrame);
00079   NS_IMETHOD ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild);
00080 
00081   virtual PRBool IsLeaf() const;
00082   
00083 #ifdef DEBUG
00084   NS_IMETHOD List(nsPresContext* aPresContext, FILE* out, PRInt32 aIndent) const;
00085 #endif  
00086 
00087   // nsContainerFrame methods
00088   virtual void DeleteNextInFlowChild(nsPresContext* aPresContext,
00089                                      nsIFrame*       aNextInFlow);
00090 
00091   static PRInt32 LengthOf(nsIFrame* aFrameList) {
00092     nsFrameList tmp(aFrameList);
00093     return tmp.GetLength();
00094   }
00095 
00096   // Positions the frame's view based on the frame's origin
00097   static void PositionFrameView(nsIFrame* aKidFrame);
00098 
00099   // Set the view's size and position after its frame has been reflowed.
00100   //
00101   // Flags:
00102   // NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
00103   //    don't want to automatically sync the frame and view
00104   // NS_FRAME_NO_SIZE_VIEW - don't size the view
00105   static void SyncFrameViewAfterReflow(nsPresContext* aPresContext,
00106                                        nsIFrame*       aFrame,
00107                                        nsIView*        aView,
00108                                        const nsRect*   aCombinedArea,
00109                                        PRUint32        aFlags = 0);
00110   
00111   // Sets view attributes from the frame style that depend on the view's size
00112   // (clip, transparency). This needs to be called if you change the size of
00113   // a view and the view's frame could have clipping set on it.
00114   // @param aStyleContext can be null, in which case the frame's style context is used
00115   static void SyncFrameViewAfterSizeChange(nsPresContext*  aPresContext,
00116                                            nsIFrame*        aFrame,
00117                                            nsStyleContext*  aStyleContext,
00118                                            nsIView*         aView,
00119                                            PRUint32         aFlags = 0);
00120   
00121   // Sets the view's attributes from the frame style.
00122   // - opacity
00123   // - visibility
00124   // - content transparency
00125   // - clip
00126   // Call this when one of these styles changes or when the view has just
00127   // been created.
00128   // @param aStyleContext can be null, in which case the frame's style context is used
00129   static void SyncFrameViewProperties(nsPresContext*  aPresContext,
00130                                       nsIFrame*        aFrame,
00131                                       nsStyleContext*  aStyleContext,
00132                                       nsIView*         aView,
00133                                       PRUint32         aFlags = 0);
00134 
00135   // Returns PR_TRUE if the frame requires a view
00136   static PRBool FrameNeedsView(nsIFrame* aFrame);
00137   
00149   nsresult ReflowChild(nsIFrame*                aKidFrame,
00150                        nsPresContext*          aPresContext,
00151                        nsHTMLReflowMetrics&     aDesiredSize,
00152                        const nsHTMLReflowState& aReflowState,
00153                        nscoord                  aX,
00154                        nscoord                  aY,
00155                        PRUint32                 aFlags,
00156                        nsReflowStatus&          aStatus);
00157 
00175   static nsresult FinishReflowChild(nsIFrame*                 aKidFrame,
00176                                     nsPresContext*           aPresContext,
00177                                     const nsHTMLReflowState*  aReflowState,
00178                                     nsHTMLReflowMetrics&      aDesiredSize,
00179                                     nscoord                   aX,
00180                                     nscoord                   aY,
00181                                     PRUint32                  aFlags);
00182 
00183   
00184   static void PositionChildViews(nsIFrame* aFrame);
00185 
00186 protected:
00187   nsContainerFrame();
00188   ~nsContainerFrame();
00189 
00190   nsresult GetFrameForPointUsing(const nsPoint& aPoint,
00191                                  nsIAtom*       aList,
00192                                  nsFramePaintLayer aWhichLayer,
00193                                  PRBool         aConsiderSelf,
00194                                  nsIFrame**     aFrame);
00195 
00196   virtual void PaintChildren(nsPresContext*      aPresContext,
00197                              nsIRenderingContext& aRenderingContext,
00198                              const nsRect&        aDirtyRect,
00199                              nsFramePaintLayer    aWhichLayer,
00200                              PRUint32             aFlags = 0);
00201 
00202   virtual void PaintChild(nsPresContext*      aPresContext,
00203                           nsIRenderingContext& aRenderingContext,
00204                           const nsRect&        aDirtyRect,
00205                           nsIFrame*            aFrame,
00206                           nsFramePaintLayer    aWhichLayer,
00207                           PRUint32             aFlags = 0);
00208 
00212   nsIFrame* GetOverflowFrames(nsPresContext* aPresContext,
00213                               PRBool          aRemoveProperty) const;
00214 
00218   nsresult SetOverflowFrames(nsPresContext* aPresContext,
00219                              nsIFrame*       aOverflowFrames);
00220 
00230   PRBool MoveOverflowToChildList(nsPresContext* aPresContext);
00231 
00246   void PushChildren(nsPresContext* aPresContext,
00247                     nsIFrame*       aFromChild,
00248                     nsIFrame*       aPrevSibling);
00249 
00250   nsFrameList mFrames;
00251 };
00252 
00253 #endif /* nsContainerFrame_h___ */