2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* base class of all rendering objects */
|
|
|
|
|
|
|
|
#ifndef nsFrame_h___
|
|
|
|
#define nsFrame_h___
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-09-25 04:21:18 -07:00
|
|
|
#include "mozilla/EventForwards.h"
|
2012-10-26 06:32:10 -07:00
|
|
|
#include "mozilla/Likely.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsBox.h"
|
|
|
|
#include "prlog.h"
|
|
|
|
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsHTMLReflowState.h"
|
2011-01-19 14:39:31 -08:00
|
|
|
#include "nsHTMLParts.h"
|
2013-08-22 11:32:52 -07:00
|
|
|
#include "nsISelectionDisplay.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* nsFrame logging constants. We redefine the nspr
|
|
|
|
* PRLogModuleInfo.level field to be a bitfield. Each bit controls a
|
|
|
|
* specific type of logging. Each logging operation has associated
|
|
|
|
* inline methods defined below.
|
|
|
|
*/
|
|
|
|
#define NS_FRAME_TRACE_CALLS 0x1
|
|
|
|
#define NS_FRAME_TRACE_PUSH_PULL 0x2
|
|
|
|
#define NS_FRAME_TRACE_CHILD_REFLOW 0x4
|
|
|
|
#define NS_FRAME_TRACE_NEW_FRAMES 0x8
|
|
|
|
|
2012-08-09 00:09:40 -07:00
|
|
|
#define NS_FRAME_LOG_TEST(_lm,_bit) (int((_lm)->level) & (_bit))
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_FRAME_LOG(_bit,_args) \
|
|
|
|
PR_BEGIN_MACRO \
|
2009-08-20 14:52:48 -07:00
|
|
|
if (NS_FRAME_LOG_TEST(nsFrame::GetLogModuleInfo(),_bit)) { \
|
2007-03-22 10:30:00 -07:00
|
|
|
PR_LogPrint _args; \
|
|
|
|
} \
|
|
|
|
PR_END_MACRO
|
|
|
|
#else
|
|
|
|
#define NS_FRAME_LOG(_bit,_args)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// XXX Need to rework this so that logging is free when it's off
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2011-10-17 07:59:28 -07:00
|
|
|
#define NS_FRAME_TRACE_IN(_method) Trace(_method, true)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
#define NS_FRAME_TRACE_OUT(_method) Trace(_method, false)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// XXX remove me
|
|
|
|
#define NS_FRAME_TRACE_MSG(_bit,_args) \
|
|
|
|
PR_BEGIN_MACRO \
|
2009-08-20 14:52:48 -07:00
|
|
|
if (NS_FRAME_LOG_TEST(nsFrame::GetLogModuleInfo(),_bit)) { \
|
2007-03-22 10:30:00 -07:00
|
|
|
TraceMsg _args; \
|
|
|
|
} \
|
|
|
|
PR_END_MACRO
|
|
|
|
|
|
|
|
#define NS_FRAME_TRACE(_bit,_args) \
|
|
|
|
PR_BEGIN_MACRO \
|
2009-08-20 14:52:48 -07:00
|
|
|
if (NS_FRAME_LOG_TEST(nsFrame::GetLogModuleInfo(),_bit)) { \
|
2007-03-22 10:30:00 -07:00
|
|
|
TraceMsg _args; \
|
|
|
|
} \
|
|
|
|
PR_END_MACRO
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
#define NS_FRAME_TRACE_REFLOW_IN(_method) Trace(_method, true)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_FRAME_TRACE_REFLOW_OUT(_method, _status) \
|
2011-10-17 07:59:28 -07:00
|
|
|
Trace(_method, false, _status)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#else
|
|
|
|
#define NS_FRAME_TRACE(_bits,_args)
|
|
|
|
#define NS_FRAME_TRACE_IN(_method)
|
|
|
|
#define NS_FRAME_TRACE_OUT(_method)
|
|
|
|
#define NS_FRAME_TRACE_MSG(_bits,_args)
|
|
|
|
#define NS_FRAME_TRACE_REFLOW_IN(_method)
|
|
|
|
#define NS_FRAME_TRACE_REFLOW_OUT(_method, _status)
|
|
|
|
#endif
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
// Frame allocation boilerplate macros. Every subclass of nsFrame
|
|
|
|
// must define its own operator new and GetAllocatedSize. If they do
|
|
|
|
// not, the per-frame recycler lists in nsPresArena will not work
|
|
|
|
// correctly, with potentially catastrophic consequences (not enough
|
|
|
|
// memory is allocated for a frame object).
|
|
|
|
|
|
|
|
#define NS_DECL_FRAMEARENA_HELPERS \
|
2013-03-23 19:14:43 -07:00
|
|
|
void* operator new(size_t, nsIPresShell*) MOZ_MUST_OVERRIDE; \
|
|
|
|
virtual nsQueryFrame::FrameIID GetFrameId() MOZ_MUST_OVERRIDE;
|
2009-09-12 09:49:24 -07:00
|
|
|
|
|
|
|
#define NS_IMPL_FRAMEARENA_HELPERS(class) \
|
|
|
|
void* class::operator new(size_t sz, nsIPresShell* aShell) \
|
2009-09-15 15:00:04 -07:00
|
|
|
{ return aShell->AllocateFrame(nsQueryFrame::class##_id, sz); } \
|
|
|
|
nsQueryFrame::FrameIID class::GetFrameId() \
|
|
|
|
{ return nsQueryFrame::class##_id; }
|
2009-09-12 09:49:24 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct nsBoxLayoutMetrics;
|
2012-11-09 15:14:59 -08:00
|
|
|
class nsDisplayBackgroundImage;
|
2013-09-06 19:15:49 -07:00
|
|
|
struct nsRect;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of a simple frame that's not splittable and has no
|
|
|
|
* child frames.
|
|
|
|
*
|
|
|
|
* Sets the NS_FRAME_SYNCHRONIZE_FRAME_AND_VIEW bit, so the default
|
|
|
|
* behavior is to keep the frame and view position and size in sync.
|
|
|
|
*/
|
|
|
|
class nsFrame : public nsBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Create a new "empty" frame that maps a given piece of content into a
|
|
|
|
* 0,0 area.
|
|
|
|
*/
|
2009-08-17 20:21:06 -07:00
|
|
|
friend nsIFrame* NS_NewEmptyFrame(nsIPresShell* aShell,
|
|
|
|
nsStyleContext* aContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
private:
|
2009-08-17 20:21:06 -07:00
|
|
|
// Left undefined; nsFrame objects are never allocated from the heap.
|
|
|
|
void* operator new(size_t sz) CPP_THROW_NEW;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Overridden to prevent the global delete from being called, since
|
|
|
|
// the memory came out of an arena instead of the heap.
|
|
|
|
//
|
|
|
|
// Ideally this would be private and undefined, like the normal
|
|
|
|
// operator new. Unfortunately, the C++ standard requires an
|
|
|
|
// overridden operator delete to be accessible to any subclass that
|
|
|
|
// defines a virtual destructor, so we can only make it protected;
|
|
|
|
// worse, some C++ compilers will synthesize calls to this function
|
|
|
|
// from the "deleting destructors" that they emit in case of
|
|
|
|
// delete-expressions, so it can't even be undefined.
|
|
|
|
void operator delete(void* aPtr, size_t sz);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
// nsQueryFrame
|
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsIFrame
|
2013-03-19 18:47:48 -07:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* asPrevInFlow) MOZ_OVERRIDE;
|
2011-08-24 13:54:30 -07:00
|
|
|
NS_IMETHOD SetInitialChildList(ChildListID aListID,
|
2013-05-14 09:33:23 -07:00
|
|
|
nsFrameList& aChildList) MOZ_OVERRIDE;
|
2011-08-24 13:54:30 -07:00
|
|
|
NS_IMETHOD AppendFrames(ChildListID aListID,
|
2013-05-14 09:33:23 -07:00
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
2011-08-24 13:54:30 -07:00
|
|
|
NS_IMETHOD InsertFrames(ChildListID aListID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aPrevFrame,
|
2013-05-14 09:33:23 -07:00
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
2011-08-24 13:54:30 -07:00
|
|
|
NS_IMETHOD RemoveFrame(ChildListID aListID,
|
2013-05-14 09:33:23 -07:00
|
|
|
nsIFrame* aOldFrame) MOZ_OVERRIDE;
|
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
|
|
|
virtual nsStyleContext* GetAdditionalStyleContext(int32_t aIndex) const MOZ_OVERRIDE;
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void SetAdditionalStyleContext(int32_t aIndex,
|
2013-05-14 09:33:23 -07:00
|
|
|
nsStyleContext* aStyleContext) MOZ_OVERRIDE;
|
|
|
|
virtual void SetParent(nsIFrame* aParent) MOZ_OVERRIDE;
|
2013-02-11 17:52:55 -08:00
|
|
|
virtual nscoord GetBaseline() const MOZ_OVERRIDE;
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual const nsFrameList& GetChildList(ChildListID aListID) const MOZ_OVERRIDE;
|
|
|
|
virtual void GetChildLists(nsTArray<ChildList>* aLists) const MOZ_OVERRIDE;
|
2011-08-24 13:54:29 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
|
2013-10-01 20:46:03 -07:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus) MOZ_OVERRIDE;
|
2013-10-01 20:46:04 -07:00
|
|
|
NS_IMETHOD GetContentForEvent(mozilla::WidgetEvent* aEvent,
|
2013-05-14 09:33:23 -07:00
|
|
|
nsIContent** aContent) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD GetCursor(const nsPoint& aPoint,
|
2013-05-29 12:37:49 -07:00
|
|
|
nsIFrame::Cursor& aCursor) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetPointFromOffset(int32_t inOffset,
|
2013-05-14 09:33:23 -07:00
|
|
|
nsPoint* outPoint) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetChildFrameContainingOffset(int32_t inContentOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool inHint,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* outFrameContentOffset,
|
2013-05-14 09:33:23 -07:00
|
|
|
nsIFrame* *outChildFrame) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static nsresult GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
|
|
|
|
nsPeekOffsetStruct *aPos,
|
|
|
|
nsIFrame *aBlockFrame,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aLineStart,
|
|
|
|
int8_t aOutSideLimit
|
2007-03-22 10:30:00 -07:00
|
|
|
);
|
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
NS_IMETHOD CharacterDataChanged(CharacterDataChangeInfo* aInfo) MOZ_OVERRIDE;
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aAttribute,
|
2013-05-14 09:33:23 -07:00
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
|
|
|
virtual nsSplittableType GetSplittableType() const MOZ_OVERRIDE;
|
|
|
|
virtual nsIFrame* GetPrevContinuation() const MOZ_OVERRIDE;
|
2013-09-25 10:54:55 -07:00
|
|
|
virtual void SetPrevContinuation(nsIFrame*) MOZ_OVERRIDE;
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual nsIFrame* GetNextContinuation() const MOZ_OVERRIDE;
|
2013-09-25 10:54:55 -07:00
|
|
|
virtual void SetNextContinuation(nsIFrame*) MOZ_OVERRIDE;
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual nsIFrame* GetPrevInFlowVirtual() const MOZ_OVERRIDE;
|
2013-09-25 10:54:55 -07:00
|
|
|
virtual void SetPrevInFlow(nsIFrame*) MOZ_OVERRIDE;
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual nsIFrame* GetNextInFlowVirtual() const MOZ_OVERRIDE;
|
2013-09-25 10:54:55 -07:00
|
|
|
virtual void SetNextInFlow(nsIFrame*) MOZ_OVERRIDE;
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
NS_IMETHOD IsSelectable(bool* aIsSelectable, uint8_t* aSelectStyle) const MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
NS_IMETHOD GetSelectionController(nsPresContext *aPresContext, nsISelectionController **aSelCon) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool PeekOffsetNoAmount(bool aForward, int32_t* aOffset) MOZ_OVERRIDE;
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool PeekOffsetCharacter(bool aForward, int32_t* aOffset,
|
2013-05-14 09:33:23 -07:00
|
|
|
bool aRespectClusters = true) MOZ_OVERRIDE;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool PeekOffsetWord(bool aForward, bool aWordSelectEatSpace, bool aIsKeyboardSelect,
|
2013-05-14 09:33:23 -07:00
|
|
|
int32_t* aOffset, PeekWordState *aState) MOZ_OVERRIDE;
|
2007-08-29 20:10:19 -07:00
|
|
|
/**
|
|
|
|
* Check whether we should break at a boundary between punctuation and
|
2008-03-03 00:37:34 -08:00
|
|
|
* non-punctuation. Only call it at a punctuation boundary
|
|
|
|
* (i.e. exactly one of the previous and next characters are punctuation).
|
|
|
|
* @param aForward true if we're moving forward in content order
|
|
|
|
* @param aPunctAfter true if the next character is punctuation
|
|
|
|
* @param aWhitespaceAfter true if the next character is whitespace
|
2007-08-29 20:10:19 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool BreakWordBetweenPunctuation(const PeekWordState* aState,
|
|
|
|
bool aForward,
|
|
|
|
bool aPunctAfter, bool aWhitespaceAfter,
|
|
|
|
bool aIsKeyboardSelect);
|
2008-03-03 00:37:34 -08:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
NS_IMETHOD CheckVisibility(nsPresContext* aContext, int32_t aStartIndex, int32_t aEndIndex, bool aRecurse, bool *aFinished, bool *_retval) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
NS_IMETHOD GetOffsets(int32_t &aStart, int32_t &aEnd) const MOZ_OVERRIDE;
|
|
|
|
virtual void ChildIsDirty(nsIFrame* aChild) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 14:53:44 -07:00
|
|
|
virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual nsIFrame* GetParentStyleContextFrame() const MOZ_OVERRIDE {
|
2011-09-12 09:08:07 -07:00
|
|
|
return DoGetParentStyleContextFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do the work for getting the parent style context frame so that
|
|
|
|
* other frame's |GetParentStyleContextFrame| methods can call this
|
|
|
|
* method on *another* frame. (This function handles out-of-flow
|
|
|
|
* frames by using the frame manager's placeholder map and it also
|
|
|
|
* handles block-within-inline and generated content wrappers.)
|
|
|
|
*/
|
2012-02-15 01:28:21 -08:00
|
|
|
nsIFrame* DoGetParentStyleContextFrame() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual bool IsEmpty() MOZ_OVERRIDE;
|
|
|
|
virtual bool IsSelfEmpty() MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
2011-04-07 18:04:40 -07:00
|
|
|
virtual void AddInlineMinWidth(nsRenderingContext *aRenderingContext,
|
2013-05-14 09:33:23 -07:00
|
|
|
InlineMinWidthData *aData) MOZ_OVERRIDE;
|
2011-04-07 18:04:40 -07:00
|
|
|
virtual void AddInlinePrefWidth(nsRenderingContext *aRenderingContext,
|
2013-05-14 09:33:23 -07:00
|
|
|
InlinePrefWidthData *aData) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual IntrinsicWidthOffsetData
|
2013-05-14 09:33:23 -07:00
|
|
|
IntrinsicWidthOffsets(nsRenderingContext* aRenderingContext) MOZ_OVERRIDE;
|
2013-09-30 14:26:04 -07:00
|
|
|
virtual mozilla::IntrinsicSize GetIntrinsicSize() MOZ_OVERRIDE;
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual nsSize GetIntrinsicRatio() MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-07 18:04:40 -07:00
|
|
|
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-10-12 01:30:54 -07:00
|
|
|
// Compute tight bounds assuming this frame honours its border, background
|
|
|
|
// and outline, its children's tight bounds, and nothing else.
|
|
|
|
nsRect ComputeSimpleTightBounds(gfxContext* aContext) const;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* A helper, used by |nsFrame::ComputeSize| (for frames that need to
|
|
|
|
* override only this part of ComputeSize), that computes the size
|
|
|
|
* that should be returned when 'width', 'height', and
|
|
|
|
* min/max-width/height are all 'auto' or equivalent.
|
|
|
|
*
|
|
|
|
* In general, frames that can accept any computed width/height should
|
|
|
|
* override only ComputeAutoSize, and frames that cannot do so need to
|
|
|
|
* override ComputeSize to enforce their width/height invariants.
|
|
|
|
*
|
|
|
|
* Implementations may optimize by returning a garbage width if
|
2013-02-16 13:51:02 -08:00
|
|
|
* StylePosition()->mWidth.GetUnit() != eStyleUnit_Auto, and
|
2007-03-22 10:30:00 -07:00
|
|
|
* likewise for height, since in such cases the result is guaranteed
|
|
|
|
* to be unused.
|
|
|
|
*/
|
2011-04-07 18:04:40 -07:00
|
|
|
virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder,
|
2011-09-28 23:19:26 -07:00
|
|
|
nsSize aPadding, bool aShrinkWrap);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Utility function for ComputeAutoSize implementations. Return
|
|
|
|
* max(GetMinWidth(), min(aWidthInCB, GetPrefWidth()))
|
|
|
|
*/
|
2011-04-07 18:04:40 -07:00
|
|
|
nscoord ShrinkWidthToFit(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord aWidthInCB);
|
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
NS_IMETHOD WillReflow(nsPresContext* aPresContext) MOZ_OVERRIDE;
|
2012-08-29 01:01:09 -07:00
|
|
|
/**
|
|
|
|
* Calculates the size of this frame after reflowing (calling Reflow on, and
|
|
|
|
* updating the size and position of) its children, as necessary. The
|
|
|
|
* calculated size is returned to the caller via the nsHTMLReflowMetrics
|
|
|
|
* outparam. (The caller is responsible for setting the actual size and
|
|
|
|
* position of this frame.)
|
|
|
|
*
|
|
|
|
* A frame's children must _all_ be reflowed if the frame is dirty (the
|
|
|
|
* NS_FRAME_IS_DIRTY bit is set on it). Otherwise, individual children
|
|
|
|
* must be reflowed if they are dirty or have the NS_FRAME_HAS_DIRTY_CHILDREN
|
|
|
|
* bit set on them. Otherwise, whether children need to be reflowed depends
|
|
|
|
* on the frame's type (it's up to individual Reflow methods), and on what
|
|
|
|
* has changed. For example, a change in the width of the frame may require
|
|
|
|
* all of its children to be reflowed (even those without dirty bits set on
|
|
|
|
* them), whereas a change in its height might not.
|
|
|
|
* (nsHTMLReflowState::ShouldReflowAllKids may be helpful in deciding whether
|
|
|
|
* to reflow all the children, but for some frame types it might result in
|
|
|
|
* over-reflow.)
|
|
|
|
*
|
|
|
|
* Note: if it's only the overflow rect(s) of a frame that need to be
|
|
|
|
* updated, then UpdateOverflow should be called instead of Reflow.
|
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
2013-05-14 09:33:23 -07:00
|
|
|
nsReflowStatus& aStatus) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD DidReflow(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState* aReflowState,
|
2013-05-14 09:33:23 -07:00
|
|
|
nsDidReflowStatus aStatus) MOZ_OVERRIDE;
|
2013-02-23 16:06:55 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* NOTE: aStatus is assumed to be already-initialized. The reflow statuses of
|
|
|
|
* any reflowed absolute children will be merged into aStatus; aside from
|
|
|
|
* that, this method won't modify aStatus.
|
|
|
|
*/
|
2011-04-29 16:02:33 -07:00
|
|
|
void ReflowAbsoluteFrames(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
2013-02-28 19:56:48 -08:00
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
bool aConstrainHeight = true);
|
2011-04-29 16:02:33 -07:00
|
|
|
void FinishReflowWithAbsoluteFrames(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
2013-02-28 19:56:48 -08:00
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
bool aConstrainHeight = true);
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual bool CanContinueTextRun() const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual bool UpdateOverflow() MOZ_OVERRIDE;
|
2011-06-15 14:03:49 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Selection Methods
|
2012-09-10 14:02:23 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD HandlePress(nsPresContext* aPresContext,
|
2013-10-01 20:46:03 -07:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext,
|
2013-10-01 20:46:03 -07:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus,
|
|
|
|
bool aControlHeld);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD HandleDrag(nsPresContext* aPresContext,
|
2013-10-01 20:46:03 -07:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD HandleRelease(nsPresContext* aPresContext,
|
2013-10-01 20:46:03 -07:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-10 14:02:23 -07:00
|
|
|
enum { SELECT_ACCUMULATE = 0x01 };
|
|
|
|
|
|
|
|
nsresult PeekBackwardAndForward(nsSelectionAmount aAmountBack,
|
|
|
|
nsSelectionAmount aAmountForward,
|
|
|
|
int32_t aStartPos,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
bool aJumpLines,
|
|
|
|
uint32_t aSelectFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-10 14:02:23 -07:00
|
|
|
nsresult SelectByTypeAtPoint(nsPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsSelectionAmount aBeginAmountType,
|
|
|
|
nsSelectionAmount aEndAmountType,
|
|
|
|
uint32_t aSelectFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Helper for GetContentAndOffsetsFromPoint; calculation of content offsets
|
|
|
|
// in this function assumes there is no child frame that can be targeted.
|
|
|
|
virtual ContentOffsets CalcContentOffsetsFromFramePoint(nsPoint aPoint);
|
|
|
|
|
|
|
|
// Box layout methods
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
|
|
|
|
virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual nscoord GetFlex(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-08-17 20:21:06 -07:00
|
|
|
// We compute and store the HTML content's overflow area. So don't
|
|
|
|
// try to compute it in the box code.
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual bool ComputesOwnOverflowArea() MOZ_OVERRIDE { return true; }
|
2009-08-17 20:21:06 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//--------------------------------------------------
|
|
|
|
// Additional methods
|
|
|
|
|
2011-01-11 17:09:22 -08:00
|
|
|
// Helper function that tests if the frame tree is too deep; if it is
|
|
|
|
// it marks the frame as "unflowable", zeroes out the metrics, sets
|
2011-10-17 07:59:28 -07:00
|
|
|
// the reflow status, and returns true. Otherwise, the frame is
|
2011-01-11 17:09:22 -08:00
|
|
|
// unmarked "unflowable" and the metrics and reflow status are not
|
2011-10-17 07:59:28 -07:00
|
|
|
// touched and false is returned.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsFrameTreeTooDeep(const nsHTMLReflowState& aReflowState,
|
2011-01-11 17:09:22 -08:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsReflowStatus& aStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-10-06 21:25:45 -07:00
|
|
|
// Incorporate the child overflow areas into aOverflowAreas.
|
|
|
|
// If the child does not have a overflow, use the child area.
|
|
|
|
void ConsiderChildOverflow(nsOverflowAreas& aOverflowAreas,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aChildFrame);
|
|
|
|
|
2012-11-08 08:09:38 -08:00
|
|
|
/**
|
|
|
|
* @return true if we should avoid a page/column break in this frame.
|
|
|
|
*/
|
|
|
|
bool ShouldAvoidBreakInside(const nsHTMLReflowState& aReflowState) const {
|
|
|
|
return !aReflowState.mFlags.mIsTopOfPage &&
|
2013-02-16 13:51:02 -08:00
|
|
|
NS_STYLE_PAGE_BREAK_AVOID == StyleDisplay()->mBreakInside &&
|
2012-11-08 08:09:38 -08:00
|
|
|
!GetPrevInFlow();
|
|
|
|
}
|
|
|
|
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Tracing method that writes a method enter/exit routine to the
|
|
|
|
* nspr log using the nsIFrame log module. The tracing is only
|
|
|
|
* done when the NS_FRAME_TRACE_CALLS bit is set in the log module's
|
|
|
|
* level field.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
void Trace(const char* aMethod, bool aEnter);
|
|
|
|
void Trace(const char* aMethod, bool aEnter, nsReflowStatus aStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
void TraceMsg(const char* fmt, ...);
|
|
|
|
|
|
|
|
// Helper function that verifies that each frame in the list has the
|
|
|
|
// NS_FRAME_IS_DIRTY bit set
|
2009-07-28 05:53:20 -07:00
|
|
|
static void VerifyDirtyBitSet(const nsFrameList& aFrameList);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static void XMLQuote(nsString& aString);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dump out the "base classes" regression data. This should dump
|
|
|
|
* out the interior data, not the "frame" XML container. And it
|
|
|
|
* should call the base classes same named method before doing
|
|
|
|
* anything specific in a derived class. This means that derived
|
|
|
|
* classes need not override DumpRegressionData unless they need
|
|
|
|
* some custom behavior that requires changing how the outer "frame"
|
|
|
|
* XML container is dumped.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void DumpBaseRegressionData(nsPresContext* aPresContext, FILE* out, int32_t aIndent);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Display Reflow Debugging
|
|
|
|
static void* DisplayReflowEnter(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const nsHTMLReflowState& aReflowState);
|
|
|
|
static void* DisplayLayoutEnter(nsIFrame* aFrame);
|
|
|
|
static void* DisplayIntrinsicWidthEnter(nsIFrame* aFrame,
|
|
|
|
const char* aType);
|
|
|
|
static void* DisplayIntrinsicSizeEnter(nsIFrame* aFrame,
|
|
|
|
const char* aType);
|
|
|
|
static void DisplayReflowExit(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aStatus,
|
2007-03-22 10:30:00 -07:00
|
|
|
void* aFrameTreeNode);
|
|
|
|
static void DisplayLayoutExit(nsIFrame* aFrame,
|
|
|
|
void* aFrameTreeNode);
|
|
|
|
static void DisplayIntrinsicWidthExit(nsIFrame* aFrame,
|
|
|
|
const char* aType,
|
|
|
|
nscoord aResult,
|
|
|
|
void* aFrameTreeNode);
|
|
|
|
static void DisplayIntrinsicSizeExit(nsIFrame* aFrame,
|
|
|
|
const char* aType,
|
|
|
|
nsSize aResult,
|
|
|
|
void* aFrameTreeNode);
|
|
|
|
|
|
|
|
static void DisplayReflowStartup();
|
|
|
|
static void DisplayReflowShutdown();
|
|
|
|
#endif
|
|
|
|
|
2009-07-21 17:44:51 -07:00
|
|
|
/**
|
2012-09-13 03:34:23 -07:00
|
|
|
* Adds display items for standard CSS background if necessary.
|
2009-07-21 17:44:51 -07:00
|
|
|
* Does not check IsVisibleForPainting.
|
|
|
|
* @param aForceBackground draw the background even if the frame
|
|
|
|
* background style appears to have no background --- this is useful
|
|
|
|
* for frames that might receive a propagated background via
|
|
|
|
* nsCSSRendering::FindBackground
|
2013-07-24 00:38:55 -07:00
|
|
|
* @return whether a themed background item was created.
|
2009-07-21 17:44:51 -07:00
|
|
|
*/
|
2013-07-24 00:38:55 -07:00
|
|
|
bool DisplayBackgroundUnconditional(nsDisplayListBuilder* aBuilder,
|
2013-02-14 03:12:27 -08:00
|
|
|
const nsDisplayListSet& aLists,
|
2013-07-24 00:38:55 -07:00
|
|
|
bool aForceBackground);
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Adds display items for standard CSS borders, background and outline for
|
|
|
|
* for this frame, as necessary. Checks IsVisibleForPainting and won't
|
|
|
|
* display anything if the frame is not visible.
|
|
|
|
* @param aForceBackground draw the background even if the frame
|
|
|
|
* background style appears to have no background --- this is useful
|
|
|
|
* for frames that might receive a propagated background via
|
|
|
|
* nsCSSRendering::FindBackground
|
|
|
|
*/
|
2013-02-14 03:12:27 -08:00
|
|
|
void DisplayBorderBackgroundOutline(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists,
|
|
|
|
bool aForceBackground = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Add a display item for the CSS outline. Does not check visibility.
|
|
|
|
*/
|
2013-02-14 03:12:27 -08:00
|
|
|
void DisplayOutlineUnconditional(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists);
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Add a display item for the CSS outline, after calling
|
|
|
|
* IsVisibleForPainting to confirm we are visible.
|
|
|
|
*/
|
2013-02-14 03:12:27 -08:00
|
|
|
void DisplayOutline(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-04-15 16:14:26 -07:00
|
|
|
/**
|
|
|
|
* Adjust the given parent frame to the right style context parent frame for
|
|
|
|
* the child, given the pseudo-type of the prospective child. This handles
|
|
|
|
* things like walking out of table pseudos and so forth.
|
|
|
|
*
|
|
|
|
* @param aProspectiveParent what GetParent() on the child returns.
|
|
|
|
* Must not be null.
|
|
|
|
* @param aChildPseudo the child's pseudo type, if any.
|
|
|
|
*/
|
|
|
|
static nsIFrame*
|
|
|
|
CorrectStyleParentFrame(nsIFrame* aProspectiveParent, nsIAtom* aChildPseudo);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
// Protected constructor and destructor
|
|
|
|
nsFrame(nsStyleContext* aContext);
|
|
|
|
virtual ~nsFrame();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* To be called by |BuildDisplayLists| of this class or derived classes to add
|
|
|
|
* a translucent overlay if this frame's content is selected.
|
|
|
|
* @param aContentType an nsISelectionDisplay DISPLAY_ constant identifying
|
|
|
|
* which kind of content this is for
|
|
|
|
*/
|
2013-02-14 03:12:27 -08:00
|
|
|
void DisplaySelectionOverlay(nsDisplayListBuilder* aBuilder,
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDisplayList* aList, uint16_t aContentType = nsISelectionDisplay::DISPLAY_FRAMES);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t DisplaySelection(nsPresContext* aPresContext, bool isOkToTurnOn = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Style post processing hook
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
//given a frame five me the first/last leaf available
|
|
|
|
//XXX Robert O'Callahan wants to move these elsewhere
|
|
|
|
static void GetLastLeaf(nsPresContext* aPresContext, nsIFrame **aFrame);
|
|
|
|
static void GetFirstLeaf(nsPresContext* aPresContext, nsIFrame **aFrame);
|
|
|
|
|
2008-10-09 03:22:30 -07:00
|
|
|
// Return the line number of the aFrame, and (optionally) the containing block
|
|
|
|
// frame.
|
|
|
|
// If aScrollLock is true, don't break outside scrollframes when looking for a
|
|
|
|
// containing block frame.
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t GetLineNumber(nsIFrame *aFrame,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aLockScroll,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame** aContainingBlock = nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-01-18 12:04:51 -08:00
|
|
|
/**
|
|
|
|
* Returns true if aFrame should apply overflow clipping.
|
|
|
|
*/
|
2013-03-06 03:08:16 -08:00
|
|
|
static bool ShouldApplyOverflowClipping(const nsIFrame* aFrame,
|
|
|
|
const nsStyleDisplay* aDisp)
|
2011-01-19 14:39:31 -08:00
|
|
|
{
|
2012-01-18 12:04:51 -08:00
|
|
|
// clip overflow:-moz-hidden-unscrollable ...
|
2012-10-26 06:32:10 -07:00
|
|
|
if (MOZ_UNLIKELY(aDisp->mOverflowX == NS_STYLE_OVERFLOW_CLIP)) {
|
2012-01-18 12:04:51 -08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// and overflow:hidden that we should interpret as -moz-hidden-unscrollable
|
|
|
|
if (aDisp->mOverflowX == NS_STYLE_OVERFLOW_HIDDEN &&
|
|
|
|
aDisp->mOverflowY == NS_STYLE_OVERFLOW_HIDDEN) {
|
|
|
|
// REVIEW: these are the frame types that set up clipping.
|
|
|
|
nsIAtom* type = aFrame->GetType();
|
|
|
|
if (type == nsGkAtoms::tableFrame ||
|
|
|
|
type == nsGkAtoms::tableCellFrame ||
|
2012-07-20 11:12:29 -07:00
|
|
|
type == nsGkAtoms::bcTableCellFrame ||
|
|
|
|
type == nsGkAtoms::svgOuterSVGFrame ||
|
|
|
|
type == nsGkAtoms::svgInnerSVGFrame ||
|
|
|
|
type == nsGkAtoms::svgForeignObjectFrame) {
|
2012-01-18 12:04:51 -08:00
|
|
|
return true;
|
|
|
|
}
|
2013-01-24 12:44:38 -08:00
|
|
|
if (aFrame->IsFrameOfType(nsIFrame::eReplacedContainsBlock)) {
|
|
|
|
return true;
|
|
|
|
}
|
2012-01-18 12:04:51 -08:00
|
|
|
}
|
2012-07-20 11:12:29 -07:00
|
|
|
|
|
|
|
if ((aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-01-19 14:39:31 -08:00
|
|
|
// If we're paginated and a block, and have NS_BLOCK_CLIP_PAGINATED_OVERFLOW
|
|
|
|
// set, then we want to clip our overflow.
|
|
|
|
return
|
2012-01-18 12:04:51 -08:00
|
|
|
(aFrame->GetStateBits() & NS_BLOCK_CLIP_PAGINATED_OVERFLOW) != 0 &&
|
2012-04-15 22:43:47 -07:00
|
|
|
aFrame->PresContext()->IsPaginated() &&
|
2012-01-18 12:04:51 -08:00
|
|
|
aFrame->GetType() == nsGkAtoms::blockFrame;
|
2011-01-19 14:39:31 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
|
|
|
|
// Test if we are selecting a table object:
|
|
|
|
// Most table/cell selection requires that Ctrl (Cmd on Mac) key is down
|
|
|
|
// during a mouse click or drag. Exception is using Shift+click when
|
|
|
|
// already in "table/cell selection mode" to extend a block selection
|
|
|
|
// Get the parent content node and offset of the frame
|
|
|
|
// of the enclosing cell or table (if not inside a cell)
|
|
|
|
// aTarget tells us what table element to select (currently only cell and table supported)
|
|
|
|
// (enums for this are defined in nsIFrame.h)
|
2013-10-01 23:38:27 -07:00
|
|
|
NS_IMETHOD GetDataForTableSelection(const nsFrameSelection* aFrameSelection,
|
|
|
|
nsIPresShell* aPresShell,
|
|
|
|
mozilla::WidgetMouseEvent* aMouseEvent,
|
|
|
|
nsIContent** aParentContent,
|
|
|
|
int32_t* aContentOffset,
|
|
|
|
int32_t* aTarget);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Fills aCursor with the appropriate information from ui
|
|
|
|
static void FillCursorInformationFromStyle(const nsStyleUserInterface* ui,
|
|
|
|
nsIFrame::Cursor& aCursor);
|
2012-09-14 09:10:08 -07:00
|
|
|
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG_LAYOUT
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void GetBoxName(nsAutoString& aName) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void InitBoxMetrics(bool aClear);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBoxLayoutMetrics* BoxMetrics() const;
|
|
|
|
|
|
|
|
// Fire DOM event. If no aContent argument use frame's mContent.
|
2012-07-30 07:20:58 -07:00
|
|
|
void FireDOMEvent(const nsAString& aDOMEventName, nsIContent *aContent = nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsresult BoxReflow(nsBoxLayoutState& aState,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext* aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
|
|
|
nscoord aWidth,
|
|
|
|
nscoord aHeight,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aMoveFrame = true);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP RefreshSizeCache(nsBoxLayoutState& aState);
|
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual nsILineIterator* GetLineIterator() MOZ_OVERRIDE;
|
2009-08-20 14:52:48 -07:00
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2009-08-20 14:52:48 -07:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Get a printable from of the name of the frame type.
|
|
|
|
* XXX This should be eliminated and we use GetType() instead...
|
|
|
|
*/
|
2013-05-14 09:33:23 -07:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
|
2014-01-05 15:31:14 -08:00
|
|
|
nsresult MakeFrameName(const nsAString& aKind, nsAString& aResult) const;
|
|
|
|
// Helper function to return the index in parent of the frame's content
|
|
|
|
// object. Returns -1 on error or if the frame doesn't have a content object
|
|
|
|
static int32_t ContentIndexInContainer(const nsIFrame* aFrame);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
public:
|
2009-08-20 14:52:48 -07:00
|
|
|
/**
|
|
|
|
* Return the state bits that are relevant to regression tests (that
|
|
|
|
* is, those bits which indicate a real difference when they differ
|
|
|
|
*/
|
2013-05-14 09:33:23 -07:00
|
|
|
NS_IMETHOD_(nsFrameState) GetDebugStateBits() const MOZ_OVERRIDE;
|
2009-08-20 14:52:48 -07:00
|
|
|
/**
|
|
|
|
* Called to dump out regression data that describes the layout
|
|
|
|
* of the frame and its children, and so on. The format of the
|
|
|
|
* data is dictated to be XML (using a specific DTD); the
|
|
|
|
* specific kind of data dumped is up to the frame itself, with
|
|
|
|
* the caveat that some base types are defined.
|
|
|
|
* For more information, see XXX.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD DumpRegressionData(nsPresContext* aPresContext,
|
2013-05-14 09:33:23 -07:00
|
|
|
FILE* out, int32_t aIndent) MOZ_OVERRIDE;
|
2009-08-20 14:52:48 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* See if style tree verification is enabled. To enable style tree
|
|
|
|
* verification add "styleverifytree:1" to your NSPR_LOG_MODULES
|
|
|
|
* environment variable (any non-zero debug level will work). Or,
|
2011-10-17 07:59:28 -07:00
|
|
|
* call SetVerifyStyleTreeEnable with true.
|
2009-08-20 14:52:48 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool GetVerifyStyleTreeEnable();
|
2009-08-20 14:52:48 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the verify-style-tree enable flag.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static void SetVerifyStyleTreeEnable(bool aEnabled);
|
2009-08-20 14:52:48 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The frame class and related classes share an nspr log module
|
|
|
|
* for logging frame activity.
|
|
|
|
*
|
|
|
|
* Note: the log module is created during library initialization which
|
|
|
|
* means that you cannot perform logging before then.
|
|
|
|
*/
|
|
|
|
static PRLogModuleInfo* GetLogModuleInfo();
|
|
|
|
|
|
|
|
// Show frame borders when rendering
|
2011-09-28 23:19:26 -07:00
|
|
|
static void ShowFrameBorders(bool aEnable);
|
|
|
|
static bool GetShowFrameBorders();
|
2009-08-20 14:52:48 -07:00
|
|
|
|
|
|
|
// Show frame border of event target
|
2011-09-28 23:19:26 -07:00
|
|
|
static void ShowEventTargetFrameBorder(bool aEnable);
|
|
|
|
static bool GetShowEventTargetFrameBorder();
|
2009-08-20 14:52:48 -07:00
|
|
|
|
2011-11-16 19:44:16 -08:00
|
|
|
#endif
|
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
public:
|
|
|
|
|
2014-01-26 14:09:14 -08:00
|
|
|
static void PrintDisplayItem(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayItem* aItem,
|
|
|
|
FILE* aFile = stdout,
|
|
|
|
bool aDumpSublist = false,
|
|
|
|
bool aDumpHtml = false);
|
|
|
|
|
2009-08-20 14:52:48 -07:00
|
|
|
static void PrintDisplayList(nsDisplayListBuilder* aBuilder,
|
2012-03-01 00:26:09 -08:00
|
|
|
const nsDisplayList& aList,
|
2012-08-07 10:57:26 -07:00
|
|
|
FILE* aFile = stdout,
|
|
|
|
bool aDumpHtml = false);
|
2013-12-12 10:27:07 -08:00
|
|
|
static void PrintDisplayListSet(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aList,
|
|
|
|
FILE* aFile = stdout,
|
|
|
|
bool aDumpHtml = false);
|
2009-08-20 14:52:48 -07:00
|
|
|
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// Start Display Reflow Debugging
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
struct DR_cookie {
|
|
|
|
DR_cookie(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
~DR_cookie();
|
|
|
|
void Change() const;
|
|
|
|
|
|
|
|
nsPresContext* mPresContext;
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
const nsHTMLReflowState& mReflowState;
|
|
|
|
nsHTMLReflowMetrics& mMetrics;
|
|
|
|
nsReflowStatus& mStatus;
|
|
|
|
void* mValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DR_layout_cookie {
|
|
|
|
DR_layout_cookie(nsIFrame* aFrame);
|
|
|
|
~DR_layout_cookie();
|
|
|
|
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
void* mValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DR_intrinsic_width_cookie {
|
|
|
|
DR_intrinsic_width_cookie(nsIFrame* aFrame, const char* aType,
|
|
|
|
nscoord& aResult);
|
|
|
|
~DR_intrinsic_width_cookie();
|
|
|
|
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
const char* mType;
|
|
|
|
nscoord& mResult;
|
|
|
|
void* mValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DR_intrinsic_size_cookie {
|
|
|
|
DR_intrinsic_size_cookie(nsIFrame* aFrame, const char* aType,
|
|
|
|
nsSize& aResult);
|
|
|
|
~DR_intrinsic_size_cookie();
|
|
|
|
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
const char* mType;
|
|
|
|
nsSize& mResult;
|
|
|
|
void* mValue;
|
|
|
|
};
|
2010-05-01 14:40:16 -07:00
|
|
|
|
|
|
|
struct DR_init_constraints_cookie {
|
|
|
|
DR_init_constraints_cookie(nsIFrame* aFrame, nsHTMLReflowState* aState,
|
|
|
|
nscoord aCBWidth, nscoord aCBHeight,
|
|
|
|
const nsMargin* aBorder,
|
|
|
|
const nsMargin* aPadding);
|
|
|
|
~DR_init_constraints_cookie();
|
|
|
|
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
nsHTMLReflowState* mState;
|
|
|
|
void* mValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DR_init_offsets_cookie {
|
|
|
|
DR_init_offsets_cookie(nsIFrame* aFrame, nsCSSOffsetState* aState,
|
2013-04-11 07:51:58 -07:00
|
|
|
nscoord aHorizontalPercentBasis,
|
|
|
|
nscoord aVerticalPercentBasis,
|
|
|
|
const nsMargin* aBorder,
|
2010-05-01 14:40:16 -07:00
|
|
|
const nsMargin* aPadding);
|
|
|
|
~DR_init_offsets_cookie();
|
|
|
|
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
nsCSSOffsetState* mState;
|
|
|
|
void* mValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DR_init_type_cookie {
|
|
|
|
DR_init_type_cookie(nsIFrame* aFrame, nsHTMLReflowState* aState);
|
|
|
|
~DR_init_type_cookie();
|
|
|
|
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
nsHTMLReflowState* mState;
|
|
|
|
void* mValue;
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#define DISPLAY_REFLOW(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status) \
|
|
|
|
DR_cookie dr_cookie(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status);
|
|
|
|
#define DISPLAY_REFLOW_CHANGE() \
|
|
|
|
dr_cookie.Change();
|
|
|
|
#define DISPLAY_LAYOUT(dr_frame) \
|
|
|
|
DR_layout_cookie dr_cookie(dr_frame);
|
|
|
|
#define DISPLAY_MIN_WIDTH(dr_frame, dr_result) \
|
|
|
|
DR_intrinsic_width_cookie dr_cookie(dr_frame, "Min", dr_result)
|
|
|
|
#define DISPLAY_PREF_WIDTH(dr_frame, dr_result) \
|
|
|
|
DR_intrinsic_width_cookie dr_cookie(dr_frame, "Pref", dr_result)
|
|
|
|
#define DISPLAY_PREF_SIZE(dr_frame, dr_result) \
|
|
|
|
DR_intrinsic_size_cookie dr_cookie(dr_frame, "Pref", dr_result)
|
|
|
|
#define DISPLAY_MIN_SIZE(dr_frame, dr_result) \
|
|
|
|
DR_intrinsic_size_cookie dr_cookie(dr_frame, "Min", dr_result)
|
|
|
|
#define DISPLAY_MAX_SIZE(dr_frame, dr_result) \
|
|
|
|
DR_intrinsic_size_cookie dr_cookie(dr_frame, "Max", dr_result)
|
2010-05-01 14:40:16 -07:00
|
|
|
#define DISPLAY_INIT_CONSTRAINTS(dr_frame, dr_state, dr_cbw, dr_cbh, \
|
|
|
|
dr_bdr, dr_pad) \
|
|
|
|
DR_init_constraints_cookie dr_cookie(dr_frame, dr_state, dr_cbw, dr_cbh, \
|
|
|
|
dr_bdr, dr_pad)
|
2013-04-11 07:51:58 -07:00
|
|
|
#define DISPLAY_INIT_OFFSETS(dr_frame, dr_state, dr_hpb, dr_vpb, dr_bdr, dr_pad) \
|
|
|
|
DR_init_offsets_cookie dr_cookie(dr_frame, dr_state, dr_hpb, dr_vpb, dr_bdr, dr_pad)
|
2010-05-01 14:40:16 -07:00
|
|
|
#define DISPLAY_INIT_TYPE(dr_frame, dr_result) \
|
|
|
|
DR_init_type_cookie dr_cookie(dr_frame, dr_result)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define DISPLAY_REFLOW(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status)
|
|
|
|
#define DISPLAY_REFLOW_CHANGE()
|
|
|
|
#define DISPLAY_LAYOUT(dr_frame) PR_BEGIN_MACRO PR_END_MACRO
|
|
|
|
#define DISPLAY_MIN_WIDTH(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
|
|
|
|
#define DISPLAY_PREF_WIDTH(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
|
|
|
|
#define DISPLAY_PREF_SIZE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
|
|
|
|
#define DISPLAY_MIN_SIZE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
|
|
|
|
#define DISPLAY_MAX_SIZE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
|
2010-05-01 14:40:16 -07:00
|
|
|
#define DISPLAY_INIT_CONSTRAINTS(dr_frame, dr_state, dr_cbw, dr_cbh, \
|
|
|
|
dr_bdr, dr_pad) \
|
|
|
|
PR_BEGIN_MACRO PR_END_MACRO
|
2013-04-11 07:51:58 -07:00
|
|
|
#define DISPLAY_INIT_OFFSETS(dr_frame, dr_state, dr_hpb, dr_vpb, dr_bdr, dr_pad) \
|
2010-05-01 14:40:16 -07:00
|
|
|
PR_BEGIN_MACRO PR_END_MACRO
|
|
|
|
#define DISPLAY_INIT_TYPE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
// End Display Reflow Debugging
|
|
|
|
|
|
|
|
// similar to NS_ENSURE_TRUE but with no return value
|
|
|
|
#define ENSURE_TRUE(x) \
|
|
|
|
PR_BEGIN_MACRO \
|
|
|
|
if (!(x)) { \
|
|
|
|
NS_WARNING("ENSURE_TRUE(" #x ") failed"); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
PR_END_MACRO
|
|
|
|
#endif /* nsFrame_h___ */
|