2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
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"
|
2013-04-11 18:51:52 +04:00
|
|
|
#include "mozilla/Assertions.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
class nsPresContext;
|
2011-04-08 05:04:40 +04:00
|
|
|
class nsRenderingContext;
|
2009-01-05 03:39:54 +03:00
|
|
|
class nsFloatManager;
|
1999-10-30 20:16:45 +04:00
|
|
|
class nsLineLayout;
|
2001-12-07 17:51:12 +03:00
|
|
|
class nsIPercentHeightObserver;
|
2000-04-16 08:07:02 +04:00
|
|
|
struct nsHypotheticalBox;
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2013-01-21 18:14:49 +04:00
|
|
|
/**
|
|
|
|
* @return aValue clamped to [aMinValue, aMaxValue].
|
|
|
|
*
|
|
|
|
* @note This function needs to handle aMinValue > aMaxValue. In that case,
|
|
|
|
* aMinValue is returned.
|
|
|
|
* @see http://www.w3.org/TR/CSS21/visudet.html#min-max-widths
|
|
|
|
* @see http://www.w3.org/TR/CSS21/visudet.html#min-max-heights
|
|
|
|
*/
|
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
|
|
|
/**
|
|
|
|
* CSS Frame type. Included as part of the reflow state.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
typedef uint32_t nsCSSFrameType;
|
1999-10-30 20:16:45 +04:00
|
|
|
|
|
|
|
#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
|
|
|
|
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:
|
2013-12-27 21:59:38 +04:00
|
|
|
typedef mozilla::WritingMode WritingMode;
|
|
|
|
typedef mozilla::LogicalMargin LogicalMargin;
|
|
|
|
|
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
|
|
|
// the frame being reflowed
|
|
|
|
nsIFrame* frame;
|
|
|
|
|
|
|
|
// rendering context to use for measurement
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* rendContext;
|
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
|
|
|
|
2013-12-27 21:59:02 +04:00
|
|
|
const nsMargin& ComputedPhysicalMargin() const { return mComputedMargin; }
|
|
|
|
const nsMargin& ComputedPhysicalBorderPadding() const { return mComputedBorderPadding; }
|
|
|
|
const nsMargin& ComputedPhysicalPadding() const { return mComputedPadding; }
|
|
|
|
|
|
|
|
// We may need to eliminate the (few) users of these writable-reference accessors
|
|
|
|
// as part of migrating to logical coordinates.
|
|
|
|
nsMargin& ComputedPhysicalMargin() { return mComputedMargin; }
|
|
|
|
nsMargin& ComputedPhysicalBorderPadding() { return mComputedBorderPadding; }
|
|
|
|
nsMargin& ComputedPhysicalPadding() { return mComputedPadding; }
|
|
|
|
|
2013-12-27 21:59:38 +04:00
|
|
|
LogicalMargin ComputedLogicalMargin() const
|
|
|
|
{ return LogicalMargin(mWritingMode, mComputedMargin); }
|
|
|
|
LogicalMargin ComputedLogicalBorderPadding() const
|
|
|
|
{ return LogicalMargin(mWritingMode, mComputedBorderPadding); }
|
|
|
|
LogicalMargin ComputedLogicalPadding() const
|
|
|
|
{ return LogicalMargin(mWritingMode, mComputedPadding); }
|
|
|
|
|
|
|
|
WritingMode GetWritingMode() const { return mWritingMode; }
|
|
|
|
|
2013-12-27 21:59:02 +04:00
|
|
|
protected:
|
2013-12-27 21:59:38 +04:00
|
|
|
// cached copy of the frame's writing-mode, for logical coordinates
|
|
|
|
WritingMode mWritingMode;
|
|
|
|
|
|
|
|
// These are PHYSICAL coordinates (for now).
|
|
|
|
// Will probably become logical in due course.
|
|
|
|
|
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
|
|
|
// Computed margin values
|
|
|
|
nsMargin mComputedMargin;
|
|
|
|
|
|
|
|
// Cached copy of the border + padding values
|
|
|
|
nsMargin mComputedBorderPadding;
|
|
|
|
|
|
|
|
// Computed padding values
|
|
|
|
nsMargin mComputedPadding;
|
|
|
|
|
2013-12-27 21:59:02 +04:00
|
|
|
public:
|
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
|
|
|
// Callers using this constructor must call InitOffsets on their own.
|
2011-04-08 05:04:40 +04:00
|
|
|
nsCSSOffsetState(nsIFrame *aFrame, nsRenderingContext *aRenderingContext)
|
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
|
|
|
: frame(aFrame)
|
|
|
|
, rendContext(aRenderingContext)
|
2013-12-27 21:59:38 +04:00
|
|
|
, mWritingMode(aFrame->GetWritingMode())
|
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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-04-08 05:04:40 +04:00
|
|
|
nsCSSOffsetState(nsIFrame *aFrame, nsRenderingContext *aRenderingContext,
|
2014-01-21 02:02:18 +04:00
|
|
|
nscoord aContainingBlockWidth);
|
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
|
|
|
|
2010-05-02 01:40:16 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
// Reflow trace methods. Defined in nsFrame.cpp so they have access
|
|
|
|
// to the display-reflow infrastructure.
|
|
|
|
static void* DisplayInitOffsetsEnter(nsIFrame* aFrame,
|
|
|
|
nsCSSOffsetState* aState,
|
2013-04-11 18:51:58 +04:00
|
|
|
nscoord aHorizontalPercentBasis,
|
|
|
|
nscoord aVerticalPercentBasis,
|
2010-05-02 01:40:16 +04:00
|
|
|
const nsMargin* aBorder,
|
|
|
|
const nsMargin* aPadding);
|
|
|
|
static void DisplayInitOffsetsExit(nsIFrame* aFrame,
|
|
|
|
nsCSSOffsetState* aState,
|
|
|
|
void* aValue);
|
|
|
|
#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 08:38:33 +03:00
|
|
|
private:
|
2010-11-10 00:14:05 +03:00
|
|
|
/**
|
|
|
|
* Computes margin values from the specified margin style information, and
|
|
|
|
* fills in the mComputedMargin member.
|
2013-04-11 18:51:52 +04:00
|
|
|
*
|
|
|
|
* @param aHorizontalPercentBasis
|
|
|
|
* Length to use for resolving percentage margin values in the horizontal
|
|
|
|
* axis. Usually the containing block width.
|
|
|
|
* @param aVerticalPercentBasis
|
|
|
|
* Length to use for resolving percentage margin values in the vertical
|
|
|
|
* axis. Usually the containing block width, per CSS21 sec 8.3, but may
|
|
|
|
* be the containing block *height*, e.g. in CSS3 Flexbox and Grid.
|
|
|
|
* @return true if the margin is dependent on the containing block size.
|
2010-11-10 00:14:05 +03:00
|
|
|
*/
|
2013-04-11 18:51:52 +04:00
|
|
|
bool ComputeMargin(nscoord aHorizontalPercentBasis,
|
|
|
|
nscoord aVerticalPercentBasis);
|
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
|
|
|
|
2010-11-10 00:14:05 +03:00
|
|
|
/**
|
|
|
|
* Computes padding values from the specified padding style information, and
|
|
|
|
* fills in the mComputedPadding member.
|
2013-04-11 18:51:52 +04:00
|
|
|
*
|
|
|
|
* @param aHorizontalPercentBasis
|
|
|
|
* Length to use for resolving percentage padding values in the horizontal
|
|
|
|
* axis. Usually the containing block width.
|
|
|
|
* @param aVerticalPercentBasis
|
|
|
|
* Length to use for resolving percentage padding values in the vertical
|
|
|
|
* axis. Usually the containing block width, per CSS21 sec 8.4, but may
|
|
|
|
* be the containing block *height* in e.g. CSS3 Flexbox and Grid.
|
|
|
|
* @return true if the padding is dependent on the containing block size.
|
2010-11-10 00:14:05 +03:00
|
|
|
*/
|
2013-04-11 18:51:52 +04:00
|
|
|
bool ComputePadding(nscoord aHorizontalPercentBasis,
|
|
|
|
nscoord aVerticalPercentBasis, nsIAtom* aFrameType);
|
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
|
|
|
|
|
|
|
protected:
|
2007-05-04 03:11:00 +04:00
|
|
|
|
2013-04-11 18:51:52 +04:00
|
|
|
void InitOffsets(nscoord aHorizontalPercentBasis,
|
|
|
|
nscoord aVerticalPercentBasis,
|
2011-06-11 03:02:14 +04:00
|
|
|
nsIAtom* aFrameType,
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsMargin *aBorder = nullptr,
|
|
|
|
const nsMargin *aPadding = nullptr);
|
2007-08-21 00:07:50 +04:00
|
|
|
|
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,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aBoxSizing,
|
2007-05-04 03:11:00 +04:00
|
|
|
const nsStyleCoord& aCoord);
|
2012-08-08 19:58:26 +04:00
|
|
|
|
|
|
|
nscoord ComputeHeightValue(nscoord aContainingBlockHeight,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aBoxSizing,
|
2012-08-08 19:58:26 +04:00
|
|
|
const nsStyleCoord& aCoord);
|
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;
|
|
|
|
|
2009-05-13 12:26:48 +04:00
|
|
|
// pointer to the float manager associated with this area
|
|
|
|
nsFloatManager* mFloatManager;
|
|
|
|
|
2013-10-08 22:47:21 +04:00
|
|
|
// LineLayout object (only for inline reflow; set to nullptr otherwise)
|
2009-05-13 12:26:48 +04:00
|
|
|
nsLineLayout* mLineLayout;
|
|
|
|
|
|
|
|
// The appropriate reflow state for the containing block (for
|
|
|
|
// percentage widths, etc.) of this reflow state's frame.
|
|
|
|
const nsHTMLReflowState *mCBReflowState;
|
|
|
|
|
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;
|
|
|
|
|
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;
|
|
|
|
|
2013-12-27 21:59:02 +04:00
|
|
|
// Accessors for the private fields below. Forcing all callers to use these
|
|
|
|
// will allow us to introduce logical-coordinate versions and gradually
|
|
|
|
// change clients from physical to logical as needed; and potentially switch
|
|
|
|
// the internal fields from physical to logical coordinates in due course,
|
|
|
|
// while maintaining compatibility with not-yet-updated code.
|
|
|
|
nscoord AvailableWidth() const { return mAvailableWidth; }
|
|
|
|
nscoord AvailableHeight() const { return mAvailableHeight; }
|
|
|
|
nscoord ComputedWidth() const { return mComputedWidth; }
|
|
|
|
nscoord ComputedHeight() const { return mComputedHeight; }
|
|
|
|
nscoord ComputedMinWidth() const { return mComputedMinWidth; }
|
|
|
|
nscoord ComputedMaxWidth() const { return mComputedMaxWidth; }
|
|
|
|
nscoord ComputedMinHeight() const { return mComputedMinHeight; }
|
|
|
|
nscoord ComputedMaxHeight() const { return mComputedMaxHeight; }
|
|
|
|
|
|
|
|
nscoord& AvailableWidth() { return mAvailableWidth; }
|
|
|
|
nscoord& AvailableHeight() { return mAvailableHeight; }
|
|
|
|
nscoord& ComputedWidth() { return mComputedWidth; }
|
|
|
|
nscoord& ComputedHeight() { return mComputedHeight; }
|
|
|
|
nscoord& ComputedMinWidth() { return mComputedMinWidth; }
|
|
|
|
nscoord& ComputedMaxWidth() { return mComputedMaxWidth; }
|
|
|
|
nscoord& ComputedMinHeight() { return mComputedMinHeight; }
|
|
|
|
nscoord& ComputedMaxHeight() { return mComputedMaxHeight; }
|
2013-12-27 21:59:38 +04:00
|
|
|
|
2013-12-30 02:04:28 +04:00
|
|
|
// ISize and BSize are logical-coordinate dimensions:
|
|
|
|
// ISize is the size in the writing mode's inline direction (which equates to
|
|
|
|
// width in horizontal writing modes, height in vertical ones), and BSize is
|
|
|
|
// the size in the block-progression direction.
|
2013-12-27 21:59:38 +04:00
|
|
|
nscoord AvailableISize() const
|
|
|
|
{ return mWritingMode.IsVertical() ? mAvailableHeight : mAvailableWidth; }
|
|
|
|
nscoord AvailableBSize() const
|
|
|
|
{ return mWritingMode.IsVertical() ? mAvailableWidth : mAvailableHeight; }
|
|
|
|
nscoord ComputedISize() const
|
|
|
|
{ return mWritingMode.IsVertical() ? mComputedHeight : mComputedWidth; }
|
|
|
|
nscoord ComputedBSize() const
|
|
|
|
{ return mWritingMode.IsVertical() ? mComputedWidth : mComputedHeight; }
|
|
|
|
nscoord ComputedMinISize() const
|
|
|
|
{ return mWritingMode.IsVertical() ? mComputedMinHeight : mComputedMinWidth; }
|
|
|
|
nscoord ComputedMaxISize() const
|
|
|
|
{ return mWritingMode.IsVertical() ? mComputedMaxHeight : mComputedMaxWidth; }
|
|
|
|
nscoord ComputedMinBSize() const
|
|
|
|
{ return mWritingMode.IsVertical() ? mComputedMinWidth : mComputedMinHeight; }
|
|
|
|
nscoord ComputedMaxBSize() const
|
|
|
|
{ return mWritingMode.IsVertical() ? mComputedMaxWidth : mComputedMaxHeight; }
|
|
|
|
|
|
|
|
nscoord& AvailableISize()
|
|
|
|
{ return mWritingMode.IsVertical() ? mAvailableHeight : mAvailableWidth; }
|
|
|
|
nscoord& AvailableBSize()
|
|
|
|
{ return mWritingMode.IsVertical() ? mAvailableWidth : mAvailableHeight; }
|
|
|
|
nscoord& ComputedISize()
|
|
|
|
{ return mWritingMode.IsVertical() ? mComputedHeight : mComputedWidth; }
|
|
|
|
nscoord& ComputedBSize()
|
|
|
|
{ return mWritingMode.IsVertical() ? mComputedWidth : mComputedHeight; }
|
|
|
|
nscoord& ComputedMinISize()
|
|
|
|
{ return mWritingMode.IsVertical() ? mComputedMinHeight : mComputedMinWidth; }
|
|
|
|
nscoord& ComputedMaxISize()
|
|
|
|
{ return mWritingMode.IsVertical() ? mComputedMaxHeight : mComputedMaxWidth; }
|
|
|
|
nscoord& ComputedMinBSize()
|
|
|
|
{ return mWritingMode.IsVertical() ? mComputedMinWidth : mComputedMinHeight; }
|
|
|
|
nscoord& ComputedMaxBSize()
|
|
|
|
{ return mWritingMode.IsVertical() ? mComputedMaxWidth : mComputedMaxHeight; }
|
|
|
|
|
|
|
|
// XXX this will need to change when we make mComputedOffsets logical;
|
|
|
|
// we won't be able to return a reference for the physical offsets
|
|
|
|
const nsMargin& ComputedPhysicalOffsets() const { return mComputedOffsets; }
|
2013-12-27 21:59:02 +04:00
|
|
|
nsMargin& ComputedPhysicalOffsets() { return mComputedOffsets; }
|
|
|
|
|
2013-12-27 21:59:38 +04:00
|
|
|
LogicalMargin ComputedLogicalOffsets() const
|
|
|
|
{ return LogicalMargin(mWritingMode, mComputedOffsets); }
|
|
|
|
|
2007-01-26 03:05:12 +03:00
|
|
|
private:
|
2013-12-27 21:59:02 +04:00
|
|
|
// the available width in which to reflow the frame. The space
|
|
|
|
// represents the amount of room for the frame's margin, border,
|
|
|
|
// padding, and content area. The frame size you choose should fit
|
|
|
|
// within the available width.
|
|
|
|
nscoord mAvailableWidth;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
// 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.
|
|
|
|
nscoord mAvailableHeight;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
// Computed values for 'left/top/right/bottom' offsets. Only applies to
|
2013-12-27 21:59:38 +04:00
|
|
|
// 'positioned' elements. These are PHYSICAL coordinates (for now).
|
1999-10-30 20:16:45 +04:00
|
|
|
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;
|
|
|
|
|
2013-12-27 21:59:02 +04:00
|
|
|
public:
|
1999-10-30 20:16:45 +04:00
|
|
|
// 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;
|
|
|
|
|
2013-10-02 01:01:49 +04:00
|
|
|
bool IsFloating() const;
|
2012-08-02 15:38:49 +04:00
|
|
|
|
2013-10-02 01:01:49 +04:00
|
|
|
uint8_t GetDisplay() const;
|
2012-08-02 15:38:51 +04:00
|
|
|
|
2001-12-07 17:51:12 +03:00
|
|
|
// 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
|
|
|
|
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.
|
2012-08-22 19:56:38 +04:00
|
|
|
int16_t mReflowDepth;
|
2001-11-05 03:15:51 +03:00
|
|
|
|
|
|
|
struct ReflowStateFlags {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mSpecialHeightReflow:1; // used by tables to communicate special reflow (in process) to handle
|
2001-12-07 17:51:12 +03:00
|
|
|
// percent height frames inside cells which may not have computed heights
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mNextInFlowUntouched:1; // nothing in the frame's next-in-flow (or its descendants)
|
2004-10-08 16:17:10 +04:00
|
|
|
// is changing
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mIsTopOfPage:1; // Is the current context at the top of a
|
2010-08-06 08:59:20 +04:00
|
|
|
// page? When true, we force something
|
|
|
|
// that's too tall for a page/column to
|
|
|
|
// fit anyway to avoid infinite loops.
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mHasClearance:1; // Block has clearance
|
|
|
|
uint16_t mAssumingHScrollbar:1; // parent frame is an nsIScrollableFrame and it
|
2005-10-18 09:00:24 +04:00
|
|
|
// is assuming a horizontal scrollbar
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mAssumingVScrollbar:1; // parent frame is an nsIScrollableFrame and it
|
2005-10-18 09:00:24 +04:00
|
|
|
// 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
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mHResize:1; // Is frame (a) not dirty and (b) a
|
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
|
|
|
// different width than before?
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mVResize:1; // Is frame (a) not dirty and (b) a
|
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
|
|
|
// different height than before or
|
|
|
|
// (potentially) in a context where
|
|
|
|
// percent heights have a different
|
|
|
|
// basis?
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mTableIsSplittable:1; // tables are splittable, this should happen only inside a page
|
2007-01-21 20:51:33 +03:00
|
|
|
// and never insider a column frame
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mHeightDependsOnAncestorCell:1; // Does frame height depend on
|
2008-02-22 00:02:07 +03:00
|
|
|
// an ancestor table-cell?
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mIsColumnBalancing:1; // nsColumnSetFrame is balancing columns
|
2012-09-30 10:38:46 +04:00
|
|
|
uint16_t mIsFlexContainerMeasuringHeight:1; // nsFlexContainerFrame is
|
|
|
|
// reflowing this child to
|
|
|
|
// measure its intrinsic height.
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mDummyParentReflowState:1; // a "fake" reflow state made
|
2012-06-13 23:49:41 +04:00
|
|
|
// in order to be the parent
|
|
|
|
// of a real one
|
2013-04-08 22:38:33 +04:00
|
|
|
uint16_t mMustReflowPlaceholders:1; // Should this frame reflow its place-
|
|
|
|
// holder children? If the available
|
|
|
|
// height of this frame didn't change,
|
|
|
|
// but its in a paginated environment
|
|
|
|
// (e.g. columns), it should always
|
|
|
|
// reflow its placeholder children.
|
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
|
|
|
|
2013-09-10 00:29:05 +04:00
|
|
|
/**
|
|
|
|
* Initialize a ROOT reflow state.
|
|
|
|
*
|
|
|
|
* @param aPresContext Must be equal to aFrame->PresContext().
|
|
|
|
* @param aFrame The frame for whose reflow state is being constructed.
|
|
|
|
* @param aRenderingContext The rendering context to be used for measurements.
|
|
|
|
* @param aAvailableSpace See comments for availableHeight and availableWidth
|
|
|
|
* members.
|
|
|
|
* @param aFlags A set of flags used for additional boolean parameters (see
|
|
|
|
* below).
|
|
|
|
*/
|
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,
|
2013-09-10 00:29:05 +04:00
|
|
|
nsRenderingContext* aRenderingContext,
|
2012-06-13 23:49:41 +04:00
|
|
|
const nsSize& aAvailableSpace,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFlags = 0);
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2013-09-10 00:29:05 +04:00
|
|
|
/**
|
|
|
|
* Initialize a reflow state for a child frame's reflow. Some parts of the
|
|
|
|
* state are copied from the parent's reflow state. The remainder is computed.
|
|
|
|
*
|
|
|
|
* @param aPresContext Must be equal to aFrame->PresContext().
|
|
|
|
* @param aParentReflowState A reference to an nsHTMLReflowState object that
|
|
|
|
* is to be the parent of this object.
|
|
|
|
* @param aFrame The frame for whose reflow state is being constructed.
|
|
|
|
* @param aAvailableSpace See comments for availableHeight and availableWidth
|
|
|
|
* members.
|
|
|
|
* @param aContainingBlockWidth An optional width, in app units, that is used
|
|
|
|
* by absolute positioning code to override default containing block
|
|
|
|
* width.
|
|
|
|
* @param aContainingBlockHeight An optional height, in app units, that is
|
|
|
|
* used by absolute positioning code to override default containing
|
|
|
|
* block height.
|
|
|
|
* @param aFlags A set of flags used for additional boolean parameters (see
|
|
|
|
* below).
|
|
|
|
*/
|
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
|
|
|
nscoord aContainingBlockWidth = -1,
|
|
|
|
nscoord aContainingBlockHeight = -1,
|
2013-09-10 00:29:05 +04:00
|
|
|
uint32_t aFlags = 0);
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2012-06-13 23:49:41 +04:00
|
|
|
// Values for |aFlags| passed to constructor
|
|
|
|
enum {
|
2013-09-10 00:29:05 +04:00
|
|
|
// Indicates that the parent of this reflow state is "fake" (see
|
|
|
|
// mDummyParentReflowState in mFlags).
|
|
|
|
DUMMY_PARENT_REFLOW_STATE = (1<<0),
|
|
|
|
|
|
|
|
// Indicates that the calling function will initialize the reflow state, and
|
|
|
|
// that the constructor should not call Init().
|
|
|
|
CALLER_WILL_INIT = (1<<1)
|
2012-06-13 23:49:41 +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,
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsMargin* aBorder = nullptr,
|
|
|
|
const nsMargin* aPadding = nullptr);
|
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
|
|
|
|
|
|
|
/**
|
2009-05-19 02:13:12 +04:00
|
|
|
* Calculate the used line-height property. The return value will be >= 0.
|
1999-10-30 20:16:45 +04:00
|
|
|
*/
|
2009-05-19 02:13:12 +04:00
|
|
|
nscoord CalcLineHeight() const;
|
|
|
|
|
2007-05-05 09:30:10 +04:00
|
|
|
/**
|
2009-05-19 02:13:12 +04:00
|
|
|
* Same as CalcLineHeight() above, but doesn't need a reflow state.
|
|
|
|
*
|
|
|
|
* @param aBlockHeight The computed height of the content rect of the block
|
|
|
|
* that the line should fill.
|
|
|
|
* Only used with line-height:-moz-block-height.
|
|
|
|
* NS_AUTOHEIGHT results in a normal line-height for
|
|
|
|
* line-height:-moz-block-height.
|
2011-11-24 06:48:23 +04:00
|
|
|
* @param aFontSizeInflation The result of the appropriate
|
|
|
|
* nsLayoutUtils::FontSizeInflationFor call,
|
|
|
|
* or 1.0 if during intrinsic size
|
|
|
|
* calculation.
|
2007-05-05 09:30:10 +04:00
|
|
|
*/
|
2009-05-19 02:13:12 +04:00
|
|
|
static nscoord CalcLineHeight(nsStyleContext* aStyleContext,
|
2011-11-24 06:48:23 +04:00
|
|
|
nscoord aBlockHeight,
|
|
|
|
float aFontSizeInflation);
|
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
|
|
|
/**
|
2012-07-18 18:26:05 +04:00
|
|
|
* Apply the mComputed(Min/Max)Width constraints to the content
|
|
|
|
* size computed so far.
|
2005-04-29 01:57:22 +04:00
|
|
|
*/
|
2012-07-18 18:26:05 +04:00
|
|
|
nscoord ApplyMinMaxWidth(nscoord aWidth) const {
|
2013-12-27 21:59:21 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != ComputedMaxWidth()) {
|
|
|
|
aWidth = std::min(aWidth, ComputedMaxWidth());
|
2012-07-18 18:26:05 +04:00
|
|
|
}
|
2013-12-27 21:59:21 +04:00
|
|
|
return std::max(aWidth, ComputedMinWidth());
|
2012-07-18 18:26:05 +04:00
|
|
|
}
|
2013-07-25 19:34:12 +04:00
|
|
|
|
2012-07-18 18:26:05 +04:00
|
|
|
/**
|
|
|
|
* Apply the mComputed(Min/Max)Height constraints to the content
|
|
|
|
* size computed so far.
|
2013-07-25 19:34:12 +04:00
|
|
|
*
|
|
|
|
* @param aHeight The height that we've computed an to which we want to apply
|
|
|
|
* min/max constraints.
|
|
|
|
* @param aConsumed The amount of the computed height that was consumed by
|
|
|
|
* our prev-in-flows.
|
2012-07-18 18:26:05 +04:00
|
|
|
*/
|
2013-07-25 19:34:12 +04:00
|
|
|
nscoord ApplyMinMaxHeight(nscoord aHeight, nscoord aConsumed = 0) const {
|
|
|
|
aHeight += aConsumed;
|
|
|
|
|
2013-12-27 21:59:21 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != ComputedMaxHeight()) {
|
|
|
|
aHeight = std::min(aHeight, ComputedMaxHeight());
|
2012-07-18 18:26:05 +04:00
|
|
|
}
|
2013-07-25 19:34:12 +04:00
|
|
|
|
2013-12-27 21:59:21 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != ComputedMinHeight()) {
|
|
|
|
aHeight = std::max(aHeight, ComputedMinHeight());
|
2013-07-25 19:34:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return aHeight - aConsumed;
|
2012-07-18 18:26:05 +04:00
|
|
|
}
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool ShouldReflowAllKids() 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 08:38:33 +03:00
|
|
|
// 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-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
|
|
|
// This method doesn't apply min/max computed heights to the value passed in.
|
|
|
|
void SetComputedHeight(nscoord aComputedHeight);
|
|
|
|
|
2009-01-29 23:39:22 +03:00
|
|
|
void SetComputedHeightWithoutResettingResizeFlags(nscoord aComputedHeight) {
|
|
|
|
// Viewport frames reset the computed height on a copy of their reflow
|
|
|
|
// state when reflowing fixed-pos kids. In that case we actually don't
|
|
|
|
// want to mess with the resize flags, because comparing the frame's rect
|
|
|
|
// to the munged computed width is pointless.
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedHeight() = aComputedHeight;
|
2009-01-29 23:39:22 +03:00
|
|
|
}
|
|
|
|
|
2007-03-11 23:34:15 +03:00
|
|
|
void SetTruncated(const nsHTMLReflowMetrics& aMetrics, nsReflowStatus* aStatus) const;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool WillReflowAgainForClearance() const {
|
2007-12-05 05:57:53 +03:00
|
|
|
return mDiscoveredClearance && *mDiscoveredClearance;
|
|
|
|
}
|
2010-05-02 01:40:16 +04:00
|
|
|
|
Bug 157681 - Part 2: Optimize positioned frame offset changes by moving the frame as opposed to reflowing it in case we know that the size of the frame will not change; r=dbaron
This patch adds a change hint to signal that one of the offsets on a
frame has been changed. When processing the hint, we do one of the
following things based on the position property of the frame.
* For static frames, we ignore the offset changes completely, as they
will not change the layout.
* For relative positioned frames, this patch refactors the
nsHTMLReflowState::ComputeRelativeOffsets function so that it can be
used from other callers, and it uses that to compute the new relative
offsets, and uses the offsets computed previously to compute the new
position of the frame.
* For absolute positioned frames, we set up a fake parent reflow state
object, and then we create a new reflow state object for the frame in
question. This setup is similar to what nsFrame::BoxReflow does.
Once we have the new reflow state object, we use it to compute the
absolute offsets, and then we use the computed offsets to set the new
position of the frame. The offset computation is similar to what
nsAbsoluteContainingBlock::ReflowAbsoluteFrame does. In some cases
where it is possible for the dimensions of the frame to change based
on the offset changes, we fall back to a full reflow.
2012-06-06 08:53:48 +04:00
|
|
|
// Compute the offsets for a relative position element
|
2012-08-22 19:56:38 +04:00
|
|
|
static void ComputeRelativeOffsets(uint8_t aCBDirection,
|
Bug 157681 - Part 2: Optimize positioned frame offset changes by moving the frame as opposed to reflowing it in case we know that the size of the frame will not change; r=dbaron
This patch adds a change hint to signal that one of the offsets on a
frame has been changed. When processing the hint, we do one of the
following things based on the position property of the frame.
* For static frames, we ignore the offset changes completely, as they
will not change the layout.
* For relative positioned frames, this patch refactors the
nsHTMLReflowState::ComputeRelativeOffsets function so that it can be
used from other callers, and it uses that to compute the new relative
offsets, and uses the offsets computed previously to compute the new
position of the frame.
* For absolute positioned frames, we set up a fake parent reflow state
object, and then we create a new reflow state object for the frame in
question. This setup is similar to what nsFrame::BoxReflow does.
Once we have the new reflow state object, we use it to compute the
absolute offsets, and then we use the computed offsets to set the new
position of the frame. The offset computation is similar to what
nsAbsoluteContainingBlock::ReflowAbsoluteFrame does. In some cases
where it is possible for the dimensions of the frame to change based
on the offset changes, we fall back to a full reflow.
2012-06-06 08:53:48 +04:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
nscoord aContainingBlockWidth,
|
|
|
|
nscoord aContainingBlockHeight,
|
|
|
|
nsMargin& aComputedOffsets);
|
|
|
|
|
2013-07-16 04:28:09 +04:00
|
|
|
// If a relatively positioned element, adjust the position appropriately.
|
2013-08-09 04:20:17 +04:00
|
|
|
static void ApplyRelativePositioning(nsIFrame* aFrame,
|
2013-07-16 04:28:09 +04:00
|
|
|
const nsMargin& aComputedOffsets,
|
|
|
|
nsPoint* aPosition);
|
|
|
|
|
|
|
|
void ApplyRelativePositioning(nsPoint* aPosition) const {
|
2013-12-27 21:59:21 +04:00
|
|
|
ApplyRelativePositioning(frame, ComputedPhysicalOffsets(), aPosition);
|
2013-07-16 04:28:09 +04:00
|
|
|
}
|
|
|
|
|
2010-05-02 01:40:16 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
// Reflow trace methods. Defined in nsFrame.cpp so they have access
|
|
|
|
// to the display-reflow infrastructure.
|
|
|
|
static void* DisplayInitConstraintsEnter(nsIFrame* aFrame,
|
|
|
|
nsHTMLReflowState* aState,
|
|
|
|
nscoord aCBWidth,
|
|
|
|
nscoord aCBHeight,
|
|
|
|
const nsMargin* aBorder,
|
|
|
|
const nsMargin* aPadding);
|
|
|
|
static void DisplayInitConstraintsExit(nsIFrame* aFrame,
|
|
|
|
nsHTMLReflowState* aState,
|
|
|
|
void* aValue);
|
|
|
|
static void* DisplayInitFrameTypeEnter(nsIFrame* aFrame,
|
|
|
|
nsHTMLReflowState* aState);
|
|
|
|
static void DisplayInitFrameTypeExit(nsIFrame* aFrame,
|
|
|
|
nsHTMLReflowState* aState,
|
|
|
|
void* aValue);
|
|
|
|
#endif
|
|
|
|
|
1999-10-30 20:16:45 +04:00
|
|
|
protected:
|
2011-06-11 03:02:14 +04:00
|
|
|
void InitFrameType(nsIAtom* aFrameType);
|
2002-05-14 16:59:55 +04:00
|
|
|
void InitCBReflowState();
|
2011-06-11 03:02:14 +04:00
|
|
|
void InitResizeFlags(nsPresContext* aPresContext, nsIAtom* aFrameType);
|
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,
|
2011-06-11 03:02:14 +04:00
|
|
|
const nsMargin* aPadding,
|
|
|
|
nsIAtom* aFrameType);
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2008-11-26 02:22:39 +03:00
|
|
|
// Returns the nearest containing block or block frame (whether or not
|
|
|
|
// it is a containing block) for the specified frame. Also returns
|
|
|
|
// the left edge and width of the containing block's content area.
|
2006-12-18 06:34:05 +03:00
|
|
|
// These are returned in the coordinate space of the containing block.
|
2008-11-26 02:22:39 +03:00
|
|
|
nsIFrame* GetHypotheticalBoxContainer(nsIFrame* aFrame,
|
|
|
|
nscoord& aCBLeftEdge,
|
|
|
|
nscoord& aCBWidth);
|
2006-12-18 06:34:05 +03:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void CalculateHypotheticalBox(nsPresContext* aPresContext,
|
2011-11-07 09:25:56 +04:00
|
|
|
nsIFrame* aPlaceholderFrame,
|
2006-12-18 06:34:05 +03:00
|
|
|
nsIFrame* aContainingBlock,
|
|
|
|
nscoord aBlockLeftContentEdge,
|
|
|
|
nscoord aBlockContentWidth,
|
2004-04-24 21:56:23 +04:00
|
|
|
const nsHTMLReflowState* cbrs,
|
2011-06-11 03:02:14 +04:00
|
|
|
nsHypotheticalBox& aHypotheticalBox,
|
|
|
|
nsIAtom* aFrameType);
|
2000-04-16 08:07:02 +04:00
|
|
|
|
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,
|
2011-06-11 03:02:14 +04:00
|
|
|
nscoord aContainingBlockHeight,
|
|
|
|
nsIAtom* aFrameType);
|
1999-10-30 20:16:45 +04:00
|
|
|
|
|
|
|
// 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,
|
2011-06-11 03:02:14 +04:00
|
|
|
nscoord aComputedWidth,
|
|
|
|
nsIAtom* aFrameType);
|
1999-10-30 20:16:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsHTMLReflowState_h___ */
|
|
|
|
|