2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2001-10-25 01:08:40 +00:00
|
|
|
// vim:cindent:ts=2:et:sw=2:
|
2001-09-28 20:14:13 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-11-16 17:11:12 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-11-16 17:11:12 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-11-16 17:11:12 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-29 18:29:03 +00:00
|
|
|
|
|
|
|
/*
|
2007-12-12 21:49:14 +00:00
|
|
|
* rendering object for CSS display:block, inline-block, and list-item
|
|
|
|
* boxes, also used for various anonymous boxes
|
2006-03-29 18:29:03 +00:00
|
|
|
*/
|
|
|
|
|
1998-11-16 17:11:12 +00:00
|
|
|
#ifndef nsBlockFrame_h___
|
|
|
|
#define nsBlockFrame_h___
|
|
|
|
|
|
|
|
#include "nsHTMLContainerFrame.h"
|
1999-11-03 00:42:12 +00:00
|
|
|
#include "nsHTMLParts.h"
|
2000-05-09 05:11:12 +00:00
|
|
|
#include "nsAbsoluteContainingBlock.h"
|
2001-10-25 01:08:40 +00:00
|
|
|
#include "nsLineBox.h"
|
2003-04-12 16:06:54 +00:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2004-01-28 00:18:22 +00:00
|
|
|
#include "nsStyleSet.h"
|
2009-05-20 11:21:34 +00:00
|
|
|
#include "nsFloatManager.h"
|
1998-11-16 17:11:12 +00:00
|
|
|
|
2006-06-29 01:19:48 +00: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 11:21:34 +00: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,
|
2006-06-29 01:19:48 +00: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
|
|
|
|
};
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
class nsBlockReflowState;
|
2007-08-22 09:08:13 +00:00
|
|
|
class nsBlockInFlowLineIterator;
|
1998-12-05 16:02:08 +00:00
|
|
|
class nsBulletFrame;
|
|
|
|
class nsLineBox;
|
1999-04-20 00:27:43 +00:00
|
|
|
class nsFirstLineFrame;
|
2001-10-25 01:08:40 +00:00
|
|
|
class nsIntervalSet;
|
1998-11-18 06:13:58 +00:00
|
|
|
/**
|
|
|
|
* Child list name indices
|
|
|
|
* @see #GetAdditionalChildListName()
|
|
|
|
*/
|
2010-08-06 04:59:19 +00:00
|
|
|
#define NS_BLOCK_LIST_COUNT (NS_CONTAINER_LIST_COUNT_INCL_OC + 5)
|
1998-11-18 06:13:58 +00:00
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
/**
|
|
|
|
* 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-06 04:59:19 +00:00
|
|
|
* -- While a block is being reflowed, and from then until
|
|
|
|
* its next-in-flow is reflowed it may have a
|
2010-08-06 04:59:20 +00:00
|
|
|
* PushedFloatProperty frame property that points to
|
2010-08-06 04:59:19 +00:00
|
|
|
* an nsFrameList. This list contains continuations for
|
2009-08-31 18:25:36 +00:00
|
|
|
* floats whose prev-in-flow is in the block's regular float
|
2010-08-06 04:59:19 +00: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.
|
2005-03-23 03:35:08 +00: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.
|
|
|
|
*/
|
|
|
|
|
2004-08-26 03:07:05 +00:00
|
|
|
// see nsHTMLParts.h for the public block state bits
|
2007-10-11 11:41:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Something in the block has changed that requires Bidi resolution to be
|
|
|
|
* performed on the block. This flag must be either set on all blocks in a
|
|
|
|
* continuation chain or none of them.
|
|
|
|
*/
|
2010-06-09 05:28:14 +00:00
|
|
|
#define NS_BLOCK_NEEDS_BIDI_RESOLUTION NS_FRAME_STATE_BIT(20)
|
2010-08-06 04:59:20 +00:00
|
|
|
#define NS_BLOCK_HAS_PUSHED_FLOATS NS_FRAME_STATE_BIT(21)
|
2010-06-09 05:28:14 +00:00
|
|
|
#define NS_BLOCK_HAS_LINE_CURSOR NS_FRAME_STATE_BIT(24)
|
|
|
|
#define NS_BLOCK_HAS_OVERFLOW_LINES NS_FRAME_STATE_BIT(25)
|
|
|
|
#define NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS NS_FRAME_STATE_BIT(26)
|
2004-08-26 03:07:05 +00:00
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
// Set on any block that has descendant frames in the normal
|
|
|
|
// flow with 'clear' set to something other than 'none'
|
|
|
|
// (including <BR CLEAR="..."> frames)
|
2010-06-09 05:28:14 +00:00
|
|
|
#define NS_BLOCK_HAS_CLEAR_CHILDREN NS_FRAME_STATE_BIT(27)
|
2004-11-25 14:51:00 +00:00
|
|
|
|
1999-02-09 17:31:33 +00:00
|
|
|
#define nsBlockFrameSuper nsHTMLContainerFrame
|
1998-12-05 16:02:08 +00:00
|
|
|
|
2000-05-09 05:11:12 +00:00
|
|
|
/*
|
|
|
|
* Base class for block and inline frames.
|
|
|
|
* The block frame has an additional named child list:
|
|
|
|
* - "Absolute-list" which contains the absolutely positioned frames
|
|
|
|
*
|
2007-01-30 00:06:41 +00:00
|
|
|
* @see nsGkAtoms::absoluteList
|
2000-05-09 05:11:12 +00:00
|
|
|
*/
|
1999-02-09 17:31:33 +00:00
|
|
|
class nsBlockFrame : public nsBlockFrameSuper
|
1998-11-16 17:11:12 +00:00
|
|
|
{
|
2001-10-25 01:08:40 +00:00
|
|
|
public:
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsBlockFrame)
|
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2009-01-12 19:20:59 +00:00
|
|
|
|
2001-10-25 01:08:40 +00: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-09 00:15:24 +00:00
|
|
|
line_iterator line(nsLineBox* aList) { return mLines.begin(aList); }
|
|
|
|
reverse_line_iterator rline(nsLineBox* aList) { return mLines.rbegin(aList); }
|
2001-10-25 01:08:40 +00:00
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
friend nsIFrame* NS_NewBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRUint32 aFlags);
|
1999-02-09 17:31:33 +00:00
|
|
|
|
2010-08-06 04:59:19 +00:00
|
|
|
// This is a child list too, but we let nsBlockReflowState get to it
|
|
|
|
// directly too.
|
2010-08-06 04:59:20 +00:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(PushedFloatProperty,
|
2010-08-06 04:59:19 +00:00
|
|
|
nsContainerFrame::DestroyFrameList)
|
2010-03-29 01:46:55 +00:00
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
// nsQueryFrame
|
|
|
|
NS_DECL_QUERYFRAME
|
1998-11-16 17:11:12 +00:00
|
|
|
|
|
|
|
// nsIFrame
|
2006-03-09 18:55:21 +00:00
|
|
|
NS_IMETHOD Init(nsIContent* aContent,
|
1999-02-25 05:31:15 +00:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow);
|
2006-04-10 00:16:29 +00:00
|
|
|
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrameList& aChildList);
|
2005-02-07 01:58:25 +00:00
|
|
|
NS_IMETHOD AppendFrames(nsIAtom* aListName,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList);
|
2005-02-07 01:58:25 +00:00
|
|
|
NS_IMETHOD InsertFrames(nsIAtom* aListName,
|
1999-02-02 17:31:09 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList);
|
2005-02-07 01:58:25 +00:00
|
|
|
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
|
1999-02-02 17:31:09 +00:00
|
|
|
nsIFrame* aOldFrame);
|
2009-07-28 12:51:09 +00:00
|
|
|
virtual nsFrameList GetChildList(nsIAtom* aListName) const;
|
2007-01-23 04:06:56 +00:00
|
|
|
virtual nscoord GetBaseline() const;
|
2010-08-31 18:54:44 +00:00
|
|
|
virtual nscoord GetCaretBaseline() const;
|
2004-01-09 14:20:53 +00:00
|
|
|
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
|
2009-12-24 05:21:15 +00:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot);
|
2006-12-20 03:52:34 +00:00
|
|
|
virtual nsSplittableType GetSplittableType() const;
|
2004-03-12 04:40:17 +00:00
|
|
|
virtual PRBool IsContainingBlock() const;
|
2005-03-18 04:13:05 +00:00
|
|
|
virtual PRBool IsFloatContainingBlock() const;
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
2006-06-08 01:11:43 +00:00
|
|
|
virtual void InvalidateInternal(const nsRect& aDamageRect,
|
|
|
|
nscoord aX, nscoord aY, nsIFrame* aForChild,
|
2008-09-18 09:47:21 +00:00
|
|
|
PRUint32 aFlags);
|
2003-10-31 20:19:18 +00:00
|
|
|
virtual nsIAtom* GetType() const;
|
2007-07-26 04:03:29 +00:00
|
|
|
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
|
|
|
|
{
|
|
|
|
return nsContainerFrame::IsFrameOfType(aFlags &
|
2008-01-29 07:40:05 +00:00
|
|
|
~(nsIFrame::eCanContainOverflowContainers |
|
|
|
|
nsIFrame::eBlockFrame));
|
2007-07-26 04:03:29 +00:00
|
|
|
}
|
|
|
|
|
1999-09-01 01:02:16 +00:00
|
|
|
#ifdef DEBUG
|
2005-09-06 21:34:50 +00:00
|
|
|
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
2004-04-04 01:48:16 +00:00
|
|
|
NS_IMETHOD_(nsFrameState) GetDebugStateBits() const;
|
2001-11-14 01:33:42 +00:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
2004-03-07 18:04:24 +00:00
|
|
|
|
2004-06-04 19:28:36 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2010-06-28 12:02:03 +00:00
|
|
|
virtual already_AddRefed<nsAccessible> CreateAccessible();
|
2004-06-04 19:28:36 +00:00
|
|
|
#endif
|
|
|
|
|
2004-03-07 18:04:24 +00:00
|
|
|
// 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-07 04:25:45 +00: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
|
2004-03-07 18:04:24 +00:00
|
|
|
// cursor property points to a "recently used" line. If we get a
|
2006-01-26 02:29:17 +00:00
|
|
|
// series of requests that work on lines
|
2004-03-07 18:04:24 +00:00
|
|
|
// "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();
|
|
|
|
// Get the first line that might contain y-coord 'y', or nsnull if you must search
|
|
|
|
// 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();
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
virtual void ChildIsDirty(nsIFrame* aChild);
|
2006-01-26 02:29:17 +00:00
|
|
|
virtual PRBool IsVisibleInSelection(nsISelection* aSelection);
|
2001-03-08 02:46:44 +00:00
|
|
|
|
2003-11-10 23:36:06 +00:00
|
|
|
virtual PRBool IsEmpty();
|
2006-02-27 04:15:05 +00:00
|
|
|
virtual PRBool CachedIsEmpty();
|
2004-11-15 05:01:11 +00:00
|
|
|
virtual PRBool IsSelfEmpty();
|
2001-10-25 01:08:40 +00:00
|
|
|
|
2009-09-11 10:46:36 +00: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'?
|
|
|
|
PRBool BulletIsEmpty() const;
|
2011-03-28 13:59:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the bullet text equivalent.
|
|
|
|
*/
|
2010-10-14 14:05:12 +00:00
|
|
|
virtual void GetBulletText(nsAString& aText) const;
|
2009-09-11 10:46:36 +00:00
|
|
|
|
2011-03-28 13:59:54 +00:00
|
|
|
/**
|
|
|
|
* Return true if there's a bullet.
|
|
|
|
*/
|
|
|
|
virtual bool HasBullet() const;
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
virtual void MarkIntrinsicWidthsDirty();
|
|
|
|
virtual nscoord GetMinWidth(nsIRenderingContext *aRenderingContext);
|
|
|
|
virtual nscoord GetPrefWidth(nsIRenderingContext *aRenderingContext);
|
|
|
|
|
2007-10-12 08:30:54 +00:00
|
|
|
virtual nsRect ComputeTightBounds(gfxContext* aContext) const;
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
1998-11-16 17:11:12 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
2005-09-07 16:49:21 +00:00
|
|
|
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
|
1999-02-23 19:18:12 +00:00
|
|
|
nsIAtom* aAttribute,
|
2003-07-11 21:16:12 +00:00
|
|
|
PRInt32 aModType);
|
1999-02-23 19:18:12 +00:00
|
|
|
|
2007-07-26 04:03:29 +00:00
|
|
|
virtual nsresult StealFrame(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aChild,
|
2009-08-31 18:25:36 +00:00
|
|
|
PRBool aForceNormal = PR_FALSE);
|
2007-07-26 04:03:29 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
virtual void DeleteNextInFlowChild(nsPresContext* aPresContext,
|
2008-12-03 01:27:19 +00:00
|
|
|
nsIFrame* aNextInFlow,
|
|
|
|
PRBool aDeletingEmptyFrames);
|
1998-11-16 17:11:12 +00:00
|
|
|
|
2005-03-23 03:35:08 +00: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)
|
|
|
|
*/
|
2004-11-25 14:51:00 +00:00
|
|
|
PRBool CheckForCollapsedBottomMarginFromClearanceLine();
|
|
|
|
|
2000-08-24 04:26:43 +00:00
|
|
|
static nsresult GetCurrentLine(nsBlockReflowState *aState, nsLineBox **aOutCurrentLine);
|
|
|
|
|
2007-02-18 23:53:25 +00:00
|
|
|
static PRBool BlockIsMarginRoot(nsIFrame* aBlock);
|
2009-01-05 00:39:54 +00:00
|
|
|
static PRBool BlockNeedsFloatManager(nsIFrame* aBlock);
|
2008-01-29 07:40:05 +00: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.)
|
|
|
|
*/
|
|
|
|
static PRBool BlockCanIntersectFloats(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the width that needs to be cleared past floats for blocks
|
2008-05-03 23:33:36 +00:00
|
|
|
* 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)
|
2008-01-29 07:40:05 +00:00
|
|
|
*/
|
2008-04-15 01:05:17 +00:00
|
|
|
struct ReplacedElementWidthToClear {
|
|
|
|
nscoord marginLeft, borderBoxWidth, marginRight;
|
|
|
|
nscoord MarginBoxWidth() const
|
|
|
|
{ return marginLeft + borderBoxWidth + marginRight; }
|
|
|
|
};
|
|
|
|
static ReplacedElementWidthToClear
|
2009-04-08 20:52:37 +00:00
|
|
|
WidthToClearPastFloats(nsBlockReflowState& aState,
|
|
|
|
const nsRect& aFloatAvailableSpace,
|
|
|
|
nsIFrame* aFrame);
|
2008-01-29 07:40:05 +00:00
|
|
|
|
2009-08-31 18:25:36 +00: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 17:41:29 +00:00
|
|
|
/**
|
|
|
|
* Walks up the frame tree, starting with aCandidate, and returns the first
|
|
|
|
* block frame that it encounters.
|
|
|
|
*/
|
|
|
|
static nsBlockFrame* GetNearestAncestorBlock(nsIFrame* aCandidate);
|
2007-02-18 23:53:25 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
protected:
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsBlockFrame(nsStyleContext* aContext)
|
|
|
|
: nsHTMLContainerFrame(aContext)
|
|
|
|
, mMinWidth(NS_INTRINSIC_WIDTH_UNKNOWN)
|
|
|
|
, mPrefWidth(NS_INTRINSIC_WIDTH_UNKNOWN)
|
2007-08-02 22:44:36 +00:00
|
|
|
, mAbsoluteContainer(nsGkAtoms::absoluteList)
|
2006-03-26 21:30:36 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
InitDebugFlags();
|
|
|
|
#endif
|
|
|
|
}
|
1999-02-09 17:31:33 +00:00
|
|
|
virtual ~nsBlockFrame();
|
2006-02-27 04:13:51 +00:00
|
|
|
|
2007-04-16 00:42:54 +00:00
|
|
|
#ifdef DEBUG
|
2010-10-14 09:05:22 +00:00
|
|
|
#ifdef _IMPL_NS_LAYOUT
|
2004-07-31 23:15:21 +00:00
|
|
|
already_AddRefed<nsStyleContext> GetFirstLetterStyle(nsPresContext* aPresContext)
|
2003-04-12 16:06:54 +00:00
|
|
|
{
|
2004-01-28 00:18:22 +00:00
|
|
|
return aPresContext->StyleSet()->
|
2010-04-30 13:12:06 +00:00
|
|
|
ProbePseudoElementStyle(mContent->AsElement(),
|
2009-12-11 07:37:40 +00:00
|
|
|
nsCSSPseudoElements::ePseudo_firstLetter,
|
|
|
|
mStyleContext);
|
2003-04-12 16:06:54 +00:00
|
|
|
}
|
2010-10-14 09:05:22 +00:00
|
|
|
#endif
|
2007-04-16 00:42:54 +00:00
|
|
|
#endif
|
1999-04-27 22:11:05 +00:00
|
|
|
|
2002-12-11 04:00:18 +00:00
|
|
|
/*
|
|
|
|
* Overides member function of nsHTMLContainerFrame. Needed to handle the
|
|
|
|
* lines in a nsBlockFrame properly.
|
|
|
|
*/
|
2008-06-12 22:02:32 +00:00
|
|
|
virtual void PaintTextDecorationLine(gfxContext* aCtx,
|
2008-03-13 02:36:58 +00:00
|
|
|
const nsPoint& aPt,
|
2006-01-26 02:29:17 +00:00
|
|
|
nsLineBox* aLine,
|
|
|
|
nscolor aColor,
|
2008-03-13 02:36:58 +00:00
|
|
|
gfxFloat aOffset,
|
|
|
|
gfxFloat aAscent,
|
|
|
|
gfxFloat aSize,
|
2007-08-06 08:15:00 +00:00
|
|
|
const PRUint8 aDecoration);
|
2002-12-11 04:00:18 +00:00
|
|
|
|
2009-09-18 18:18:35 +00:00
|
|
|
virtual void AdjustForTextIndent(const nsLineBox* aLine,
|
|
|
|
nscoord& start,
|
|
|
|
nscoord& width);
|
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
void TryAllLines(nsLineList::iterator* aIterator,
|
2007-10-07 17:32:07 +00:00
|
|
|
nsLineList::iterator* aStartIterator,
|
2004-10-08 12:17:10 +00:00
|
|
|
nsLineList::iterator* aEndIterator,
|
|
|
|
PRBool* aInOverflowLines);
|
2004-08-26 12:38:50 +00:00
|
|
|
|
2010-11-30 18:19:57 +00:00
|
|
|
void SetFlags(nsFrameState aFlags) {
|
1999-11-03 00:42:12 +00:00
|
|
|
mState &= ~NS_BLOCK_FLAGS_MASK;
|
|
|
|
mState |= aFlags;
|
1998-11-16 17:11:12 +00:00
|
|
|
}
|
|
|
|
|
1999-02-18 22:22:55 +00:00
|
|
|
PRBool HaveOutsideBullet() const {
|
2002-06-19 21:51:13 +00:00
|
|
|
#if defined(DEBUG) && !defined(DEBUG_rods)
|
2001-03-14 06:45:41 +00:00
|
|
|
if(mState & NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET) {
|
|
|
|
NS_ASSERTION(mBullet,"NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET flag set and no mBullet");
|
|
|
|
}
|
|
|
|
#endif
|
1999-02-18 22:22:55 +00:00
|
|
|
return 0 != (mState & NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET);
|
|
|
|
}
|
|
|
|
|
2000-03-22 23:19:10 +00:00
|
|
|
/** move the frames contained by aLine by aDY
|
2005-11-20 22:05:24 +00:00
|
|
|
* if aLine is a block, its child floats are added to the state manager
|
2000-03-22 23:19:10 +00:00
|
|
|
*/
|
1999-09-16 19:56:36 +00:00
|
|
|
void SlideLine(nsBlockReflowState& aState,
|
1999-04-03 18:59:01 +00:00
|
|
|
nsLineBox* aLine, nscoord aDY);
|
1998-11-16 17:11:12 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
virtual PRIntn GetSkipSides() const;
|
1998-11-16 17:11:12 +00:00
|
|
|
|
1999-03-05 04:21:32 +00:00
|
|
|
virtual void ComputeFinalSize(const nsHTMLReflowState& aReflowState,
|
2002-10-21 14:54:00 +00:00
|
|
|
nsBlockReflowState& aState,
|
2008-12-29 08:18:40 +00:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nscoord* aBottomEdgeOfChildren);
|
1998-11-16 17:11:12 +00:00
|
|
|
|
2010-10-07 04:25:45 +00:00
|
|
|
void ComputeOverflowAreas(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nscoord aBottomEdgeOfChildren);
|
2002-09-24 11:43:48 +00:00
|
|
|
|
2000-03-22 23:19:10 +00: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.
|
2009-09-29 19:47:05 +00:00
|
|
|
* This function will clear aFrameList.
|
2000-03-22 23:19:10 +00:00
|
|
|
*/
|
2009-09-29 19:47:05 +00:00
|
|
|
virtual nsresult AddFrames(nsFrameList& aFrameList, nsIFrame* aPrevSibling);
|
1999-04-20 00:27:43 +00:00
|
|
|
|
2007-02-11 07:19:09 +00:00
|
|
|
#ifdef IBMBIDI
|
2007-05-28 14:40:56 +00:00
|
|
|
/**
|
|
|
|
* Perform Bidi resolution on this frame
|
|
|
|
*/
|
|
|
|
nsresult ResolveBidi();
|
|
|
|
|
2007-02-11 07:19:09 +00: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
|
|
|
|
*/
|
|
|
|
PRBool IsVisualFormControl(nsPresContext* aPresContext);
|
|
|
|
#endif
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
public:
|
2008-12-03 01:27:19 +00: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 18:25:35 +00:00
|
|
|
* -- destroys all removed frames
|
2008-12-03 01:27:19 +00:00
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
REMOVE_FIXED_CONTINUATIONS = 0x02,
|
|
|
|
FRAMES_ARE_EMPTY = 0x04
|
|
|
|
};
|
|
|
|
nsresult DoRemoveFrame(nsIFrame* aDeletedFrame, PRUint32 aFlags);
|
2007-04-21 00:42:58 +00:00
|
|
|
|
|
|
|
void ReparentFloats(nsIFrame* aFirstFrame,
|
|
|
|
nsBlockFrame* aOldParent, PRBool aFromOverflow,
|
|
|
|
PRBool aReparentSiblings);
|
|
|
|
|
2009-08-31 18:25:36 +00: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).
|
|
|
|
*/
|
|
|
|
static void RecoverFloatsFor(nsIFrame* aFrame,
|
|
|
|
nsFloatManager& aFloatManager);
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
protected:
|
1999-08-31 03:09:40 +00:00
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
/** grab overflow lines from this block's prevInFlow, and make them
|
|
|
|
* part of this block's mLines list.
|
|
|
|
* @return PR_TRUE if any lines were drained.
|
|
|
|
*/
|
2005-03-23 03:35:08 +00:00
|
|
|
PRBool DrainOverflowLines(nsBlockReflowState& aState);
|
2004-10-08 12:17:10 +00:00
|
|
|
|
2010-08-06 04:59:20 +00:00
|
|
|
/** grab pushed floats from this block's prevInFlow, and splice
|
2009-08-31 18:25:36 +00:00
|
|
|
* them into this block's mFloats list.
|
|
|
|
*/
|
2010-08-06 04:59:20 +00:00
|
|
|
void DrainPushedFloats(nsBlockReflowState& aState);
|
2009-08-31 18:25:36 +00:00
|
|
|
|
|
|
|
/** Load all our floats into the float manager (without reflowing them).
|
|
|
|
* Assumes float manager is in our own coordinate system.
|
|
|
|
*/
|
|
|
|
void RecoverFloats(nsFloatManager& aFloatManager);
|
|
|
|
|
2010-08-06 04:59:20 +00:00
|
|
|
/** Reflow pushed floats
|
2009-08-31 18:25:36 +00:00
|
|
|
*/
|
2010-08-06 04:59:20 +00:00
|
|
|
nsresult ReflowPushedFloats(nsBlockReflowState& aState,
|
2010-10-07 04:25:45 +00:00
|
|
|
nsOverflowAreas& aOverflowAreas,
|
|
|
|
nsReflowStatus& aStatus);
|
2009-08-31 18:25:36 +00:00
|
|
|
|
2009-08-31 18:25:36 +00:00
|
|
|
/** Find any trailing BR clear from the last line of the block (or its PIFs)
|
|
|
|
*/
|
|
|
|
PRUint8 FindTrailingClear();
|
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
/**
|
|
|
|
* Remove a float from our float list and also the float cache
|
|
|
|
* for the line its placeholder is on.
|
|
|
|
*/
|
|
|
|
line_iterator RemoveFloat(nsIFrame* aFloat);
|
|
|
|
|
2009-09-18 11:09:36 +00:00
|
|
|
void CollectFloats(nsIFrame* aFrame, nsFrameList& aList,
|
2007-04-21 00:42:58 +00:00
|
|
|
PRBool aFromOverflow, PRBool aCollectFromSiblings);
|
2003-10-13 21:51:02 +00:00
|
|
|
// Remove a float, abs, rel positioned frame from the appropriate block's list
|
2005-02-07 01:58:25 +00:00
|
|
|
static void DoRemoveOutOfFlowFrame(nsIFrame* aFrame);
|
1999-04-20 00:27:43 +00:00
|
|
|
|
2000-03-22 23:19:10 +00:00
|
|
|
/** set up the conditions necessary for an resize reflow
|
|
|
|
* the primary task is to mark the minimumly sufficient lines dirty.
|
|
|
|
*/
|
1999-02-09 17:31:33 +00:00
|
|
|
nsresult PrepareResizeReflow(nsBlockReflowState& aState);
|
1998-11-16 17:11:12 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/** reflow all lines that have been marked dirty */
|
|
|
|
nsresult ReflowDirtyLines(nsBlockReflowState& aState);
|
1998-11-16 17:11:12 +00:00
|
|
|
|
2009-04-21 23:53:52 +00:00
|
|
|
/** Mark a given line dirty due to reflow being interrupted on or before it */
|
|
|
|
void MarkLineDirtyForInterrupt(nsLineBox* aLine);
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
//----------------------------------------
|
|
|
|
// Methods for line reflow
|
2000-03-22 23:19:10 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
1999-02-09 17:31:33 +00:00
|
|
|
nsresult ReflowLine(nsBlockReflowState& aState,
|
2001-10-25 01:08:40 +00:00
|
|
|
line_iterator aLine,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
PRBool* aKeepReflowGoing);
|
1998-11-16 17:11:12 +00:00
|
|
|
|
2009-05-20 11:21:34 +00: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.
|
|
|
|
PRBool PlaceLine(nsBlockReflowState& aState,
|
|
|
|
nsLineLayout& aLineLayout,
|
|
|
|
line_iterator aLine,
|
|
|
|
nsFloatManager::SavedState* aFloatStateBeforeLine,
|
|
|
|
nsRect& aFloatAvailableSpace, /* in-out */
|
2009-06-16 15:00:20 +00:00
|
|
|
nscoord& aAvailableSpaceHeight, /* in-out */
|
2009-05-20 11:21:34 +00:00
|
|
|
PRBool* aKeepReflowGoing);
|
1998-11-16 17:11:12 +00:00
|
|
|
|
2001-10-25 01:08:40 +00:00
|
|
|
/**
|
|
|
|
* Mark |aLine| dirty, and, if necessary because of possible
|
2007-11-09 06:55:32 +00: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 19:26:06 +00:00
|
|
|
* @param aLine the line to mark dirty
|
|
|
|
* @param aLineList the line list containing that line, null means the line
|
|
|
|
* is in 'mLines' of this frame.
|
2001-10-25 01:08:40 +00:00
|
|
|
*/
|
2008-10-12 19:26:06 +00:00
|
|
|
nsresult MarkLineDirty(line_iterator aLine,
|
|
|
|
const nsLineList* aLineList = nsnull);
|
2000-01-12 08:28:24 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// XXX where to go
|
2001-10-25 01:08:40 +00:00
|
|
|
PRBool ShouldJustifyLine(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine);
|
1998-11-16 17:11:12 +00:00
|
|
|
|
2001-10-25 01:08:40 +00:00
|
|
|
void DeleteLine(nsBlockReflowState& aState,
|
|
|
|
nsLineList::iterator aLine,
|
|
|
|
nsLineList::iterator aLineEnd);
|
1998-12-07 22:28:23 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
//----------------------------------------
|
|
|
|
// Methods for individual frame reflow
|
|
|
|
|
1999-03-27 01:21:21 +00:00
|
|
|
PRBool ShouldApplyTopMargin(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine);
|
1998-12-05 16:02:08 +00:00
|
|
|
|
|
|
|
nsresult ReflowBlockFrame(nsBlockReflowState& aState,
|
2001-10-25 01:08:40 +00:00
|
|
|
line_iterator aLine,
|
1999-02-12 17:45:58 +00:00
|
|
|
PRBool* aKeepGoing);
|
1998-12-05 16:02:08 +00:00
|
|
|
|
1999-03-21 01:15:12 +00:00
|
|
|
nsresult ReflowInlineFrames(nsBlockReflowState& aState,
|
2001-10-25 01:08:40 +00:00
|
|
|
line_iterator aLine,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
PRBool* aKeepLineGoing);
|
1999-03-21 01:15:12 +00:00
|
|
|
|
1999-08-27 21:45:37 +00:00
|
|
|
nsresult DoReflowInlineFrames(nsBlockReflowState& aState,
|
|
|
|
nsLineLayout& aLineLayout,
|
2001-10-25 01:08:40 +00:00
|
|
|
line_iterator aLine,
|
2009-05-20 11:21:34 +00:00
|
|
|
nsFlowAreaRect& aFloatAvailableSpace,
|
2009-06-16 15:00:20 +00:00
|
|
|
nscoord& aAvailableSpaceHeight,
|
2009-05-20 11:21:34 +00:00
|
|
|
nsFloatManager::SavedState*
|
|
|
|
aFloatStateBeforeLine,
|
1999-08-27 21:45:37 +00:00
|
|
|
PRBool* aKeepReflowGoing,
|
2006-06-29 01:19:48 +00:00
|
|
|
LineReflowStatus* aLineReflowStatus,
|
|
|
|
PRBool aAllowPullUp);
|
1999-08-27 21:45:37 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
nsresult ReflowInlineFrame(nsBlockReflowState& aState,
|
1999-08-27 21:45:37 +00:00
|
|
|
nsLineLayout& aLineLayout,
|
2001-10-25 01:08:40 +00:00
|
|
|
line_iterator aLine,
|
1998-12-05 16:02:08 +00:00
|
|
|
nsIFrame* aFrame,
|
2006-06-29 01:19:48 +00:00
|
|
|
LineReflowStatus* aLineReflowStatus);
|
1998-11-16 17:11:12 +00:00
|
|
|
|
2008-06-10 23:53:22 +00:00
|
|
|
// Compute the available width for a float.
|
2009-04-08 20:52:36 +00:00
|
|
|
nsRect AdjustFloatAvailableSpace(nsBlockReflowState& aState,
|
|
|
|
const nsRect& aFloatAvailableSpace,
|
|
|
|
nsIFrame* aFloatFrame);
|
2008-06-10 23:53:22 +00:00
|
|
|
// Computes the border-box width of the float
|
|
|
|
nscoord ComputeFloatWidth(nsBlockReflowState& aState,
|
2009-04-08 20:52:36 +00:00
|
|
|
const nsRect& aFloatAvailableSpace,
|
2009-08-31 18:25:35 +00:00
|
|
|
nsIFrame* aFloat);
|
2003-10-13 21:51:02 +00:00
|
|
|
// An incomplete aReflowStatus indicates the float should be split
|
2002-06-14 14:30:33 +00:00
|
|
|
// but only if the available height is constrained.
|
2010-08-06 04:59:18 +00:00
|
|
|
// aAdjustedAvailableSpace is the result of calling
|
|
|
|
// nsBlockFrame::AdjustFloatAvailableSpace.
|
2003-10-13 21:51:02 +00:00
|
|
|
nsresult ReflowFloat(nsBlockReflowState& aState,
|
2010-08-06 04:59:18 +00:00
|
|
|
const nsRect& aAdjustedAvailableSpace,
|
2009-08-31 18:25:35 +00:00
|
|
|
nsIFrame* aFloat,
|
2007-06-16 20:27:46 +00:00
|
|
|
nsMargin& aFloatMargin,
|
2010-08-06 04:59:19 +00:00
|
|
|
// Whether the float's position
|
|
|
|
// (aAdjustedAvailableSpace) has been pushed down
|
|
|
|
// due to the presence of other floats.
|
|
|
|
PRBool aFloatPushedDown,
|
2003-10-13 21:51:02 +00:00
|
|
|
nsReflowStatus& aReflowStatus);
|
1998-11-16 17:11:12 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
//----------------------------------------
|
|
|
|
// Methods for pushing/pulling lines/frames
|
|
|
|
|
2009-09-18 11:09:35 +00: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
|
|
|
|
* @param aMadeNewFrame PR_TRUE if a new frame was created, PR_FALSE if not
|
|
|
|
* @return NS_OK if a next-in-flow already exists or is successfully created
|
|
|
|
*/
|
1998-12-05 16:02:08 +00:00
|
|
|
virtual nsresult CreateContinuationFor(nsBlockReflowState& aState,
|
2002-05-28 22:50:43 +00:00
|
|
|
nsLineBox* aLine,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
PRBool& aMadeNewFrame);
|
|
|
|
|
2010-08-06 04:59:20 +00:00
|
|
|
// Push aLine, which cannot be placed on this page/column but should
|
|
|
|
// fit on a future one. Set aKeepReflowGoing to false.
|
|
|
|
void PushTruncatedLine(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine,
|
|
|
|
PRBool& aKeepReflowGoing);
|
2002-05-28 22:50:43 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
nsresult SplitLine(nsBlockReflowState& aState,
|
1999-08-27 21:45:37 +00:00
|
|
|
nsLineLayout& aLineLayout,
|
2001-10-25 01:08:40 +00:00
|
|
|
line_iterator aLine,
|
2006-06-29 01:19:48 +00:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
LineReflowStatus* aLineReflowStatus);
|
1998-12-05 16:02:08 +00:00
|
|
|
|
2010-01-11 14:08:23 +00:00
|
|
|
/**
|
|
|
|
* Pull a frame from the next available location (one of our lines or
|
|
|
|
* one of our next-in-flows lines).
|
|
|
|
* @return the pulled frame or nsnull
|
|
|
|
*/
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* @return the pulled frame or nsnull
|
|
|
|
*/
|
|
|
|
nsIFrame* PullFrameFrom(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nsBlockFrame* aFromContainer,
|
|
|
|
PRBool aFromOverflowLine,
|
|
|
|
nsLineList::iterator aFromLine);
|
1998-12-05 16:02:08 +00:00
|
|
|
|
2001-10-25 01:08:40 +00:00
|
|
|
void PushLines(nsBlockReflowState& aState,
|
|
|
|
nsLineList::iterator aLineBefore);
|
1998-12-05 16:02:08 +00:00
|
|
|
|
2003-10-13 21:51:02 +00:00
|
|
|
void PropagateFloatDamage(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nscoord aDeltaY);
|
1998-12-05 16:02:08 +00:00
|
|
|
|
2006-04-09 22:56:27 +00:00
|
|
|
void CheckFloats(nsBlockReflowState& aState);
|
1998-12-05 16:02:08 +00:00
|
|
|
|
1999-07-14 17:26:20 +00:00
|
|
|
//----------------------------------------
|
|
|
|
// List handling kludge
|
|
|
|
|
2007-05-06 19:16:51 +00:00
|
|
|
// If this returns PR_TRUE, the block it's called on should get the
|
|
|
|
// 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.
|
|
|
|
PRBool RenumberLists(nsPresContext* aPresContext);
|
1998-12-05 16:02:08 +00:00
|
|
|
|
2008-02-24 07:31:29 +00:00
|
|
|
static PRBool RenumberListsInBlock(nsPresContext* aPresContext,
|
|
|
|
nsBlockFrame* aBlockFrame,
|
|
|
|
PRInt32* aOrdinal,
|
|
|
|
PRInt32 aDepth);
|
1999-09-17 23:16:43 +00:00
|
|
|
|
2008-02-24 07:31:29 +00:00
|
|
|
static PRBool RenumberListsFor(nsPresContext* aPresContext, nsIFrame* aKid, PRInt32* aOrdinal, PRInt32 aDepth);
|
1999-07-14 17:26:20 +00:00
|
|
|
|
2005-05-17 03:15:14 +00:00
|
|
|
static PRBool FrameStartsCounterScope(nsIFrame* aFrame);
|
1999-07-14 17:26:20 +00:00
|
|
|
|
1999-02-18 22:22:55 +00:00
|
|
|
void ReflowBullet(nsBlockReflowState& aState,
|
2008-02-10 21:49:24 +00:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nscoord aLineTop);
|
1998-12-05 16:02:08 +00:00
|
|
|
|
1999-07-14 17:26:20 +00:00
|
|
|
//----------------------------------------
|
|
|
|
|
2008-10-30 19:17:59 +00:00
|
|
|
virtual nsILineIterator* GetLineIterator();
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
public:
|
2004-06-01 06:20:16 +00:00
|
|
|
nsLineList* GetOverflowLines() const;
|
2005-03-23 03:35:08 +00:00
|
|
|
protected:
|
2004-08-26 03:07:05 +00:00
|
|
|
nsLineList* RemoveOverflowLines();
|
2004-06-01 06:20:16 +00:00
|
|
|
nsresult SetOverflowLines(nsLineList* aOverflowLines);
|
1999-11-02 23:42:52 +00:00
|
|
|
|
2011-01-19 22:39:31 +00:00
|
|
|
// Determine the computed height that's in effect for this block
|
|
|
|
// frame (that is, our computed height minus the heights of our
|
|
|
|
// previous in-flows).
|
|
|
|
// XXXbz this clearly makes laying out a block with N in-flows
|
|
|
|
// O(N^2)! Good thing the constant is tiny.
|
|
|
|
nscoord GetEffectiveComputedHeight(const nsHTMLReflowState& aReflowState) const;
|
|
|
|
|
2005-03-23 03:35:08 +00: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;
|
|
|
|
|
2009-09-18 11:09:36 +00:00
|
|
|
nsAutoOOFFrameList(nsBlockFrame* aBlock)
|
2009-09-24 02:39:21 +00:00
|
|
|
: mPropValue(aBlock->GetOverflowOutOfFlows())
|
|
|
|
, mBlock(aBlock) {
|
|
|
|
if (mPropValue) {
|
|
|
|
mList = *mPropValue;
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-24 02:39:21 +00:00
|
|
|
~nsAutoOOFFrameList() {
|
|
|
|
mBlock->SetOverflowOutOfFlows(mList, mPropValue);
|
|
|
|
}
|
2005-03-23 03:35:08 +00:00
|
|
|
protected:
|
2009-09-24 02:39:21 +00:00
|
|
|
nsFrameList* const mPropValue;
|
2009-09-18 11:09:36 +00:00
|
|
|
nsBlockFrame* const mBlock;
|
2005-03-23 03:35:08 +00:00
|
|
|
};
|
2005-06-01 16:28:06 +00:00
|
|
|
friend struct nsAutoOOFFrameList;
|
2005-03-23 03:35:08 +00:00
|
|
|
|
2009-09-24 02:39:21 +00:00
|
|
|
nsFrameList* GetOverflowOutOfFlows() const;
|
|
|
|
void SetOverflowOutOfFlows(const nsFrameList& aList, nsFrameList* aPropValue);
|
2004-05-05 02:30:33 +00:00
|
|
|
|
2010-08-06 04:59:20 +00:00
|
|
|
// Get the pushed floats list
|
|
|
|
nsFrameList* GetPushedFloats() const;
|
|
|
|
// Get the pushed floats list, or if there is not currently one,
|
2010-08-06 04:59:19 +00:00
|
|
|
// make a new empty one.
|
2010-08-06 04:59:20 +00:00
|
|
|
nsFrameList* EnsurePushedFloats();
|
|
|
|
// Remove and return the pushed floats list.
|
|
|
|
nsFrameList* RemovePushedFloats();
|
2010-08-06 04:59:19 +00:00
|
|
|
|
1999-02-09 17:31:33 +00:00
|
|
|
#ifdef NS_DEBUG
|
1999-04-20 00:27:43 +00:00
|
|
|
void VerifyLines(PRBool aFinalCheckOK);
|
2004-06-01 06:20:16 +00:00
|
|
|
void VerifyOverflowSituation();
|
1999-03-22 22:41:09 +00:00
|
|
|
PRInt32 GetDepth() const;
|
1999-02-09 17:31:33 +00:00
|
|
|
#endif
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nscoord mMinWidth, mPrefWidth;
|
|
|
|
|
2001-10-25 01:08:40 +00:00
|
|
|
nsLineList mLines;
|
1999-02-09 17:31:33 +00:00
|
|
|
|
2003-10-13 21:51:02 +00:00
|
|
|
// List of all floats in this block
|
|
|
|
nsFrameList mFloats;
|
1998-11-16 17:11:12 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// XXX_fix_me: subclass one more time!
|
|
|
|
// For list-item frames, this is the bullet frame.
|
|
|
|
nsBulletFrame* mBullet;
|
1998-11-16 17:11:12 +00:00
|
|
|
|
1999-02-09 17:31:33 +00:00
|
|
|
friend class nsBlockReflowState;
|
2007-08-22 09:08:13 +00:00
|
|
|
friend class nsBlockInFlowLineIterator;
|
2000-05-09 05:11:12 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsAbsoluteContainingBlock mAbsoluteContainer;
|
|
|
|
|
2001-05-01 04:22:57 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
public:
|
|
|
|
static PRBool gLamePaintMetrics;
|
|
|
|
static PRBool gLameReflowMetrics;
|
|
|
|
static PRBool gNoisy;
|
|
|
|
static PRBool gNoisyDamageRepair;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
static PRBool gNoisyIntrinsic;
|
2001-05-01 04:22:57 +00:00
|
|
|
static PRBool gNoisyReflow;
|
|
|
|
static PRBool gReallyNoisyReflow;
|
2009-01-05 00:39:54 +00:00
|
|
|
static PRBool gNoisyFloatManager;
|
2001-05-01 04:22:57 +00:00
|
|
|
static PRBool gVerifyLines;
|
|
|
|
static PRBool gDisableResizeOpt;
|
|
|
|
|
|
|
|
static PRInt32 gNoiseIndent;
|
|
|
|
|
2001-12-17 22:39:59 +00:00
|
|
|
static const char* kReflowCommandType[];
|
|
|
|
|
2001-05-01 04:22:57 +00:00
|
|
|
protected:
|
|
|
|
static void InitDebugFlags();
|
|
|
|
#endif
|
1998-11-16 17:11:12 +00:00
|
|
|
};
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
class AutoNoisyIndenter {
|
|
|
|
public:
|
|
|
|
AutoNoisyIndenter(PRBool aDoIndent) : mIndented(aDoIndent) {
|
|
|
|
if (mIndented) {
|
|
|
|
nsBlockFrame::gNoiseIndent++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
~AutoNoisyIndenter() {
|
|
|
|
if (mIndented) {
|
|
|
|
nsBlockFrame::gNoiseIndent--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
PRBool mIndented;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2007-08-22 09:08:13 +00: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;
|
2008-01-29 23:39:39 +00:00
|
|
|
nsBlockInFlowLineIterator(nsBlockFrame* aFrame, line_iterator aLine, PRBool aInOverflow);
|
2008-02-27 09:53:48 +00: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 19:09:08 +00:00
|
|
|
* After aFoundValidLine has returned false, don't call any methods on this
|
|
|
|
* object again.
|
2008-02-27 09:53:48 +00:00
|
|
|
*/
|
2008-02-24 07:31:29 +00:00
|
|
|
nsBlockInFlowLineIterator(nsBlockFrame* aFrame, PRBool* aFoundValidLine);
|
2008-02-27 09:53:48 +00: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 19:09:08 +00: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 09:53:48 +00:00
|
|
|
*/
|
|
|
|
nsBlockInFlowLineIterator(nsBlockFrame* aFrame, nsIFrame* aFindFrame,
|
|
|
|
PRBool* aFoundValidLine);
|
|
|
|
|
2007-08-22 09:08:13 +00:00
|
|
|
line_iterator GetLine() { return mLine; }
|
2008-01-29 23:39:39 +00:00
|
|
|
PRBool IsLastLineInList();
|
2007-08-22 09:08:13 +00:00
|
|
|
nsBlockFrame* GetContainer() { return mFrame; }
|
|
|
|
PRBool GetInOverflow() { return mInOverflowLines != nsnull; }
|
2008-04-12 05:32:49 +00:00
|
|
|
|
2008-10-12 19:26:06 +00:00
|
|
|
/**
|
|
|
|
* Returns the current line list we're iterating, null means
|
|
|
|
* we're iterating |mLines| of the container.
|
|
|
|
*/
|
|
|
|
nsLineList* GetLineList() { return mInOverflowLines; }
|
2008-04-12 05:32:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the end-iterator of whatever line list we're in.
|
|
|
|
*/
|
|
|
|
line_iterator End();
|
|
|
|
|
2007-08-22 09:08:13 +00:00
|
|
|
/**
|
|
|
|
* Returns false if there are no more lines. After this has returned false,
|
|
|
|
* don't call any methods on this object again.
|
|
|
|
*/
|
|
|
|
PRBool Next();
|
|
|
|
/**
|
|
|
|
* Returns false if there are no more lines. After this has returned false,
|
|
|
|
* don't call any methods on this object again.
|
|
|
|
*/
|
|
|
|
PRBool Prev();
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsBlockFrame* mFrame;
|
|
|
|
line_iterator mLine;
|
|
|
|
nsLineList* mInOverflowLines;
|
2008-02-24 07:31:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Moves iterator to next valid line reachable from the current block.
|
|
|
|
* Returns false if there are no valid lines.
|
|
|
|
*/
|
|
|
|
PRBool FindValidLine();
|
2007-08-22 09:08:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsBlockFrame_h___ */
|