Back to index

lightning-sunbird  0.9+nobinonly
nsInlineFrame.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 Communicator client 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 nsInlineFrame_h___
00038 #define nsInlineFrame_h___
00039 
00040 #include "nsHTMLContainerFrame.h"
00041 #include "nsAbsoluteContainingBlock.h"
00042 #include "nsLineLayout.h"
00043 #include "nsLayoutAtoms.h"
00044 
00045 class nsAnonymousBlockFrame;
00046 
00047 #define NS_INLINE_FRAME_CID \
00048  { 0xa6cf90e0, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
00049 
00050 #define nsInlineFrameSuper nsHTMLContainerFrame
00051 
00052 #define NS_INLINE_FRAME_CONTAINS_PERCENT_AWARE_CHILD 0x00100000
00053 
00054 // NS_INLINE_FRAME_HARD_TEXT_OFFSETS is used for access keys, where what
00055 // would normally be 1 text frame is split into 3 sets of an inline parent 
00056 // and text child (the pre access key text, the underlined key text, and
00057 // the post access key text). The offsets of the 3 text frame children
00058 // are set in nsCSSFrameConstructor
00059 
00060 #define NS_INLINE_FRAME_HARD_TEXT_OFFSETS            0x00200000
00061 
00068 class nsInlineFrame : public nsInlineFrameSuper
00069 {
00070 public:
00071   friend nsresult NS_NewInlineFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame);
00072 
00073   // nsISupports overrides
00074   NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
00075 
00076   // nsIFrame overrides
00077   NS_IMETHOD AppendFrames(nsIAtom*        aListName,
00078                           nsIFrame*       aFrameList);
00079   NS_IMETHOD InsertFrames(nsIAtom*        aListName,
00080                           nsIFrame*       aPrevFrame,
00081                           nsIFrame*       aFrameList);
00082   NS_IMETHOD RemoveFrame(nsIAtom*        aListName,
00083                          nsIFrame*       aOldFrame);
00084   NS_IMETHOD ReplaceFrame(nsIAtom*        aListName,
00085                           nsIFrame*       aOldFrame,
00086                           nsIFrame*       aNewFrame);
00087   NS_IMETHOD Paint(nsPresContext*      aPresContext,
00088                    nsIRenderingContext& aRenderingContext,
00089                    const nsRect&        aDirtyRect,
00090                    nsFramePaintLayer    aWhichLayer,
00091                    PRUint32             aFlags = 0);
00092   NS_IMETHOD ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild);
00093 
00094 #ifdef ACCESSIBILITY
00095   NS_IMETHODIMP GetAccessible(nsIAccessible** aAccessible);
00096 #endif
00097 
00098 #ifdef DEBUG
00099   NS_IMETHOD GetFrameName(nsAString& aResult) const;
00100 #endif
00101   virtual nsIAtom* GetType() const;
00102 
00103   virtual PRBool IsEmpty();
00104   virtual PRBool IsSelfEmpty();
00105 
00106   // nsIHTMLReflow overrides
00107   NS_IMETHOD Reflow(nsPresContext* aPresContext,
00108                     nsHTMLReflowMetrics& aDesiredSize,
00109                     const nsHTMLReflowState& aReflowState,
00110                     nsReflowStatus& aStatus);
00111 
00112   NS_IMETHOD CanContinueTextRun(PRBool& aContinueTextRun) const;
00113 
00114   // Take all of the frames away from this frame. The caller is
00115   // presumed to keep them alive.
00116   void StealAllFrames() {
00117     mFrames.SetFrames(nsnull);
00118   }
00119 
00120 protected:
00121   // Additional reflow state used during our reflow methods
00122   struct InlineReflowState {
00123     nsIFrame* mPrevFrame;
00124     nsInlineFrame* mNextInFlow;
00125     nsIFrame*      mLineContainer;
00126     PRPackedBool mSetParentPointer;  // when reflowing child frame first set its
00127                                      // parent frame pointer
00128 
00129     InlineReflowState()  {
00130       mPrevFrame = nsnull;
00131       mNextInFlow = nsnull;
00132       mLineContainer = nsnull;
00133       mSetParentPointer = PR_FALSE;
00134     };
00135   };
00136 
00137   nsInlineFrame();
00138 
00139   virtual PRIntn GetSkipSides() const;
00140 
00141   nsresult ReflowFrames(nsPresContext* aPresContext,
00142                         const nsHTMLReflowState& aReflowState,
00143                         InlineReflowState& rs,
00144                         nsHTMLReflowMetrics& aMetrics,
00145                         nsReflowStatus& aStatus);
00146 
00147   nsresult ReflowInlineFrame(nsPresContext* aPresContext,
00148                              const nsHTMLReflowState& aReflowState,
00149                              InlineReflowState& rs,
00150                              nsIFrame* aFrame,
00151                              nsReflowStatus& aStatus);
00152 
00159   void ReparentFloatsForInlineChild(nsIFrame* aOurBlock, nsIFrame* aFrame,
00160                                     PRBool aReparentSiblings);
00161 
00162   virtual nsIFrame* PullOneFrame(nsPresContext* aPresContext,
00163                                  InlineReflowState& rs,
00164                                  PRBool* aIsComplete);
00165 
00166   virtual void PushFrames(nsPresContext* aPresContext,
00167                           nsIFrame* aFromChild,
00168                           nsIFrame* aPrevSibling);
00169 
00170 };
00171 
00172 //----------------------------------------------------------------------
00173 
00178 class nsFirstLineFrame : public nsInlineFrame {
00179 public:
00180   friend nsresult NS_NewFirstLineFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame);
00181 
00182 #ifdef DEBUG
00183   NS_IMETHOD GetFrameName(nsAString& aResult) const;
00184 #endif
00185   virtual nsIAtom* GetType() const;
00186   NS_IMETHOD Reflow(nsPresContext* aPresContext,
00187                     nsHTMLReflowMetrics& aDesiredSize,
00188                     const nsHTMLReflowState& aReflowState,
00189                     nsReflowStatus& aStatus);
00190 
00191   // Take frames starting at aFrame until the end of the frame-list
00192   // away from this frame. The caller is presumed to keep them alive.
00193   void StealFramesFrom(nsIFrame* aFrame);
00194 
00195 protected:
00196   nsFirstLineFrame();
00197 
00198   virtual nsIFrame* PullOneFrame(nsPresContext* aPresContext,
00199                                  InlineReflowState& rs,
00200                                  PRBool* aIsComplete);
00201 };
00202 
00203 //----------------------------------------------------------------------
00204 
00205 // Derived class created for relatively positioned inline-level elements
00206 // that acts as a containing block for child absolutely positioned
00207 // elements
00208 
00209 class nsPositionedInlineFrame : public nsInlineFrame
00210 {
00211 public:
00212   nsPositionedInlineFrame() { }          // useful for debugging
00213 
00214   virtual ~nsPositionedInlineFrame() { } // useful for debugging
00215 
00216   NS_IMETHOD Destroy(nsPresContext* aPresContext);
00217 
00218   NS_IMETHOD SetInitialChildList(nsPresContext* aPresContext,
00219                                  nsIAtom*        aListName,
00220                                  nsIFrame*       aChildList);
00221   NS_IMETHOD AppendFrames(nsIAtom*        aListName,
00222                           nsIFrame*       aFrameList);
00223   NS_IMETHOD InsertFrames(nsIAtom*        aListName,
00224                           nsIFrame*       aPrevFrame,
00225                           nsIFrame*       aFrameList);
00226   NS_IMETHOD RemoveFrame(nsIAtom*        aListName,
00227                          nsIFrame*       aOldFrame);
00228   NS_IMETHOD ReplaceFrame(nsIAtom*        aListName,
00229                           nsIFrame*       aOldFrame,
00230                           nsIFrame*       aNewFrame);
00231 
00232   virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
00233 
00234   virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
00235 
00236   NS_IMETHOD Reflow(nsPresContext*          aPresContext,
00237                     nsHTMLReflowMetrics&     aDesiredSize,
00238                     const nsHTMLReflowState& aReflowState,
00239                     nsReflowStatus&          aStatus);
00240   
00241   virtual nsIAtom* GetType() const;
00242 
00243 protected:
00244   nsAbsoluteContainingBlock mAbsoluteContainer;
00245 };
00246 
00247 #endif /* nsInlineFrame_h___ */