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 #1 for rendering objects that have child lists */
|
|
|
|
|
|
|
|
#ifndef nsContainerFrame_h___
|
|
|
|
#define nsContainerFrame_h___
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsSplittableFrame.h"
|
|
|
|
#include "nsFrameList.h"
|
|
|
|
#include "nsLayoutUtils.h"
|
|
|
|
|
|
|
|
// Option flags for ReflowChild() and FinishReflowChild()
|
|
|
|
// member functions
|
|
|
|
#define NS_FRAME_NO_MOVE_VIEW 0x0001
|
|
|
|
#define NS_FRAME_NO_MOVE_FRAME (0x0002 | NS_FRAME_NO_MOVE_VIEW)
|
|
|
|
#define NS_FRAME_NO_SIZE_VIEW 0x0004
|
|
|
|
#define NS_FRAME_NO_VISIBILITY 0x0008
|
2013-03-15 11:36:30 -07:00
|
|
|
// Only applies to ReflowChild; if true, don't delete the next-in-flow, even
|
|
|
|
// if the reflow is fully complete.
|
2013-03-15 15:32:35 -07:00
|
|
|
#define NS_FRAME_NO_DELETE_NEXT_IN_FLOW_CHILD 0x0010
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-25 21:03:29 -07:00
|
|
|
class nsOverflowContinuationTracker;
|
2013-02-10 18:28:50 -08:00
|
|
|
namespace mozilla {
|
|
|
|
class FramePropertyTable;
|
|
|
|
}
|
2007-07-25 21:03:29 -07:00
|
|
|
|
2011-12-27 12:18:48 -08:00
|
|
|
// Some macros for container classes to do sanity checking on
|
|
|
|
// width/height/x/y values computed during reflow.
|
|
|
|
// NOTE: AppUnitsPerCSSPixel value hardwired here to remove the
|
|
|
|
// dependency on nsDeviceContext.h. It doesn't matter if it's a
|
|
|
|
// little off.
|
|
|
|
#ifdef DEBUG
|
2014-03-11 13:23:50 -07:00
|
|
|
#define CRAZY_COORD (1000000*60)
|
|
|
|
#define CRAZY_SIZE(_x) (((_x) < -CRAZY_COORD) || ((_x) > CRAZY_COORD))
|
2011-12-27 12:18:48 -08:00
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Implementation of a container frame.
|
|
|
|
*/
|
|
|
|
class nsContainerFrame : public nsSplittableFrame
|
|
|
|
{
|
|
|
|
public:
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2009-09-18 04:09:35 -07:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsContainerFrame)
|
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 09:49:24 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIFrame overrides
|
2013-03-19 18:47:48 -07:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult SetInitialChildList(ChildListID aListID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsFrameList& aChildList) MOZ_OVERRIDE;
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult AppendFrames(ChildListID aListID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult InsertFrames(ChildListID aListID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult RemoveFrame(ChildListID aListID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsIFrame* aOldFrame) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual const nsFrameList& GetChildList(ChildListID aList) const MOZ_OVERRIDE;
|
|
|
|
virtual void GetChildLists(nsTArray<ChildList>* aLists) const MOZ_OVERRIDE;
|
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
|
|
|
virtual void ChildIsDirty(nsIFrame* aChild) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual bool IsLeaf() const MOZ_OVERRIDE;
|
2014-03-13 07:14:37 -07:00
|
|
|
virtual FrameSearchResult PeekOffsetNoAmount(bool aForward, int32_t* aOffset) MOZ_OVERRIDE;
|
|
|
|
virtual FrameSearchResult PeekOffsetCharacter(bool aForward, int32_t* aOffset,
|
2012-09-14 09:10:08 -07:00
|
|
|
bool aRespectClusters = true) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-01-26 14:07:02 -08:00
|
|
|
void List(FILE* out = stderr, const char* aPrefix = "", uint32_t aFlags = 0) const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// nsContainerFrame methods
|
2008-12-02 17:27:19 -08:00
|
|
|
|
2011-12-27 12:18:48 -08:00
|
|
|
/**
|
|
|
|
* Helper method to create next-in-flows if necessary. If aFrame
|
|
|
|
* already has a next-in-flow then this method does
|
|
|
|
* nothing. Otherwise, a new continuation frame is created and
|
|
|
|
* linked into the flow. In addition, the new frame is inserted
|
|
|
|
* into the principal child list after aFrame.
|
|
|
|
* @note calling this method on a block frame is illegal. Use
|
|
|
|
* nsBlockFrame::CreateContinuationFor() instead.
|
|
|
|
* @param aNextInFlowResult will contain the next-in-flow
|
|
|
|
* <b>if and only if</b> one is created. If a next-in-flow already
|
2012-07-30 07:20:58 -07:00
|
|
|
* exists aNextInFlowResult is set to nullptr.
|
2011-12-27 12:18:48 -08:00
|
|
|
* @return NS_OK if a next-in-flow already exists or is successfully created.
|
|
|
|
*/
|
2014-02-06 14:07:48 -08:00
|
|
|
nsresult CreateNextInFlow(nsIFrame* aFrame, nsIFrame*& aNextInFlowResult);
|
2011-12-27 12:18:48 -08:00
|
|
|
|
2008-12-02 17:27:19 -08:00
|
|
|
/**
|
|
|
|
* Delete aNextInFlow and its next-in-flows.
|
|
|
|
* @param aDeletingEmptyFrames if set, then the reflow for aNextInFlow's
|
|
|
|
* content was complete before aNextInFlow, so aNextInFlow and its
|
|
|
|
* next-in-flows no longer map any real content.
|
|
|
|
*/
|
2014-02-06 14:07:48 -08:00
|
|
|
virtual void DeleteNextInFlowChild(nsIFrame* aNextInFlow,
|
|
|
|
bool aDeletingEmptyFrames);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-19 04:55:11 -07:00
|
|
|
/**
|
|
|
|
* Helper method to wrap views around frames. Used by containers
|
|
|
|
* under special circumstances (can be used by leaf frames as well)
|
|
|
|
*/
|
2013-03-19 18:47:47 -07:00
|
|
|
static void CreateViewForFrame(nsIFrame* aFrame,
|
|
|
|
bool aForce);
|
2011-04-19 04:55:11 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Positions the frame's view based on the frame's origin
|
|
|
|
static void PositionFrameView(nsIFrame* aKidFrame);
|
|
|
|
|
2014-02-06 14:07:48 -08:00
|
|
|
static nsresult ReparentFrameView(nsIFrame* aChildFrame,
|
|
|
|
nsIFrame* aOldParentFrame,
|
|
|
|
nsIFrame* aNewParentFrame);
|
2011-04-19 04:55:11 -07:00
|
|
|
|
2014-02-06 14:07:47 -08:00
|
|
|
static nsresult ReparentFrameViewList(const nsFrameList& aChildFrameList,
|
2011-04-19 04:55:11 -07:00
|
|
|
nsIFrame* aOldParentFrame,
|
|
|
|
nsIFrame* aNewParentFrame);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Set the view's size and position after its frame has been reflowed.
|
|
|
|
//
|
|
|
|
// Flags:
|
|
|
|
// NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
|
|
|
|
// don't want to automatically sync the frame and view
|
|
|
|
// NS_FRAME_NO_SIZE_VIEW - don't size the view
|
|
|
|
static void SyncFrameViewAfterReflow(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* aView,
|
2010-10-06 21:25:45 -07:00
|
|
|
const nsRect& aVisualOverflowArea,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags = 0);
|
2009-08-12 13:48:30 -07:00
|
|
|
|
|
|
|
// Syncs properties to the top level view and window, like transparency and
|
|
|
|
// shadow.
|
|
|
|
static void SyncWindowProperties(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* aView,
|
2012-07-30 17:43:29 -07:00
|
|
|
nsRenderingContext* aRC = nullptr);
|
2009-08-12 13:48:30 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Sets the view's attributes from the frame style.
|
|
|
|
// - visibility
|
|
|
|
// - clip
|
|
|
|
// Call this when one of these styles changes or when the view has just
|
|
|
|
// been created.
|
|
|
|
// @param aStyleContext can be null, in which case the frame's style context is used
|
|
|
|
static void SyncFrameViewProperties(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsStyleContext* aStyleContext,
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* aView,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags = 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 17:43:29 -07:00
|
|
|
/**
|
|
|
|
* Converts the minimum and maximum sizes given in inner window app units to
|
|
|
|
* outer window device pixel sizes and assigns these constraints to the widget.
|
|
|
|
*
|
|
|
|
* @param aPresContext pres context
|
|
|
|
* @param aWidget widget for this frame
|
|
|
|
* @param minimum size of the window in app units
|
|
|
|
* @param maxmimum size of the window in app units
|
|
|
|
*/
|
|
|
|
static void SetSizeConstraints(nsPresContext* aPresContext,
|
|
|
|
nsIWidget* aWidget,
|
|
|
|
const nsSize& aMinSize,
|
|
|
|
const nsSize& aMaxSize);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Used by both nsInlineFrame and nsFirstLetterFrame.
|
2011-04-07 18:04:40 -07:00
|
|
|
void DoInlineIntrinsicWidth(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
InlineIntrinsicWidthData *aData,
|
|
|
|
nsLayoutUtils::IntrinsicWidthType aType);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the CSS block concept of computing 'auto' widths, which most
|
|
|
|
* classes derived from nsContainerFrame want.
|
|
|
|
*/
|
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,
|
2012-09-14 09:10:08 -07:00
|
|
|
nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Invokes the WillReflow() function, positions the frame and its view (if
|
|
|
|
* requested), and then calls Reflow(). If the reflow succeeds and the child
|
|
|
|
* frame is complete, deletes any next-in-flows using DeleteNextInFlowChild()
|
|
|
|
*
|
|
|
|
* Flags:
|
|
|
|
* NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
|
|
|
|
* don't want to automatically sync the frame and view
|
2007-07-03 15:49:00 -07:00
|
|
|
* NS_FRAME_NO_MOVE_FRAME - don't move the frame. aX and aY are ignored in this
|
2007-03-22 10:30:00 -07:00
|
|
|
* case. Also implies NS_FRAME_NO_MOVE_VIEW
|
|
|
|
*/
|
2014-05-12 17:47:53 -07:00
|
|
|
void ReflowChild(nsIFrame* aKidFrame,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
|
|
|
uint32_t aFlags,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsOverflowContinuationTracker* aTracker = nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The second half of frame reflow. Does the following:
|
|
|
|
* - sets the frame's bounds
|
|
|
|
* - sizes and positions (if requested) the frame's view. If the frame's final
|
|
|
|
* position differs from the current position and the frame itself does not
|
|
|
|
* have a view, then any child frames with views are positioned so they stay
|
|
|
|
* in sync
|
|
|
|
* - sets the view's visibility, opacity, content transparency, and clip
|
|
|
|
* - invoked the DidReflow() function
|
|
|
|
*
|
|
|
|
* Flags:
|
|
|
|
* NS_FRAME_NO_MOVE_FRAME - don't move the frame. aX and aY are ignored in this
|
|
|
|
* case. Also implies NS_FRAME_NO_MOVE_VIEW
|
|
|
|
* NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
|
|
|
|
* don't want to automatically sync the frame and view
|
|
|
|
* NS_FRAME_NO_SIZE_VIEW - don't size the frame's view
|
|
|
|
*/
|
2014-05-12 17:47:53 -07:00
|
|
|
static void FinishReflowChild(nsIFrame* aKidFrame,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState* aReflowState,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
|
|
|
uint32_t aFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
static void PositionChildViews(nsIFrame* aFrame);
|
2007-07-25 21:03:29 -07:00
|
|
|
|
|
|
|
// ==========================================================================
|
|
|
|
/* Overflow containers are continuation frames that hold overflow. They
|
|
|
|
* are created when the frame runs out of computed height, but still has
|
|
|
|
* too much content to fit in the availableHeight. The parent creates a
|
|
|
|
* continuation as usual, but marks it as NS_FRAME_IS_OVERFLOW_CONTAINER
|
|
|
|
* and adds it to its next-in-flow's overflow container list, either by
|
|
|
|
* adding it directly or by putting it in its own excess overflow containers
|
|
|
|
* list (to be drained by the next-in-flow when it calls
|
|
|
|
* ReflowOverflowContainerChildren). The parent continues reflow as if
|
|
|
|
* the frame was complete once it ran out of computed height, but returns
|
|
|
|
* either an NS_FRAME_NOT_COMPLETE or NS_FRAME_OVERFLOW_INCOMPLETE reflow
|
|
|
|
* status to request a next-in-flow. The parent's next-in-flow is then
|
|
|
|
* responsible for calling ReflowOverflowContainerChildren to (drain and)
|
|
|
|
* reflow these overflow continuations. Overflow containers do not affect
|
|
|
|
* other frames' size or position during reflow (but do affect their
|
|
|
|
* parent's overflow area).
|
|
|
|
*
|
|
|
|
* Overflow container continuations are different from normal continuations
|
|
|
|
* in that
|
|
|
|
* - more than one child of the frame can have its next-in-flow broken
|
|
|
|
* off and pushed into the frame's next-in-flow
|
|
|
|
* - new continuations may need to be spliced into the middle of the list
|
|
|
|
* or deleted continuations slipped out
|
|
|
|
* e.g. A, B, C are all fixed-size containers on one page, all have
|
|
|
|
* overflow beyond availableHeight, and content is dynamically added
|
|
|
|
* and removed from B
|
|
|
|
* As a result, it is not possible to simply prepend the new continuations
|
|
|
|
* to the old list as with the overflowProperty mechanism. To avoid
|
|
|
|
* complicated list splicing, the code assumes only one overflow containers
|
|
|
|
* list exists for a given frame: either its own overflowContainersProperty
|
|
|
|
* or its prev-in-flow's excessOverflowContainersProperty, not both.
|
|
|
|
*
|
|
|
|
* The nsOverflowContinuationTracker helper class should be used for tracking
|
|
|
|
* overflow containers and adding them to the appropriate list.
|
|
|
|
* See nsBlockFrame::Reflow for a sample implementation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
friend class nsOverflowContinuationTracker;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reflow overflow container children. They are invisible to normal reflow
|
|
|
|
* (i.e. don't affect sizing or placement of other children) and inherit
|
|
|
|
* width and horizontal position from their prev-in-flow.
|
|
|
|
*
|
|
|
|
* This method
|
|
|
|
* 1. Pulls excess overflow containers from the prev-in-flow and adds
|
|
|
|
* them to our overflow container list
|
|
|
|
* 2. Reflows all our overflow container kids
|
|
|
|
* 3. Expands aOverflowRect as necessary to accomodate these children.
|
|
|
|
* 4. Sets aStatus's NS_FRAME_OVERFLOW_IS_INCOMPLETE flag (along with
|
|
|
|
* NS_FRAME_REFLOW_NEXTINFLOW as necessary) if any overflow children
|
|
|
|
* are incomplete and
|
|
|
|
* 5. Prepends a list of their continuations to our excess overflow
|
|
|
|
* container list, to be drained into our next-in-flow when it is
|
|
|
|
* reflowed.
|
|
|
|
*
|
|
|
|
* The caller is responsible for tracking any new overflow container
|
|
|
|
* continuations it makes, removing them from its child list, and
|
|
|
|
* making sure they are stored properly in the overflow container lists.
|
|
|
|
* The nsOverflowContinuationTracker helper class should be used for this.
|
|
|
|
*
|
|
|
|
* (aFlags just gets passed through to ReflowChild)
|
|
|
|
*/
|
2014-05-12 15:47:41 -07:00
|
|
|
nsresult ReflowOverflowContainerChildren(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsOverflowAreas& aOverflowRects,
|
|
|
|
uint32_t aFlags,
|
|
|
|
nsReflowStatus& aStatus);
|
2007-07-25 21:03:29 -07:00
|
|
|
|
2012-09-17 16:05:05 -07:00
|
|
|
/**
|
|
|
|
* Move any frames on our overflow list to the end of our principal list.
|
|
|
|
* @return true if there were any overflow frames
|
|
|
|
*/
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual bool DrainSelfOverflowList() MOZ_OVERRIDE;
|
2012-09-17 16:05:05 -07:00
|
|
|
|
2007-07-25 21:03:29 -07:00
|
|
|
/**
|
|
|
|
* Removes aChild without destroying it and without requesting reflow.
|
|
|
|
* Continuations are not affected. Checks the primary and overflow
|
|
|
|
* or overflow containers and excess overflow containers lists, depending
|
|
|
|
* on whether the NS_FRAME_IS_OVERFLOW_CONTAINER flag is set. Does not
|
|
|
|
* check any other auxiliary lists.
|
|
|
|
* Returns NS_ERROR_UNEXPECTED if we failed to remove aChild.
|
|
|
|
* Returns other error codes if we failed to put back a proptable list.
|
|
|
|
* If aForceNormal is true, only checks the primary and overflow lists
|
|
|
|
* even when the NS_FRAME_IS_OVERFLOW_CONTAINER flag is set.
|
|
|
|
*/
|
2014-02-06 14:07:48 -08:00
|
|
|
virtual nsresult StealFrame(nsIFrame* aChild,
|
|
|
|
bool aForceNormal = false);
|
2007-07-25 21:03:29 -07:00
|
|
|
|
2009-09-18 04:09:35 -07:00
|
|
|
/**
|
|
|
|
* Removes the next-siblings of aChild without destroying them and without
|
|
|
|
* requesting reflow. Checks the principal and overflow lists (not
|
|
|
|
* overflow containers / excess overflow containers). Does not check any
|
|
|
|
* other auxiliary lists.
|
2012-07-30 07:20:58 -07:00
|
|
|
* @param aChild a child frame or nullptr
|
2009-09-18 04:09:35 -07:00
|
|
|
* @return If aChild is non-null, the next-siblings of aChild, if any.
|
|
|
|
* If aChild is null, all child frames on the principal list, if any.
|
|
|
|
*/
|
|
|
|
nsFrameList StealFramesAfter(nsIFrame* aChild);
|
|
|
|
|
2007-07-25 21:03:29 -07:00
|
|
|
/**
|
|
|
|
* Add overflow containers to the display list
|
|
|
|
*/
|
|
|
|
void DisplayOverflowContainers(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Builds display lists for the children. The background
|
|
|
|
* of each child is placed in the Content() list (suitable for inline
|
|
|
|
* children and other elements that behave like inlines,
|
|
|
|
* but not for in-flow block children of blocks). DOES NOT
|
|
|
|
* paint the background/borders/outline of this frame. This should
|
|
|
|
* probably be avoided and eventually removed. It's currently here
|
|
|
|
* to emulate what nsContainerFrame::Paint did.
|
|
|
|
*/
|
2013-02-14 03:12:27 -08:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-01 08:26:02 -07:00
|
|
|
/**
|
|
|
|
* Destructor function for the proptable-stored framelists --
|
|
|
|
* it should never be called.
|
|
|
|
*/
|
2010-03-28 18:46:55 -07:00
|
|
|
static void DestroyFrameList(void* aPropertyValue)
|
|
|
|
{
|
2013-04-01 08:26:02 -07:00
|
|
|
MOZ_ASSERT(false, "The owning frame should destroy its nsFrameList props");
|
2010-03-28 18:46:55 -07:00
|
|
|
}
|
|
|
|
|
2013-11-15 05:19:02 -08:00
|
|
|
static void PlaceFrameView(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (aFrame->HasView())
|
|
|
|
nsContainerFrame::PositionFrameView(aFrame);
|
|
|
|
else
|
|
|
|
nsContainerFrame::PositionChildViews(aFrame);
|
|
|
|
}
|
|
|
|
|
2013-04-01 08:26:02 -07:00
|
|
|
#define NS_DECLARE_FRAME_PROPERTY_FRAMELIST(prop) \
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(prop, nsContainerFrame::DestroyFrameList)
|
|
|
|
|
|
|
|
NS_DECLARE_FRAME_PROPERTY_FRAMELIST(OverflowProperty)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY_FRAMELIST(OverflowContainersProperty)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY_FRAMELIST(ExcessOverflowContainersProperty)
|
2010-03-28 18:46:55 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
nsContainerFrame(nsStyleContext* aContext) : nsSplittableFrame(aContext) {}
|
|
|
|
~nsContainerFrame();
|
|
|
|
|
2012-11-01 17:52:59 -07:00
|
|
|
/**
|
|
|
|
* Helper for DestroyFrom. DestroyAbsoluteFrames is called before
|
|
|
|
* destroying frames on lists that can contain placeholders.
|
|
|
|
* Derived classes must do that too, if they destroy such frame lists.
|
|
|
|
* See nsBlockFrame::DestroyFrom for an example.
|
|
|
|
*/
|
|
|
|
void DestroyAbsoluteFrames(nsIFrame* aDestructRoot);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Builds a display list for non-block children that behave like
|
|
|
|
* inlines. This puts the background of each child into the
|
|
|
|
* Content() list (suitable for inline children but not for
|
|
|
|
* in-flow block children of blocks).
|
|
|
|
* @param aForcePseudoStack forces each child into a pseudo-stacking-context
|
|
|
|
* so its background and all other display items (except for positioned
|
|
|
|
* display items) go into the Content() list.
|
|
|
|
*/
|
2013-02-14 03:12:27 -08:00
|
|
|
void BuildDisplayListForNonBlockChildren(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists,
|
|
|
|
uint32_t aFlags = 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-12-27 12:18:48 -08:00
|
|
|
/**
|
|
|
|
* A version of BuildDisplayList that use DISPLAY_CHILD_INLINE.
|
|
|
|
* Intended as a convenience for derived classes.
|
|
|
|
*/
|
2013-02-14 03:12:27 -08:00
|
|
|
void BuildDisplayListForInline(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) {
|
2013-02-14 03:08:08 -08:00
|
|
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
|
|
|
BuildDisplayListForNonBlockChildren(aBuilder, aDirtyRect, aLists,
|
|
|
|
DISPLAY_CHILD_INLINE);
|
2011-12-27 12:18:48 -08:00
|
|
|
}
|
|
|
|
|
2007-07-25 21:03:29 -07:00
|
|
|
|
|
|
|
// ==========================================================================
|
|
|
|
/* Overflow Frames are frames that did not fit and must be pulled by
|
|
|
|
* our next-in-flow during its reflow. (The same concept for overflow
|
|
|
|
* containers is called "excess frames". We should probably make the
|
|
|
|
* names match.)
|
|
|
|
*/
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2009-07-28 05:51:09 -07:00
|
|
|
* Get the frames on the overflow list. Can return null if there are no
|
|
|
|
* overflow frames. The caller does NOT take ownership of the list; it's
|
|
|
|
* still owned by this frame. A non-null return value indicates that the
|
|
|
|
* list is nonempty.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2009-07-28 05:51:09 -07:00
|
|
|
inline nsFrameList* GetOverflowFrames() const;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2009-07-28 05:51:09 -07:00
|
|
|
* As GetOverflowFrames, but removes the overflow frames property. The
|
|
|
|
* caller is responsible for deleting nsFrameList and either passing
|
2013-04-01 08:26:02 -07:00
|
|
|
* ownership of the frames to someone else or destroying the frames.
|
|
|
|
* A non-null return value indicates that the list is nonempty. The
|
2009-07-28 05:51:09 -07:00
|
|
|
* recommended way to use this function it to assign its return value
|
2013-04-01 08:26:02 -07:00
|
|
|
* into an AutoFrameListPtr.
|
2009-07-28 05:51:09 -07:00
|
|
|
*/
|
|
|
|
inline nsFrameList* StealOverflowFrames();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the overflow list. aOverflowFrames must not be an empty list.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2014-02-06 14:07:47 -08:00
|
|
|
void SetOverflowFrames(const nsFrameList& aOverflowFrames);
|
2009-07-28 05:51:09 -07:00
|
|
|
|
|
|
|
/**
|
2013-04-01 08:26:02 -07:00
|
|
|
* Destroy the overflow list, which must be empty.
|
2009-07-28 05:51:09 -07:00
|
|
|
*/
|
2014-02-06 14:07:47 -08:00
|
|
|
inline void DestroyOverflowList();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Moves any frames on both the prev-in-flow's overflow list and the
|
|
|
|
* receiver's overflow to the receiver's child list.
|
|
|
|
*
|
2012-07-30 07:20:58 -07:00
|
|
|
* Resets the overlist pointers to nullptr, and updates the receiver's child
|
2007-03-22 10:30:00 -07:00
|
|
|
* count and content mapping.
|
|
|
|
*
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true if any frames were moved and false otherwise
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2014-02-06 14:07:47 -08:00
|
|
|
bool MoveOverflowToChildList();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Push aFromChild and its next siblings to the next-in-flow. Change
|
|
|
|
* the geometric parent of each frame that's pushed. If there is no
|
|
|
|
* next-in-flow the frames are placed on the overflow list (and the
|
|
|
|
* geometric parent is left unchanged).
|
|
|
|
*
|
|
|
|
* Updates the next-in-flow's child count. Does <b>not</b> update the
|
|
|
|
* pusher's child count.
|
|
|
|
*
|
|
|
|
* @param aFromChild the first child frame to push. It is disconnected from
|
|
|
|
* aPrevSibling
|
|
|
|
* @param aPrevSibling aFromChild's previous sibling. Must not be null.
|
|
|
|
* It's an error to push a parent's first child frame
|
|
|
|
*/
|
2014-02-06 14:07:48 -08:00
|
|
|
void PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-25 21:03:29 -07:00
|
|
|
// ==========================================================================
|
|
|
|
/*
|
|
|
|
* Convenience methods for nsFrameLists stored in the
|
|
|
|
* PresContext's proptable
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the PresContext-stored nsFrameList named aPropID for this frame.
|
|
|
|
* May return null.
|
|
|
|
*/
|
2014-02-06 14:07:47 -08:00
|
|
|
nsFrameList* GetPropTableFrames(const FramePropertyDescriptor* aProperty) const;
|
2007-07-25 21:03:29 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove and return the PresContext-stored nsFrameList named aPropID for
|
|
|
|
* this frame. May return null.
|
|
|
|
*/
|
2014-02-06 14:07:47 -08:00
|
|
|
nsFrameList* RemovePropTableFrames(const FramePropertyDescriptor* aProperty);
|
2007-07-25 21:03:29 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the PresContext-stored nsFrameList named aPropID for this frame
|
|
|
|
* to the given aFrameList, which must not be null.
|
|
|
|
*/
|
2014-02-06 14:07:47 -08:00
|
|
|
void SetPropTableFrames(nsFrameList* aFrameList,
|
2013-03-23 13:10:33 -07:00
|
|
|
const FramePropertyDescriptor* aProperty);
|
2013-02-10 18:28:50 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Safely destroy the frames on the nsFrameList stored on aProp for this
|
|
|
|
* frame then remove the property and delete the frame list.
|
|
|
|
* Nothing happens if the property doesn't exist.
|
|
|
|
*/
|
|
|
|
void SafelyDestroyFrameListProp(nsIFrame* aDestructRoot,
|
2013-04-01 08:26:02 -07:00
|
|
|
nsIPresShell* aPresShell,
|
2013-02-10 18:28:50 -08:00
|
|
|
mozilla::FramePropertyTable* aPropTable,
|
|
|
|
const FramePropertyDescriptor* aProp);
|
|
|
|
|
2007-07-25 21:03:29 -07:00
|
|
|
// ==========================================================================
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsFrameList mFrames;
|
|
|
|
};
|
|
|
|
|
2007-10-01 22:57:45 -07:00
|
|
|
// ==========================================================================
|
|
|
|
/* The out-of-flow-related code below is for a hacky way of splitting
|
|
|
|
* absolutely-positioned frames. Basically what we do is split the frame
|
|
|
|
* in nsAbsoluteContainingBlock and pretend the continuation is an overflow
|
|
|
|
* container. This isn't an ideal solution, but it lets us print the content
|
|
|
|
* at least. See bug 154892.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define IS_TRUE_OVERFLOW_CONTAINER(frame) \
|
|
|
|
( (frame->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) \
|
2009-08-31 11:25:36 -07:00
|
|
|
&& !( (frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) && \
|
2012-08-02 04:38:50 -07:00
|
|
|
frame->IsAbsolutelyPositioned() ) )
|
2007-10-01 22:57:45 -07:00
|
|
|
//XXXfr This check isn't quite correct, because it doesn't handle cases
|
|
|
|
// where the out-of-flow has overflow.. but that's rare.
|
|
|
|
// We'll need to revisit the way abspos continuations are handled later
|
|
|
|
// for various reasons, this detail is one of them. See bug 154892
|
|
|
|
|
2007-07-25 21:03:29 -07:00
|
|
|
/**
|
|
|
|
* Helper class for tracking overflow container continuations during reflow.
|
|
|
|
*
|
|
|
|
* A frame is related to two sets of overflow containers: those that /are/
|
|
|
|
* its own children, and those that are /continuations/ of its children.
|
|
|
|
* This tracker walks through those continuations (the frame's NIF's children)
|
|
|
|
* and their prev-in-flows (a subset of the frame's normal and overflow
|
|
|
|
* container children) in parallel. It allows the reflower to synchronously
|
|
|
|
* walk its overflow continuations while it loops through and reflows its
|
|
|
|
* children. This makes it possible to insert new continuations at the correct
|
|
|
|
* place in the overflow containers list.
|
|
|
|
*
|
|
|
|
* The reflower is expected to loop through its children in the same order it
|
|
|
|
* looped through them the last time (if there was a last time).
|
|
|
|
* For each child, the reflower should either
|
|
|
|
* - call Skip for the child if was not reflowed in this pass
|
|
|
|
* - call Insert for the overflow continuation if the child was reflowed
|
|
|
|
* but has incomplete overflow
|
|
|
|
* - call Finished for the child if it was reflowed in this pass but
|
|
|
|
* is either complete or has a normal next-in-flow. This call can
|
|
|
|
* be skipped if the child did not previously have an overflow
|
|
|
|
* continuation.
|
|
|
|
*/
|
|
|
|
class nsOverflowContinuationTracker {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Initializes an nsOverflowContinuationTracker to help track overflow
|
|
|
|
* continuations of aFrame's children. Typically invoked on 'this'.
|
|
|
|
*
|
2007-10-01 22:57:45 -07:00
|
|
|
* aWalkOOFFrames determines whether the walker skips out-of-flow frames
|
|
|
|
* or skips non-out-of-flow frames.
|
|
|
|
*
|
2011-10-17 07:59:28 -07:00
|
|
|
* Don't set aSkipOverflowContainerChildren to false unless you plan
|
2007-07-25 21:03:29 -07:00
|
|
|
* to walk your own overflow container children. (Usually they are handled
|
2007-10-01 22:57:45 -07:00
|
|
|
* by calling ReflowOverflowContainerChildren.) aWalkOOFFrames is ignored
|
|
|
|
* if aSkipOverflowContainerChildren is false.
|
2007-07-25 21:03:29 -07:00
|
|
|
*/
|
2014-02-06 14:07:47 -08:00
|
|
|
nsOverflowContinuationTracker(nsContainerFrame* aFrame,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aWalkOOFFrames,
|
|
|
|
bool aSkipOverflowContainerChildren = true);
|
2007-07-25 21:03:29 -07:00
|
|
|
/**
|
|
|
|
* This function adds an overflow continuation to our running list and
|
|
|
|
* sets its NS_FRAME_IS_OVERFLOW_CONTAINER flag.
|
|
|
|
*
|
|
|
|
* aReflowStatus should preferably be specific to the recently-reflowed
|
|
|
|
* child and not influenced by any of its siblings' statuses. This
|
|
|
|
* function sets the NS_FRAME_IS_DIRTY bit on aOverflowCont if it needs
|
|
|
|
* to be reflowed. (Its need for reflow depends on changes to its
|
|
|
|
* prev-in-flow, not to its parent--for whom it is invisible, reflow-wise.)
|
|
|
|
*
|
|
|
|
* The caller MUST disconnect the frame from its parent's child list
|
|
|
|
* if it was not previously an NS_FRAME_IS_OVERFLOW_CONTAINER (because
|
|
|
|
* StealFrame is much more inefficient than disconnecting in place
|
|
|
|
* during Reflow, which the caller is able to do but we are not).
|
|
|
|
*
|
|
|
|
* The caller MUST NOT disconnect the frame from its parent's
|
|
|
|
* child list if it is already an NS_FRAME_IS_OVERFLOW_CONTAINER.
|
|
|
|
* (In this case we will disconnect and reconnect it ourselves.)
|
|
|
|
*/
|
|
|
|
nsresult Insert(nsIFrame* aOverflowCont,
|
|
|
|
nsReflowStatus& aReflowStatus);
|
|
|
|
/**
|
2013-06-10 11:31:59 -07:00
|
|
|
* Begin/EndFinish() must be called for each child that is reflowed
|
2007-10-01 22:57:45 -07:00
|
|
|
* but no longer has an overflow continuation. (It may be called for
|
|
|
|
* other children, but in that case has no effect.) It increments our
|
2007-07-25 21:03:29 -07:00
|
|
|
* walker and makes sure we drop any dangling pointers to its
|
|
|
|
* next-in-flow. This function MUST be called before stealing or
|
|
|
|
* deleting aChild's next-in-flow.
|
2013-06-10 11:31:59 -07:00
|
|
|
* The AutoFinish helper object does that for you. Use it like so:
|
|
|
|
* if (kidNextInFlow) {
|
|
|
|
* nsOverflowContinuationTracker::AutoFinish fini(tracker, kid);
|
|
|
|
* ... DeleteNextInFlowChild/StealFrame(kidNextInFlow) here ...
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
class MOZ_STACK_CLASS AutoFinish {
|
|
|
|
public:
|
|
|
|
AutoFinish(nsOverflowContinuationTracker* aTracker, nsIFrame* aChild)
|
|
|
|
: mTracker(aTracker), mChild(aChild)
|
|
|
|
{
|
|
|
|
if (mTracker) mTracker->BeginFinish(mChild);
|
|
|
|
}
|
|
|
|
~AutoFinish()
|
|
|
|
{
|
|
|
|
if (mTracker) mTracker->EndFinish(mChild);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsOverflowContinuationTracker* mTracker;
|
|
|
|
nsIFrame* mChild;
|
|
|
|
};
|
2007-07-25 21:03:29 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This function should be called for each child that isn't reflowed.
|
|
|
|
* It increments our walker and sets the NS_FRAME_OVERFLOW_INCOMPLETE
|
|
|
|
* reflow flag if it encounters an overflow continuation so that our
|
|
|
|
* next-in-flow doesn't get prematurely deleted. It MUST be called on
|
|
|
|
* each unreflowed child that has an overflow container continuation;
|
|
|
|
* it MAY be called on other children, but it isn't necessary (doesn't
|
|
|
|
* do anything).
|
|
|
|
*/
|
|
|
|
void Skip(nsIFrame* aChild, nsReflowStatus& aReflowStatus)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aChild, "null ptr");
|
|
|
|
if (aChild == mSentry) {
|
|
|
|
StepForward();
|
2008-05-28 06:39:41 -07:00
|
|
|
NS_MergeReflowStatusInto(&aReflowStatus, NS_FRAME_OVERFLOW_INCOMPLETE);
|
2007-07-25 21:03:29 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2013-06-10 11:31:59 -07:00
|
|
|
/**
|
|
|
|
* @see class AutoFinish
|
|
|
|
*/
|
|
|
|
void BeginFinish(nsIFrame* aChild);
|
|
|
|
void EndFinish(nsIFrame* aChild);
|
|
|
|
|
|
|
|
void SetupOverflowContList();
|
2007-07-25 21:03:29 -07:00
|
|
|
void SetUpListWalker();
|
|
|
|
void StepForward();
|
|
|
|
|
|
|
|
/* We hold a pointer to either the next-in-flow's overflow containers list
|
|
|
|
or, if that doesn't exist, our frame's excess overflow containers list.
|
|
|
|
We need to make sure that we drop that pointer if the list becomes
|
|
|
|
empty and is deleted elsewhere. */
|
|
|
|
nsFrameList* mOverflowContList;
|
|
|
|
/* We hold a pointer to the most recently-reflowed child that has an
|
|
|
|
overflow container next-in-flow. We do this because it's a known
|
|
|
|
good point; this pointer won't be deleted on us. We can use it to
|
|
|
|
recover our place in the list. */
|
|
|
|
nsIFrame* mPrevOverflowCont;
|
|
|
|
/* This is a pointer to the next overflow container's prev-in-flow, which
|
|
|
|
is (or should be) a child of our frame. When we hit this, we will need
|
|
|
|
to increment this walker to the next overflow container. */
|
|
|
|
nsIFrame* mSentry;
|
|
|
|
/* Parent of all frames in mOverflowContList. If our mOverflowContList
|
2010-05-12 17:56:08 -07:00
|
|
|
is an excessOverflowContainersProperty, or null, then this is our frame
|
|
|
|
(the frame that was passed in to our constructor). Otherwise this is
|
|
|
|
that frame's next-in-flow, and our mOverflowContList is mParent's
|
2007-07-25 21:03:29 -07:00
|
|
|
overflowContainersProperty */
|
|
|
|
nsContainerFrame* mParent;
|
|
|
|
/* Tells SetUpListWalker whether or not to walk us past any continuations
|
2007-10-01 22:57:45 -07:00
|
|
|
of overflow containers. aWalkOOFFrames is ignored when this is false. */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mSkipOverflowContainerChildren;
|
2007-10-01 22:57:45 -07:00
|
|
|
/* Tells us whether to pay attention to OOF frames or non-OOF frames */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mWalkOOFFrames;
|
2007-07-25 21:03:29 -07:00
|
|
|
};
|
|
|
|
|
2009-07-28 05:51:09 -07:00
|
|
|
inline
|
|
|
|
nsFrameList*
|
|
|
|
nsContainerFrame::GetOverflowFrames() const
|
|
|
|
{
|
|
|
|
nsFrameList* list =
|
2010-03-28 18:46:55 -07:00
|
|
|
static_cast<nsFrameList*>(Properties().Get(OverflowProperty()));
|
2009-07-28 05:51:09 -07:00
|
|
|
NS_ASSERTION(!list || !list->IsEmpty(), "Unexpected empty overflow list");
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
nsFrameList*
|
|
|
|
nsContainerFrame::StealOverflowFrames()
|
|
|
|
{
|
|
|
|
nsFrameList* list =
|
2010-03-28 18:46:55 -07:00
|
|
|
static_cast<nsFrameList*>(Properties().Remove(OverflowProperty()));
|
2009-07-28 05:51:09 -07:00
|
|
|
NS_ASSERTION(!list || !list->IsEmpty(), "Unexpected empty overflow list");
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2013-04-01 08:26:02 -07:00
|
|
|
inline void
|
2014-02-06 14:07:47 -08:00
|
|
|
nsContainerFrame::DestroyOverflowList()
|
2013-04-01 08:26:02 -07:00
|
|
|
{
|
2014-02-06 14:07:47 -08:00
|
|
|
nsFrameList* list = RemovePropTableFrames(OverflowProperty());
|
2013-04-01 08:26:02 -07:00
|
|
|
MOZ_ASSERT(list && list->IsEmpty());
|
2014-02-06 14:07:47 -08:00
|
|
|
list->Delete(PresContext()->PresShell());
|
2013-04-01 08:26:02 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif /* nsContainerFrame_h___ */
|