Back to index

lightning-sunbird  0.9+nobinonly
nsFrame.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  *   Pierre Phaneuf <pp@ludusdesign.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 #ifndef nsFrame_h___
00039 #define nsFrame_h___
00040 
00041 #include "nsBox.h"
00042 #include "nsRect.h"
00043 #include "nsString.h"
00044 #include "prlog.h"
00045 #ifdef NS_DEBUG
00046 #include "nsIFrameDebug.h"
00047 #endif
00048 
00049 #include "nsIPresShell.h"
00050 #include "nsHTMLReflowCommand.h"
00051 #include "nsIFrameSelection.h"
00052 #include "nsHTMLReflowState.h"
00053 #include "nsHTMLReflowMetrics.h"
00054 
00061 #define NS_FRAME_TRACE_CALLS        0x1
00062 #define NS_FRAME_TRACE_PUSH_PULL    0x2
00063 #define NS_FRAME_TRACE_CHILD_REFLOW 0x4
00064 #define NS_FRAME_TRACE_NEW_FRAMES   0x8
00065 
00066 #define NS_FRAME_LOG_TEST(_lm,_bit) (PRIntn((_lm)->level) & (_bit))
00067 
00068 #ifdef NS_DEBUG
00069 #define NS_FRAME_LOG(_bit,_args)                                \
00070   PR_BEGIN_MACRO                                                \
00071     if (NS_FRAME_LOG_TEST(nsIFrameDebug::GetLogModuleInfo(),_bit)) { \
00072       PR_LogPrint _args;                                        \
00073     }                                                           \
00074   PR_END_MACRO
00075 #else
00076 #define NS_FRAME_LOG(_bit,_args)
00077 #endif
00078 
00079 // XXX Need to rework this so that logging is free when it's off
00080 #ifdef NS_DEBUG
00081 #define NS_FRAME_TRACE_IN(_method) Trace(_method, PR_TRUE)
00082 
00083 #define NS_FRAME_TRACE_OUT(_method) Trace(_method, PR_FALSE)
00084 
00085 // XXX remove me
00086 #define NS_FRAME_TRACE_MSG(_bit,_args)                          \
00087   PR_BEGIN_MACRO                                                \
00088     if (NS_FRAME_LOG_TEST(nsIFrameDebug::GetLogModuleInfo(),_bit)) { \
00089       TraceMsg _args;                                           \
00090     }                                                           \
00091   PR_END_MACRO
00092 
00093 #define NS_FRAME_TRACE(_bit,_args)                              \
00094   PR_BEGIN_MACRO                                                \
00095     if (NS_FRAME_LOG_TEST(nsIFrameDebug::GetLogModuleInfo(),_bit)) { \
00096       TraceMsg _args;                                           \
00097     }                                                           \
00098   PR_END_MACRO
00099 
00100 #define NS_FRAME_TRACE_REFLOW_IN(_method) Trace(_method, PR_TRUE)
00101 
00102 #define NS_FRAME_TRACE_REFLOW_OUT(_method, _status) \
00103   Trace(_method, PR_FALSE, _status)
00104 
00105 #else
00106 #define NS_FRAME_TRACE(_bits,_args)
00107 #define NS_FRAME_TRACE_IN(_method)
00108 #define NS_FRAME_TRACE_OUT(_method)
00109 #define NS_FRAME_TRACE_MSG(_bits,_args)
00110 #define NS_FRAME_TRACE_REFLOW_IN(_method)
00111 #define NS_FRAME_TRACE_REFLOW_OUT(_method, _status)
00112 #endif
00113 
00114 // handy utilities
00115 void SetFontFromStyle(nsIRenderingContext* aRC, nsStyleContext* aSC);
00116 
00117 //----------------------------------------------------------------------
00118 
00119 struct nsBoxLayoutMetrics;
00120 
00128 class nsFrame : public nsBox
00129 #ifdef NS_DEBUG
00130   , public nsIFrameDebug
00131 #endif
00132 {
00133 public:
00138   friend nsresult NS_NewEmptyFrame(nsIPresShell* aShell, nsIFrame** aInstancePtrResult);
00139 
00140   // Overloaded new operator. Initializes the memory to 0 and relies on an arena
00141   // (which comes from the presShell) to perform the allocation.
00142   void* operator new(size_t sz, nsIPresShell* aPresShell) CPP_THROW_NEW;
00143 
00144   // Overridden to prevent the global delete from being called, since the memory
00145   // came out of an arena instead of the global delete operator's heap.  
00146   // XXX Would like to make this private some day, but our UNIX compilers can't 
00147   // deal with it.
00148   void operator delete(void* aPtr, size_t sz);
00149 
00150   // We compute and store the HTML content's overflow area. So don't
00151   // try to compute it in the box code.
00152   virtual PRBool ComputesOwnOverflowArea() { return PR_TRUE; }
00153 
00154 private:
00155   // The normal operator new is disallowed on nsFrames.
00156   void* operator new(size_t sz) CPP_THROW_NEW { return nsnull; };
00157 
00158 public:
00159 
00160   // nsISupports
00161   NS_IMETHOD  QueryInterface(const nsIID& aIID, void** aInstancePtr);
00162 
00163   // nsIFrame
00164   NS_IMETHOD  Init(nsPresContext*  aPresContext,
00165                    nsIContent*      aContent,
00166                    nsIFrame*        aParent,
00167                    nsStyleContext*  aContext,
00168                    nsIFrame*        asPrevInFlow);
00169   NS_IMETHOD  SetInitialChildList(nsPresContext* aPresContext,
00170                                   nsIAtom*        aListName,
00171                                   nsIFrame*       aChildList);
00172   NS_IMETHOD  AppendFrames(nsIAtom*        aListName,
00173                            nsIFrame*       aFrameList);
00174   NS_IMETHOD  InsertFrames(nsIAtom*        aListName,
00175                            nsIFrame*       aPrevFrame,
00176                            nsIFrame*       aFrameList);
00177   NS_IMETHOD  RemoveFrame(nsIAtom*        aListName,
00178                           nsIFrame*       aOldFrame);
00179   NS_IMETHOD  ReplaceFrame(nsIAtom*        aListName,
00180                            nsIFrame*       aOldFrame,
00181                            nsIFrame*       aNewFrame);
00182   NS_IMETHOD  Destroy(nsPresContext* aPresContext);
00183   NS_IMETHOD  CalcBorderPadding(nsMargin& aBorderPadding) const;
00184   virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const;
00185   virtual void SetAdditionalStyleContext(PRInt32 aIndex,
00186                                          nsStyleContext* aStyleContext);
00187   NS_IMETHOD  SetParent(const nsIFrame* aParent);
00188   virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
00189   virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
00190   NS_IMETHOD  Paint(nsPresContext*      aPresContext,
00191                     nsIRenderingContext& aRenderingContext,
00192                     const nsRect&        aDirtyRect,
00193                     nsFramePaintLayer    aWhichLayer,
00194                     PRUint32             aFlags = 0);
00195   NS_IMETHOD  HandleEvent(nsPresContext* aPresContext, 
00196                           nsGUIEvent*     aEvent,
00197                           nsEventStatus*  aEventStatus);
00198   NS_IMETHOD  GetContentForEvent(nsPresContext* aPresContext,
00199                                  nsEvent* aEvent,
00200                                  nsIContent** aContent);
00201   NS_IMETHOD  GetCursor(const nsPoint&    aPoint,
00202                         nsIFrame::Cursor& aCursor);
00203   NS_IMETHOD  GetFrameForPoint(const nsPoint& aPoint, 
00204                                nsFramePaintLayer aWhichLayer,
00205                                nsIFrame**     aFrame);
00206 
00207   NS_IMETHOD  GetPointFromOffset(nsPresContext*        inPresContext,
00208                                  nsIRenderingContext*   inRendContext,
00209                                  PRInt32                inOffset,
00210                                  nsPoint*               outPoint);
00211 
00212   NS_IMETHOD  GetChildFrameContainingOffset(PRInt32     inContentOffset,
00213                                  PRBool                 inHint,
00214                                  PRInt32*               outFrameContentOffset,
00215                                  nsIFrame*              *outChildFrame);
00216 
00217   static nsresult  GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
00218                                         nsPeekOffsetStruct *aPos, 
00219                                         nsIFrame *aBlockFrame, 
00220                                         PRInt32 aLineStart, 
00221                                         PRInt8 aOutSideLimit
00222                                         );
00223   NS_IMETHOD  CharacterDataChanged(nsPresContext* aPresContext,
00224                                    nsIContent*     aChild,
00225                                    PRBool          aAppend);
00226   NS_IMETHOD  AttributeChanged(nsIContent*     aChild,
00227                                PRInt32         aNameSpaceID,
00228                                nsIAtom*        aAttribute,
00229                                PRInt32         aModType);
00230   NS_IMETHOD  IsSplittable(nsSplittableType& aIsSplittable) const;
00231   virtual nsIFrame* GetPrevInFlow() const;
00232   NS_IMETHOD  SetPrevInFlow(nsIFrame*);
00233   virtual nsIFrame* GetNextInFlow() const;
00234   NS_IMETHOD  SetNextInFlow(nsIFrame*);
00235   NS_IMETHOD  GetOffsetFromView(nsPoint& aOffset, nsIView** aView) const;
00236   NS_IMETHOD  GetOriginToViewOffset(nsPoint& aOffset, nsIView **aView) const;
00237   virtual nsIAtom* GetType() const;
00238   virtual PRBool IsContainingBlock() const;
00239 #ifdef NS_DEBUG
00240   NS_IMETHOD  List(nsPresContext* aPresContext, FILE* out, PRInt32 aIndent) const;
00241   NS_IMETHOD  GetFrameName(nsAString& aResult) const;
00242   NS_IMETHOD_(nsFrameState) GetDebugStateBits() const;
00243   NS_IMETHOD  DumpRegressionData(nsPresContext* aPresContext, FILE* out, PRInt32 aIndent, PRBool aIncludeStyleData);
00244   NS_IMETHOD  VerifyTree() const;
00245 #endif
00246 
00247   NS_IMETHOD  SetSelected(nsPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread);
00248   NS_IMETHOD  GetSelected(PRBool *aSelected) const;
00249   NS_IMETHOD  IsSelectable(PRBool* aIsSelectable, PRUint8* aSelectStyle) const;
00250 
00251   NS_IMETHOD  GetSelectionController(nsPresContext *aPresContext, nsISelectionController **aSelCon);
00252   NS_IMETHOD  PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos) ;
00253   NS_IMETHOD  CheckVisibility(nsPresContext* aContext, PRInt32 aStartIndex, PRInt32 aEndIndex, PRBool aRecurse, PRBool *aFinished, PRBool *_retval);
00254 
00255   NS_IMETHOD  PeekOffsetParagraph(nsPresContext* aPresContext,
00256                                   nsPeekOffsetStruct *aPos);
00257   NS_IMETHOD  GetOffsets(PRInt32 &aStart, PRInt32 &aEnd) const;
00258   NS_IMETHOD  ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild);
00259 
00260 #ifdef ACCESSIBILITY
00261   NS_IMETHOD  GetAccessible(nsIAccessible** aAccessible);
00262 #endif
00263 
00264   NS_IMETHOD GetParentStyleContextFrame(nsPresContext* aPresContext,
00265                                         nsIFrame**      aProviderFrame,
00266                                         PRBool*         aIsChild);
00267 
00268   // Check Style Visibility and mState for Selection (when printing)
00269   NS_IMETHOD IsVisibleForPainting(nsPresContext *     aPresContext, 
00270                                   nsIRenderingContext& aRenderingContext,
00271                                   PRBool               aCheckVis,
00272                                   PRBool*              aIsVisible);
00273 
00274   virtual PRBool IsEmpty();
00275   virtual PRBool IsSelfEmpty();
00276 
00277   // nsIHTMLReflow
00278   NS_IMETHOD  WillReflow(nsPresContext* aPresContext);
00279   NS_IMETHOD  Reflow(nsPresContext*          aPresContext,
00280                      nsHTMLReflowMetrics&     aDesiredSize,
00281                      const nsHTMLReflowState& aReflowState,
00282                      nsReflowStatus&          aStatus);
00283   NS_IMETHOD  DidReflow(nsPresContext*           aPresContext,
00284                         const nsHTMLReflowState*  aReflowState,
00285                         nsDidReflowStatus         aStatus);
00286   NS_IMETHOD CanContinueTextRun(PRBool& aContinueTextRun) const;
00287   NS_IMETHOD AdjustFrameSize(nscoord aExtraSpace, nscoord& aUsedSpace);
00288   NS_IMETHOD TrimTrailingWhiteSpace(nsPresContext* aPresContext,
00289                                     nsIRenderingContext& aRC,
00290                                     nscoord& aDeltaWidth,
00291                                     PRBool& aLastCharIsJustifiable);
00292 
00293   // Selection Methods
00294   // XXX Doc me... (in nsIFrame.h puhleeze)
00295   // XXX If these are selection specific, then the name should imply selection
00296   // rather than generic event processing, e.g., SelectionHandlePress...
00297   NS_IMETHOD HandlePress(nsPresContext* aPresContext,
00298                          nsGUIEvent *    aEvent,
00299                          nsEventStatus*  aEventStatus);
00300 
00301   NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext,
00302                          nsGUIEvent *    aEvent,
00303                          nsEventStatus*  aEventStatus);
00304 
00305   NS_IMETHOD HandleDrag(nsPresContext* aPresContext,
00306                         nsGUIEvent *    aEvent,
00307                         nsEventStatus*  aEventStatus);
00308 
00309   NS_IMETHOD HandleRelease(nsPresContext* aPresContext,
00310                            nsGUIEvent *    aEvent,
00311                            nsEventStatus*  aEventStatus);
00312 
00313   NS_IMETHOD GetContentAndOffsetsFromPoint(nsPresContext* aCX,
00314                                            const nsPoint& aPoint,
00315                                            nsIContent **   aNewContent,
00316                                            PRInt32&        aContentOffset,
00317                                            PRInt32&        aContentOffsetEnd,
00318                                            PRBool&         aBeginFrameContent);
00319   NS_IMETHOD PeekBackwardAndForward(nsSelectionAmount aAmountBack,
00320                                     nsSelectionAmount aAmountForward,
00321                                     PRInt32 aStartPos,
00322                                     nsPresContext* aPresContext,
00323                                     PRBool aJumpLines);
00324 
00325 
00326   // Box layout methods
00327   NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
00328   NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
00329   NS_IMETHOD GetMaxSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
00330   NS_IMETHOD GetFlex(nsBoxLayoutState& aBoxLayoutState, nscoord& aFlex);
00331   NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent);
00332   NS_IMETHOD SetIncludeOverflow(PRBool aInclude);
00333   NS_IMETHOD GetOverflow(nsSize& aOverflow);
00334   NS_IMETHOD NeedsRecalc();
00335 
00336   //--------------------------------------------------
00337   // Additional methods
00338 
00349   void CheckInvalidateSizeChange(nsPresContext*          aPresContext,
00350                                  nsHTMLReflowMetrics&     aDesiredSize,
00351                                  const nsHTMLReflowState& aReflowState);
00352 
00353   // Helper function that tests if the frame tree is too deep; if it
00354   // is it marks the frame as "unflowable" and zeros out the metrics
00355   // and returns PR_TRUE. Otherwise, the frame is unmarked
00356   // "unflowable" and the metrics are not touched and PR_FALSE is
00357   // returned.
00358   PRBool IsFrameTreeTooDeep(const nsHTMLReflowState& aReflowState,
00359                             nsHTMLReflowMetrics& aMetrics);
00360 
00361   // Do the work for getting the parent style context frame so that
00362   // other frame's |GetParentStyleContextFrame| methods can call this
00363   // method on *another* frame.  (This function handles out-of-flow
00364   // frames by using the frame manager's placeholder map and it also
00365   // handles block-within-inline and generated content wrappers.)
00366   nsresult DoGetParentStyleContextFrame(nsPresContext* aPresContext,
00367                                         nsIFrame**      aProviderFrame,
00368                                         PRBool*         aIsChild);
00369 
00370   // incorporate the child overflow area into the parent overflow area
00371   // if the child does not have a overflow use the child area
00372   void ConsiderChildOverflow(nsRect&   aOverflowArea,
00373                              nsIFrame* aChildFrame);
00374 
00375   //Mouse Capturing code used by the frames to tell the view to capture all the following events
00376   NS_IMETHOD CaptureMouse(nsPresContext* aPresContext, PRBool aGrabMouseEvents);
00377   PRBool   IsMouseCaptured(nsPresContext* aPresContext);
00378 
00379   virtual const nsStyleStruct* GetStyleDataExternal(nsStyleStructID aSID) const;
00380 
00381 
00382 #ifdef NS_DEBUG
00383 
00389   void Trace(const char* aMethod, PRBool aEnter);
00390   void Trace(const char* aMethod, PRBool aEnter, nsReflowStatus aStatus);
00391   void TraceMsg(const char* fmt, ...);
00392 
00393   // Helper function that verifies that each frame in the list has the
00394   // NS_FRAME_IS_DIRTY bit set
00395   static void VerifyDirtyBitSet(nsIFrame* aFrameList);
00396 
00397   // Helper function to return the index in parent of the frame's content
00398   // object. Returns -1 on error or if the frame doesn't have a content object
00399   static PRInt32 ContentIndexInContainer(const nsIFrame* aFrame);
00400 
00401   void ListTag(FILE* out) const {
00402     ListTag(out, (nsIFrame*)this);
00403   }
00404 
00405   static void ListTag(FILE* out, nsIFrame* aFrame) {
00406     nsAutoString tmp;
00407     nsIFrameDebug*  frameDebug;
00408 
00409     if (NS_SUCCEEDED(aFrame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) {
00410       frameDebug->GetFrameName(tmp);
00411     }
00412     fputs(NS_LossyConvertUCS2toASCII(tmp).get(), out);
00413     fprintf(out, "@%p", NS_STATIC_CAST(void*, aFrame));
00414   }
00415 
00416   static void IndentBy(FILE* out, PRInt32 aIndent) {
00417     while (--aIndent >= 0) fputs("  ", out);
00418   }
00419   
00420   static void XMLQuote(nsString& aString);
00421 
00431   virtual void DumpBaseRegressionData(nsPresContext* aPresContext, FILE* out, PRInt32 aIndent, PRBool aIncludeStyleData);
00432   
00433   nsresult MakeFrameName(const nsAString& aKind, nsAString& aResult) const;
00434 
00435   // Display Reflow Debugging 
00436   static void* DisplayReflowEnter(nsPresContext*          aPresContext,
00437                                   nsIFrame*                aFrame,
00438                                   const nsHTMLReflowState& aReflowState);
00439   static void  DisplayReflowExit(nsPresContext*      aPresContext,
00440                                  nsIFrame*            aFrame,
00441                                  nsHTMLReflowMetrics& aMetrics,
00442                                  PRUint32             aStatus,
00443                                  void*                aFrameTreeNode);
00444 
00445   static void DisplayReflowStartup();
00446   static void DisplayReflowShutdown();
00447 #endif
00448 
00458   static nsIFrame*
00459   CorrectStyleParentFrame(nsIFrame* aProspectiveParent, nsIAtom* aChildPseudo);
00460 
00461 protected:
00462   // Protected constructor and destructor
00463   nsFrame();
00464   virtual ~nsFrame();
00465 
00471   void PaintSelf(nsPresContext*      aPresContext,
00472                  nsIRenderingContext& aRenderingContext,
00473                  const nsRect&        aDirtyRect,
00474                  PRIntn               aSkipSides = 0,
00475                  PRBool               aUsePrintBackgroundSettings = PR_TRUE);
00476 
00477   PRInt16 DisplaySelection(nsPresContext* aPresContext, PRBool isOkToTurnOn = PR_FALSE);
00478   
00479   //this will modify aPos and return the next frame ect.
00480   NS_IMETHOD GetFrameFromDirection(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos);
00481 
00482   // Style post processing hook
00483   NS_IMETHOD DidSetStyleContext(nsPresContext* aPresContext);
00484 
00485   // Helper routine for determining whether to print selection
00486   nsresult GetSelectionForVisCheck(nsPresContext * aPresContext, nsISelection** aSelection);
00487 
00488   //return the line number of the aFrame
00489   static PRInt32 GetLineNumber(nsIFrame *aFrame);
00490 
00491 public:
00492   //given a frame five me the first/last leaf available
00493   //XXX Robert O'Callahan wants to move these elsewhere
00494   static void GetLastLeaf(nsPresContext* aPresContext, nsIFrame **aFrame);
00495   static void GetFirstLeaf(nsPresContext* aPresContext, nsIFrame **aFrame);
00496   
00497 protected:
00498 
00499   // Test if we are selecting a table object:
00500   //  Most table/cell selection requires that Ctrl (Cmd on Mac) key is down 
00501   //   during a mouse click or drag. Exception is using Shift+click when
00502   //   already in "table/cell selection mode" to extend a block selection
00503   //  Get the parent content node and offset of the frame 
00504   //   of the enclosing cell or table (if not inside a cell)
00505   //  aTarget tells us what table element to select (currently only cell and table supported)
00506   //  (enums for this are defined in nsIFrame.h)
00507   NS_IMETHOD GetDataForTableSelection(nsIFrameSelection *aFrameSelection, 
00508                                       nsIPresShell *aPresShell, nsMouseEvent *aMouseEvent, 
00509                                       nsIContent **aParentContent, PRInt32 *aContentOffset, 
00510                                       PRInt32 *aTarget);
00511 
00512   virtual PRBool ParentDisablesSelection() const;
00513 
00514   // Set the overflow clip rect into the rendering-context. Used for block-level
00515   // elements and replaced elements that have 'overflow' set to 'hidden'. This
00516   // member function assumes that the caller has checked that the clip property
00517   // applies to its situation.
00518   void SetOverflowClipRect(nsIRenderingContext& aRenderingContext);
00519 
00520   // Fills aCursor with the appropriate information from ui
00521   static void FillCursorInformationFromStyle(const nsStyleUserInterface* ui,
00522                                              nsIFrame::Cursor& aCursor);
00523   NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
00524 
00525 #ifdef DEBUG_LAYOUT
00526   virtual void GetBoxName(nsAutoString& aName);
00527 #endif
00528   virtual PRBool HasStyleChange();
00529   virtual void SetStyleChangeFlag(PRBool aDirty);
00530 
00531   virtual PRBool GetWasCollapsed(nsBoxLayoutState& aState);
00532   virtual void SetWasCollapsed(nsBoxLayoutState& aState, PRBool aWas);
00533 
00534   void InitBoxMetrics(PRBool aClear);
00535   nsBoxLayoutMetrics* BoxMetrics() const;
00536 
00537   // Fire DOM event. If no aContent argument use frame's mContent.
00538   void FireDOMEvent(const nsAString& aDOMEventName, nsIContent *aContent = nsnull);
00539 
00540 private:
00541   nsresult BoxReflow(nsBoxLayoutState& aState,
00542                      nsPresContext*    aPresContext,
00543                      nsHTMLReflowMetrics&     aDesiredSize,
00544                      const nsHTMLReflowState& aReflowState,
00545                      nsReflowStatus&          aStatus,
00546                      nscoord aX,
00547                      nscoord aY,
00548                      nscoord aWidth,
00549                      nscoord aHeight,
00550                      PRBool aMoveFrame = PR_TRUE);
00551 
00552   void HandleIncrementalReflow(nsBoxLayoutState& aState, 
00553                                const nsHTMLReflowState& aReflowState, 
00554                                nsReflowReason& aReason,
00555                                nsReflowPath** aReflowPath,
00556                                PRBool& aRedrawNow,
00557                                PRBool& aNeedReflow,
00558                                PRBool& aRedrawAfterReflow,
00559                                PRBool& aMoveFrame);
00560 
00561   PRBool CanSetMaxElementWidth(nsBoxLayoutState& aState,
00562                                nsReflowReason& aReason,
00563                                nsReflowPath **aReflowPath);
00564 
00565   NS_IMETHODIMP RefreshSizeCache(nsBoxLayoutState& aState);
00566 
00567 protected:
00568   NS_IMETHOD_(nsrefcnt) AddRef(void);
00569   NS_IMETHOD_(nsrefcnt) Release(void);
00570 };
00571 
00572 // Start Display Reflow Debugging
00573 #ifdef DEBUG
00574 
00575   struct DR_cookie {
00576     DR_cookie(nsPresContext*          aPresContext,
00577               nsIFrame*                aFrame, 
00578               const nsHTMLReflowState& aReflowState,
00579               nsHTMLReflowMetrics&     aMetrics,
00580               nsReflowStatus&          aStatus);     
00581     ~DR_cookie();
00582     void Change() const;
00583 
00584     nsPresContext*          mPresContext;
00585     nsIFrame*                mFrame;
00586     const nsHTMLReflowState& mReflowState;
00587     nsHTMLReflowMetrics&     mMetrics;
00588     nsReflowStatus&          mStatus;    
00589     void*                    mValue;
00590   };
00591   
00592 #define DISPLAY_REFLOW(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status) \
00593   DR_cookie dr_cookie(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status); 
00594 #define DISPLAY_REFLOW_CHANGE() \
00595   dr_cookie.Change();
00596 
00597 #else
00598 
00599 #define DISPLAY_REFLOW(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status) 
00600 #define DISPLAY_REFLOW_CHANGE() 
00601   
00602 #endif
00603 // End Display Reflow Debugging
00604 
00605 // similar to NS_ENSURE_TRUE but with no return value
00606 #define ENSURE_TRUE(x)                                        \
00607   PR_BEGIN_MACRO                                              \
00608     if (!(x)) {                                               \
00609        NS_WARNING("ENSURE_TRUE(" #x ") failed");              \
00610        return;                                                \
00611     }                                                         \
00612   PR_END_MACRO
00613 #endif /* nsFrame_h___ */