2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
// vim:cindent:ts=2:et:sw=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
|
|
|
|
|
|
|
/*
|
2007-12-12 13:49:14 -08:00
|
|
|
* rendering object for CSS display:block, inline-block, and list-item
|
|
|
|
* boxes, also used for various anonymous boxes
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsBlockFrame_h___
|
|
|
|
#define nsBlockFrame_h___
|
|
|
|
|
2011-12-27 12:18:48 -08:00
|
|
|
#include "nsContainerFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsLineBox.h"
|
|
|
|
#include "nsCSSPseudoElements.h"
|
|
|
|
#include "nsStyleSet.h"
|
2009-05-20 04:21:34 -07:00
|
|
|
#include "nsFloatManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
enum LineReflowStatus {
|
|
|
|
// The line was completely reflowed and fit in available width, and we should
|
|
|
|
// try to pull up content from the next line if possible.
|
|
|
|
LINE_REFLOW_OK,
|
|
|
|
// The line was completely reflowed and fit in available width, but we should
|
|
|
|
// not try to pull up content from the next line.
|
|
|
|
LINE_REFLOW_STOP,
|
|
|
|
// We need to reflow the line again at its current vertical position. The
|
|
|
|
// new reflow should not try to pull up any frames from the next line.
|
|
|
|
LINE_REFLOW_REDO_NO_PULL,
|
2009-05-20 04:21:34 -07:00
|
|
|
// We need to reflow the line again using the floats from its height
|
|
|
|
// this reflow, since its height made it hit floats that were not
|
|
|
|
// adjacent to its top.
|
|
|
|
LINE_REFLOW_REDO_MORE_FLOATS,
|
2007-03-22 10:30:00 -07:00
|
|
|
// We need to reflow the line again at a lower vertical postion where there
|
|
|
|
// may be more horizontal space due to different float configuration.
|
|
|
|
LINE_REFLOW_REDO_NEXT_BAND,
|
|
|
|
// The line did not fit in the available vertical space. Try pushing it to
|
|
|
|
// the next page or column if it's not the first line on the current page/column.
|
|
|
|
LINE_REFLOW_TRUNCATED
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsBlockReflowState;
|
2007-08-22 02:08:13 -07:00
|
|
|
class nsBlockInFlowLineIterator;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsBulletFrame;
|
|
|
|
class nsFirstLineFrame;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Some invariants:
|
|
|
|
* -- The overflow out-of-flows list contains the out-of-
|
|
|
|
* flow frames whose placeholders are in the overflow list.
|
|
|
|
* -- A given piece of content has at most one placeholder
|
|
|
|
* frame in a block's normal child list.
|
2010-08-05 21:59:19 -07:00
|
|
|
* -- While a block is being reflowed, and from then until
|
|
|
|
* its next-in-flow is reflowed it may have a
|
2010-08-05 21:59:20 -07:00
|
|
|
* PushedFloatProperty frame property that points to
|
2010-08-05 21:59:19 -07:00
|
|
|
* an nsFrameList. This list contains continuations for
|
2009-08-31 11:25:36 -07:00
|
|
|
* floats whose prev-in-flow is in the block's regular float
|
2010-08-05 21:59:19 -07:00
|
|
|
* list and first-in-flows of floats that did not fit, but
|
|
|
|
* whose placeholders are in the block or one of its
|
|
|
|
* prev-in-flows.
|
2007-03-22 10:30:00 -07:00
|
|
|
* -- In all these frame lists, if there are two frames for
|
|
|
|
* the same content appearing in the list, then the frames
|
|
|
|
* appear with the prev-in-flow before the next-in-flow.
|
|
|
|
* -- While reflowing a block, its overflow line list
|
|
|
|
* will usually be empty but in some cases will have lines
|
|
|
|
* (while we reflow the block at its shrink-wrap width).
|
|
|
|
* In this case any new overflowing content must be
|
|
|
|
* prepended to the overflow lines.
|
|
|
|
*/
|
|
|
|
|
2014-02-19 00:21:56 -08:00
|
|
|
typedef nsContainerFrame nsBlockFrameSuper;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Base class for block and inline frames.
|
2011-08-24 13:54:30 -07:00
|
|
|
* The block frame has an additional child list, kAbsoluteList, which
|
|
|
|
* contains the absolutely positioned frames.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
class nsBlockFrame : public nsBlockFrameSuper
|
|
|
|
{
|
|
|
|
public:
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsBlockFrame)
|
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2009-01-12 11:20:59 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef nsLineList::iterator line_iterator;
|
|
|
|
typedef nsLineList::const_iterator const_line_iterator;
|
|
|
|
typedef nsLineList::reverse_iterator reverse_line_iterator;
|
|
|
|
typedef nsLineList::const_reverse_iterator const_reverse_line_iterator;
|
|
|
|
|
|
|
|
line_iterator begin_lines() { return mLines.begin(); }
|
|
|
|
line_iterator end_lines() { return mLines.end(); }
|
|
|
|
const_line_iterator begin_lines() const { return mLines.begin(); }
|
|
|
|
const_line_iterator end_lines() const { return mLines.end(); }
|
|
|
|
reverse_line_iterator rbegin_lines() { return mLines.rbegin(); }
|
|
|
|
reverse_line_iterator rend_lines() { return mLines.rend(); }
|
|
|
|
const_reverse_line_iterator rbegin_lines() const { return mLines.rbegin(); }
|
|
|
|
const_reverse_line_iterator rend_lines() const { return mLines.rend(); }
|
2010-09-08 17:15:24 -07:00
|
|
|
line_iterator line(nsLineBox* aList) { return mLines.begin(aList); }
|
|
|
|
reverse_line_iterator rline(nsLineBox* aList) { return mLines.rbegin(aList); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-24 15:20:39 -07:00
|
|
|
friend nsBlockFrame* NS_NewBlockFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext,
|
|
|
|
nsFrameState aFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
// nsQueryFrame
|
|
|
|
NS_DECL_QUERYFRAME
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsIFrame
|
2014-05-24 15:20:40 -07:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
2014-05-28 12:36:58 -07:00
|
|
|
virtual void SetInitialChildList(ChildListID aListID,
|
2014-05-28 12:36:58 -07:00
|
|
|
nsFrameList& aChildList) MOZ_OVERRIDE;
|
|
|
|
virtual void AppendFrames(ChildListID aListID,
|
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
|
|
|
virtual void InsertFrames(ChildListID aListID,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
|
|
|
virtual void RemoveFrame(ChildListID aListID,
|
|
|
|
nsIFrame* aOldFrame) MOZ_OVERRIDE;
|
2013-07-31 18:59:25 -07:00
|
|
|
virtual const nsFrameList& GetChildList(ChildListID aListID) const MOZ_OVERRIDE;
|
|
|
|
virtual void GetChildLists(nsTArray<ChildList>* aLists) const MOZ_OVERRIDE;
|
2014-06-17 05:19:38 -07:00
|
|
|
virtual nscoord GetLogicalBaseline(mozilla::WritingMode aWritingMode) const MOZ_OVERRIDE;
|
2013-02-11 17:52:55 -08:00
|
|
|
virtual nscoord GetCaretBaseline() const MOZ_OVERRIDE;
|
2013-07-31 18:59:25 -07:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
|
|
|
virtual nsSplittableType GetSplittableType() const MOZ_OVERRIDE;
|
|
|
|
virtual bool IsFloatContainingBlock() const MOZ_OVERRIDE;
|
2013-02-14 03:12:27 -08:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
2013-07-31 18:59:25 -07:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
|
2007-07-25 21:03:29 -07:00
|
|
|
{
|
|
|
|
return nsContainerFrame::IsFrameOfType(aFlags &
|
2008-01-28 23:40:05 -08:00
|
|
|
~(nsIFrame::eCanContainOverflowContainers |
|
|
|
|
nsIFrame::eBlockFrame));
|
2007-07-25 21:03:29 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 18:59:25 -07:00
|
|
|
virtual void InvalidateFrame(uint32_t aDisplayItemKey = 0) MOZ_OVERRIDE;
|
|
|
|
virtual void InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey = 0) MOZ_OVERRIDE;
|
2013-02-10 22:22:20 -08: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;
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsFrameState GetDebugStateBits() const MOZ_OVERRIDE;
|
2014-01-05 15:31:14 -08:00
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
|
|
|
|
// line cursor methods to speed up searching for the line(s)
|
|
|
|
// containing a point. The basic idea is that we set the cursor
|
2010-10-06 21:25:45 -07:00
|
|
|
// property if the lines' overflowArea.VisualOverflow().ys and
|
|
|
|
// overflowArea.VisualOverflow().yMosts are non-decreasing
|
|
|
|
// (considering only non-empty overflowArea.VisualOverflow()s; empty
|
|
|
|
// overflowArea.VisualOverflow()s never participate in event handling
|
|
|
|
// or painting), and the block has sufficient number of lines. The
|
2007-03-22 10:30:00 -07:00
|
|
|
// cursor property points to a "recently used" line. If we get a
|
|
|
|
// series of requests that work on lines
|
|
|
|
// "near" the cursor, then we can find those nearby lines quickly by
|
|
|
|
// starting our search at the cursor.
|
|
|
|
|
|
|
|
// Clear out line cursor because we're disturbing the lines (i.e., Reflow)
|
|
|
|
void ClearLineCursor();
|
2012-07-30 07:20:58 -07:00
|
|
|
// Get the first line that might contain y-coord 'y', or nullptr if you must search
|
2007-03-22 10:30:00 -07:00
|
|
|
// all lines. If nonnull is returned then we guarantee that the lines'
|
|
|
|
// combinedArea.ys and combinedArea.yMosts are non-decreasing.
|
|
|
|
// The actual line returned might not contain 'y', but if not, it is guaranteed
|
|
|
|
// to be before any line which does contain 'y'.
|
|
|
|
nsLineBox* GetFirstLineContaining(nscoord y);
|
|
|
|
// Set the line cursor to our first line. Only call this if you
|
|
|
|
// guarantee that the lines' combinedArea.ys and combinedArea.yMosts
|
|
|
|
// are non-decreasing.
|
|
|
|
void SetupLineCursor();
|
|
|
|
|
2013-07-31 18:59:25 -07:00
|
|
|
virtual void ChildIsDirty(nsIFrame* aChild) MOZ_OVERRIDE;
|
|
|
|
virtual bool IsVisibleInSelection(nsISelection* aSelection) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-31 18:59:25 -07:00
|
|
|
virtual bool IsEmpty() MOZ_OVERRIDE;
|
|
|
|
virtual bool CachedIsEmpty() MOZ_OVERRIDE;
|
|
|
|
virtual bool IsSelfEmpty() MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-11 03:46:36 -07:00
|
|
|
// Given that we have a bullet, does it actually draw something, i.e.,
|
|
|
|
// do we have either a 'list-style-type' or 'list-style-image' that is
|
|
|
|
// not 'none'?
|
2011-09-28 23:19:26 -07:00
|
|
|
bool BulletIsEmpty() const;
|
2011-03-28 06:59:54 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the bullet text equivalent.
|
|
|
|
*/
|
2014-06-11 18:12:00 -07:00
|
|
|
void GetSpokenBulletText(nsAString& aText) const;
|
2009-09-11 03:46:36 -07:00
|
|
|
|
2011-03-28 06:59:54 -07:00
|
|
|
/**
|
|
|
|
* Return true if there's a bullet.
|
|
|
|
*/
|
2012-03-07 17:57:37 -08:00
|
|
|
bool HasBullet() const {
|
|
|
|
return HasOutsideBullet() || HasInsideBullet();
|
|
|
|
}
|
2011-03-28 06:59:54 -07:00
|
|
|
|
2012-05-13 21:51:45 -07:00
|
|
|
/**
|
|
|
|
* @return true if this frame has an inside bullet frame.
|
|
|
|
*/
|
|
|
|
bool HasInsideBullet() const {
|
|
|
|
return 0 != (mState & NS_BLOCK_FRAME_HAS_INSIDE_BULLET);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if this frame has an outside bullet frame.
|
|
|
|
*/
|
|
|
|
bool HasOutsideBullet() const {
|
|
|
|
return 0 != (mState & NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-07-30 07:20:58 -07:00
|
|
|
* @return the bullet frame or nullptr if we don't have one.
|
2012-05-13 21:51:45 -07:00
|
|
|
*/
|
|
|
|
nsBulletFrame* GetBullet() const {
|
|
|
|
nsBulletFrame* outside = GetOutsideBullet();
|
|
|
|
return outside ? outside : GetInsideBullet();
|
|
|
|
}
|
|
|
|
|
2014-07-24 10:03:26 -07:00
|
|
|
virtual void MarkIntrinsicISizesDirty() MOZ_OVERRIDE;
|
2012-06-05 19:13:41 -07:00
|
|
|
private:
|
|
|
|
void CheckIntrinsicCacheAgainstShrinkWrapState();
|
|
|
|
public:
|
2014-07-24 10:03:25 -07:00
|
|
|
virtual nscoord GetMinISize(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetPrefISize(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-31 18:59:25 -07:00
|
|
|
virtual nsRect ComputeTightBounds(gfxContext* aContext) const MOZ_OVERRIDE;
|
2014-06-20 02:55:35 -07:00
|
|
|
|
2013-11-25 06:20:20 -08:00
|
|
|
virtual nsresult GetPrefWidthTightBounds(nsRenderingContext* aContext,
|
|
|
|
nscoord* aX,
|
|
|
|
nscoord* aXMost) MOZ_OVERRIDE;
|
|
|
|
|
2013-07-25 08:34:22 -07:00
|
|
|
/**
|
2014-06-20 02:55:35 -07:00
|
|
|
* Compute the final block size of this frame.
|
2013-07-25 08:34:22 -07:00
|
|
|
*
|
|
|
|
* @param aReflowState Data structure passed from parent during reflow.
|
2014-06-20 02:55:35 -07:00
|
|
|
* @param aReflowStatus A pointer to the reflow status for when we're finished
|
|
|
|
* doing reflow. this will get set appropriately if the block-size
|
|
|
|
* causes us to exceed the current available (page) block-size.
|
|
|
|
* @param aContentBSize The block-size of content, precomputed outside of this
|
|
|
|
* function. The final block-size that is used in aMetrics will be set
|
|
|
|
* to either this or the available block-size, whichever is larger, in
|
|
|
|
* the case where our available block-size is constrained, and we
|
|
|
|
* overflow that available block-size.
|
2013-07-25 08:34:22 -07:00
|
|
|
* @param aBorderPadding The margins representing the border padding for block
|
|
|
|
* frames. Can be 0.
|
2014-06-20 02:55:35 -07:00
|
|
|
* @param aFinalSize Out parameter for final block-size.
|
|
|
|
* @param aConsumed The block-size already consumed by our previous-in-flows.
|
2013-07-25 08:34:22 -07:00
|
|
|
*/
|
2014-06-20 02:55:35 -07:00
|
|
|
void ComputeFinalBSize(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus* aStatus,
|
|
|
|
nscoord aContentBSize,
|
|
|
|
const mozilla::LogicalMargin& aBorderPadding,
|
|
|
|
mozilla::LogicalSize& aFinalSize,
|
|
|
|
nscoord aConsumed);
|
2013-07-25 08:34:22 -07:00
|
|
|
|
2014-05-12 17:47:52 -07:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -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-07-31 18:59:25 -07:00
|
|
|
virtual bool DrainSelfOverflowList() MOZ_OVERRIDE;
|
2012-09-17 16:05:05 -07:00
|
|
|
|
2014-02-06 14:07:48 -08:00
|
|
|
virtual nsresult StealFrame(nsIFrame* aChild,
|
|
|
|
bool aForceNormal = false) MOZ_OVERRIDE;
|
2007-07-25 21:03:29 -07:00
|
|
|
|
2014-02-06 14:07:48 -08:00
|
|
|
virtual void DeleteNextInFlowChild(nsIFrame* aNextInFlow,
|
|
|
|
bool aDeletingEmptyFrames) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-12-13 09:42:43 -08:00
|
|
|
/**
|
|
|
|
* This is a special method that allows a child class of nsBlockFrame to
|
|
|
|
* return a special, customized nsStyleText object to the nsLineLayout
|
|
|
|
* constructor. It is used when the nsBlockFrame child needs to specify its
|
|
|
|
* custom rendering style.
|
|
|
|
*/
|
|
|
|
virtual const nsStyleText* StyleTextForLineLayout();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Determines whether the collapsed margin carried out of the last
|
|
|
|
* line includes the margin-top of a line with clearance (in which
|
|
|
|
* case we must avoid collapsing that margin with our bottom margin)
|
|
|
|
*/
|
2014-06-20 02:55:35 -07:00
|
|
|
bool CheckForCollapsedBEndMarginFromClearanceLine();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static nsresult GetCurrentLine(nsBlockReflowState *aState, nsLineBox **aOutCurrentLine);
|
|
|
|
|
2012-07-20 11:27:04 -07:00
|
|
|
/**
|
|
|
|
* Determine if this block is a margin root at the top/bottom edges.
|
|
|
|
*/
|
2014-06-20 02:55:35 -07:00
|
|
|
void IsMarginRoot(bool* aBStartMarginRoot, bool* aBEndMarginRoot);
|
2012-07-20 11:27:04 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool BlockNeedsFloatManager(nsIFrame* aBlock);
|
2008-01-28 23:40:05 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether aFrame is a block frame that will wrap its contents
|
|
|
|
* around floats intruding on it from the outside. (aFrame need not
|
|
|
|
* be a block frame, but if it's not, the result will be false.)
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool BlockCanIntersectFloats(nsIFrame* aFrame);
|
2008-01-28 23:40:05 -08:00
|
|
|
|
|
|
|
/**
|
2014-10-19 18:44:16 -07:00
|
|
|
* Returns the width that needs to be cleared past floats for blocks
|
|
|
|
* that cannot intersect floats. aState must already have
|
|
|
|
* GetAvailableSpace called on it for the vertical position that we
|
|
|
|
* care about (which need not be its current mY)
|
|
|
|
*/
|
|
|
|
struct ReplacedElementWidthToClear {
|
|
|
|
nscoord marginLeft, borderBoxWidth, marginRight;
|
|
|
|
nscoord MarginBoxWidth() const
|
|
|
|
{ return marginLeft + borderBoxWidth + marginRight; }
|
2008-04-14 18:05:17 -07:00
|
|
|
};
|
2014-10-19 18:44:16 -07:00
|
|
|
static ReplacedElementWidthToClear
|
|
|
|
WidthToClearPastFloats(nsBlockReflowState& aState,
|
|
|
|
const nsRect& aFloatAvailableSpace,
|
2009-04-08 13:52:37 -07:00
|
|
|
nsIFrame* aFrame);
|
2008-01-28 23:40:05 -08:00
|
|
|
|
2009-08-31 11:25:36 -07:00
|
|
|
/**
|
|
|
|
* Creates a contination for aFloat and adds it to the list of overflow floats.
|
|
|
|
* Also updates aState.mReflowStatus to include the float's incompleteness.
|
|
|
|
* Must only be called while this block frame is in reflow.
|
|
|
|
* aFloatStatus must be the float's true, unmodified reflow status.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
nsresult SplitFloat(nsBlockReflowState& aState,
|
|
|
|
nsIFrame* aFloat,
|
|
|
|
nsReflowStatus aFloatStatus);
|
|
|
|
|
2007-10-19 10:41:29 -07:00
|
|
|
/**
|
|
|
|
* Walks up the frame tree, starting with aCandidate, and returns the first
|
|
|
|
* block frame that it encounters.
|
|
|
|
*/
|
|
|
|
static nsBlockFrame* GetNearestAncestorBlock(nsIFrame* aCandidate);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
struct FrameLines {
|
|
|
|
nsLineList mLines;
|
|
|
|
nsFrameList mFrames;
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2014-08-31 20:36:37 -07:00
|
|
|
explicit nsBlockFrame(nsStyleContext* aContext)
|
2011-12-27 12:18:48 -08:00
|
|
|
: nsContainerFrame(aContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
, mMinWidth(NS_INTRINSIC_WIDTH_UNKNOWN)
|
|
|
|
, mPrefWidth(NS_INTRINSIC_WIDTH_UNKNOWN)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
InitDebugFlags();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
virtual ~nsBlockFrame();
|
|
|
|
|
2007-04-15 17:42:54 -07:00
|
|
|
#ifdef DEBUG
|
2007-03-22 10:30:00 -07:00
|
|
|
already_AddRefed<nsStyleContext> GetFirstLetterStyle(nsPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
return aPresContext->StyleSet()->
|
2010-04-30 06:12:06 -07:00
|
|
|
ProbePseudoElementStyle(mContent->AsElement(),
|
2009-12-10 23:37:40 -08:00
|
|
|
nsCSSPseudoElements::ePseudo_firstLetter,
|
|
|
|
mStyleContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-04-15 17:42:54 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(LineCursorProperty, nullptr)
|
2012-05-03 17:14:01 -07:00
|
|
|
nsLineBox* GetLineCursor() {
|
|
|
|
return (GetStateBits() & NS_BLOCK_HAS_LINE_CURSOR) ?
|
2012-07-30 07:20:58 -07:00
|
|
|
static_cast<nsLineBox*>(Properties().Get(LineCursorProperty())) : nullptr;
|
2012-05-03 17:14:01 -07:00
|
|
|
}
|
|
|
|
|
2012-03-10 18:32:27 -08:00
|
|
|
nsLineBox* NewLineBox(nsIFrame* aFrame, bool aIsBlock) {
|
|
|
|
return NS_NewLineBox(PresContext()->PresShell(), aFrame, aIsBlock);
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
nsLineBox* NewLineBox(nsLineBox* aFromLine, nsIFrame* aFrame, int32_t aCount) {
|
2012-03-10 18:32:27 -08:00
|
|
|
return NS_NewLineBox(PresContext()->PresShell(), aFromLine, aFrame, aCount);
|
2012-03-10 18:32:27 -08:00
|
|
|
}
|
|
|
|
void FreeLineBox(nsLineBox* aLine) {
|
2012-05-03 17:14:01 -07:00
|
|
|
if (aLine == GetLineCursor()) {
|
|
|
|
ClearLineCursor();
|
|
|
|
}
|
2012-03-10 18:32:27 -08:00
|
|
|
aLine->Destroy(PresContext()->PresShell());
|
|
|
|
}
|
2013-03-23 13:49:45 -07:00
|
|
|
/**
|
|
|
|
* Helper method for StealFrame.
|
|
|
|
*/
|
|
|
|
void RemoveFrameFromLine(nsIFrame* aChild, nsLineList::iterator aLine,
|
|
|
|
nsFrameList& aFrameList, nsLineList& aLineList);
|
2012-03-10 18:32:27 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void TryAllLines(nsLineList::iterator* aIterator,
|
2007-10-07 10:32:07 -07:00
|
|
|
nsLineList::iterator* aStartIterator,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsLineList::iterator* aEndIterator,
|
2012-03-07 17:57:37 -08:00
|
|
|
bool* aInOverflowLines,
|
|
|
|
FrameLines** aOverflowLines);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-11-30 10:19:57 -08:00
|
|
|
void SetFlags(nsFrameState aFlags) {
|
2007-03-22 10:30:00 -07:00
|
|
|
mState &= ~NS_BLOCK_FLAGS_MASK;
|
|
|
|
mState |= aFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** move the frames contained by aLine by aDY
|
|
|
|
* if aLine is a block, its child floats are added to the state manager
|
|
|
|
*/
|
|
|
|
void SlideLine(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine, nscoord aDY);
|
|
|
|
|
2013-05-09 17:23:28 -07:00
|
|
|
void ComputeFinalSize(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsBlockReflowState& aState,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nscoord* aBottomEdgeOfChildren);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-15 14:03:49 -07:00
|
|
|
void ComputeOverflowAreas(const nsRect& aBounds,
|
|
|
|
const nsStyleDisplay* aDisplay,
|
|
|
|
nscoord aBottomEdgeOfChildren,
|
|
|
|
nsOverflowAreas& aOverflowAreas);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-03-23 13:10:34 -07:00
|
|
|
/**
|
|
|
|
* Add the frames in aFrameList to this block after aPrevSibling.
|
|
|
|
* This block thinks in terms of lines, but the frame construction code
|
|
|
|
* knows nothing about lines at all so we need to find the line that
|
|
|
|
* contains aPrevSibling and add aFrameList after aPrevSibling on that line.
|
|
|
|
* New lines are created as necessary to handle block data in aFrameList.
|
|
|
|
* This function will clear aFrameList.
|
|
|
|
*/
|
|
|
|
void AddFrames(nsFrameList& aFrameList, nsIFrame* aPrevSibling);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-05-28 07:40:56 -07:00
|
|
|
/**
|
|
|
|
* Perform Bidi resolution on this frame
|
|
|
|
*/
|
|
|
|
nsresult ResolveBidi();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Test whether the frame is a form control in a visual Bidi page.
|
|
|
|
* This is necessary for backwards-compatibility, because most visual
|
|
|
|
* pages use logical order for form controls so that they will
|
|
|
|
* display correctly on native widgets in OSs with Bidi support
|
|
|
|
* @param aPresContext the pres context
|
|
|
|
* @return whether the frame is a BIDI form control
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsVisualFormControl(nsPresContext* aPresContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
public:
|
2008-12-02 17:27:19 -08:00
|
|
|
/**
|
|
|
|
* Does all the real work for removing aDeletedFrame
|
|
|
|
* -- finds the line containing aDeletedFrame
|
|
|
|
* -- removes all aDeletedFrame next-in-flows (or all continuations,
|
|
|
|
* if REMOVE_FIXED_CONTINUATIONS is given)
|
|
|
|
* -- marks lines dirty as needed
|
|
|
|
* -- marks textruns dirty (unless FRAMES_ARE_EMPTY is given, in which
|
|
|
|
* case textruns do not need to be dirtied)
|
2009-08-31 11:25:35 -07:00
|
|
|
* -- destroys all removed frames
|
2008-12-02 17:27:19 -08:00
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
REMOVE_FIXED_CONTINUATIONS = 0x02,
|
|
|
|
FRAMES_ARE_EMPTY = 0x04
|
|
|
|
};
|
2014-05-28 12:36:58 -07:00
|
|
|
void DoRemoveFrame(nsIFrame* aDeletedFrame, uint32_t aFlags);
|
2007-04-20 17:42:58 -07:00
|
|
|
|
2013-02-27 15:05:45 -08:00
|
|
|
void ReparentFloats(nsIFrame* aFirstFrame, nsBlockFrame* aOldParent,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aReparentSiblings);
|
2007-04-20 17:42:58 -07:00
|
|
|
|
2013-07-31 18:59:25 -07:00
|
|
|
virtual bool UpdateOverflow() MOZ_OVERRIDE;
|
2011-06-15 14:03:49 -07:00
|
|
|
|
2009-08-31 11:25:36 -07:00
|
|
|
/** Load all of aFrame's floats into the float manager iff aFrame is not a
|
|
|
|
* block formatting context. Handles all necessary float manager translations;
|
|
|
|
* assumes float manager is in aFrame's parent's coord system.
|
|
|
|
* Safe to call on non-blocks (does nothing).
|
|
|
|
*/
|
2014-10-21 15:16:12 -07:00
|
|
|
static void RecoverFloatsFor(nsIFrame* aFrame,
|
|
|
|
nsFloatManager& aFloatManager,
|
|
|
|
mozilla::WritingMode aWM,
|
|
|
|
nscoord aContainerWidth);
|
2009-08-31 11:25:36 -07:00
|
|
|
|
2013-03-19 07:05:05 -07:00
|
|
|
/**
|
|
|
|
* Determine if we have any pushed floats from a previous continuation.
|
|
|
|
*
|
|
|
|
* @returns true, if any of the floats at the beginning of our mFloats list
|
|
|
|
* have the NS_FRAME_IS_PUSHED_FLOAT bit set; false otherwise.
|
|
|
|
*/
|
|
|
|
bool HasPushedFloatsFromPrevContinuation() const {
|
|
|
|
if (!mFloats.IsEmpty()) {
|
|
|
|
// If we have pushed floats, then they should be at the beginning of our
|
|
|
|
// float list.
|
2013-03-19 10:36:05 -07:00
|
|
|
if (mFloats.FirstChild()->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT) {
|
2013-03-19 07:05:05 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Double-check the above assertion that pushed floats should be at the
|
|
|
|
// beginning of our floats list.
|
2013-03-19 10:36:05 -07:00
|
|
|
for (nsFrameList::Enumerator e(mFloats); !e.AtEnd(); e.Next()) {
|
|
|
|
nsIFrame* f = e.get();
|
|
|
|
NS_ASSERTION(!(f->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT),
|
2013-03-19 07:05:05 -07:00
|
|
|
"pushed floats must be at the beginning of the float list");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
|
|
|
|
/** grab overflow lines from this block's prevInFlow, and make them
|
|
|
|
* part of this block's mLines list.
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true if any lines were drained.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-01-30 15:35:03 -08:00
|
|
|
bool DrainOverflowLines();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-27 15:05:45 -08:00
|
|
|
/**
|
|
|
|
* @return false iff this block does not have a float on any child list.
|
|
|
|
* This function is O(1).
|
|
|
|
*/
|
|
|
|
bool MaybeHasFloats() const {
|
|
|
|
if (!mFloats.IsEmpty()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// XXX this could be replaced with HasPushedFloats() if we enforced
|
|
|
|
// removing the property when the frame list becomes empty.
|
|
|
|
nsFrameList* list = GetPushedFloats();
|
|
|
|
if (list && !list->IsEmpty()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// For the OverflowOutOfFlowsProperty I think we do enforce that, but it's
|
|
|
|
// a mix of out-of-flow frames, so that's why the method name has "Maybe".
|
|
|
|
return GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS;
|
|
|
|
}
|
|
|
|
|
2010-08-05 21:59:20 -07:00
|
|
|
/** grab pushed floats from this block's prevInFlow, and splice
|
2009-08-31 11:25:36 -07:00
|
|
|
* them into this block's mFloats list.
|
|
|
|
*/
|
2010-08-05 21:59:20 -07:00
|
|
|
void DrainPushedFloats(nsBlockReflowState& aState);
|
2009-08-31 11:25:36 -07:00
|
|
|
|
|
|
|
/** Load all our floats into the float manager (without reflowing them).
|
|
|
|
* Assumes float manager is in our own coordinate system.
|
|
|
|
*/
|
2014-10-21 15:16:12 -07:00
|
|
|
void RecoverFloats(nsFloatManager& aFloatManager,
|
|
|
|
mozilla::WritingMode aWM,
|
|
|
|
nscoord aContainerWidth);
|
2009-08-31 11:25:36 -07:00
|
|
|
|
2010-08-05 21:59:20 -07:00
|
|
|
/** Reflow pushed floats
|
2009-08-31 11:25:36 -07:00
|
|
|
*/
|
2013-06-18 23:09:22 -07:00
|
|
|
void ReflowPushedFloats(nsBlockReflowState& aState,
|
|
|
|
nsOverflowAreas& aOverflowAreas,
|
|
|
|
nsReflowStatus& aStatus);
|
2009-08-31 11:25:36 -07:00
|
|
|
|
2009-08-31 11:25:36 -07:00
|
|
|
/** Find any trailing BR clear from the last line of the block (or its PIFs)
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t FindTrailingClear();
|
2009-08-31 11:25:36 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2013-03-15 15:32:35 -07:00
|
|
|
* Remove a float from our float list.
|
|
|
|
*/
|
2013-02-27 15:05:45 -08:00
|
|
|
void RemoveFloat(nsIFrame* aFloat);
|
2013-03-15 15:32:35 -07:00
|
|
|
/**
|
|
|
|
* Remove a float from the float cache for the line its placeholder is on.
|
|
|
|
*/
|
|
|
|
void RemoveFloatFromFloatCache(nsIFrame* aFloat);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-18 04:09:36 -07:00
|
|
|
void CollectFloats(nsIFrame* aFrame, nsFrameList& aList,
|
2013-02-27 15:05:45 -08:00
|
|
|
bool aCollectFromSiblings) {
|
|
|
|
if (MaybeHasFloats()) {
|
|
|
|
DoCollectFloats(aFrame, aList, aCollectFromSiblings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void DoCollectFloats(nsIFrame* aFrame, nsFrameList& aList,
|
|
|
|
bool aCollectFromSiblings);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Remove a float, abs, rel positioned frame from the appropriate block's list
|
|
|
|
static void DoRemoveOutOfFlowFrame(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/** set up the conditions necessary for an resize reflow
|
|
|
|
* the primary task is to mark the minimumly sufficient lines dirty.
|
|
|
|
*/
|
2013-06-18 23:09:22 -07:00
|
|
|
void PrepareResizeReflow(nsBlockReflowState& aState);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** reflow all lines that have been marked dirty */
|
2014-05-12 17:47:53 -07:00
|
|
|
void ReflowDirtyLines(nsBlockReflowState& aState);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-04-21 16:53:52 -07:00
|
|
|
/** Mark a given line dirty due to reflow being interrupted on or before it */
|
|
|
|
void MarkLineDirtyForInterrupt(nsLineBox* aLine);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------
|
|
|
|
// Methods for line reflow
|
|
|
|
/**
|
|
|
|
* Reflow a line.
|
|
|
|
* @param aState the current reflow state
|
|
|
|
* @param aLine the line to reflow. can contain a single block frame
|
|
|
|
* or contain 1 or more inline frames.
|
|
|
|
* @param aKeepReflowGoing [OUT] indicates whether the caller should continue to reflow more lines
|
|
|
|
*/
|
2014-05-12 17:47:52 -07:00
|
|
|
void ReflowLine(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine,
|
|
|
|
bool* aKeepReflowGoing);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-05-20 04:21:34 -07:00
|
|
|
// Return false if it needs another reflow because of reduced space
|
|
|
|
// between floats that are next to it (but not next to its top), and
|
|
|
|
// return true otherwise.
|
2014-10-19 18:44:16 -07:00
|
|
|
bool PlaceLine(nsBlockReflowState& aState,
|
|
|
|
nsLineLayout& aLineLayout,
|
|
|
|
line_iterator aLine,
|
2009-05-20 04:21:34 -07:00
|
|
|
nsFloatManager::SavedState* aFloatStateBeforeLine,
|
2014-10-19 18:44:16 -07:00
|
|
|
nsRect& aFloatAvailableSpace, /* in-out */
|
|
|
|
nscoord& aAvailableSpaceHeight, /* in-out */
|
|
|
|
bool* aKeepReflowGoing);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-13 15:37:00 -07:00
|
|
|
/**
|
|
|
|
* If NS_BLOCK_LOOK_FOR_DIRTY_FRAMES is set, call MarkLineDirty
|
|
|
|
* on any line with a child frame that is dirty.
|
|
|
|
*/
|
|
|
|
void LazyMarkLinesDirty();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Mark |aLine| dirty, and, if necessary because of possible
|
2007-11-08 22:55:32 -08:00
|
|
|
* pull-up, mark the previous line dirty as well. Also invalidates textruns
|
|
|
|
* on those lines because the text in the lines might have changed due to
|
|
|
|
* addition/removal of frames.
|
2008-10-12 12:26:06 -07:00
|
|
|
* @param aLine the line to mark dirty
|
2012-07-20 11:27:03 -07:00
|
|
|
* @param aLineList the line list containing that line
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-07-20 11:27:03 -07:00
|
|
|
void MarkLineDirty(line_iterator aLine, const nsLineList* aLineList);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// XXX where to go
|
2012-01-12 09:52:21 -08:00
|
|
|
bool IsLastLine(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void DeleteLine(nsBlockReflowState& aState,
|
|
|
|
nsLineList::iterator aLine,
|
|
|
|
nsLineList::iterator aLineEnd);
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
// Methods for individual frame reflow
|
|
|
|
|
2014-06-20 02:55:35 -07:00
|
|
|
bool ShouldApplyBStartMargin(nsBlockReflowState& aState,
|
2014-06-24 10:52:19 -07:00
|
|
|
nsLineBox* aLine,
|
|
|
|
nsIFrame* aChildFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-12 17:47:52 -07:00
|
|
|
void ReflowBlockFrame(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine,
|
|
|
|
bool* aKeepGoing);
|
|
|
|
|
|
|
|
void ReflowInlineFrames(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine,
|
|
|
|
bool* aKeepLineGoing);
|
|
|
|
|
|
|
|
void DoReflowInlineFrames(nsBlockReflowState& aState,
|
|
|
|
nsLineLayout& aLineLayout,
|
2007-03-22 10:30:00 -07:00
|
|
|
line_iterator aLine,
|
2014-05-12 17:47:52 -07:00
|
|
|
nsFlowAreaRect& aFloatAvailableSpace,
|
|
|
|
nscoord& aAvailableSpaceHeight,
|
|
|
|
nsFloatManager::SavedState*
|
|
|
|
aFloatStateBeforeLine,
|
|
|
|
bool* aKeepReflowGoing,
|
|
|
|
LineReflowStatus* aLineReflowStatus,
|
|
|
|
bool aAllowPullUp);
|
|
|
|
|
|
|
|
void ReflowInlineFrame(nsBlockReflowState& aState,
|
|
|
|
nsLineLayout& aLineLayout,
|
|
|
|
line_iterator aLine,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
LineReflowStatus* aLineReflowStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-10-19 18:44:16 -07:00
|
|
|
// Compute the available width for a float.
|
|
|
|
nsRect AdjustFloatAvailableSpace(nsBlockReflowState& aState,
|
|
|
|
const nsRect& aFloatAvailableSpace,
|
|
|
|
nsIFrame* aFloatFrame);
|
|
|
|
// Computes the border-box width of the float
|
|
|
|
nscoord ComputeFloatWidth(nsBlockReflowState& aState,
|
|
|
|
const nsRect& aFloatAvailableSpace,
|
|
|
|
nsIFrame* aFloat);
|
2007-03-22 10:30:00 -07:00
|
|
|
// An incomplete aReflowStatus indicates the float should be split
|
|
|
|
// but only if the available height is constrained.
|
2010-08-05 21:59:18 -07:00
|
|
|
// aAdjustedAvailableSpace is the result of calling
|
|
|
|
// nsBlockFrame::AdjustFloatAvailableSpace.
|
2014-10-19 18:44:16 -07:00
|
|
|
void ReflowFloat(nsBlockReflowState& aState,
|
|
|
|
const nsRect& aAdjustedAvailableSpace,
|
|
|
|
nsIFrame* aFloat,
|
|
|
|
nsMargin& aFloatMargin,
|
|
|
|
nsMargin& aFloatOffsets,
|
2014-05-12 17:47:52 -07:00
|
|
|
// Whether the float's position
|
|
|
|
// (aAdjustedAvailableSpace) has been pushed down
|
|
|
|
// due to the presence of other floats.
|
2014-10-19 18:44:16 -07:00
|
|
|
bool aFloatPushedDown,
|
|
|
|
nsReflowStatus& aReflowStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
// Methods for pushing/pulling lines/frames
|
|
|
|
|
2009-09-18 04:09:35 -07:00
|
|
|
/**
|
|
|
|
* Create a next-in-flow, if necessary, for aFrame. If a new frame is
|
|
|
|
* created, place it in aLine if aLine is not null.
|
|
|
|
* @param aState the block reflow state
|
|
|
|
* @param aLine where to put a new frame
|
|
|
|
* @param aFrame the frame
|
2013-06-18 23:09:20 -07:00
|
|
|
* @return true if a new frame was created, false if not
|
2009-09-18 04:09:35 -07:00
|
|
|
*/
|
2013-06-18 23:09:20 -07:00
|
|
|
bool CreateContinuationFor(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nsIFrame* aFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-11-08 08:09:38 -08:00
|
|
|
/**
|
|
|
|
* Push aLine (and any after it), since it cannot be placed on this
|
|
|
|
* page/column. Set aKeepReflowGoing to false and set
|
|
|
|
* flag aState.mReflowStatus as incomplete.
|
|
|
|
*/
|
2010-08-05 21:59:20 -07:00
|
|
|
void PushTruncatedLine(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine,
|
2012-11-08 08:09:38 -08:00
|
|
|
bool* aKeepReflowGoing);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-06-18 23:09:22 -07:00
|
|
|
void SplitLine(nsBlockReflowState& aState,
|
|
|
|
nsLineLayout& aLineLayout,
|
|
|
|
line_iterator aLine,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
LineReflowStatus* aLineReflowStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-01-11 06:08:23 -08:00
|
|
|
/**
|
|
|
|
* Pull a frame from the next available location (one of our lines or
|
|
|
|
* one of our next-in-flows lines).
|
2012-07-30 07:20:58 -07:00
|
|
|
* @return the pulled frame or nullptr
|
2010-01-11 06:08:23 -08:00
|
|
|
*/
|
|
|
|
nsIFrame* PullFrame(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to pull a frame out of a line pointed at by aFromLine.
|
|
|
|
*
|
|
|
|
* Note: pulling a frame from a line that is a place-holder frame
|
|
|
|
* doesn't automatically remove the corresponding float from the
|
|
|
|
* line's float array. This happens indirectly: either the line gets
|
|
|
|
* emptied (and destroyed) or the line gets reflowed (because we mark
|
|
|
|
* it dirty) and the code at the top of ReflowLine empties the
|
|
|
|
* array. So eventually, it will be removed, just not right away.
|
|
|
|
*
|
2012-07-30 07:20:58 -07:00
|
|
|
* @return the pulled frame or nullptr
|
2010-01-11 06:08:23 -08:00
|
|
|
*/
|
2013-02-27 15:05:46 -08:00
|
|
|
nsIFrame* PullFrameFrom(nsLineBox* aLine,
|
2010-01-11 06:08:23 -08:00
|
|
|
nsBlockFrame* aFromContainer,
|
|
|
|
nsLineList::iterator aFromLine);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
/**
|
|
|
|
* Push the line after aLineBefore to the overflow line list.
|
|
|
|
* @param aLineBefore a line in 'mLines' (or begin_lines() when
|
|
|
|
* pushing the first line)
|
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
void PushLines(nsBlockReflowState& aState,
|
|
|
|
nsLineList::iterator aLineBefore);
|
|
|
|
|
|
|
|
void PropagateFloatDamage(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
2014-10-19 18:44:16 -07:00
|
|
|
nscoord aDeltaY);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void CheckFloats(nsBlockReflowState& aState);
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
// List handling kludge
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
// If this returns true, the block it's called on should get the
|
2007-05-06 12:16:51 -07:00
|
|
|
// NS_FRAME_HAS_DIRTY_CHILDREN bit set on it by the caller; either directly
|
|
|
|
// if it's already in reflow, or via calling FrameNeedsReflow() to schedule a
|
|
|
|
// reflow.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool RenumberLists(nsPresContext* aPresContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool RenumberListsInBlock(nsPresContext* aPresContext,
|
2012-09-07 19:30:24 -07:00
|
|
|
nsBlockFrame* aBlockFrame,
|
|
|
|
int32_t* aOrdinal,
|
|
|
|
int32_t aDepth,
|
|
|
|
int32_t aIncrement);
|
|
|
|
|
|
|
|
static bool RenumberListsFor(nsPresContext* aPresContext, nsIFrame* aKid,
|
|
|
|
int32_t* aOrdinal, int32_t aDepth,
|
|
|
|
int32_t aIncrement);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool FrameStartsCounterScope(nsIFrame* aFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
void ReflowBullet(nsIFrame* aBulletFrame,
|
|
|
|
nsBlockReflowState& aState,
|
2008-02-10 13:49:24 -08:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nscoord aLineTop);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
2013-07-31 18:59:25 -07:00
|
|
|
virtual nsILineIterator* GetLineIterator() MOZ_OVERRIDE;
|
2008-10-30 12:17:59 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2012-03-07 17:57:37 -08:00
|
|
|
bool HasOverflowLines() const {
|
|
|
|
return 0 != (GetStateBits() & NS_BLOCK_HAS_OVERFLOW_LINES);
|
|
|
|
}
|
|
|
|
FrameLines* GetOverflowLines() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2012-03-07 17:57:37 -08:00
|
|
|
FrameLines* RemoveOverflowLines();
|
|
|
|
void SetOverflowLines(FrameLines* aOverflowLines);
|
|
|
|
void DestroyOverflowLines();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This class is useful for efficiently modifying the out of flow
|
|
|
|
* overflow list. It gives the client direct writable access to
|
|
|
|
* the frame list temporarily but ensures that property is only
|
|
|
|
* written back if absolutely necessary.
|
|
|
|
*/
|
|
|
|
struct nsAutoOOFFrameList {
|
|
|
|
nsFrameList mList;
|
|
|
|
|
2014-08-31 20:36:37 -07:00
|
|
|
explicit nsAutoOOFFrameList(nsBlockFrame* aBlock)
|
2009-09-23 19:39:21 -07:00
|
|
|
: mPropValue(aBlock->GetOverflowOutOfFlows())
|
|
|
|
, mBlock(aBlock) {
|
|
|
|
if (mPropValue) {
|
|
|
|
mList = *mPropValue;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2009-09-23 19:39:21 -07:00
|
|
|
~nsAutoOOFFrameList() {
|
|
|
|
mBlock->SetOverflowOutOfFlows(mList, mPropValue);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2009-09-23 19:39:21 -07:00
|
|
|
nsFrameList* const mPropValue;
|
2009-09-18 04:09:36 -07:00
|
|
|
nsBlockFrame* const mBlock;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
friend struct nsAutoOOFFrameList;
|
|
|
|
|
2009-09-23 19:39:21 -07:00
|
|
|
nsFrameList* GetOverflowOutOfFlows() const;
|
|
|
|
void SetOverflowOutOfFlows(const nsFrameList& aList, nsFrameList* aPropValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
/**
|
2012-07-30 07:20:58 -07:00
|
|
|
* @return the inside bullet frame or nullptr if we don't have one.
|
2012-03-07 17:57:37 -08:00
|
|
|
*/
|
|
|
|
nsBulletFrame* GetInsideBullet() const;
|
|
|
|
|
|
|
|
/**
|
2012-07-30 07:20:58 -07:00
|
|
|
* @return the outside bullet frame or nullptr if we don't have one.
|
2012-03-07 17:57:37 -08:00
|
|
|
*/
|
|
|
|
nsBulletFrame* GetOutsideBullet() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the outside bullet frame list frame property.
|
|
|
|
*/
|
|
|
|
nsFrameList* GetOutsideBulletList() const;
|
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
/**
|
|
|
|
* @return true if this frame has pushed floats.
|
|
|
|
*/
|
|
|
|
bool HasPushedFloats() const {
|
|
|
|
return 0 != (GetStateBits() & NS_BLOCK_HAS_PUSHED_FLOATS);
|
|
|
|
}
|
|
|
|
|
2013-01-11 14:51:21 -08:00
|
|
|
// Get the pushed floats list, which is used for *temporary* storage
|
|
|
|
// of floats during reflow, between when we decide they don't fit in
|
|
|
|
// this block until our next continuation takes them.
|
2010-08-05 21:59:20 -07:00
|
|
|
nsFrameList* GetPushedFloats() const;
|
|
|
|
// Get the pushed floats list, or if there is not currently one,
|
2010-08-05 21:59:19 -07:00
|
|
|
// make a new empty one.
|
2010-08-05 21:59:20 -07:00
|
|
|
nsFrameList* EnsurePushedFloats();
|
|
|
|
// Remove and return the pushed floats list.
|
|
|
|
nsFrameList* RemovePushedFloats();
|
2010-08-05 21:59:19 -07:00
|
|
|
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2011-09-28 23:19:26 -07:00
|
|
|
void VerifyLines(bool aFinalCheckOK);
|
2007-03-22 10:30:00 -07:00
|
|
|
void VerifyOverflowSituation();
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetDepth() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
nscoord mMinWidth, mPrefWidth;
|
|
|
|
|
|
|
|
nsLineList mLines;
|
|
|
|
|
|
|
|
// List of all floats in this block
|
2012-03-07 17:57:37 -08:00
|
|
|
// XXXmats blocks rarely have floats, make it a frame property
|
2007-03-22 10:30:00 -07:00
|
|
|
nsFrameList mFloats;
|
|
|
|
|
|
|
|
friend class nsBlockReflowState;
|
2007-08-22 02:08:13 -07:00
|
|
|
friend class nsBlockInFlowLineIterator;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
public:
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool gLamePaintMetrics;
|
|
|
|
static bool gLameReflowMetrics;
|
|
|
|
static bool gNoisy;
|
|
|
|
static bool gNoisyDamageRepair;
|
|
|
|
static bool gNoisyIntrinsic;
|
|
|
|
static bool gNoisyReflow;
|
|
|
|
static bool gReallyNoisyReflow;
|
|
|
|
static bool gNoisyFloatManager;
|
|
|
|
static bool gVerifyLines;
|
|
|
|
static bool gDisableResizeOpt;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t gNoiseIndent;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static const char* kReflowCommandType[];
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void InitDebugFlags();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
class AutoNoisyIndenter {
|
|
|
|
public:
|
2014-08-31 20:36:37 -07:00
|
|
|
explicit AutoNoisyIndenter(bool aDoIndent) : mIndented(aDoIndent) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mIndented) {
|
|
|
|
nsBlockFrame::gNoiseIndent++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
~AutoNoisyIndenter() {
|
|
|
|
if (mIndented) {
|
|
|
|
nsBlockFrame::gNoiseIndent--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private:
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIndented;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2007-08-22 02:08:13 -07:00
|
|
|
/**
|
|
|
|
* Iterates over all lines in the prev-in-flows/next-in-flows of this block.
|
|
|
|
*/
|
|
|
|
class nsBlockInFlowLineIterator {
|
|
|
|
public:
|
|
|
|
typedef nsBlockFrame::line_iterator line_iterator;
|
2012-03-07 17:57:37 -08:00
|
|
|
/**
|
|
|
|
* Set up the iterator to point to aLine which must be a normal line
|
|
|
|
* in aFrame (not an overflow line).
|
|
|
|
*/
|
|
|
|
nsBlockInFlowLineIterator(nsBlockFrame* aFrame, line_iterator aLine);
|
2008-02-27 01:53:48 -08:00
|
|
|
/**
|
|
|
|
* Set up the iterator to point to the first line found starting from
|
|
|
|
* aFrame. Sets aFoundValidLine to false if there is no such line.
|
2010-09-17 12:09:08 -07:00
|
|
|
* After aFoundValidLine has returned false, don't call any methods on this
|
|
|
|
* object again.
|
2008-02-27 01:53:48 -08:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
nsBlockInFlowLineIterator(nsBlockFrame* aFrame, bool* aFoundValidLine);
|
2008-02-27 01:53:48 -08:00
|
|
|
/**
|
|
|
|
* Set up the iterator to point to the line that contains aFindFrame (either
|
|
|
|
* directly or indirectly). If aFrame is out of flow, or contained in an
|
|
|
|
* out-of-flow, finds the line containing the out-of-flow's placeholder. If
|
2010-09-17 12:09:08 -07:00
|
|
|
* the frame is not found, sets aFoundValidLine to false. After
|
|
|
|
* aFoundValidLine has returned false, don't call any methods on this
|
|
|
|
* object again.
|
2008-02-27 01:53:48 -08:00
|
|
|
*/
|
|
|
|
nsBlockInFlowLineIterator(nsBlockFrame* aFrame, nsIFrame* aFindFrame,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aFoundValidLine);
|
2008-02-27 01:53:48 -08:00
|
|
|
|
2007-08-22 02:08:13 -07:00
|
|
|
line_iterator GetLine() { return mLine; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsLastLineInList();
|
2007-08-22 02:08:13 -07:00
|
|
|
nsBlockFrame* GetContainer() { return mFrame; }
|
2012-07-20 11:27:03 -07:00
|
|
|
bool GetInOverflow() { return mLineList != &mFrame->mLines; }
|
2008-04-11 22:32:49 -07:00
|
|
|
|
2008-10-12 12:26:06 -07:00
|
|
|
/**
|
|
|
|
* Returns the current line list we're iterating, null means
|
|
|
|
* we're iterating |mLines| of the container.
|
|
|
|
*/
|
2012-07-20 11:27:03 -07:00
|
|
|
nsLineList* GetLineList() { return mLineList; }
|
2008-04-11 22:32:49 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the end-iterator of whatever line list we're in.
|
|
|
|
*/
|
|
|
|
line_iterator End();
|
|
|
|
|
2007-08-22 02:08:13 -07:00
|
|
|
/**
|
|
|
|
* Returns false if there are no more lines. After this has returned false,
|
|
|
|
* don't call any methods on this object again.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool Next();
|
2007-08-22 02:08:13 -07:00
|
|
|
/**
|
|
|
|
* Returns false if there are no more lines. After this has returned false,
|
|
|
|
* don't call any methods on this object again.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool Prev();
|
2007-08-22 02:08:13 -07:00
|
|
|
|
|
|
|
private:
|
2012-03-07 17:57:37 -08:00
|
|
|
friend class nsBlockFrame;
|
|
|
|
// XXX nsBlockFrame uses this internally in one place. Try to remove it.
|
|
|
|
nsBlockInFlowLineIterator(nsBlockFrame* aFrame, line_iterator aLine, bool aInOverflow);
|
|
|
|
|
2007-08-22 02:08:13 -07:00
|
|
|
nsBlockFrame* mFrame;
|
|
|
|
line_iterator mLine;
|
2012-07-20 11:27:03 -07:00
|
|
|
nsLineList* mLineList; // the line list mLine is in
|
2008-02-23 23:31:29 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Moves iterator to next valid line reachable from the current block.
|
|
|
|
* Returns false if there are no valid lines.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool FindValidLine();
|
2007-08-22 02:08:13 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsBlockFrame_h___ */
|