2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-10-30 20:16:45 +04: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/
|
1999-10-30 20:16:45 +04: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.
|
1999-10-30 20:16:45 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org 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 ***** */
|
2006-03-29 22:29:03 +04:00
|
|
|
|
|
|
|
/* struct containing the input to nsIFrame::Reflow */
|
|
|
|
|
1999-10-30 20:16:45 +04:00
|
|
|
#ifndef nsHTMLReflowState_h___
|
|
|
|
#define nsHTMLReflowState_h___
|
|
|
|
|
2001-07-16 06:40:48 +04:00
|
|
|
#include "nsMargin.h"
|
|
|
|
#include "nsStyleCoord.h"
|
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 08:38:33 +03:00
|
|
|
#include "nsIFrame.h"
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
class nsPresContext;
|
1999-10-30 20:16:45 +04:00
|
|
|
class nsIRenderingContext;
|
2001-10-26 09:06:07 +04:00
|
|
|
class nsSpaceManager;
|
1999-10-30 20:16:45 +04:00
|
|
|
class nsLineLayout;
|
2001-12-07 17:51:12 +03:00
|
|
|
class nsIPercentHeightObserver;
|
1999-10-30 20:16:45 +04:00
|
|
|
|
|
|
|
struct nsStyleDisplay;
|
2001-06-01 02:19:43 +04:00
|
|
|
struct nsStyleVisibility;
|
1999-10-30 20:16:45 +04:00
|
|
|
struct nsStylePosition;
|
2001-02-07 12:57:26 +03:00
|
|
|
struct nsStyleBorder;
|
|
|
|
struct nsStyleMargin;
|
|
|
|
struct nsStylePadding;
|
2000-07-28 03:37:44 +04:00
|
|
|
struct nsStyleText;
|
2000-04-16 08:07:02 +04:00
|
|
|
struct nsHypotheticalBox;
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2008-01-24 04:21:31 +03:00
|
|
|
template <class NumericType>
|
|
|
|
NumericType
|
|
|
|
NS_CSS_MINMAX(NumericType aValue, NumericType aMinValue, NumericType aMaxValue)
|
|
|
|
{
|
|
|
|
NumericType result = aValue;
|
|
|
|
if (aMaxValue < result)
|
|
|
|
result = aMaxValue;
|
|
|
|
if (aMinValue > result)
|
|
|
|
result = aMinValue;
|
|
|
|
return result;
|
|
|
|
}
|
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 08:38:33 +03:00
|
|
|
|
1999-10-30 20:16:45 +04:00
|
|
|
/**
|
|
|
|
* Constant used to indicate an unconstrained size.
|
|
|
|
*
|
|
|
|
* @see #Reflow()
|
|
|
|
*/
|
|
|
|
#define NS_UNCONSTRAINEDSIZE NS_MAXSIZE
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CSS Frame type. Included as part of the reflow state.
|
|
|
|
*/
|
|
|
|
typedef PRUint32 nsCSSFrameType;
|
|
|
|
|
|
|
|
#define NS_CSS_FRAME_TYPE_UNKNOWN 0
|
|
|
|
#define NS_CSS_FRAME_TYPE_INLINE 1
|
|
|
|
#define NS_CSS_FRAME_TYPE_BLOCK 2 /* block-level in normal flow */
|
|
|
|
#define NS_CSS_FRAME_TYPE_FLOATING 3
|
|
|
|
#define NS_CSS_FRAME_TYPE_ABSOLUTE 4
|
|
|
|
#define NS_CSS_FRAME_TYPE_INTERNAL_TABLE 5 /* row group frame, row frame, cell frame, ... */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bit-flag that indicates whether the element is replaced. Applies to inline,
|
|
|
|
* block-level, floating, and absolutely positioned elements
|
|
|
|
*/
|
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 08:38:33 +03:00
|
|
|
#define NS_CSS_FRAME_TYPE_REPLACED 0x08000
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bit-flag that indicates that the element is replaced and contains a block
|
|
|
|
* (eg some form controls). Applies to inline, block-level, floating, and
|
|
|
|
* absolutely positioned elements. Mutually exclusive with
|
|
|
|
* NS_CSS_FRAME_TYPE_REPLACED.
|
|
|
|
*/
|
|
|
|
#define NS_CSS_FRAME_TYPE_REPLACED_CONTAINS_BLOCK 0x10000
|
1999-10-30 20:16:45 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper macros for telling whether items are replaced
|
|
|
|
*/
|
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 08:38:33 +03:00
|
|
|
#define NS_FRAME_IS_REPLACED_NOBLOCK(_ft) \
|
1999-10-30 20:16:45 +04:00
|
|
|
(NS_CSS_FRAME_TYPE_REPLACED == ((_ft) & NS_CSS_FRAME_TYPE_REPLACED))
|
|
|
|
|
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 08:38:33 +03:00
|
|
|
#define NS_FRAME_IS_REPLACED(_ft) \
|
|
|
|
(NS_FRAME_IS_REPLACED_NOBLOCK(_ft) || \
|
|
|
|
NS_FRAME_IS_REPLACED_CONTAINS_BLOCK(_ft))
|
|
|
|
|
1999-10-30 20:16:45 +04:00
|
|
|
#define NS_FRAME_REPLACED(_ft) \
|
|
|
|
(NS_CSS_FRAME_TYPE_REPLACED | (_ft))
|
|
|
|
|
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 08:38:33 +03:00
|
|
|
#define NS_FRAME_IS_REPLACED_CONTAINS_BLOCK(_ft) \
|
|
|
|
(NS_CSS_FRAME_TYPE_REPLACED_CONTAINS_BLOCK == \
|
|
|
|
((_ft) & NS_CSS_FRAME_TYPE_REPLACED_CONTAINS_BLOCK))
|
|
|
|
|
|
|
|
#define NS_FRAME_REPLACED_CONTAINS_BLOCK(_ft) \
|
|
|
|
(NS_CSS_FRAME_TYPE_REPLACED_CONTAINS_BLOCK | (_ft))
|
|
|
|
|
1999-10-30 20:16:45 +04:00
|
|
|
/**
|
|
|
|
* A macro to extract the type. Masks off the 'replaced' bit-flag
|
|
|
|
*/
|
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 08:38:33 +03:00
|
|
|
#define NS_FRAME_GET_TYPE(_ft) \
|
|
|
|
((_ft) & ~(NS_CSS_FRAME_TYPE_REPLACED | \
|
|
|
|
NS_CSS_FRAME_TYPE_REPLACED_CONTAINS_BLOCK))
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2000-01-03 07:32:13 +03:00
|
|
|
#define NS_INTRINSICSIZE NS_UNCONSTRAINEDSIZE
|
|
|
|
#define NS_AUTOHEIGHT NS_UNCONSTRAINEDSIZE
|
|
|
|
#define NS_AUTOMARGIN NS_UNCONSTRAINEDSIZE
|
2000-04-16 08:07:02 +04:00
|
|
|
#define NS_AUTOOFFSET NS_UNCONSTRAINEDSIZE
|
2001-03-06 08:56:19 +03:00
|
|
|
// NOTE: there are assumptions all over that these have the same value, namely NS_UNCONSTRAINEDSIZE
|
|
|
|
// if any are changed to be a value other than NS_UNCONSTRAINEDSIZE
|
|
|
|
// at least update AdjustComputedHeight/Width and test ad nauseum
|
1999-10-30 20:16:45 +04: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 08:38:33 +03:00
|
|
|
// A base class of nsHTMLReflowState that computes only the padding,
|
|
|
|
// border, and margin, since those values are needed more often.
|
|
|
|
struct nsCSSOffsetState {
|
|
|
|
public:
|
|
|
|
// the frame being reflowed
|
|
|
|
nsIFrame* frame;
|
|
|
|
|
|
|
|
// rendering context to use for measurement
|
|
|
|
nsIRenderingContext* rendContext;
|
|
|
|
|
|
|
|
// Computed margin values
|
|
|
|
nsMargin mComputedMargin;
|
|
|
|
|
|
|
|
// Cached copy of the border + padding values
|
|
|
|
nsMargin mComputedBorderPadding;
|
|
|
|
|
|
|
|
// Computed padding values
|
|
|
|
nsMargin mComputedPadding;
|
|
|
|
|
|
|
|
// Callers using this constructor must call InitOffsets on their own.
|
|
|
|
nsCSSOffsetState(nsIFrame *aFrame, nsIRenderingContext *aRenderingContext)
|
|
|
|
: frame(aFrame)
|
|
|
|
, rendContext(aRenderingContext)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSOffsetState(nsIFrame *aFrame, nsIRenderingContext *aRenderingContext,
|
|
|
|
nscoord aContainingBlockWidth)
|
|
|
|
: frame(aFrame)
|
|
|
|
, rendContext(aRenderingContext)
|
|
|
|
{
|
|
|
|
InitOffsets(aContainingBlockWidth);
|
|
|
|
}
|
|
|
|
|
2007-02-20 21:54:16 +03:00
|
|
|
// Destructor for usedPaddingProperty
|
|
|
|
static void DestroyMarginFunc(void* aFrame,
|
|
|
|
nsIAtom* aPropertyName,
|
|
|
|
void* aPropertyValue,
|
|
|
|
void* aDtorData);
|
|
|
|
|
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 08:38:33 +03:00
|
|
|
private:
|
|
|
|
// Computes margin values from the specified margin style information, and
|
|
|
|
// fills in the mComputedMargin member
|
|
|
|
void ComputeMargin(nscoord aContainingBlockWidth);
|
|
|
|
|
|
|
|
// Computes padding values from the specified padding style information, and
|
|
|
|
// fills in the mComputedPadding member
|
|
|
|
void ComputePadding(nscoord aContainingBlockWidth);
|
|
|
|
|
|
|
|
protected:
|
2007-05-04 03:11:00 +04:00
|
|
|
|
2007-08-21 00:07:50 +04:00
|
|
|
void InitOffsets(nscoord aContainingBlockWidth,
|
|
|
|
const nsMargin *aBorder = nsnull,
|
|
|
|
const nsMargin *aPadding = nsnull);
|
|
|
|
|
2007-05-04 03:11:00 +04:00
|
|
|
/*
|
|
|
|
* Convert nsStyleCoord to nscoord when percentages depend on the
|
|
|
|
* containing block width.
|
|
|
|
*/
|
|
|
|
// XXX Make aResult a return value
|
2006-12-18 16:20:18 +03:00
|
|
|
inline void ComputeWidthDependentValue(nscoord aContainingBlockWidth,
|
|
|
|
const nsStyleCoord& aCoord,
|
|
|
|
nscoord& aResult);
|
2007-05-04 03:11:00 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert nsStyleCoord to nscoord when percentages depend on the
|
|
|
|
* containing block width, and enumerated values are for width,
|
|
|
|
* min-width, or max-width. Does not handle auto widths.
|
|
|
|
*/
|
|
|
|
inline nscoord ComputeWidthValue(nscoord aContainingBlockWidth,
|
|
|
|
nscoord aContentEdgeToBoxSizing,
|
|
|
|
nscoord aBoxSizingToMarginEdge,
|
|
|
|
const nsStyleCoord& aCoord);
|
|
|
|
// same as previous, but using mComputedBorderPadding, mComputedPadding,
|
|
|
|
// and mComputedMargin
|
|
|
|
nscoord ComputeWidthValue(nscoord aContainingBlockWidth,
|
|
|
|
PRUint8 aBoxSizing,
|
|
|
|
const nsStyleCoord& aCoord);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert nsStyleCoord to nscoord when percentages depend on the
|
|
|
|
* containing block height.
|
|
|
|
*/
|
|
|
|
// XXX Make aResult a return value
|
2006-12-18 16:20:18 +03:00
|
|
|
inline void ComputeHeightDependentValue(nscoord aContainingBlockHeight,
|
|
|
|
const nsStyleCoord& aCoord,
|
|
|
|
nscoord& aResult);
|
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 08:38:33 +03:00
|
|
|
};
|
|
|
|
|
1999-10-30 20:16:45 +04: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 08:38:33 +03:00
|
|
|
* State passed to a frame during reflow or intrinsic size calculation.
|
|
|
|
*
|
|
|
|
* XXX Refactor so only a base class (nsSizingState?) is used for intrinsic
|
|
|
|
* size calculation.
|
1999-10-30 20:16:45 +04:00
|
|
|
*
|
2000-01-03 07:32:13 +03:00
|
|
|
* @see nsIFrame#Reflow()
|
1999-10-30 20:16:45 +04: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 08:38:33 +03:00
|
|
|
struct nsHTMLReflowState : public nsCSSOffsetState {
|
2000-01-03 07:32:13 +03:00
|
|
|
// the reflow states are linked together. this is the pointer to the
|
|
|
|
// parent's reflow state
|
1999-10-30 20:16:45 +04:00
|
|
|
const nsHTMLReflowState* parentReflowState;
|
|
|
|
|
2005-03-23 06:35:08 +03:00
|
|
|
// the available width in which to reflow the frame. The space
|
|
|
|
// represents the amount of room for the frame's border, padding,
|
|
|
|
// and content area (not the margin area. The parent frame deals
|
|
|
|
// with the child frame's margins). The frame size you choose should
|
|
|
|
// fit within the available width.
|
|
|
|
nscoord availableWidth;
|
|
|
|
|
|
|
|
// A value of NS_UNCONSTRAINEDSIZE for the available height means
|
|
|
|
// you can choose whatever size you want. In galley mode the
|
|
|
|
// available height is always NS_UNCONSTRAINEDSIZE, and only page
|
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 08:38:33 +03:00
|
|
|
// mode or multi-column layout involves a constrained height. The
|
|
|
|
// element's the top border and padding, and content, must fit. If the
|
|
|
|
// element is complete after reflow then its bottom border, padding
|
|
|
|
// and margin (and similar for its complete ancestors) will need to
|
|
|
|
// fit in this height.
|
2005-03-23 06:35:08 +03:00
|
|
|
nscoord availableHeight;
|
1999-10-30 20:16:45 +04:00
|
|
|
|
|
|
|
// The type of frame, from css's perspective. This value is
|
|
|
|
// initialized by the Init method below.
|
|
|
|
nsCSSFrameType mFrameType;
|
|
|
|
|
2000-01-03 07:32:13 +03:00
|
|
|
// pointer to the space manager associated with this area
|
2001-10-26 09:06:07 +04:00
|
|
|
nsSpaceManager* mSpaceManager;
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2007-08-21 00:07:50 +04:00
|
|
|
// The amount the in-flow position of the block is moving vertically relative
|
|
|
|
// to its previous in-flow position (i.e. the amount the line containing the
|
|
|
|
// block is moving).
|
|
|
|
// This should be zero for anything which is not a block outside, and it
|
|
|
|
// should be zero for anything which has a non-block parent.
|
|
|
|
// The intended use of this value is to allow the accurate determination
|
|
|
|
// of the potential impact of a float
|
|
|
|
// This takes on an arbitrary value the first time a block is reflowed
|
|
|
|
nscoord mBlockDelta;
|
|
|
|
|
1999-10-30 20:16:45 +04:00
|
|
|
// LineLayout object (only for inline reflow; set to NULL otherwise)
|
|
|
|
nsLineLayout* mLineLayout;
|
|
|
|
|
2002-05-14 16:59:55 +04:00
|
|
|
// The appropriate reflow state for the containing block (for
|
2004-04-24 21:56:23 +04:00
|
|
|
// percentage widths, etc.) of this reflow state's frame.
|
2002-05-14 16:59:55 +04:00
|
|
|
const nsHTMLReflowState *mCBReflowState;
|
|
|
|
|
2007-01-26 03:05:12 +03:00
|
|
|
private:
|
2000-01-03 07:32:13 +03:00
|
|
|
// The computed width specifies the frame's content area width, and it does
|
|
|
|
// not apply to inline non-replaced elements
|
1999-10-30 20:16:45 +04:00
|
|
|
//
|
|
|
|
// For replaced inline frames, a value of NS_INTRINSICSIZE means you should
|
|
|
|
// use your intrinsic width as the computed width
|
|
|
|
//
|
|
|
|
// For block-level frames, the computed width is based on the width of the
|
2000-01-03 07:32:13 +03:00
|
|
|
// containing block, the margin/border/padding areas, and the min/max width.
|
1999-10-30 20:16:45 +04:00
|
|
|
nscoord mComputedWidth;
|
|
|
|
|
|
|
|
// The computed height specifies the frame's content height, and it does
|
|
|
|
// not apply to inline non-replaced elements
|
|
|
|
//
|
|
|
|
// For replaced inline frames, a value of NS_INTRINSICSIZE means you should
|
|
|
|
// use your intrinsic height as the computed height
|
|
|
|
//
|
|
|
|
// For non-replaced block-level frames in the flow and floated, a value of
|
|
|
|
// NS_AUTOHEIGHT means you choose a height to shrink wrap around the normal
|
|
|
|
// flow child frames. The height must be within the limit of the min/max
|
|
|
|
// height if there is such a limit
|
|
|
|
//
|
|
|
|
// For replaced block-level frames, a value of NS_INTRINSICSIZE
|
|
|
|
// means you use your intrinsic height as the computed height
|
|
|
|
nscoord mComputedHeight;
|
|
|
|
|
2007-08-02 22:08:05 +04:00
|
|
|
public:
|
1999-10-30 20:16:45 +04:00
|
|
|
// Computed values for 'left/top/right/bottom' offsets. Only applies to
|
|
|
|
// 'positioned' elements
|
|
|
|
nsMargin mComputedOffsets;
|
|
|
|
|
|
|
|
// Computed values for 'min-width/max-width' and 'min-height/max-height'
|
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 08:38:33 +03:00
|
|
|
// XXXldb The width ones here should go; they should be needed only
|
|
|
|
// internally.
|
1999-10-30 20:16:45 +04:00
|
|
|
nscoord mComputedMinWidth, mComputedMaxWidth;
|
|
|
|
nscoord mComputedMinHeight, mComputedMaxHeight;
|
|
|
|
|
|
|
|
// Cached pointers to the various style structs used during intialization
|
2001-12-07 17:51:12 +03:00
|
|
|
const nsStyleDisplay* mStyleDisplay;
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleVisibility* mStyleVisibility;
|
2001-12-07 17:51:12 +03:00
|
|
|
const nsStylePosition* mStylePosition;
|
|
|
|
const nsStyleBorder* mStyleBorder;
|
|
|
|
const nsStyleMargin* mStyleMargin;
|
|
|
|
const nsStylePadding* mStylePadding;
|
|
|
|
const nsStyleText* mStyleText;
|
|
|
|
|
|
|
|
// a frame (e.g. nsTableCellFrame) which may need to generate a special
|
|
|
|
// reflow for percent height calculations
|
|
|
|
nsIPercentHeightObserver* mPercentHeightObserver;
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2002-04-01 10:46:17 +04:00
|
|
|
// a frame (e.g. nsTableFrame) which initiates a special reflow for percent height calculations
|
|
|
|
nsIFrame* mPercentHeightReflowInitiator;
|
|
|
|
|
2004-11-25 17:51:00 +03:00
|
|
|
// CSS margin collapsing sometimes requires us to reflow
|
|
|
|
// optimistically assuming that margins collapse to see if clearance
|
|
|
|
// is required. When we discover that clearance is required, we
|
|
|
|
// store the frame in which clearance was discovered to the location
|
|
|
|
// requested here.
|
|
|
|
nsIFrame** mDiscoveredClearance;
|
|
|
|
|
1999-10-30 20:16:45 +04:00
|
|
|
// This value keeps track of how deeply nested a given reflow state
|
|
|
|
// is from the top of the frame tree.
|
2001-11-05 03:15:51 +03:00
|
|
|
PRInt16 mReflowDepth;
|
|
|
|
|
|
|
|
struct ReflowStateFlags {
|
2001-12-07 17:51:12 +03:00
|
|
|
PRUint16 mSpecialHeightReflow:1; // used by tables to communicate special reflow (in process) to handle
|
|
|
|
// percent height frames inside cells which may not have computed heights
|
2004-10-08 16:17:10 +04:00
|
|
|
PRUint16 mNextInFlowUntouched:1; // nothing in the frame's next-in-flow (or its descendants)
|
|
|
|
// is changing
|
2001-12-07 17:51:12 +03:00
|
|
|
PRUint16 mIsTopOfPage:1; // is the current context at the top of a page?
|
|
|
|
PRUint16 mBlinks:1; // Keep track of text-decoration: blink
|
2004-11-25 17:51:00 +03:00
|
|
|
PRUint16 mHasClearance:1; // Block has clearance
|
2005-10-18 09:00:24 +04:00
|
|
|
PRUint16 mAssumingHScrollbar:1; // parent frame is an nsIScrollableFrame and it
|
|
|
|
// is assuming a horizontal scrollbar
|
|
|
|
PRUint16 mAssumingVScrollbar:1; // parent frame is an nsIScrollableFrame and it
|
|
|
|
// is assuming a vertical scrollbar
|
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 08:38:33 +03:00
|
|
|
|
|
|
|
PRUint16 mHResize:1; // Is frame (a) not dirty and (b) a
|
|
|
|
// different width than before?
|
|
|
|
|
|
|
|
PRUint16 mVResize:1; // Is frame (a) not dirty and (b) a
|
|
|
|
// different height than before or
|
|
|
|
// (potentially) in a context where
|
|
|
|
// percent heights have a different
|
|
|
|
// basis?
|
2007-01-21 20:51:33 +03:00
|
|
|
PRUint16 mTableIsSplittable:1; // tables are splittable, this should happen only inside a page
|
|
|
|
// and never insider a column frame
|
2008-02-22 00:02:07 +03:00
|
|
|
PRUint16 mHeightDependsOnAncestorCell:1; // Does frame height depend on
|
|
|
|
// an ancestor table-cell?
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
} mFlags;
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2004-04-24 21:56:23 +04:00
|
|
|
// Note: The copy constructor is written by the compiler automatically. You
|
|
|
|
// can use that and then override specific values if you want, or you can
|
|
|
|
// call Init as desired...
|
1999-10-30 20:16:45 +04:00
|
|
|
|
|
|
|
// Initialize a <b>root</b> reflow state with a rendering context to
|
|
|
|
// use for measuring things.
|
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 08:38:33 +03:00
|
|
|
nsHTMLReflowState(nsPresContext* aPresContext,
|
1999-10-30 20:16:45 +04:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIRenderingContext* aRenderingContext,
|
|
|
|
const nsSize& aAvailableSpace);
|
|
|
|
|
|
|
|
// Initialize a reflow state for a child frames reflow. Some state
|
|
|
|
// is copied from the parent reflow state; the remaining state is
|
2002-02-19 18:48:28 +03:00
|
|
|
// computed.
|
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 08:38:33 +03:00
|
|
|
nsHTMLReflowState(nsPresContext* aPresContext,
|
1999-10-30 20:16:45 +04:00
|
|
|
const nsHTMLReflowState& aParentReflowState,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const nsSize& aAvailableSpace,
|
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 08:38:33 +03:00
|
|
|
// These two are used by absolute positioning code
|
|
|
|
// to override default containing block w & h:
|
|
|
|
nscoord aContainingBlockWidth = -1,
|
|
|
|
nscoord aContainingBlockHeight = -1,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRBool aInit = PR_TRUE);
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
// This method initializes various data members. It is automatically
|
|
|
|
// called by the various constructors
|
2004-08-01 03:15:21 +04:00
|
|
|
void Init(nsPresContext* aPresContext,
|
2002-02-19 18:48:28 +03:00
|
|
|
nscoord aContainingBlockWidth = -1,
|
|
|
|
nscoord aContainingBlockHeight = -1,
|
2006-12-12 18:18:40 +03:00
|
|
|
const nsMargin* aBorder = nsnull,
|
|
|
|
const nsMargin* aPadding = nsnull);
|
1999-10-30 20:16:45 +04:00
|
|
|
/**
|
2004-04-24 21:56:23 +04:00
|
|
|
* Find the content width of the containing block of aReflowState
|
1999-10-30 20:16:45 +04:00
|
|
|
*/
|
|
|
|
static nscoord
|
2004-04-24 21:56:23 +04:00
|
|
|
GetContainingBlockContentWidth(const nsHTMLReflowState* aReflowState);
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2004-11-25 05:43:28 +03:00
|
|
|
/**
|
|
|
|
* Find the containing block of aFrame. This may return null if
|
|
|
|
* there isn't one (but that should really only happen for root
|
|
|
|
* frames).
|
|
|
|
*/
|
2004-11-25 05:58:01 +03:00
|
|
|
static nsIFrame* GetContainingBlockFor(const nsIFrame* aFrame);
|
2004-11-25 05:43:28 +03:00
|
|
|
|
1999-10-30 20:16:45 +04:00
|
|
|
/**
|
|
|
|
* Calculate the raw line-height property for the given frame. The return
|
2007-05-05 09:30:10 +04:00
|
|
|
* value will be >= 0.
|
1999-10-30 20:16:45 +04:00
|
|
|
*/
|
2007-05-05 09:30:10 +04:00
|
|
|
static nscoord CalcLineHeight(nsIRenderingContext* aRenderingContext,
|
2007-08-25 02:20:24 +04:00
|
|
|
nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
return CalcLineHeight(aRenderingContext, aFrame->GetStyleContext());
|
|
|
|
}
|
|
|
|
|
2007-05-05 09:30:10 +04:00
|
|
|
/**
|
2007-08-25 02:20:24 +04:00
|
|
|
* Same as above, but doesn't need a frame.
|
2007-05-05 09:30:10 +04:00
|
|
|
*/
|
2007-08-25 02:20:24 +04:00
|
|
|
static nscoord CalcLineHeight(nsIRenderingContext* aRenderingContext,
|
|
|
|
nsStyleContext* aStyleContext);
|
1999-10-30 20:16:45 +04:00
|
|
|
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void ComputeContainingBlockRectangle(nsPresContext* aPresContext,
|
2000-04-29 01:05:31 +04:00
|
|
|
const nsHTMLReflowState* aContainingBlockRS,
|
|
|
|
nscoord& aContainingBlockWidth,
|
|
|
|
nscoord& aContainingBlockHeight);
|
|
|
|
|
2005-04-29 01:57:22 +04:00
|
|
|
/**
|
|
|
|
* Apply the mComputed(Min/Max)(Width/Height) values to the content
|
|
|
|
* size computed so far. If a passed-in pointer is null, we skip
|
|
|
|
* adjusting that dimension.
|
|
|
|
*/
|
|
|
|
void ApplyMinMaxConstraints(nscoord* aContentWidth, nscoord* aContentHeight) const;
|
1999-10-30 20:16:45 +04: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 08:38:33 +03:00
|
|
|
PRBool ShouldReflowAllKids() const {
|
|
|
|
// Note that we could make a stronger optimization for mVResize if
|
|
|
|
// we use it in a ShouldReflowChild test that replaces the current
|
|
|
|
// checks of NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN, if it
|
|
|
|
// were tested there along with NS_FRAME_CONTAINS_RELATIVE_HEIGHT.
|
|
|
|
// This would need to be combined with a slight change in which
|
|
|
|
// frames NS_FRAME_CONTAINS_RELATIVE_HEIGHT is marked on.
|
|
|
|
return (frame->GetStateBits() & NS_FRAME_IS_DIRTY) ||
|
|
|
|
mFlags.mHResize ||
|
|
|
|
(mFlags.mVResize &&
|
|
|
|
(frame->GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_HEIGHT));
|
|
|
|
}
|
|
|
|
|
2007-01-26 03:05:12 +03:00
|
|
|
nscoord ComputedWidth() const { return mComputedWidth; }
|
2007-08-02 22:08:05 +04:00
|
|
|
// This method doesn't apply min/max computed widths to the value passed in.
|
2007-01-26 03:05:12 +03:00
|
|
|
void SetComputedWidth(nscoord aComputedWidth);
|
|
|
|
|
2007-08-02 22:08:05 +04:00
|
|
|
nscoord ComputedHeight() const { return mComputedHeight; }
|
|
|
|
// This method doesn't apply min/max computed heights to the value passed in.
|
|
|
|
void SetComputedHeight(nscoord aComputedHeight);
|
|
|
|
|
2007-03-11 23:34:15 +03:00
|
|
|
void SetTruncated(const nsHTMLReflowMetrics& aMetrics, nsReflowStatus* aStatus) const;
|
|
|
|
|
2007-12-05 05:57:53 +03:00
|
|
|
PRBool WillReflowAgainForClearance() const {
|
|
|
|
return mDiscoveredClearance && *mDiscoveredClearance;
|
|
|
|
}
|
|
|
|
|
1999-10-30 20:16:45 +04:00
|
|
|
protected:
|
2007-08-21 00:07:50 +04:00
|
|
|
void InitFrameType();
|
2002-05-14 16:59:55 +04:00
|
|
|
void InitCBReflowState();
|
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 08:38:33 +03:00
|
|
|
void InitResizeFlags(nsPresContext* aPresContext);
|
2002-05-14 16:59:55 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void InitConstraints(nsPresContext* aPresContext,
|
1999-10-30 20:16:45 +04:00
|
|
|
nscoord aContainingBlockWidth,
|
2002-02-19 18:48:28 +03:00
|
|
|
nscoord aContainingBlockHeight,
|
2006-12-12 18:18:40 +03:00
|
|
|
const nsMargin* aBorder,
|
|
|
|
const nsMargin* aPadding);
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2006-12-18 06:34:05 +03:00
|
|
|
// Returns the nearest containing block frame for the specified frame. Also
|
|
|
|
// returns the left edge and width of the containing block's content area.
|
|
|
|
// These are returned in the coordinate space of the containing block.
|
|
|
|
nsIFrame* GetNearestContainingBlock(nsIFrame* aFrame, nscoord& aCBLeftEdge,
|
|
|
|
nscoord& aCBWidth);
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void CalculateHypotheticalBox(nsPresContext* aPresContext,
|
2006-12-18 06:34:05 +03:00
|
|
|
nsIFrame* aPlaceholderFrame,
|
|
|
|
nsIFrame* aContainingBlock,
|
|
|
|
nscoord aBlockLeftContentEdge,
|
|
|
|
nscoord aBlockContentWidth,
|
2004-04-24 21:56:23 +04:00
|
|
|
const nsHTMLReflowState* cbrs,
|
2000-04-16 08:07:02 +04:00
|
|
|
nsHypotheticalBox& aHypotheticalBox);
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void InitAbsoluteConstraints(nsPresContext* aPresContext,
|
1999-10-30 20:16:45 +04:00
|
|
|
const nsHTMLReflowState* cbrs,
|
|
|
|
nscoord aContainingBlockWidth,
|
|
|
|
nscoord aContainingBlockHeight);
|
|
|
|
|
|
|
|
void ComputeRelativeOffsets(const nsHTMLReflowState* cbrs,
|
|
|
|
nscoord aContainingBlockWidth,
|
|
|
|
nscoord aContainingBlockHeight);
|
|
|
|
|
|
|
|
// Calculates the computed values for the 'min-Width', 'max-Width',
|
|
|
|
// 'min-Height', and 'max-Height' properties, and stores them in the assorted
|
|
|
|
// data members
|
|
|
|
void ComputeMinMaxValues(nscoord aContainingBlockWidth,
|
|
|
|
nscoord aContainingBlockHeight,
|
|
|
|
const nsHTMLReflowState* aContainingBlockRS);
|
|
|
|
|
2007-05-04 03:11:00 +04:00
|
|
|
void CalculateHorizBorderPaddingMargin(nscoord aContainingBlockWidth,
|
|
|
|
nscoord* aInsideBoxSizing,
|
|
|
|
nscoord* aOutsideBoxSizing);
|
2001-03-06 08:56:19 +03:00
|
|
|
|
2007-08-21 00:07:50 +04:00
|
|
|
void CalculateBlockSideMargins(nscoord aAvailWidth,
|
|
|
|
nscoord aComputedWidth);
|
1999-10-30 20:16:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsHTMLReflowState_h___ */
|
|
|
|
|