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
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/
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
15 * The Original Code is mozilla.org code.
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.
23 * Pierre Phaneuf <pp@ludusdesign.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 /* base class of all rendering objects */
49 #include "nsIPresShell.h"
50 #include "nsFrameSelection.h"
51 #include "nsHTMLReflowState.h"
52 #include "nsHTMLReflowMetrics.h"
55 * nsFrame logging constants. We redefine the nspr
56 * PRLogModuleInfo.level field to be a bitfield. Each bit controls a
57 * specific type of logging. Each logging operation has associated
58 * inline methods defined below.
60 #define NS_FRAME_TRACE_CALLS 0x1
61 #define NS_FRAME_TRACE_PUSH_PULL 0x2
62 #define NS_FRAME_TRACE_CHILD_REFLOW 0x4
63 #define NS_FRAME_TRACE_NEW_FRAMES 0x8
65 #define NS_FRAME_LOG_TEST(_lm,_bit) (PRIntn((_lm)->level) & (_bit))
68 #define NS_FRAME_LOG(_bit,_args) \
70 if (NS_FRAME_LOG_TEST(nsFrame::GetLogModuleInfo(),_bit)) { \
75 #define NS_FRAME_LOG(_bit,_args)
78 // XXX Need to rework this so that logging is free when it's off
80 #define NS_FRAME_TRACE_IN(_method) Trace(_method, PR_TRUE)
82 #define NS_FRAME_TRACE_OUT(_method) Trace(_method, PR_FALSE)
85 #define NS_FRAME_TRACE_MSG(_bit,_args) \
87 if (NS_FRAME_LOG_TEST(nsFrame::GetLogModuleInfo(),_bit)) { \
92 #define NS_FRAME_TRACE(_bit,_args) \
94 if (NS_FRAME_LOG_TEST(nsFrame::GetLogModuleInfo(),_bit)) { \
99 #define NS_FRAME_TRACE_REFLOW_IN(_method) Trace(_method, PR_TRUE)
101 #define NS_FRAME_TRACE_REFLOW_OUT(_method, _status) \
102 Trace(_method, PR_FALSE, _status)
105 #define NS_FRAME_TRACE(_bits,_args)
106 #define NS_FRAME_TRACE_IN(_method)
107 #define NS_FRAME_TRACE_OUT(_method)
108 #define NS_FRAME_TRACE_MSG(_bits,_args)
109 #define NS_FRAME_TRACE_REFLOW_IN(_method)
110 #define NS_FRAME_TRACE_REFLOW_OUT(_method, _status)
113 // Frame allocation boilerplate macros. Every subclass of nsFrame
114 // must define its own operator new and GetAllocatedSize. If they do
115 // not, the per-frame recycler lists in nsPresArena will not work
116 // correctly, with potentially catastrophic consequences (not enough
117 // memory is allocated for a frame object).
119 #define NS_DECL_FRAMEARENA_HELPERS \
120 NS_MUST_OVERRIDE void* operator new(size_t, nsIPresShell*); \
121 virtual NS_MUST_OVERRIDE nsQueryFrame::FrameIID GetFrameId();
123 #define NS_IMPL_FRAMEARENA_HELPERS(class) \
124 void* class::operator new(size_t sz, nsIPresShell* aShell) \
125 { return aShell->AllocateFrame(nsQueryFrame::class##_id, sz); } \
126 nsQueryFrame::FrameIID class::GetFrameId() \
127 { return nsQueryFrame::class##_id; }
129 //----------------------------------------------------------------------
131 struct nsBoxLayoutMetrics
;
134 * Implementation of a simple frame that's not splittable and has no
137 * Sets the NS_FRAME_SYNCHRONIZE_FRAME_AND_VIEW bit, so the default
138 * behavior is to keep the frame and view position and size in sync.
140 class nsFrame
: public nsBox
144 * Create a new "empty" frame that maps a given piece of content into a
147 friend nsIFrame
* NS_NewEmptyFrame(nsIPresShell
* aShell
,
148 nsStyleContext
* aContext
);
151 // Left undefined; nsFrame objects are never allocated from the heap.
152 void* operator new(size_t sz
) CPP_THROW_NEW
;
155 // Overridden to prevent the global delete from being called, since
156 // the memory came out of an arena instead of the heap.
158 // Ideally this would be private and undefined, like the normal
159 // operator new. Unfortunately, the C++ standard requires an
160 // overridden operator delete to be accessible to any subclass that
161 // defines a virtual destructor, so we can only make it protected;
162 // worse, some C++ compilers will synthesize calls to this function
163 // from the "deleting destructors" that they emit in case of
164 // delete-expressions, so it can't even be undefined.
165 void operator delete(void* aPtr
, size_t sz
);
171 NS_DECL_FRAMEARENA_HELPERS
174 NS_IMETHOD
Init(nsIContent
* aContent
,
176 nsIFrame
* asPrevInFlow
);
177 NS_IMETHOD
SetInitialChildList(nsIAtom
* aListName
,
178 nsFrameList
& aChildList
);
179 NS_IMETHOD
AppendFrames(nsIAtom
* aListName
,
180 nsFrameList
& aFrameList
);
181 NS_IMETHOD
InsertFrames(nsIAtom
* aListName
,
182 nsIFrame
* aPrevFrame
,
183 nsFrameList
& aFrameList
);
184 NS_IMETHOD
RemoveFrame(nsIAtom
* aListName
,
185 nsIFrame
* aOldFrame
);
186 virtual void DestroyFrom(nsIFrame
* aDestructRoot
);
187 virtual nsStyleContext
* GetAdditionalStyleContext(PRInt32 aIndex
) const;
188 virtual void SetAdditionalStyleContext(PRInt32 aIndex
,
189 nsStyleContext
* aStyleContext
);
190 NS_IMETHOD
SetParent(const nsIFrame
* aParent
);
191 virtual nscoord
GetBaseline() const;
192 virtual nsIAtom
* GetAdditionalChildListName(PRInt32 aIndex
) const;
193 virtual nsFrameList
GetChildList(nsIAtom
* aListName
) const;
194 NS_IMETHOD
HandleEvent(nsPresContext
* aPresContext
,
196 nsEventStatus
* aEventStatus
);
197 NS_IMETHOD
GetContentForEvent(nsPresContext
* aPresContext
,
199 nsIContent
** aContent
);
200 NS_IMETHOD
GetCursor(const nsPoint
& aPoint
,
201 nsIFrame::Cursor
& aCursor
);
203 NS_IMETHOD
GetPointFromOffset(PRInt32 inOffset
,
206 NS_IMETHOD
GetChildFrameContainingOffset(PRInt32 inContentOffset
,
208 PRInt32
* outFrameContentOffset
,
209 nsIFrame
* *outChildFrame
);
211 static nsresult
GetNextPrevLineFromeBlockFrame(nsPresContext
* aPresContext
,
212 nsPeekOffsetStruct
*aPos
,
213 nsIFrame
*aBlockFrame
,
218 NS_IMETHOD
CharacterDataChanged(CharacterDataChangeInfo
* aInfo
);
219 NS_IMETHOD
AttributeChanged(PRInt32 aNameSpaceID
,
222 virtual nsSplittableType
GetSplittableType() const;
223 virtual nsIFrame
* GetPrevContinuation() const;
224 NS_IMETHOD
SetPrevContinuation(nsIFrame
*);
225 virtual nsIFrame
* GetNextContinuation() const;
226 NS_IMETHOD
SetNextContinuation(nsIFrame
*);
227 virtual nsIFrame
* GetPrevInFlowVirtual() const;
228 NS_IMETHOD
SetPrevInFlow(nsIFrame
*);
229 virtual nsIFrame
* GetNextInFlowVirtual() const;
230 NS_IMETHOD
SetNextInFlow(nsIFrame
*);
231 NS_IMETHOD
GetOffsetFromView(nsPoint
& aOffset
, nsIView
** aView
) const;
232 virtual nsIAtom
* GetType() const;
233 virtual PRBool
IsContainingBlock() const;
235 NS_IMETHOD
GetSelected(PRBool
*aSelected
) const;
236 NS_IMETHOD
IsSelectable(PRBool
* aIsSelectable
, PRUint8
* aSelectStyle
) const;
238 NS_IMETHOD
GetSelectionController(nsPresContext
*aPresContext
, nsISelectionController
**aSelCon
);
240 virtual PRBool
PeekOffsetNoAmount(PRBool aForward
, PRInt32
* aOffset
);
241 virtual PRBool
PeekOffsetCharacter(PRBool aForward
, PRInt32
* aOffset
);
242 virtual PRBool
PeekOffsetWord(PRBool aForward
, PRBool aWordSelectEatSpace
, PRBool aIsKeyboardSelect
,
243 PRInt32
* aOffset
, PeekWordState
*aState
);
245 * Check whether we should break at a boundary between punctuation and
246 * non-punctuation. Only call it at a punctuation boundary
247 * (i.e. exactly one of the previous and next characters are punctuation).
248 * @param aForward true if we're moving forward in content order
249 * @param aPunctAfter true if the next character is punctuation
250 * @param aWhitespaceAfter true if the next character is whitespace
252 PRBool
BreakWordBetweenPunctuation(const PeekWordState
* aState
,
254 PRBool aPunctAfter
, PRBool aWhitespaceAfter
,
255 PRBool aIsKeyboardSelect
);
257 NS_IMETHOD
CheckVisibility(nsPresContext
* aContext
, PRInt32 aStartIndex
, PRInt32 aEndIndex
, PRBool aRecurse
, PRBool
*aFinished
, PRBool
*_retval
);
259 NS_IMETHOD
GetOffsets(PRInt32
&aStart
, PRInt32
&aEnd
) const;
260 virtual void ChildIsDirty(nsIFrame
* aChild
);
263 virtual already_AddRefed
<nsAccessible
> CreateAccessible();
266 NS_IMETHOD
GetParentStyleContextFrame(nsPresContext
* aPresContext
,
267 nsIFrame
** aProviderFrame
,
270 virtual PRBool
IsEmpty();
271 virtual PRBool
IsSelfEmpty();
273 virtual void MarkIntrinsicWidthsDirty();
274 virtual nscoord
GetMinWidth(nsIRenderingContext
*aRenderingContext
);
275 virtual nscoord
GetPrefWidth(nsIRenderingContext
*aRenderingContext
);
276 virtual void AddInlineMinWidth(nsIRenderingContext
*aRenderingContext
,
277 InlineMinWidthData
*aData
);
278 virtual void AddInlinePrefWidth(nsIRenderingContext
*aRenderingContext
,
279 InlinePrefWidthData
*aData
);
280 virtual IntrinsicWidthOffsetData
281 IntrinsicWidthOffsets(nsIRenderingContext
* aRenderingContext
);
282 virtual IntrinsicSize
GetIntrinsicSize();
283 virtual nsSize
GetIntrinsicRatio();
285 virtual nsSize
ComputeSize(nsIRenderingContext
*aRenderingContext
,
286 nsSize aCBSize
, nscoord aAvailableWidth
,
287 nsSize aMargin
, nsSize aBorder
, nsSize aPadding
,
290 // Compute tight bounds assuming this frame honours its border, background
291 // and outline, its children's tight bounds, and nothing else.
292 nsRect
ComputeSimpleTightBounds(gfxContext
* aContext
) const;
295 * A helper, used by |nsFrame::ComputeSize| (for frames that need to
296 * override only this part of ComputeSize), that computes the size
297 * that should be returned when 'width', 'height', and
298 * min/max-width/height are all 'auto' or equivalent.
300 * In general, frames that can accept any computed width/height should
301 * override only ComputeAutoSize, and frames that cannot do so need to
302 * override ComputeSize to enforce their width/height invariants.
304 * Implementations may optimize by returning a garbage width if
305 * GetStylePosition()->mWidth.GetUnit() != eStyleUnit_Auto, and
306 * likewise for height, since in such cases the result is guaranteed
309 virtual nsSize
ComputeAutoSize(nsIRenderingContext
*aRenderingContext
,
310 nsSize aCBSize
, nscoord aAvailableWidth
,
311 nsSize aMargin
, nsSize aBorder
,
312 nsSize aPadding
, PRBool aShrinkWrap
);
315 * Utility function for ComputeAutoSize implementations. Return
316 * max(GetMinWidth(), min(aWidthInCB, GetPrefWidth()))
318 nscoord
ShrinkWidthToFit(nsIRenderingContext
*aRenderingContext
,
321 NS_IMETHOD
WillReflow(nsPresContext
* aPresContext
);
322 NS_IMETHOD
Reflow(nsPresContext
* aPresContext
,
323 nsHTMLReflowMetrics
& aDesiredSize
,
324 const nsHTMLReflowState
& aReflowState
,
325 nsReflowStatus
& aStatus
);
326 NS_IMETHOD
DidReflow(nsPresContext
* aPresContext
,
327 const nsHTMLReflowState
* aReflowState
,
328 nsDidReflowStatus aStatus
);
329 virtual PRBool
CanContinueTextRun() const;
332 // XXX Doc me... (in nsIFrame.h puhleeze)
333 // XXX If these are selection specific, then the name should imply selection
334 // rather than generic event processing, e.g., SelectionHandlePress...
335 NS_IMETHOD
HandlePress(nsPresContext
* aPresContext
,
337 nsEventStatus
* aEventStatus
);
339 NS_IMETHOD
HandleMultiplePress(nsPresContext
* aPresContext
,
341 nsEventStatus
* aEventStatus
,
342 PRBool aControlHeld
);
344 NS_IMETHOD
HandleDrag(nsPresContext
* aPresContext
,
346 nsEventStatus
* aEventStatus
);
348 NS_IMETHOD
HandleRelease(nsPresContext
* aPresContext
,
350 nsEventStatus
* aEventStatus
);
352 NS_IMETHOD
PeekBackwardAndForward(nsSelectionAmount aAmountBack
,
353 nsSelectionAmount aAmountForward
,
355 nsPresContext
* aPresContext
,
357 PRBool aMultipleSelection
);
360 // Helper for GetContentAndOffsetsFromPoint; calculation of content offsets
361 // in this function assumes there is no child frame that can be targeted.
362 virtual ContentOffsets
CalcContentOffsetsFromFramePoint(nsPoint aPoint
);
364 // Box layout methods
365 virtual nsSize
GetPrefSize(nsBoxLayoutState
& aBoxLayoutState
);
366 virtual nsSize
GetMinSize(nsBoxLayoutState
& aBoxLayoutState
);
367 virtual nsSize
GetMaxSize(nsBoxLayoutState
& aBoxLayoutState
);
368 virtual nscoord
GetFlex(nsBoxLayoutState
& aBoxLayoutState
);
369 virtual nscoord
GetBoxAscent(nsBoxLayoutState
& aBoxLayoutState
);
371 // We compute and store the HTML content's overflow area. So don't
372 // try to compute it in the box code.
373 virtual PRBool
ComputesOwnOverflowArea() { return PR_TRUE
; }
375 //--------------------------------------------------
376 // Additional methods
379 * Helper method to invalidate portions of a standard container frame if the
380 * desired size indicates that the size has changed (specifically border,
381 * background and outline).
382 * We assume that the difference between the old frame area and the new
383 * frame area is invalidated by some other means.
384 * @param aDesiredSize the new size of the frame
386 void CheckInvalidateSizeChange(nsHTMLReflowMetrics
& aNewDesiredSize
);
388 // Helper function that tests if the frame tree is too deep; if it
389 // is it marks the frame as "unflowable" and zeros out the metrics
390 // and returns PR_TRUE. Otherwise, the frame is unmarked
391 // "unflowable" and the metrics are not touched and PR_FALSE is
393 PRBool
IsFrameTreeTooDeep(const nsHTMLReflowState
& aReflowState
,
394 nsHTMLReflowMetrics
& aMetrics
);
396 // Do the work for getting the parent style context frame so that
397 // other frame's |GetParentStyleContextFrame| methods can call this
398 // method on *another* frame. (This function handles out-of-flow
399 // frames by using the frame manager's placeholder map and it also
400 // handles block-within-inline and generated content wrappers.)
401 nsresult
DoGetParentStyleContextFrame(nsPresContext
* aPresContext
,
402 nsIFrame
** aProviderFrame
,
405 // incorporate the child overflow area into the parent overflow area
406 // if the child does not have a overflow use the child area
407 void ConsiderChildOverflow(nsRect
& aOverflowArea
,
408 nsIFrame
* aChildFrame
);
410 virtual const void* GetStyleDataExternal(nsStyleStructID aSID
) const;
415 * Tracing method that writes a method enter/exit routine to the
416 * nspr log using the nsIFrame log module. The tracing is only
417 * done when the NS_FRAME_TRACE_CALLS bit is set in the log module's
420 void Trace(const char* aMethod
, PRBool aEnter
);
421 void Trace(const char* aMethod
, PRBool aEnter
, nsReflowStatus aStatus
);
422 void TraceMsg(const char* fmt
, ...);
424 // Helper function that verifies that each frame in the list has the
425 // NS_FRAME_IS_DIRTY bit set
426 static void VerifyDirtyBitSet(const nsFrameList
& aFrameList
);
428 // Helper function to return the index in parent of the frame's content
429 // object. Returns -1 on error or if the frame doesn't have a content object
430 static PRInt32
ContentIndexInContainer(const nsIFrame
* aFrame
);
432 static void IndentBy(FILE* out
, PRInt32 aIndent
) {
433 while (--aIndent
>= 0) fputs(" ", out
);
436 void ListTag(FILE* out
) const {
440 static void ListTag(FILE* out
, const nsIFrame
* aFrame
) {
442 aFrame
->GetFrameName(tmp
);
443 fputs(NS_LossyConvertUTF16toASCII(tmp
).get(), out
);
444 fprintf(out
, "@%p", static_cast<const void*>(aFrame
));
447 static void XMLQuote(nsString
& aString
);
450 * Dump out the "base classes" regression data. This should dump
451 * out the interior data, not the "frame" XML container. And it
452 * should call the base classes same named method before doing
453 * anything specific in a derived class. This means that derived
454 * classes need not override DumpRegressionData unless they need
455 * some custom behavior that requires changing how the outer "frame"
456 * XML container is dumped.
458 virtual void DumpBaseRegressionData(nsPresContext
* aPresContext
, FILE* out
, PRInt32 aIndent
);
460 nsresult
MakeFrameName(const nsAString
& aKind
, nsAString
& aResult
) const;
462 // Display Reflow Debugging
463 static void* DisplayReflowEnter(nsPresContext
* aPresContext
,
465 const nsHTMLReflowState
& aReflowState
);
466 static void* DisplayLayoutEnter(nsIFrame
* aFrame
);
467 static void* DisplayIntrinsicWidthEnter(nsIFrame
* aFrame
,
469 static void* DisplayIntrinsicSizeEnter(nsIFrame
* aFrame
,
471 static void DisplayReflowExit(nsPresContext
* aPresContext
,
473 nsHTMLReflowMetrics
& aMetrics
,
475 void* aFrameTreeNode
);
476 static void DisplayLayoutExit(nsIFrame
* aFrame
,
477 void* aFrameTreeNode
);
478 static void DisplayIntrinsicWidthExit(nsIFrame
* aFrame
,
481 void* aFrameTreeNode
);
482 static void DisplayIntrinsicSizeExit(nsIFrame
* aFrame
,
485 void* aFrameTreeNode
);
487 static void DisplayReflowStartup();
488 static void DisplayReflowShutdown();
491 static void ShutdownLayerActivityTimer();
494 * Adds display item for standard CSS background if necessary.
495 * Does not check IsVisibleForPainting.
496 * @param aForceBackground draw the background even if the frame
497 * background style appears to have no background --- this is useful
498 * for frames that might receive a propagated background via
499 * nsCSSRendering::FindBackground
501 nsresult
DisplayBackgroundUnconditional(nsDisplayListBuilder
* aBuilder
,
502 const nsDisplayListSet
& aLists
,
503 PRBool aForceBackground
= PR_FALSE
);
505 * Adds display items for standard CSS borders, background and outline for
506 * for this frame, as necessary. Checks IsVisibleForPainting and won't
507 * display anything if the frame is not visible.
508 * @param aForceBackground draw the background even if the frame
509 * background style appears to have no background --- this is useful
510 * for frames that might receive a propagated background via
511 * nsCSSRendering::FindBackground
513 nsresult
DisplayBorderBackgroundOutline(nsDisplayListBuilder
* aBuilder
,
514 const nsDisplayListSet
& aLists
,
515 PRBool aForceBackground
= PR_FALSE
);
517 * Add a display item for the CSS outline. Does not check visibility.
519 nsresult
DisplayOutlineUnconditional(nsDisplayListBuilder
* aBuilder
,
520 const nsDisplayListSet
& aLists
);
522 * Add a display item for the CSS outline, after calling
523 * IsVisibleForPainting to confirm we are visible.
525 nsresult
DisplayOutline(nsDisplayListBuilder
* aBuilder
,
526 const nsDisplayListSet
& aLists
);
529 * Adjust the given parent frame to the right style context parent frame for
530 * the child, given the pseudo-type of the prospective child. This handles
531 * things like walking out of table pseudos and so forth.
533 * @param aProspectiveParent what GetParent() on the child returns.
535 * @param aChildPseudo the child's pseudo type, if any.
538 CorrectStyleParentFrame(nsIFrame
* aProspectiveParent
, nsIAtom
* aChildPseudo
);
541 // Protected constructor and destructor
542 nsFrame(nsStyleContext
* aContext
);
546 * To be called by |BuildDisplayLists| of this class or derived classes to add
547 * a translucent overlay if this frame's content is selected.
548 * @param aContentType an nsISelectionDisplay DISPLAY_ constant identifying
549 * which kind of content this is for
551 nsresult
DisplaySelectionOverlay(nsDisplayListBuilder
* aBuilder
,
552 const nsDisplayListSet
& aLists
, PRUint16 aContentType
= nsISelectionDisplay::DISPLAY_FRAMES
);
554 PRInt16
DisplaySelection(nsPresContext
* aPresContext
, PRBool isOkToTurnOn
= PR_FALSE
);
556 // Style post processing hook
557 virtual void DidSetStyleContext(nsStyleContext
* aOldStyleContext
);
560 //given a frame five me the first/last leaf available
561 //XXX Robert O'Callahan wants to move these elsewhere
562 static void GetLastLeaf(nsPresContext
* aPresContext
, nsIFrame
**aFrame
);
563 static void GetFirstLeaf(nsPresContext
* aPresContext
, nsIFrame
**aFrame
);
565 // Return the line number of the aFrame, and (optionally) the containing block
567 // If aScrollLock is true, don't break outside scrollframes when looking for a
568 // containing block frame.
569 static PRInt32
GetLineNumber(nsIFrame
*aFrame
,
571 nsIFrame
** aContainingBlock
= nsnull
);
575 // Test if we are selecting a table object:
576 // Most table/cell selection requires that Ctrl (Cmd on Mac) key is down
577 // during a mouse click or drag. Exception is using Shift+click when
578 // already in "table/cell selection mode" to extend a block selection
579 // Get the parent content node and offset of the frame
580 // of the enclosing cell or table (if not inside a cell)
581 // aTarget tells us what table element to select (currently only cell and table supported)
582 // (enums for this are defined in nsIFrame.h)
583 NS_IMETHOD
GetDataForTableSelection(const nsFrameSelection
*aFrameSelection
,
584 nsIPresShell
*aPresShell
, nsMouseEvent
*aMouseEvent
,
585 nsIContent
**aParentContent
, PRInt32
*aContentOffset
,
588 // Fills aCursor with the appropriate information from ui
589 static void FillCursorInformationFromStyle(const nsStyleUserInterface
* ui
,
590 nsIFrame::Cursor
& aCursor
);
591 NS_IMETHOD
DoLayout(nsBoxLayoutState
& aBoxLayoutState
);
594 virtual void GetBoxName(nsAutoString
& aName
);
597 void InitBoxMetrics(PRBool aClear
);
598 nsBoxLayoutMetrics
* BoxMetrics() const;
600 // Fire DOM event. If no aContent argument use frame's mContent.
601 void FireDOMEvent(const nsAString
& aDOMEventName
, nsIContent
*aContent
= nsnull
);
604 nsresult
BoxReflow(nsBoxLayoutState
& aState
,
605 nsPresContext
* aPresContext
,
606 nsHTMLReflowMetrics
& aDesiredSize
,
607 nsIRenderingContext
* aRenderingContext
,
612 PRBool aMoveFrame
= PR_TRUE
);
614 NS_IMETHODIMP
RefreshSizeCache(nsBoxLayoutState
& aState
);
616 virtual nsILineIterator
* GetLineIterator();
620 // Formerly the nsIFrameDebug interface
622 NS_IMETHOD
List(FILE* out
, PRInt32 aIndent
) const;
624 * lists the frames beginning from the root frame
625 * - calls root frame's List(...)
627 static void RootFrameList(nsPresContext
* aPresContext
,
628 FILE* out
, PRInt32 aIndent
);
630 static void DumpFrameTree(nsIFrame
* aFrame
);
633 * Get a printable from of the name of the frame type.
634 * XXX This should be eliminated and we use GetType() instead...
636 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const;
638 * Return the state bits that are relevant to regression tests (that
639 * is, those bits which indicate a real difference when they differ
641 NS_IMETHOD_(nsFrameState
) GetDebugStateBits() const;
643 * Called to dump out regression data that describes the layout
644 * of the frame and its children, and so on. The format of the
645 * data is dictated to be XML (using a specific DTD); the
646 * specific kind of data dumped is up to the frame itself, with
647 * the caveat that some base types are defined.
648 * For more information, see XXX.
650 NS_IMETHOD
DumpRegressionData(nsPresContext
* aPresContext
,
651 FILE* out
, PRInt32 aIndent
);
654 * See if style tree verification is enabled. To enable style tree
655 * verification add "styleverifytree:1" to your NSPR_LOG_MODULES
656 * environment variable (any non-zero debug level will work). Or,
657 * call SetVerifyStyleTreeEnable with PR_TRUE.
659 static PRBool
GetVerifyStyleTreeEnable();
662 * Set the verify-style-tree enable flag.
664 static void SetVerifyStyleTreeEnable(PRBool aEnabled
);
667 * The frame class and related classes share an nspr log module
668 * for logging frame activity.
670 * Note: the log module is created during library initialization which
671 * means that you cannot perform logging before then.
673 static PRLogModuleInfo
* GetLogModuleInfo();
675 // Show frame borders when rendering
676 static void ShowFrameBorders(PRBool aEnable
);
677 static PRBool
GetShowFrameBorders();
679 // Show frame border of event target
680 static void ShowEventTargetFrameBorder(PRBool aEnable
);
681 static PRBool
GetShowEventTargetFrameBorder();
683 static void PrintDisplayList(nsDisplayListBuilder
* aBuilder
,
684 const nsDisplayList
& aList
);
689 // Start Display Reflow Debugging
693 DR_cookie(nsPresContext
* aPresContext
,
695 const nsHTMLReflowState
& aReflowState
,
696 nsHTMLReflowMetrics
& aMetrics
,
697 nsReflowStatus
& aStatus
);
701 nsPresContext
* mPresContext
;
703 const nsHTMLReflowState
& mReflowState
;
704 nsHTMLReflowMetrics
& mMetrics
;
705 nsReflowStatus
& mStatus
;
709 struct DR_layout_cookie
{
710 DR_layout_cookie(nsIFrame
* aFrame
);
717 struct DR_intrinsic_width_cookie
{
718 DR_intrinsic_width_cookie(nsIFrame
* aFrame
, const char* aType
,
720 ~DR_intrinsic_width_cookie();
728 struct DR_intrinsic_size_cookie
{
729 DR_intrinsic_size_cookie(nsIFrame
* aFrame
, const char* aType
,
731 ~DR_intrinsic_size_cookie();
739 struct DR_init_constraints_cookie
{
740 DR_init_constraints_cookie(nsIFrame
* aFrame
, nsHTMLReflowState
* aState
,
741 nscoord aCBWidth
, nscoord aCBHeight
,
742 const nsMargin
* aBorder
,
743 const nsMargin
* aPadding
);
744 ~DR_init_constraints_cookie();
747 nsHTMLReflowState
* mState
;
751 struct DR_init_offsets_cookie
{
752 DR_init_offsets_cookie(nsIFrame
* aFrame
, nsCSSOffsetState
* aState
,
753 nscoord aCBWidth
, const nsMargin
* aBorder
,
754 const nsMargin
* aPadding
);
755 ~DR_init_offsets_cookie();
758 nsCSSOffsetState
* mState
;
762 struct DR_init_type_cookie
{
763 DR_init_type_cookie(nsIFrame
* aFrame
, nsHTMLReflowState
* aState
);
764 ~DR_init_type_cookie();
767 nsHTMLReflowState
* mState
;
771 #define DISPLAY_REFLOW(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status) \
772 DR_cookie dr_cookie(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status);
773 #define DISPLAY_REFLOW_CHANGE() \
775 #define DISPLAY_LAYOUT(dr_frame) \
776 DR_layout_cookie dr_cookie(dr_frame);
777 #define DISPLAY_MIN_WIDTH(dr_frame, dr_result) \
778 DR_intrinsic_width_cookie dr_cookie(dr_frame, "Min", dr_result)
779 #define DISPLAY_PREF_WIDTH(dr_frame, dr_result) \
780 DR_intrinsic_width_cookie dr_cookie(dr_frame, "Pref", dr_result)
781 #define DISPLAY_PREF_SIZE(dr_frame, dr_result) \
782 DR_intrinsic_size_cookie dr_cookie(dr_frame, "Pref", dr_result)
783 #define DISPLAY_MIN_SIZE(dr_frame, dr_result) \
784 DR_intrinsic_size_cookie dr_cookie(dr_frame, "Min", dr_result)
785 #define DISPLAY_MAX_SIZE(dr_frame, dr_result) \
786 DR_intrinsic_size_cookie dr_cookie(dr_frame, "Max", dr_result)
787 #define DISPLAY_INIT_CONSTRAINTS(dr_frame, dr_state, dr_cbw, dr_cbh, \
789 DR_init_constraints_cookie dr_cookie(dr_frame, dr_state, dr_cbw, dr_cbh, \
791 #define DISPLAY_INIT_OFFSETS(dr_frame, dr_state, dr_cbw, dr_bdr, dr_pad) \
792 DR_init_offsets_cookie dr_cookie(dr_frame, dr_state, dr_cbw, dr_bdr, dr_pad)
793 #define DISPLAY_INIT_TYPE(dr_frame, dr_result) \
794 DR_init_type_cookie dr_cookie(dr_frame, dr_result)
798 #define DISPLAY_REFLOW(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status)
799 #define DISPLAY_REFLOW_CHANGE()
800 #define DISPLAY_LAYOUT(dr_frame) PR_BEGIN_MACRO PR_END_MACRO
801 #define DISPLAY_MIN_WIDTH(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
802 #define DISPLAY_PREF_WIDTH(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
803 #define DISPLAY_PREF_SIZE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
804 #define DISPLAY_MIN_SIZE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
805 #define DISPLAY_MAX_SIZE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
806 #define DISPLAY_INIT_CONSTRAINTS(dr_frame, dr_state, dr_cbw, dr_cbh, \
808 PR_BEGIN_MACRO PR_END_MACRO
809 #define DISPLAY_INIT_OFFSETS(dr_frame, dr_state, dr_cbw, dr_bdr, dr_pad) \
810 PR_BEGIN_MACRO PR_END_MACRO
811 #define DISPLAY_INIT_TYPE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
814 // End Display Reflow Debugging
816 // similar to NS_ENSURE_TRUE but with no return value
817 #define ENSURE_TRUE(x) \
820 NS_WARNING("ENSURE_TRUE(" #x ") failed"); \
824 #endif /* nsFrame_h___ */