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 "nsIFrameDebug.h"
52 #include "nsIPresShell.h"
53 #include "nsFrameSelection.h"
54 #include "nsHTMLReflowState.h"
55 #include "nsHTMLReflowMetrics.h"
58 * nsFrame logging constants. We redefine the nspr
59 * PRLogModuleInfo.level field to be a bitfield. Each bit controls a
60 * specific type of logging. Each logging operation has associated
61 * inline methods defined below.
63 #define NS_FRAME_TRACE_CALLS 0x1
64 #define NS_FRAME_TRACE_PUSH_PULL 0x2
65 #define NS_FRAME_TRACE_CHILD_REFLOW 0x4
66 #define NS_FRAME_TRACE_NEW_FRAMES 0x8
68 #define NS_FRAME_LOG_TEST(_lm,_bit) (PRIntn((_lm)->level) & (_bit))
71 #define NS_FRAME_LOG(_bit,_args) \
73 if (NS_FRAME_LOG_TEST(nsIFrameDebug::GetLogModuleInfo(),_bit)) { \
78 #define NS_FRAME_LOG(_bit,_args)
81 // XXX Need to rework this so that logging is free when it's off
83 #define NS_FRAME_TRACE_IN(_method) Trace(_method, PR_TRUE)
85 #define NS_FRAME_TRACE_OUT(_method) Trace(_method, PR_FALSE)
88 #define NS_FRAME_TRACE_MSG(_bit,_args) \
90 if (NS_FRAME_LOG_TEST(nsIFrameDebug::GetLogModuleInfo(),_bit)) { \
95 #define NS_FRAME_TRACE(_bit,_args) \
97 if (NS_FRAME_LOG_TEST(nsIFrameDebug::GetLogModuleInfo(),_bit)) { \
102 #define NS_FRAME_TRACE_REFLOW_IN(_method) Trace(_method, PR_TRUE)
104 #define NS_FRAME_TRACE_REFLOW_OUT(_method, _status) \
105 Trace(_method, PR_FALSE, _status)
108 #define NS_FRAME_TRACE(_bits,_args)
109 #define NS_FRAME_TRACE_IN(_method)
110 #define NS_FRAME_TRACE_OUT(_method)
111 #define NS_FRAME_TRACE_MSG(_bits,_args)
112 #define NS_FRAME_TRACE_REFLOW_IN(_method)
113 #define NS_FRAME_TRACE_REFLOW_OUT(_method, _status)
116 //----------------------------------------------------------------------
118 struct nsBoxLayoutMetrics
;
121 * Implementation of a simple frame that's not splittable and has no
124 * Sets the NS_FRAME_SYNCHRONIZE_FRAME_AND_VIEW bit, so the default
125 * behavior is to keep the frame and view position and size in sync.
127 class nsFrame
: public nsBox
129 , public nsIFrameDebug
134 * Create a new "empty" frame that maps a given piece of content into a
137 friend nsIFrame
* NS_NewEmptyFrame(nsIPresShell
* aShell
, nsStyleContext
* aContext
);
139 // Overloaded new operator. Initializes the memory to 0 and relies on an arena
140 // (which comes from the presShell) to perform the allocation.
141 void* operator new(size_t sz
, nsIPresShell
* aPresShell
) CPP_THROW_NEW
;
143 // Overridden to prevent the global delete from being called, since the memory
144 // came out of an arena instead of the global delete operator's heap.
145 // XXX Would like to make this private some day, but our UNIX compilers can't
147 void operator delete(void* aPtr
, size_t sz
);
149 // We compute and store the HTML content's overflow area. So don't
150 // try to compute it in the box code.
151 virtual PRBool
ComputesOwnOverflowArea() { return PR_TRUE
; }
154 // The normal operator new is disallowed on nsFrames.
155 void* operator new(size_t sz
) CPP_THROW_NEW
{ return nsnull
; }
160 NS_IMETHOD
QueryInterface(const nsIID
& aIID
, void** aInstancePtr
);
163 NS_IMETHOD
Init(nsIContent
* aContent
,
165 nsIFrame
* asPrevInFlow
);
166 NS_IMETHOD
SetInitialChildList(nsIAtom
* aListName
,
167 nsIFrame
* aChildList
);
168 NS_IMETHOD
AppendFrames(nsIAtom
* aListName
,
169 nsIFrame
* aFrameList
);
170 NS_IMETHOD
InsertFrames(nsIAtom
* aListName
,
171 nsIFrame
* aPrevFrame
,
172 nsIFrame
* aFrameList
);
173 NS_IMETHOD
RemoveFrame(nsIAtom
* aListName
,
174 nsIFrame
* aOldFrame
);
175 virtual void Destroy();
176 virtual nsStyleContext
* GetAdditionalStyleContext(PRInt32 aIndex
) const;
177 virtual void SetAdditionalStyleContext(PRInt32 aIndex
,
178 nsStyleContext
* aStyleContext
);
179 NS_IMETHOD
SetParent(const nsIFrame
* aParent
);
180 virtual nscoord
GetBaseline() const;
181 virtual nsIAtom
* GetAdditionalChildListName(PRInt32 aIndex
) const;
182 virtual nsIFrame
* GetFirstChild(nsIAtom
* aListName
) const;
183 NS_IMETHOD
HandleEvent(nsPresContext
* aPresContext
,
185 nsEventStatus
* aEventStatus
);
186 NS_IMETHOD
GetContentForEvent(nsPresContext
* aPresContext
,
188 nsIContent
** aContent
);
189 NS_IMETHOD
GetCursor(const nsPoint
& aPoint
,
190 nsIFrame::Cursor
& aCursor
);
192 NS_IMETHOD
GetPointFromOffset(PRInt32 inOffset
,
195 NS_IMETHOD
GetChildFrameContainingOffset(PRInt32 inContentOffset
,
197 PRInt32
* outFrameContentOffset
,
198 nsIFrame
* *outChildFrame
);
200 static nsresult
GetNextPrevLineFromeBlockFrame(nsPresContext
* aPresContext
,
201 nsPeekOffsetStruct
*aPos
,
202 nsIFrame
*aBlockFrame
,
208 * Find the nearest frame with a mouse capturer. If no
209 * parent has mouse capture this will return null.
210 * @param aFrame Frame drag began in.
211 * @return Nearest capturing frame.
213 static nsIFrame
* GetNearestCapturingFrame(nsIFrame
* aFrame
);
215 NS_IMETHOD
CharacterDataChanged(nsPresContext
* aPresContext
,
218 NS_IMETHOD
AttributeChanged(PRInt32 aNameSpaceID
,
221 virtual nsSplittableType
GetSplittableType() const;
222 virtual nsIFrame
* GetPrevContinuation() const;
223 NS_IMETHOD
SetPrevContinuation(nsIFrame
*);
224 virtual nsIFrame
* GetNextContinuation() const;
225 NS_IMETHOD
SetNextContinuation(nsIFrame
*);
226 virtual nsIFrame
* GetPrevInFlowVirtual() const;
227 NS_IMETHOD
SetPrevInFlow(nsIFrame
*);
228 virtual nsIFrame
* GetNextInFlowVirtual() const;
229 NS_IMETHOD
SetNextInFlow(nsIFrame
*);
230 NS_IMETHOD
GetOffsetFromView(nsPoint
& aOffset
, nsIView
** aView
) const;
231 NS_IMETHOD
GetOriginToViewOffset(nsPoint
& aOffset
, nsIView
**aView
) const;
232 virtual nsIAtom
* GetType() const;
233 virtual PRBool
IsContainingBlock() const;
235 NS_IMETHOD
List(FILE* out
, PRInt32 aIndent
) const;
236 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const;
237 NS_IMETHOD_(nsFrameState
) GetDebugStateBits() const;
238 NS_IMETHOD
DumpRegressionData(nsPresContext
* aPresContext
, FILE* out
, PRInt32 aIndent
, PRBool aIncludeStyleData
);
239 NS_IMETHOD
VerifyTree() const;
242 NS_IMETHOD
SetSelected(nsPresContext
* aPresContext
, nsIDOMRange
*aRange
,PRBool aSelected
, nsSpread aSpread
);
243 NS_IMETHOD
GetSelected(PRBool
*aSelected
) const;
244 NS_IMETHOD
IsSelectable(PRBool
* aIsSelectable
, PRUint8
* aSelectStyle
) const;
246 NS_IMETHOD
GetSelectionController(nsPresContext
*aPresContext
, nsISelectionController
**aSelCon
);
248 virtual PRBool
PeekOffsetNoAmount(PRBool aForward
, PRInt32
* aOffset
);
249 virtual PRBool
PeekOffsetCharacter(PRBool aForward
, PRInt32
* aOffset
);
250 virtual PRBool
PeekOffsetWord(PRBool aForward
, PRBool aWordSelectEatSpace
, PRBool aIsKeyboardSelect
,
251 PRInt32
* aOffset
, PeekWordState
*aState
);
253 * Check whether we should break at a boundary between punctuation and
254 * non-punctuation. Only call it at a punctuation boundary
255 * (i.e. exactly one of the previous and next characters are punctuation).
256 * @param aForward true if we're moving forward in content order
257 * @param aPunctAfter true if the next character is punctuation
258 * @param aWhitespaceAfter true if the next character is whitespace
260 PRBool
BreakWordBetweenPunctuation(const PeekWordState
* aState
,
262 PRBool aPunctAfter
, PRBool aWhitespaceAfter
,
263 PRBool aIsKeyboardSelect
);
265 NS_IMETHOD
CheckVisibility(nsPresContext
* aContext
, PRInt32 aStartIndex
, PRInt32 aEndIndex
, PRBool aRecurse
, PRBool
*aFinished
, PRBool
*_retval
);
267 NS_IMETHOD
GetOffsets(PRInt32
&aStart
, PRInt32
&aEnd
) const;
268 virtual void ChildIsDirty(nsIFrame
* aChild
);
271 NS_IMETHOD
GetAccessible(nsIAccessible
** aAccessible
);
274 NS_IMETHOD
GetParentStyleContextFrame(nsPresContext
* aPresContext
,
275 nsIFrame
** aProviderFrame
,
278 virtual PRBool
IsEmpty();
279 virtual PRBool
IsSelfEmpty();
281 virtual void MarkIntrinsicWidthsDirty();
282 virtual nscoord
GetMinWidth(nsIRenderingContext
*aRenderingContext
);
283 virtual nscoord
GetPrefWidth(nsIRenderingContext
*aRenderingContext
);
284 virtual void AddInlineMinWidth(nsIRenderingContext
*aRenderingContext
,
285 InlineMinWidthData
*aData
);
286 virtual void AddInlinePrefWidth(nsIRenderingContext
*aRenderingContext
,
287 InlinePrefWidthData
*aData
);
288 virtual IntrinsicWidthOffsetData
289 IntrinsicWidthOffsets(nsIRenderingContext
* aRenderingContext
);
290 virtual IntrinsicSize
GetIntrinsicSize();
291 virtual nsSize
GetIntrinsicRatio();
293 virtual nsSize
ComputeSize(nsIRenderingContext
*aRenderingContext
,
294 nsSize aCBSize
, nscoord aAvailableWidth
,
295 nsSize aMargin
, nsSize aBorder
, nsSize aPadding
,
298 // Compute tight bounds assuming this frame honours its border, background
299 // and outline, its children's tight bounds, and nothing else.
300 nsRect
ComputeSimpleTightBounds(gfxContext
* aContext
) const;
303 * A helper, used by |nsFrame::ComputeSize| (for frames that need to
304 * override only this part of ComputeSize), that computes the size
305 * that should be returned when 'width', 'height', and
306 * min/max-width/height are all 'auto' or equivalent.
308 * In general, frames that can accept any computed width/height should
309 * override only ComputeAutoSize, and frames that cannot do so need to
310 * override ComputeSize to enforce their width/height invariants.
312 * Implementations may optimize by returning a garbage width if
313 * GetStylePosition()->mWidth.GetUnit() != eStyleUnit_Auto, and
314 * likewise for height, since in such cases the result is guaranteed
317 virtual nsSize
ComputeAutoSize(nsIRenderingContext
*aRenderingContext
,
318 nsSize aCBSize
, nscoord aAvailableWidth
,
319 nsSize aMargin
, nsSize aBorder
,
320 nsSize aPadding
, PRBool aShrinkWrap
);
323 * Utility function for ComputeAutoSize implementations. Return
324 * max(GetMinWidth(), min(aWidthInCB, GetPrefWidth()))
326 nscoord
ShrinkWidthToFit(nsIRenderingContext
*aRenderingContext
,
329 NS_IMETHOD
WillReflow(nsPresContext
* aPresContext
);
330 NS_IMETHOD
Reflow(nsPresContext
* aPresContext
,
331 nsHTMLReflowMetrics
& aDesiredSize
,
332 const nsHTMLReflowState
& aReflowState
,
333 nsReflowStatus
& aStatus
);
334 NS_IMETHOD
DidReflow(nsPresContext
* aPresContext
,
335 const nsHTMLReflowState
* aReflowState
,
336 nsDidReflowStatus aStatus
);
337 virtual PRBool
CanContinueTextRun() const;
340 // XXX Doc me... (in nsIFrame.h puhleeze)
341 // XXX If these are selection specific, then the name should imply selection
342 // rather than generic event processing, e.g., SelectionHandlePress...
343 NS_IMETHOD
HandlePress(nsPresContext
* aPresContext
,
345 nsEventStatus
* aEventStatus
);
347 NS_IMETHOD
HandleMultiplePress(nsPresContext
* aPresContext
,
349 nsEventStatus
* aEventStatus
);
351 NS_IMETHOD
HandleDrag(nsPresContext
* aPresContext
,
353 nsEventStatus
* aEventStatus
);
355 NS_IMETHOD
HandleRelease(nsPresContext
* aPresContext
,
357 nsEventStatus
* aEventStatus
);
359 NS_IMETHOD
PeekBackwardAndForward(nsSelectionAmount aAmountBack
,
360 nsSelectionAmount aAmountForward
,
362 nsPresContext
* aPresContext
,
366 // Helper for GetContentAndOffsetsFromPoint; calculation of content offsets
367 // in this function assumes there is no child frame that can be targeted.
368 virtual ContentOffsets
CalcContentOffsetsFromFramePoint(nsPoint aPoint
);
370 // Box layout methods
371 virtual nsSize
GetPrefSize(nsBoxLayoutState
& aBoxLayoutState
);
372 virtual nsSize
GetMinSize(nsBoxLayoutState
& aBoxLayoutState
);
373 virtual nsSize
GetMaxSize(nsBoxLayoutState
& aBoxLayoutState
);
374 virtual nscoord
GetFlex(nsBoxLayoutState
& aBoxLayoutState
);
375 virtual nscoord
GetBoxAscent(nsBoxLayoutState
& aBoxLayoutState
);
377 //--------------------------------------------------
378 // Additional methods
381 * Helper method to invalidate portions of a standard container frame if the
382 * reflow state indicates that the size has changed (specifically border,
383 * background and outline).
384 * We assume that the difference between the old frame area and the new
385 * frame area is invalidated by some other means.
386 * @param aPresContext the presentation context
387 * @param aDesiredSize the new size of the frame
388 * @param aReflowState the reflow that was just done on this frame
390 void CheckInvalidateSizeChange(nsPresContext
* aPresContext
,
391 nsHTMLReflowMetrics
& aDesiredSize
,
392 const nsHTMLReflowState
& aReflowState
);
394 // Helper function that tests if the frame tree is too deep; if it
395 // is it marks the frame as "unflowable" and zeros out the metrics
396 // and returns PR_TRUE. Otherwise, the frame is unmarked
397 // "unflowable" and the metrics are not touched and PR_FALSE is
399 PRBool
IsFrameTreeTooDeep(const nsHTMLReflowState
& aReflowState
,
400 nsHTMLReflowMetrics
& aMetrics
);
402 // Do the work for getting the parent style context frame so that
403 // other frame's |GetParentStyleContextFrame| methods can call this
404 // method on *another* frame. (This function handles out-of-flow
405 // frames by using the frame manager's placeholder map and it also
406 // handles block-within-inline and generated content wrappers.)
407 nsresult
DoGetParentStyleContextFrame(nsPresContext
* aPresContext
,
408 nsIFrame
** aProviderFrame
,
411 // incorporate the child overflow area into the parent overflow area
412 // if the child does not have a overflow use the child area
413 void ConsiderChildOverflow(nsRect
& aOverflowArea
,
414 nsIFrame
* aChildFrame
);
416 //Mouse Capturing code used by the frames to tell the view to capture all the following events
417 NS_IMETHOD
CaptureMouse(nsPresContext
* aPresContext
, PRBool aGrabMouseEvents
);
418 PRBool
IsMouseCaptured(nsPresContext
* aPresContext
);
420 virtual const void* GetStyleDataExternal(nsStyleStructID aSID
) const;
425 * Tracing method that writes a method enter/exit routine to the
426 * nspr log using the nsIFrame log module. The tracing is only
427 * done when the NS_FRAME_TRACE_CALLS bit is set in the log module's
430 void Trace(const char* aMethod
, PRBool aEnter
);
431 void Trace(const char* aMethod
, PRBool aEnter
, nsReflowStatus aStatus
);
432 void TraceMsg(const char* fmt
, ...);
434 // Helper function that verifies that each frame in the list has the
435 // NS_FRAME_IS_DIRTY bit set
436 static void VerifyDirtyBitSet(nsIFrame
* aFrameList
);
438 // Helper function to return the index in parent of the frame's content
439 // object. Returns -1 on error or if the frame doesn't have a content object
440 static PRInt32
ContentIndexInContainer(const nsIFrame
* aFrame
);
442 void ListTag(FILE* out
) const {
443 ListTag(out
, (nsIFrame
*)this);
446 static void ListTag(FILE* out
, nsIFrame
* aFrame
) {
448 nsIFrameDebug
* frameDebug
;
450 if (NS_SUCCEEDED(aFrame
->QueryInterface(NS_GET_IID(nsIFrameDebug
), (void**)&frameDebug
))) {
451 frameDebug
->GetFrameName(tmp
);
453 fputs(NS_LossyConvertUTF16toASCII(tmp
).get(), out
);
454 fprintf(out
, "@%p", static_cast<void*>(aFrame
));
457 static void IndentBy(FILE* out
, PRInt32 aIndent
) {
458 while (--aIndent
>= 0) fputs(" ", out
);
461 static void XMLQuote(nsString
& aString
);
464 * Dump out the "base classes" regression data. This should dump
465 * out the interior data, not the "frame" XML container. And it
466 * should call the base classes same named method before doing
467 * anything specific in a derived class. This means that derived
468 * classes need not override DumpRegressionData unless they need
469 * some custom behavior that requires changing how the outer "frame"
470 * XML container is dumped.
472 virtual void DumpBaseRegressionData(nsPresContext
* aPresContext
, FILE* out
, PRInt32 aIndent
, PRBool aIncludeStyleData
);
474 nsresult
MakeFrameName(const nsAString
& aKind
, nsAString
& aResult
) const;
476 // Display Reflow Debugging
477 static void* DisplayReflowEnter(nsPresContext
* aPresContext
,
479 const nsHTMLReflowState
& aReflowState
);
480 static void* DisplayLayoutEnter(nsIFrame
* aFrame
);
481 static void* DisplayIntrinsicWidthEnter(nsIFrame
* aFrame
,
483 static void* DisplayIntrinsicSizeEnter(nsIFrame
* aFrame
,
485 static void DisplayReflowExit(nsPresContext
* aPresContext
,
487 nsHTMLReflowMetrics
& aMetrics
,
489 void* aFrameTreeNode
);
490 static void DisplayLayoutExit(nsIFrame
* aFrame
,
491 void* aFrameTreeNode
);
492 static void DisplayIntrinsicWidthExit(nsIFrame
* aFrame
,
495 void* aFrameTreeNode
);
496 static void DisplayIntrinsicSizeExit(nsIFrame
* aFrame
,
499 void* aFrameTreeNode
);
501 static void DisplayReflowStartup();
502 static void DisplayReflowShutdown();
506 * Adds display items for standard CSS borders, background and outline for
507 * for this frame, as necessary. Checks IsVisibleForPainting and won't
508 * display anything if the frame is not visible.
509 * @param aForceBackground draw the background even if the frame
510 * background style appears to have no background --- this is useful
511 * for frames that might receive a propagated background via
512 * nsCSSRendering::FindBackground
514 nsresult
DisplayBorderBackgroundOutline(nsDisplayListBuilder
* aBuilder
,
515 const nsDisplayListSet
& aLists
,
516 PRBool aForceBackground
= PR_FALSE
);
518 * Add a display item for the CSS outline. Does not check visibility.
520 nsresult
DisplayOutlineUnconditional(nsDisplayListBuilder
* aBuilder
,
521 const nsDisplayListSet
& aLists
);
523 * Add a display item for the CSS outline, after calling
524 * IsVisibleForPainting to confirm we are visible.
526 nsresult
DisplayOutline(nsDisplayListBuilder
* aBuilder
,
527 const nsDisplayListSet
& aLists
);
530 * Adjust the given parent frame to the right style context parent frame for
531 * the child, given the pseudo-type of the prospective child. This handles
532 * things like walking out of table pseudos and so forth.
534 * @param aProspectiveParent what GetParent() on the child returns.
536 * @param aChildPseudo the child's pseudo type, if any.
539 CorrectStyleParentFrame(nsIFrame
* aProspectiveParent
, nsIAtom
* aChildPseudo
);
542 // Protected constructor and destructor
543 nsFrame(nsStyleContext
* aContext
);
547 * @return PR_FALSE if this frame definitely has no borders at all
549 PRBool
HasBorder() const;
552 * To be called by |BuildDisplayLists| of this class or derived classes to add
553 * a translucent overlay if this frame's content is selected.
554 * @param aContentType an nsISelectionDisplay DISPLAY_ constant identifying
555 * which kind of content this is for
557 nsresult
DisplaySelectionOverlay(nsDisplayListBuilder
* aBuilder
,
558 const nsDisplayListSet
& aLists
, PRUint16 aContentType
= nsISelectionDisplay::DISPLAY_FRAMES
);
560 PRInt16
DisplaySelection(nsPresContext
* aPresContext
, PRBool isOkToTurnOn
= PR_FALSE
);
562 // Style post processing hook
563 NS_IMETHOD
DidSetStyleContext();
566 //given a frame five me the first/last leaf available
567 //XXX Robert O'Callahan wants to move these elsewhere
568 static void GetLastLeaf(nsPresContext
* aPresContext
, nsIFrame
**aFrame
);
569 static void GetFirstLeaf(nsPresContext
* aPresContext
, nsIFrame
**aFrame
);
571 // return the line number of the aFrame, and (optionally) the containing block frame.
572 static PRInt32
GetLineNumber(nsIFrame
*aFrame
, nsIFrame
** aContainingBlock
= nsnull
);
576 // Test if we are selecting a table object:
577 // Most table/cell selection requires that Ctrl (Cmd on Mac) key is down
578 // during a mouse click or drag. Exception is using Shift+click when
579 // already in "table/cell selection mode" to extend a block selection
580 // Get the parent content node and offset of the frame
581 // of the enclosing cell or table (if not inside a cell)
582 // aTarget tells us what table element to select (currently only cell and table supported)
583 // (enums for this are defined in nsIFrame.h)
584 NS_IMETHOD
GetDataForTableSelection(const nsFrameSelection
*aFrameSelection
,
585 nsIPresShell
*aPresShell
, nsMouseEvent
*aMouseEvent
,
586 nsIContent
**aParentContent
, PRInt32
*aContentOffset
,
589 virtual PRBool
ParentDisablesSelection() const;
591 // Fills aCursor with the appropriate information from ui
592 static void FillCursorInformationFromStyle(const nsStyleUserInterface
* ui
,
593 nsIFrame::Cursor
& aCursor
);
594 NS_IMETHOD
DoLayout(nsBoxLayoutState
& aBoxLayoutState
);
597 virtual void GetBoxName(nsAutoString
& aName
);
600 virtual PRBool
GetWasCollapsed(nsBoxLayoutState
& aState
);
601 virtual void SetWasCollapsed(nsBoxLayoutState
& aState
, PRBool aWas
);
603 void InitBoxMetrics(PRBool aClear
);
604 nsBoxLayoutMetrics
* BoxMetrics() const;
606 // Fire DOM event. If no aContent argument use frame's mContent.
607 void FireDOMEvent(const nsAString
& aDOMEventName
, nsIContent
*aContent
= nsnull
);
610 nsresult
BoxReflow(nsBoxLayoutState
& aState
,
611 nsPresContext
* aPresContext
,
612 nsHTMLReflowMetrics
& aDesiredSize
,
613 nsIRenderingContext
* aRenderingContext
,
618 PRBool aMoveFrame
= PR_TRUE
);
620 NS_IMETHODIMP
RefreshSizeCache(nsBoxLayoutState
& aState
);
623 NS_IMETHOD_(nsrefcnt
) AddRef(void);
624 NS_IMETHOD_(nsrefcnt
) Release(void);
627 // Start Display Reflow Debugging
631 DR_cookie(nsPresContext
* aPresContext
,
633 const nsHTMLReflowState
& aReflowState
,
634 nsHTMLReflowMetrics
& aMetrics
,
635 nsReflowStatus
& aStatus
);
639 nsPresContext
* mPresContext
;
641 const nsHTMLReflowState
& mReflowState
;
642 nsHTMLReflowMetrics
& mMetrics
;
643 nsReflowStatus
& mStatus
;
647 struct DR_layout_cookie
{
648 DR_layout_cookie(nsIFrame
* aFrame
);
655 struct DR_intrinsic_width_cookie
{
656 DR_intrinsic_width_cookie(nsIFrame
* aFrame
, const char* aType
,
658 ~DR_intrinsic_width_cookie();
666 struct DR_intrinsic_size_cookie
{
667 DR_intrinsic_size_cookie(nsIFrame
* aFrame
, const char* aType
,
669 ~DR_intrinsic_size_cookie();
677 #define DISPLAY_REFLOW(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status) \
678 DR_cookie dr_cookie(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status);
679 #define DISPLAY_REFLOW_CHANGE() \
681 #define DISPLAY_LAYOUT(dr_frame) \
682 DR_layout_cookie dr_cookie(dr_frame);
683 #define DISPLAY_MIN_WIDTH(dr_frame, dr_result) \
684 DR_intrinsic_width_cookie dr_cookie(dr_frame, "Min", dr_result)
685 #define DISPLAY_PREF_WIDTH(dr_frame, dr_result) \
686 DR_intrinsic_width_cookie dr_cookie(dr_frame, "Pref", dr_result)
687 #define DISPLAY_PREF_SIZE(dr_frame, dr_result) \
688 DR_intrinsic_size_cookie dr_cookie(dr_frame, "Pref", dr_result)
689 #define DISPLAY_MIN_SIZE(dr_frame, dr_result) \
690 DR_intrinsic_size_cookie dr_cookie(dr_frame, "Min", dr_result)
691 #define DISPLAY_MAX_SIZE(dr_frame, dr_result) \
692 DR_intrinsic_size_cookie dr_cookie(dr_frame, "Max", dr_result)
696 #define DISPLAY_REFLOW(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status)
697 #define DISPLAY_REFLOW_CHANGE()
698 #define DISPLAY_LAYOUT(dr_frame) PR_BEGIN_MACRO PR_END_MACRO
699 #define DISPLAY_MIN_WIDTH(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
700 #define DISPLAY_PREF_WIDTH(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
701 #define DISPLAY_PREF_SIZE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
702 #define DISPLAY_MIN_SIZE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
703 #define DISPLAY_MAX_SIZE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
706 // End Display Reflow Debugging
708 // similar to NS_ENSURE_TRUE but with no return value
709 #define ENSURE_TRUE(x) \
712 NS_WARNING("ENSURE_TRUE(" #x ") failed"); \
716 #endif /* nsFrame_h___ */