2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2001-10-25 05:08:40 +04:00
|
|
|
// vim:cindent:ts=2:et:sw=2:
|
2001-09-29 00:14:13 +04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-11-16 20:11:12 +03:00
|
|
|
*
|
2004-04-18 18:30:37 +04: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 20:11:12 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04: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 20:11:12 +03:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04: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-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-11-16 20:11:12 +03:00
|
|
|
#ifndef nsBlockFrame_h___
|
|
|
|
#define nsBlockFrame_h___
|
|
|
|
|
|
|
|
#include "nsHTMLContainerFrame.h"
|
1999-11-03 03:42:12 +03:00
|
|
|
#include "nsHTMLParts.h"
|
2000-05-09 09:11:12 +04:00
|
|
|
#include "nsAbsoluteContainingBlock.h"
|
2001-10-25 05:08:40 +04:00
|
|
|
#include "nsLineBox.h"
|
2002-05-10 22:22:41 +04:00
|
|
|
#include "nsReflowPath.h"
|
2003-04-12 20:06:54 +04:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2004-01-28 03:18:22 +03:00
|
|
|
#include "nsStyleSet.h"
|
1998-11-16 20:11:12 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
class nsBlockReflowState;
|
|
|
|
class nsBulletFrame;
|
|
|
|
class nsLineBox;
|
1999-04-20 04:27:43 +04:00
|
|
|
class nsFirstLineFrame;
|
2001-05-11 12:04:29 +04:00
|
|
|
class nsILineIterator;
|
2001-10-25 05:08:40 +04:00
|
|
|
class nsIntervalSet;
|
1998-11-18 09:13:58 +03:00
|
|
|
/**
|
|
|
|
* Child list name indices
|
|
|
|
* @see #GetAdditionalChildListName()
|
|
|
|
*/
|
2004-05-05 06:30:33 +04:00
|
|
|
#define NS_BLOCK_FRAME_FLOAT_LIST_INDEX 0
|
|
|
|
#define NS_BLOCK_FRAME_BULLET_LIST_INDEX 1
|
|
|
|
#define NS_BLOCK_FRAME_OVERFLOW_LIST_INDEX 2
|
|
|
|
#define NS_BLOCK_FRAME_OVERFLOW_OOF_LIST_INDEX 3
|
|
|
|
#define NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX 4
|
2000-05-09 09:11:12 +04:00
|
|
|
#define NS_BLOCK_FRAME_LAST_LIST_INDEX NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX
|
1998-11-18 09:13:58 +03:00
|
|
|
|
2005-03-23 06:35:08 +03: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.
|
|
|
|
* -- A given piece of content can have an unlimited number
|
|
|
|
* of placeholder frames in the overflow-lines list.
|
|
|
|
* -- A line containing a continuation placeholder contains
|
|
|
|
* only continuation placeholders.
|
|
|
|
* -- While a block is being reflowed, its overflowPlaceholdersList
|
|
|
|
* frame property points to an nsFrameList in its
|
|
|
|
* nsBlockReflowState. This list contains placeholders for
|
|
|
|
* floats whose prev-in-flow is in the block's regular line
|
|
|
|
* list. The list is always empty/non-existent after the
|
|
|
|
* block has been reflowed.
|
|
|
|
* -- 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 07:07:05 +04:00
|
|
|
// see nsHTMLParts.h for the public block state bits
|
|
|
|
#define NS_BLOCK_HAS_LINE_CURSOR 0x01000000
|
|
|
|
#define NS_BLOCK_HAS_OVERFLOW_LINES 0x02000000
|
|
|
|
#define NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS 0x04000000
|
|
|
|
#define NS_BLOCK_HAS_OVERFLOW_PLACEHOLDERS 0x08000000
|
|
|
|
|
2004-11-25 17:51:00 +03: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)
|
|
|
|
#define NS_BLOCK_HAS_CLEAR_CHILDREN 0x10000000
|
|
|
|
|
1999-02-09 20:31:33 +03:00
|
|
|
#define nsBlockFrameSuper nsHTMLContainerFrame
|
1998-12-05 19:02:08 +03:00
|
|
|
|
1999-03-27 04:21:21 +03:00
|
|
|
#define NS_BLOCK_FRAME_CID \
|
|
|
|
{ 0xa6cf90df, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
|
|
|
|
|
|
|
extern const nsIID kBlockFrameCID;
|
|
|
|
|
2000-05-09 09:11:12 +04: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
|
|
|
|
*
|
|
|
|
* @see nsLayoutAtoms::absoluteList
|
|
|
|
*/
|
1999-02-09 20:31:33 +03:00
|
|
|
class nsBlockFrame : public nsBlockFrameSuper
|
1998-11-16 20:11:12 +03:00
|
|
|
{
|
2001-10-25 05:08:40 +04:00
|
|
|
public:
|
|
|
|
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(); }
|
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
friend nsIFrame* NS_NewBlockFrame(nsIPresShell* aPresShell, PRUint32 aFlags);
|
1999-02-09 20:31:33 +03:00
|
|
|
|
1998-11-16 20:11:12 +03:00
|
|
|
// nsISupports
|
|
|
|
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
|
|
|
|
|
|
|
// nsIFrame
|
2006-03-09 21:55:21 +03:00
|
|
|
NS_IMETHOD Init(nsIContent* aContent,
|
1999-02-25 08:31:15 +03:00
|
|
|
nsIFrame* aParent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
1999-02-25 08:31:15 +03:00
|
|
|
nsIFrame* aPrevInFlow);
|
2006-03-15 09:43:36 +03:00
|
|
|
NS_IMETHOD SetInitialChildList(nsPresContext* aPresContext,
|
|
|
|
nsIAtom* aListName,
|
1998-11-16 20:11:12 +03:00
|
|
|
nsIFrame* aChildList);
|
2005-02-07 04:58:25 +03:00
|
|
|
NS_IMETHOD AppendFrames(nsIAtom* aListName,
|
1999-02-02 20:31:09 +03:00
|
|
|
nsIFrame* aFrameList);
|
2005-02-07 04:58:25 +03:00
|
|
|
NS_IMETHOD InsertFrames(nsIAtom* aListName,
|
1999-02-02 20:31:09 +03:00
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList);
|
2005-02-07 04:58:25 +03:00
|
|
|
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
|
1999-02-02 20:31:09 +03:00
|
|
|
nsIFrame* aOldFrame);
|
2004-01-09 17:20:53 +03:00
|
|
|
virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
|
2004-09-28 22:37:50 +04:00
|
|
|
NS_IMETHOD SetParent(const nsIFrame* aParent);
|
2004-01-09 17:20:53 +03:00
|
|
|
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
|
2006-03-15 09:43:36 +03:00
|
|
|
NS_IMETHOD Destroy(nsPresContext* aPresContext);
|
1998-11-16 20:11:12 +03:00
|
|
|
NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const;
|
2004-03-12 07:40:17 +03:00
|
|
|
virtual PRBool IsContainingBlock() const;
|
2005-03-18 07:13:05 +03:00
|
|
|
virtual PRBool IsFloatContainingBlock() const;
|
2006-01-26 05:29:17 +03:00
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
2003-10-31 23:19:18 +03:00
|
|
|
virtual nsIAtom* GetType() const;
|
1999-09-01 05:02:16 +04:00
|
|
|
#ifdef DEBUG
|
2005-09-07 01:34:50 +04:00
|
|
|
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
2004-04-04 05:48:16 +04:00
|
|
|
NS_IMETHOD_(nsFrameState) GetDebugStateBits() const;
|
2001-11-14 04:33:42 +03:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
1998-11-16 20:11:12 +03:00
|
|
|
NS_IMETHOD VerifyTree() const;
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
2004-03-07 21:04:24 +03:00
|
|
|
|
2004-06-04 23:28:36 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
|
|
|
|
#endif
|
|
|
|
|
2004-03-07 21:04:24 +03:00
|
|
|
// line cursor methods to speed up searching for the line(s)
|
|
|
|
// containing a point. The basic idea is that we set the cursor
|
|
|
|
// property if the lines' combinedArea.ys and combinedArea.yMosts
|
|
|
|
// are non-decreasing (considering only non-empty combinedAreas;
|
|
|
|
// empty combinedAreas never participate in event handling or
|
|
|
|
// painting), and the block has sufficient number of lines. The
|
|
|
|
// cursor property points to a "recently used" line. If we get a
|
2006-01-26 05:29:17 +03:00
|
|
|
// series of requests that work on lines
|
2004-03-07 21:04:24 +03: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();
|
|
|
|
|
2000-01-12 11:28:24 +03:00
|
|
|
NS_IMETHOD ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild);
|
2006-01-26 05:29:17 +03:00
|
|
|
virtual PRBool IsVisibleInSelection(nsISelection* aSelection);
|
2001-03-08 05:46:44 +03:00
|
|
|
|
2003-11-11 02:36:06 +03:00
|
|
|
virtual PRBool IsEmpty();
|
2006-02-27 07:15:05 +03:00
|
|
|
virtual PRBool CachedIsEmpty();
|
2004-11-15 08:01:11 +03:00
|
|
|
virtual PRBool IsSelfEmpty();
|
2001-10-25 05:08:40 +04:00
|
|
|
|
1998-11-16 20:11:12 +03:00
|
|
|
// nsIHTMLReflow
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
1998-11-16 20:11:12 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
2005-09-07 20:49:21 +04:00
|
|
|
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
|
1999-02-23 22:18:12 +03:00
|
|
|
nsIAtom* aAttribute,
|
2003-07-12 01:16:12 +04:00
|
|
|
PRInt32 aModType);
|
1999-02-23 22:18:12 +03:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
virtual void DeleteNextInFlowChild(nsPresContext* aPresContext,
|
2002-10-09 00:35:26 +04:00
|
|
|
nsIFrame* aNextInFlow);
|
1998-11-16 20:11:12 +03:00
|
|
|
|
2005-03-23 06:35:08 +03: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 17:51:00 +03:00
|
|
|
PRBool CheckForCollapsedBottomMarginFromClearanceLine();
|
|
|
|
|
2000-03-23 02:19:10 +03:00
|
|
|
/** return the topmost block child based on y-index.
|
|
|
|
* almost always the first or second line, if there is one.
|
|
|
|
* accounts for lines that hold only compressed white space, etc.
|
|
|
|
*/
|
2004-08-01 03:15:21 +04:00
|
|
|
nsIFrame* GetTopBlockChild(nsPresContext *aPresContext);
|
1999-03-27 04:21:21 +03:00
|
|
|
|
2002-04-26 23:19:39 +04:00
|
|
|
// Returns the line containing aFrame, or end_lines() if the frame
|
|
|
|
// isn't in the block.
|
|
|
|
line_iterator FindLineFor(nsIFrame* aFrame);
|
2000-04-14 08:05:58 +04:00
|
|
|
|
2000-08-24 08:26:43 +04:00
|
|
|
static nsresult GetCurrentLine(nsBlockReflowState *aState, nsLineBox **aOutCurrentLine);
|
|
|
|
|
2001-12-04 02:41:13 +03:00
|
|
|
inline nscoord GetAscent() { return mAscent; }
|
|
|
|
|
2002-09-25 02:13:20 +04:00
|
|
|
// Create a contination for aPlaceholder and its out of flow frame and
|
2003-10-14 01:51:02 +04:00
|
|
|
// add it to the list of overflow floats
|
2005-03-23 06:35:08 +03:00
|
|
|
nsresult SplitPlaceholder(nsBlockReflowState& aState, nsIFrame* aPlaceholder);
|
2002-09-25 02:13:20 +04:00
|
|
|
|
2002-12-04 03:58:52 +03:00
|
|
|
void UndoSplitPlaceholders(nsBlockReflowState& aState,
|
|
|
|
nsIFrame* aLastPlaceholder);
|
|
|
|
|
2005-03-23 06:35:08 +03:00
|
|
|
PRBool HandleOverflowPlaceholdersForPulledFrame(
|
|
|
|
nsBlockReflowState& aState, nsIFrame* aFrame);
|
|
|
|
|
|
|
|
PRBool HandleOverflowPlaceholdersOnPulledLine(
|
|
|
|
nsBlockReflowState& aState, nsLineBox* aLine);
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
protected:
|
1999-02-09 20:31:33 +03:00
|
|
|
nsBlockFrame();
|
|
|
|
virtual ~nsBlockFrame();
|
2006-02-27 07:13:51 +03:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
already_AddRefed<nsStyleContext> GetFirstLetterStyle(nsPresContext* aPresContext)
|
2003-04-12 20:06:54 +04:00
|
|
|
{
|
2004-01-28 03:18:22 +03:00
|
|
|
return aPresContext->StyleSet()->
|
|
|
|
ProbePseudoStyleFor(mContent,
|
|
|
|
nsCSSPseudoElements::firstLetter, mStyleContext);
|
2003-04-12 20:06:54 +04:00
|
|
|
}
|
1999-04-28 02:11:05 +04:00
|
|
|
|
2002-12-11 07:00:18 +03:00
|
|
|
/*
|
|
|
|
* Overides member function of nsHTMLContainerFrame. Needed to handle the
|
|
|
|
* lines in a nsBlockFrame properly.
|
|
|
|
*/
|
2006-01-26 05:29:17 +03:00
|
|
|
virtual void PaintTextDecorationLine(nsIRenderingContext& aRenderingContext,
|
|
|
|
nsPoint aPt,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nscolor aColor,
|
|
|
|
nscoord aOffset,
|
|
|
|
nscoord aAscent,
|
|
|
|
nscoord aSize);
|
2002-12-11 07:00:18 +03:00
|
|
|
|
2004-10-08 16:17:10 +04:00
|
|
|
void TryAllLines(nsLineList::iterator* aIterator,
|
|
|
|
nsLineList::iterator* aEndIterator,
|
|
|
|
PRBool* aInOverflowLines);
|
2004-08-26 16:38:50 +04:00
|
|
|
|
1998-11-16 20:11:12 +03:00
|
|
|
void SetFlags(PRUint32 aFlags) {
|
1999-11-03 03:42:12 +03:00
|
|
|
mState &= ~NS_BLOCK_FLAGS_MASK;
|
|
|
|
mState |= aFlags;
|
1998-11-16 20:11:12 +03:00
|
|
|
}
|
|
|
|
|
1999-02-19 01:22:55 +03:00
|
|
|
PRBool HaveOutsideBullet() const {
|
2002-06-20 01:51:13 +04:00
|
|
|
#if defined(DEBUG) && !defined(DEBUG_rods)
|
2001-03-14 09:45:41 +03: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-19 01:22:55 +03:00
|
|
|
return 0 != (mState & NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET);
|
|
|
|
}
|
|
|
|
|
2000-03-23 02:19:10 +03:00
|
|
|
/** move the frames contained by aLine by aDY
|
2005-11-21 01:05:24 +03:00
|
|
|
* if aLine is a block, its child floats are added to the state manager
|
2000-03-23 02:19:10 +03:00
|
|
|
*/
|
1999-09-16 23:56:36 +04:00
|
|
|
void SlideLine(nsBlockReflowState& aState,
|
1999-04-03 22:59:01 +04:00
|
|
|
nsLineBox* aLine, nscoord aDY);
|
1998-11-16 20:11:12 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
virtual PRIntn GetSkipSides() const;
|
1998-11-16 20:11:12 +03:00
|
|
|
|
1999-03-05 07:21:32 +03:00
|
|
|
virtual void ComputeFinalSize(const nsHTMLReflowState& aReflowState,
|
2002-10-21 18:54:00 +04:00
|
|
|
nsBlockReflowState& aState,
|
|
|
|
nsHTMLReflowMetrics& aMetrics);
|
1998-11-16 20:11:12 +03:00
|
|
|
|
2002-09-24 15:43:48 +04:00
|
|
|
void ComputeCombinedArea(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aMetrics);
|
|
|
|
|
2000-03-23 02:19:10 +03: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.
|
|
|
|
*/
|
2005-02-07 04:58:25 +03:00
|
|
|
nsresult AddFrames(nsIFrame* aFrameList,
|
1999-04-20 04:27:43 +04:00
|
|
|
nsIFrame* aPrevSibling);
|
|
|
|
|
2005-03-23 06:35:08 +03:00
|
|
|
public:
|
2000-03-23 02:19:10 +03:00
|
|
|
/** does all the real work for removing aDeletedFrame from this
|
|
|
|
* finds the line containing aFrame.
|
|
|
|
* handled continued frames
|
|
|
|
* marks lines dirty as needed
|
2005-03-23 06:35:08 +03:00
|
|
|
* @param aDestroyFrames if false then we don't actually destroy the
|
|
|
|
* frame or its next in flows, we just remove them. This does NOT work
|
|
|
|
* on out of flow frames so always use PR_TRUE for out of flows.
|
2006-02-22 00:33:47 +03:00
|
|
|
* @param aRemoveOnlyFluidContinuations if true, only in-flows are removed;
|
|
|
|
* if false, all continuations are removed.
|
2000-03-23 02:19:10 +03:00
|
|
|
*/
|
2006-02-22 00:33:47 +03:00
|
|
|
nsresult DoRemoveFrame(nsIFrame* aDeletedFrame, PRBool aDestroyFrames = PR_TRUE,
|
|
|
|
PRBool aRemoveOnlyFluidContinuations = PR_TRUE);
|
2005-03-23 06:35:08 +03:00
|
|
|
protected:
|
1999-08-31 07:09:40 +04:00
|
|
|
|
2004-10-08 16:17:10 +04: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 06:35:08 +03:00
|
|
|
PRBool DrainOverflowLines(nsBlockReflowState& aState);
|
2004-10-08 16:17:10 +04: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);
|
|
|
|
|
2005-03-23 06:35:08 +03:00
|
|
|
void CollectFloats(nsIFrame* aFrame, nsFrameList& aList, nsIFrame** aTail,
|
|
|
|
PRBool aFromOverflow);
|
2003-10-14 01:51:02 +04:00
|
|
|
// Remove a float, abs, rel positioned frame from the appropriate block's list
|
2005-02-07 04:58:25 +03:00
|
|
|
static void DoRemoveOutOfFlowFrame(nsIFrame* aFrame);
|
1999-04-20 04:27:43 +04:00
|
|
|
|
2000-03-23 02:19:10 +03:00
|
|
|
/** set up the conditions necessary for an initial reflow */
|
1999-02-09 20:31:33 +03:00
|
|
|
nsresult PrepareInitialReflow(nsBlockReflowState& aState);
|
1998-11-16 20:11:12 +03:00
|
|
|
|
2000-03-23 02:19:10 +03:00
|
|
|
/** set up the conditions necessary for an styleChanged reflow */
|
1999-02-09 20:31:33 +03:00
|
|
|
nsresult PrepareStyleChangedReflow(nsBlockReflowState& aState);
|
1998-11-16 20:11:12 +03:00
|
|
|
|
2000-03-23 02:19:10 +03:00
|
|
|
/** set up the conditions necessary for an incremental reflow.
|
|
|
|
* the primary task is to mark the minimumly sufficient lines dirty.
|
|
|
|
*/
|
1999-02-09 20:31:33 +03:00
|
|
|
nsresult PrepareChildIncrementalReflow(nsBlockReflowState& aState);
|
1998-11-16 20:11:12 +03:00
|
|
|
|
2002-01-05 04:42:36 +03:00
|
|
|
/**
|
|
|
|
* Retarget an inline incremental reflow from continuing frames that
|
|
|
|
* will be destroyed.
|
|
|
|
*
|
|
|
|
* @param aState |aState.mNextRCFrame| contains the next frame in
|
|
|
|
* the reflow path; this will be ``rewound'' to either the target
|
|
|
|
* frame's primary frame, or to the first continuation frame after a
|
|
|
|
* ``hard break''. In other words, it will be set to the closest
|
|
|
|
* continuation which will not be destroyed by the unconstrained
|
|
|
|
* reflow. The remaining frames in the reflow path for
|
|
|
|
* |aState.mReflowState.reflowCommand| will be altered similarly.
|
|
|
|
*
|
|
|
|
* @param aLine is initially the line box that contains the target
|
|
|
|
* frame. It will be ``rewound'' in lockstep with
|
|
|
|
* |aState.mNextRCFrame|.
|
|
|
|
*
|
|
|
|
* @param aPrevInFlow points to the target frame's prev-in-flow.
|
|
|
|
*/
|
2002-05-10 22:22:41 +04:00
|
|
|
void RetargetInlineIncrementalReflow(nsReflowPath::iterator &aFrame,
|
|
|
|
line_iterator &aLine,
|
|
|
|
nsIFrame *aPrevInFlow);
|
2002-01-05 04:42:36 +03:00
|
|
|
|
2000-03-23 02:19:10 +03:00
|
|
|
/** set up the conditions necessary for an resize reflow
|
|
|
|
* the primary task is to mark the minimumly sufficient lines dirty.
|
|
|
|
*/
|
1999-02-09 20:31:33 +03:00
|
|
|
nsresult PrepareResizeReflow(nsBlockReflowState& aState);
|
1998-11-16 20:11:12 +03:00
|
|
|
|
2005-03-23 06:35:08 +03:00
|
|
|
/** reflow all lines that have been marked dirty.
|
|
|
|
* @param aTryPull set this to PR_TRUE if you want to try pulling content from
|
|
|
|
* our next in flow while there is room.
|
|
|
|
*/
|
|
|
|
nsresult ReflowDirtyLines(nsBlockReflowState& aState, PRBool aTryPull);
|
1998-11-16 20:11:12 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
//----------------------------------------
|
|
|
|
// Methods for line reflow
|
2000-03-23 02:19:10 +03: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
|
|
|
|
* @param aDamageDirtyArea if PR_TRUE, do extra work to mark the changed areas as damaged for painting
|
|
|
|
* this indicates that frames may have changed size, for example
|
|
|
|
*/
|
1999-02-09 20:31:33 +03:00
|
|
|
nsresult ReflowLine(nsBlockReflowState& aState,
|
2001-10-25 05:08:40 +04:00
|
|
|
line_iterator aLine,
|
1999-07-14 19:16:56 +04:00
|
|
|
PRBool* aKeepReflowGoing,
|
1999-08-01 20:50:52 +04:00
|
|
|
PRBool aDamageDirtyArea = PR_FALSE);
|
1998-11-16 20:11:12 +03:00
|
|
|
|
2002-07-17 05:48:56 +04:00
|
|
|
// Return PR_TRUE if aLine gets pushed.
|
|
|
|
PRBool PlaceLine(nsBlockReflowState& aState,
|
|
|
|
nsLineLayout& aLineLayout,
|
|
|
|
line_iterator aLine,
|
|
|
|
PRBool* aKeepReflowGoing,
|
|
|
|
PRBool aUpdateMaximumWidth);
|
1998-11-16 20:11:12 +03:00
|
|
|
|
2001-10-25 05:08:40 +04:00
|
|
|
/**
|
|
|
|
* Mark |aLine| dirty, and, if necessary because of possible
|
|
|
|
* pull-up, mark the previous line dirty as well.
|
|
|
|
*/
|
|
|
|
nsresult MarkLineDirty(line_iterator aLine);
|
2000-01-12 11:28:24 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX blech
|
|
|
|
void PostPlaceLine(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
2003-01-09 17:26:32 +03:00
|
|
|
nscoord aMaxElementWidth);
|
1998-11-16 20:11:12 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX where to go
|
2001-10-25 05:08:40 +04:00
|
|
|
PRBool ShouldJustifyLine(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine);
|
1998-11-16 20:11:12 +03:00
|
|
|
|
2001-10-25 05:08:40 +04:00
|
|
|
void DeleteLine(nsBlockReflowState& aState,
|
|
|
|
nsLineList::iterator aLine,
|
|
|
|
nsLineList::iterator aLineEnd);
|
1998-12-08 01:28:23 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
//----------------------------------------
|
|
|
|
// Methods for individual frame reflow
|
|
|
|
|
1999-03-27 04:21:21 +03:00
|
|
|
PRBool ShouldApplyTopMargin(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine);
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
nsresult ReflowBlockFrame(nsBlockReflowState& aState,
|
2001-10-25 05:08:40 +04:00
|
|
|
line_iterator aLine,
|
1999-02-12 20:45:58 +03:00
|
|
|
PRBool* aKeepGoing);
|
1998-12-05 19:02:08 +03:00
|
|
|
|
1999-03-21 04:15:12 +03:00
|
|
|
nsresult ReflowInlineFrames(nsBlockReflowState& aState,
|
2001-10-25 05:08:40 +04:00
|
|
|
line_iterator aLine,
|
2000-01-08 06:58:27 +03:00
|
|
|
PRBool* aKeepLineGoing,
|
2000-04-19 07:12:13 +04:00
|
|
|
PRBool aDamageDirtyArea,
|
2000-01-08 06:58:27 +03:00
|
|
|
PRBool aUpdateMaximumWidth = PR_FALSE);
|
1999-03-21 04:15:12 +03:00
|
|
|
|
1999-08-28 01:45:37 +04:00
|
|
|
nsresult DoReflowInlineFrames(nsBlockReflowState& aState,
|
|
|
|
nsLineLayout& aLineLayout,
|
2001-10-25 05:08:40 +04:00
|
|
|
line_iterator aLine,
|
1999-08-28 01:45:37 +04:00
|
|
|
PRBool* aKeepReflowGoing,
|
2000-01-08 06:58:27 +03:00
|
|
|
PRUint8* aLineReflowStatus,
|
2000-04-19 07:12:13 +04:00
|
|
|
PRBool aUpdateMaximumWidth,
|
|
|
|
PRBool aDamageDirtyArea);
|
1999-08-28 01:45:37 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult ReflowInlineFrame(nsBlockReflowState& aState,
|
1999-08-28 01:45:37 +04:00
|
|
|
nsLineLayout& aLineLayout,
|
2001-10-25 05:08:40 +04:00
|
|
|
line_iterator aLine,
|
1998-12-05 19:02:08 +03:00
|
|
|
nsIFrame* aFrame,
|
1999-03-21 04:15:12 +03:00
|
|
|
PRUint8* aLineReflowStatus);
|
1998-11-16 20:11:12 +03:00
|
|
|
|
2003-10-14 01:51:02 +04:00
|
|
|
// An incomplete aReflowStatus indicates the float should be split
|
2002-06-14 18:30:33 +04:00
|
|
|
// but only if the available height is constrained.
|
2003-10-14 01:51:02 +04:00
|
|
|
nsresult ReflowFloat(nsBlockReflowState& aState,
|
|
|
|
nsPlaceholderFrame* aPlaceholder,
|
|
|
|
nsFloatCache* aFloatCache,
|
|
|
|
nsReflowStatus& aReflowStatus);
|
1998-11-16 20:11:12 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
//----------------------------------------
|
|
|
|
// Methods for pushing/pulling lines/frames
|
|
|
|
|
|
|
|
virtual nsresult CreateContinuationFor(nsBlockReflowState& aState,
|
2002-05-29 02:50:43 +04:00
|
|
|
nsLineBox* aLine,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
PRBool& aMadeNewFrame);
|
|
|
|
|
|
|
|
// Push aLine which contains a positioned element that was truncated. Clean up any
|
|
|
|
// placeholders on the same line that were continued. Set aKeepReflowGoing to false.
|
|
|
|
void PushTruncatedPlaceholderLine(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine,
|
|
|
|
nsIFrame* aLastPlaceholder,
|
|
|
|
PRBool& aKeepReflowGoing);
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsresult SplitLine(nsBlockReflowState& aState,
|
1999-08-28 01:45:37 +04:00
|
|
|
nsLineLayout& aLineLayout,
|
2001-10-25 05:08:40 +04:00
|
|
|
line_iterator aLine,
|
1998-12-05 19:02:08 +03:00
|
|
|
nsIFrame* aFrame);
|
|
|
|
|
|
|
|
nsresult PullFrame(nsBlockReflowState& aState,
|
2001-10-25 05:08:40 +04:00
|
|
|
line_iterator aLine,
|
2000-04-19 07:12:13 +04:00
|
|
|
PRBool aDamageDeletedLine,
|
1998-12-05 19:02:08 +03:00
|
|
|
nsIFrame*& aFrameResult);
|
|
|
|
|
2005-03-23 06:35:08 +03:00
|
|
|
PRBool PullFrameFrom(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nsBlockFrame* aFromContainer,
|
|
|
|
PRBool aFromOverflowLine,
|
|
|
|
nsLineList::iterator aFromLine,
|
|
|
|
PRBool aDamageDeletedLines,
|
|
|
|
nsIFrame*& aFrameResult);
|
1998-12-05 19:02:08 +03:00
|
|
|
|
2001-10-25 05:08:40 +04:00
|
|
|
void PushLines(nsBlockReflowState& aState,
|
|
|
|
nsLineList::iterator aLineBefore);
|
1998-12-05 19:02:08 +03:00
|
|
|
|
2004-10-08 16:17:10 +04:00
|
|
|
|
|
|
|
void ReparentFloats(nsIFrame* aFirstFrame,
|
|
|
|
nsBlockFrame* aOldParent, PRBool aFromOverflow);
|
|
|
|
|
2003-10-14 01:51:02 +04:00
|
|
|
void PropagateFloatDamage(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nscoord aDeltaY);
|
1998-12-05 19:02:08 +03:00
|
|
|
|
2004-09-13 17:35:46 +04:00
|
|
|
void BuildFloatList(nsBlockReflowState& aState);
|
1998-12-05 19:02:08 +03:00
|
|
|
|
1999-07-14 21:26:20 +04:00
|
|
|
//----------------------------------------
|
|
|
|
// List handling kludge
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void RenumberLists(nsPresContext* aPresContext);
|
1998-12-05 19:02:08 +03:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
PRBool RenumberListsInBlock(nsPresContext* aPresContext,
|
2000-01-22 04:16:50 +03:00
|
|
|
nsBlockFrame* aContainerFrame,
|
2000-07-28 13:02:34 +04:00
|
|
|
PRInt32* aOrdinal,
|
|
|
|
PRInt32 aDepth);
|
1999-09-18 03:16:43 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
PRBool RenumberListsFor(nsPresContext* aPresContext, nsIFrame* aKid, PRInt32* aOrdinal, PRInt32 aDepth);
|
1999-07-14 21:26:20 +04:00
|
|
|
|
2005-05-17 07:15:14 +04:00
|
|
|
static PRBool FrameStartsCounterScope(nsIFrame* aFrame);
|
1999-07-14 21:26:20 +04:00
|
|
|
|
1999-10-20 03:04:19 +04:00
|
|
|
nsresult UpdateBulletPosition(nsBlockReflowState& aState);
|
1999-03-05 07:21:32 +03:00
|
|
|
|
1999-02-19 01:22:55 +03:00
|
|
|
void ReflowBullet(nsBlockReflowState& aState,
|
|
|
|
nsHTMLReflowMetrics& aMetrics);
|
1998-12-05 19:02:08 +03:00
|
|
|
|
1999-07-14 21:26:20 +04:00
|
|
|
//----------------------------------------
|
|
|
|
|
2005-03-23 06:35:08 +03:00
|
|
|
public:
|
2004-06-01 10:20:16 +04:00
|
|
|
nsLineList* GetOverflowLines() const;
|
2005-03-23 06:35:08 +03:00
|
|
|
protected:
|
2004-08-26 07:07:05 +04:00
|
|
|
nsLineList* RemoveOverflowLines();
|
2004-06-01 10:20:16 +04:00
|
|
|
nsresult SetOverflowLines(nsLineList* aOverflowLines);
|
1999-11-03 02:42:52 +03:00
|
|
|
|
2004-06-01 10:20:16 +04:00
|
|
|
nsFrameList* GetOverflowPlaceholders() const;
|
2002-12-04 03:58:52 +03:00
|
|
|
|
2005-03-23 06:35:08 +03: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;
|
|
|
|
|
|
|
|
nsAutoOOFFrameList(nsBlockFrame* aBlock) :
|
|
|
|
mList(aBlock->GetOverflowOutOfFlows().FirstChild()),
|
|
|
|
aOldHead(mList.FirstChild()), mBlock(aBlock) {}
|
|
|
|
~nsAutoOOFFrameList() {
|
|
|
|
if (mList.FirstChild() != aOldHead) {
|
|
|
|
mBlock->SetOverflowOutOfFlows(mList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
protected:
|
|
|
|
nsIFrame* aOldHead;
|
|
|
|
nsBlockFrame* mBlock;
|
|
|
|
};
|
2005-06-01 20:28:06 +04:00
|
|
|
friend struct nsAutoOOFFrameList;
|
2005-03-23 06:35:08 +03:00
|
|
|
|
|
|
|
nsFrameList GetOverflowOutOfFlows() const;
|
|
|
|
void SetOverflowOutOfFlows(const nsFrameList& aList);
|
2004-05-05 06:30:33 +04:00
|
|
|
|
1999-04-20 04:27:43 +04:00
|
|
|
nsIFrame* LastChild();
|
1998-12-05 19:02:08 +03:00
|
|
|
|
1999-02-09 20:31:33 +03:00
|
|
|
#ifdef NS_DEBUG
|
2004-06-01 10:20:16 +04:00
|
|
|
PRBool IsChild(nsIFrame* aFrame);
|
1999-04-20 04:27:43 +04:00
|
|
|
void VerifyLines(PRBool aFinalCheckOK);
|
2004-06-01 10:20:16 +04:00
|
|
|
void VerifyOverflowSituation();
|
1999-03-23 01:41:09 +03:00
|
|
|
PRInt32 GetDepth() const;
|
1999-02-09 20:31:33 +03:00
|
|
|
#endif
|
|
|
|
|
2000-06-05 12:24:18 +04:00
|
|
|
// Ascent of our first line to support 'vertical-align: baseline' in table-cells
|
|
|
|
nscoord mAscent;
|
|
|
|
|
2001-10-25 05:08:40 +04:00
|
|
|
nsLineList mLines;
|
1999-02-09 20:31:33 +03:00
|
|
|
|
2003-10-14 01:51:02 +04:00
|
|
|
// List of all floats in this block
|
|
|
|
nsFrameList mFloats;
|
1998-11-16 20:11:12 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// XXX_fix_me: subclass one more time!
|
|
|
|
// For list-item frames, this is the bullet frame.
|
|
|
|
nsBulletFrame* mBullet;
|
1998-11-16 20:11:12 +03:00
|
|
|
|
1999-02-09 20:31:33 +03:00
|
|
|
friend class nsBlockReflowState;
|
2000-05-09 09:11:12 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsAbsoluteContainingBlock mAbsoluteContainer;
|
|
|
|
|
2001-05-01 08:22:57 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
public:
|
|
|
|
static PRBool gLamePaintMetrics;
|
|
|
|
static PRBool gLameReflowMetrics;
|
|
|
|
static PRBool gNoisy;
|
|
|
|
static PRBool gNoisyDamageRepair;
|
2003-01-09 17:26:32 +03:00
|
|
|
static PRBool gNoisyMaxElementWidth;
|
2001-05-01 08:22:57 +04:00
|
|
|
static PRBool gNoisyReflow;
|
|
|
|
static PRBool gReallyNoisyReflow;
|
|
|
|
static PRBool gNoisySpaceManager;
|
|
|
|
static PRBool gVerifyLines;
|
|
|
|
static PRBool gDisableResizeOpt;
|
|
|
|
|
|
|
|
static PRInt32 gNoiseIndent;
|
|
|
|
|
2001-12-18 01:39:59 +03:00
|
|
|
static const char* kReflowCommandType[];
|
|
|
|
|
2001-05-01 08:22:57 +04:00
|
|
|
protected:
|
|
|
|
static void InitDebugFlags();
|
|
|
|
#endif
|
1998-11-16 20:11:12 +03:00
|
|
|
};
|
|
|
|
|
2005-03-23 06:35:08 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
class AutoNoisyIndenter {
|
|
|
|
public:
|
|
|
|
AutoNoisyIndenter(PRBool aDoIndent) : mIndented(aDoIndent) {
|
|
|
|
if (mIndented) {
|
|
|
|
nsBlockFrame::gNoiseIndent++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
~AutoNoisyIndenter() {
|
|
|
|
if (mIndented) {
|
|
|
|
nsBlockFrame::gNoiseIndent--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
PRBool mIndented;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
1998-11-16 20:11:12 +03:00
|
|
|
#endif /* nsBlockFrame_h___ */
|
|
|
|
|