2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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 */
|
|
|
|
|
2016-07-21 13:36:35 +03:00
|
|
|
#ifndef mozilla_ReflowInput_h
|
|
|
|
#define mozilla_ReflowInput_h
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2001-07-16 06:40:48 +04:00
|
|
|
#include "nsMargin.h"
|
2019-06-28 12:46:26 +03:00
|
|
|
#include "nsStyleConsts.h"
|
2013-04-11 18:51:52 +04:00
|
|
|
#include "mozilla/Assertions.h"
|
2020-09-11 20:59:21 +03:00
|
|
|
#include "mozilla/EnumSet.h"
|
2019-04-24 20:35:31 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
2020-07-06 23:31:51 +03:00
|
|
|
#include "mozilla/WritingModes.h"
|
|
|
|
#include "LayoutConstants.h"
|
|
|
|
#include "ReflowOutput.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2017-06-09 22:14:53 +03:00
|
|
|
class gfxContext;
|
2009-01-05 03:39:54 +03:00
|
|
|
class nsFloatManager;
|
2015-08-12 13:02:02 +03:00
|
|
|
struct nsHypotheticalPosition;
|
2017-05-23 20:09:26 +03:00
|
|
|
class nsIPercentBSizeObserver;
|
|
|
|
class nsLineLayout;
|
|
|
|
class nsPlaceholderFrame;
|
|
|
|
class nsPresContext;
|
2020-07-06 23:31:51 +03:00
|
|
|
class nsReflowStatus;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
enum class LayoutFrameType : uint8_t;
|
|
|
|
}
|
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
|
|
|
/**
|
2019-04-11 23:27:37 +03:00
|
|
|
* CSS Frame type. Included as part of the reflow input.
|
1999-10-30 20:16:45 +04:00
|
|
|
*/
|
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
|
|
|
|
2016-07-21 13:36:34 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
2016-07-21 13:36:35 +03:00
|
|
|
// A base class of ReflowInput that computes only the padding,
|
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
|
|
|
// border, and margin, since those values are needed more often.
|
2016-07-21 13:36:35 +03:00
|
|
|
struct SizeComputationInput {
|
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
|
|
|
public:
|
2013-12-27 21:59:38 +04:00
|
|
|
typedef mozilla::WritingMode WritingMode;
|
|
|
|
typedef mozilla::LogicalMargin LogicalMargin;
|
|
|
|
|
2016-07-21 13:36:38 +03:00
|
|
|
// The frame being reflowed.
|
|
|
|
nsIFrame* mFrame;
|
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
|
|
|
|
2016-07-21 13:36:38 +03:00
|
|
|
// Rendering context to use for measurement.
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* mRenderingContext;
|
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
|
|
|
|
2020-10-31 17:42:04 +03:00
|
|
|
nsMargin ComputedPhysicalMargin() const {
|
|
|
|
return mComputedMargin.GetPhysicalMargin(mWritingMode);
|
2013-12-27 21:59:02 +04:00
|
|
|
}
|
2020-10-31 17:42:04 +03:00
|
|
|
nsMargin ComputedPhysicalBorderPadding() const {
|
|
|
|
return mComputedBorderPadding.GetPhysicalMargin(mWritingMode);
|
2013-12-27 21:59:38 +04:00
|
|
|
}
|
2020-10-31 17:42:04 +03:00
|
|
|
nsMargin ComputedPhysicalPadding() const {
|
|
|
|
return mComputedPadding.GetPhysicalMargin(mWritingMode);
|
2013-12-27 21:59:38 +04:00
|
|
|
}
|
2020-10-31 17:42:04 +03:00
|
|
|
|
2020-11-03 22:44:58 +03:00
|
|
|
LogicalMargin ComputedLogicalMargin(mozilla::WritingMode aWM) const {
|
|
|
|
return mComputedMargin.ConvertTo(aWM, mWritingMode);
|
|
|
|
}
|
2020-11-03 22:57:40 +03:00
|
|
|
LogicalMargin ComputedLogicalBorderPadding(mozilla::WritingMode aWM) const {
|
|
|
|
return mComputedBorderPadding.ConvertTo(aWM, mWritingMode);
|
2013-12-27 21:59:38 +04:00
|
|
|
}
|
2020-11-03 22:56:03 +03:00
|
|
|
LogicalMargin ComputedLogicalPadding(mozilla::WritingMode aWM) const {
|
|
|
|
return mComputedPadding.ConvertTo(aWM, mWritingMode);
|
|
|
|
}
|
2013-12-27 21:59:38 +04:00
|
|
|
|
2015-06-11 09:42:56 +03:00
|
|
|
void SetComputedLogicalMargin(mozilla::WritingMode aWM,
|
|
|
|
const LogicalMargin& aMargin) {
|
2020-10-31 17:42:04 +03:00
|
|
|
mComputedMargin = aMargin.ConvertTo(mWritingMode, aWM);
|
2015-06-11 09:42:56 +03:00
|
|
|
}
|
|
|
|
void SetComputedLogicalBorderPadding(mozilla::WritingMode aWM,
|
2020-10-31 17:42:04 +03:00
|
|
|
const LogicalMargin& aBorderPadding) {
|
|
|
|
mComputedBorderPadding = aBorderPadding.ConvertTo(mWritingMode, aWM);
|
2015-06-11 09:42:56 +03:00
|
|
|
}
|
|
|
|
void SetComputedLogicalPadding(mozilla::WritingMode aWM,
|
2020-10-31 17:42:04 +03:00
|
|
|
const LogicalMargin& aPadding) {
|
|
|
|
mComputedPadding = aPadding.ConvertTo(mWritingMode, aWM);
|
2015-06-11 09:42:56 +03:00
|
|
|
}
|
2014-10-24 15:24:39 +04:00
|
|
|
|
2013-12-27 21:59:38 +04:00
|
|
|
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;
|
|
|
|
|
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
|
2020-10-31 17:42:04 +03:00
|
|
|
LogicalMargin mComputedMargin;
|
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
|
|
|
|
|
|
|
// Cached copy of the border + padding values
|
2020-10-31 17:42:04 +03:00
|
|
|
LogicalMargin mComputedBorderPadding;
|
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 padding values
|
2020-10-31 17:42:04 +03:00
|
|
|
LogicalMargin mComputedPadding;
|
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
|
|
|
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.
|
2020-07-06 23:31:51 +03:00
|
|
|
SizeComputationInput(nsIFrame* aFrame, gfxContext* 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
|
|
|
|
2017-06-09 22:14:53 +03:00
|
|
|
SizeComputationInput(nsIFrame* aFrame, gfxContext* aRenderingContext,
|
2015-06-11 09:42:56 +03:00
|
|
|
mozilla::WritingMode aContainingBlockWritingMode,
|
2015-06-04 13:43:02 +03:00
|
|
|
nscoord aContainingBlockISize);
|
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.
|
2015-06-04 13:43:02 +03:00
|
|
|
static void* DisplayInitOffsetsEnter(nsIFrame* aFrame,
|
2016-07-21 13:36:35 +03:00
|
|
|
SizeComputationInput* aState,
|
2018-01-31 06:24:55 +03:00
|
|
|
nscoord aPercentBasis,
|
2017-07-07 19:20:56 +03:00
|
|
|
WritingMode aCBWritingMode,
|
2015-06-04 13:43:02 +03:00
|
|
|
const nsMargin* aBorder,
|
|
|
|
const nsMargin* aPadding);
|
2010-05-02 01:40:16 +04:00
|
|
|
static void DisplayInitOffsetsExit(nsIFrame* aFrame,
|
2016-07-21 13:36:35 +03:00
|
|
|
SizeComputationInput* aState,
|
2010-05-02 01:40:16 +04:00
|
|
|
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
|
|
|
*
|
2020-10-31 17:29:20 +03:00
|
|
|
* @param aCBWM Writing mode of the containing block
|
2015-06-04 13:43:02 +03:00
|
|
|
* @param aPercentBasis
|
2018-01-31 06:24:55 +03:00
|
|
|
* Inline size of the containing block (in its own writing mode), to use
|
|
|
|
* for resolving percentage margin values in the inline and block axes.
|
2013-04-11 18:51:52 +04:00
|
|
|
* @return true if the margin is dependent on the containing block size.
|
2010-11-10 00:14:05 +03:00
|
|
|
*/
|
2020-10-31 17:29:20 +03:00
|
|
|
bool ComputeMargin(mozilla::WritingMode aCBWM, nscoord aPercentBasis);
|
2017-07-06 15:00:35 +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
|
|
|
*
|
2020-10-31 17:29:20 +03:00
|
|
|
* @param aCBWM Writing mode of the containing block
|
2015-06-04 13:43:02 +03:00
|
|
|
* @param aPercentBasis
|
2018-01-31 06:24:55 +03:00
|
|
|
* Inline size of the containing block (in its own writing mode), to use
|
|
|
|
* for resolving percentage padding values in the inline and block axes.
|
2013-04-11 18:51:52 +04:00
|
|
|
* @return true if the padding is dependent on the containing block size.
|
2010-11-10 00:14:05 +03:00
|
|
|
*/
|
2020-10-31 17:29:20 +03:00
|
|
|
bool ComputePadding(mozilla::WritingMode aCBWM, nscoord aPercentBasis,
|
2017-05-01 20:32:52 +03:00
|
|
|
mozilla::LayoutFrameType 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:
|
2020-10-31 17:29:20 +03:00
|
|
|
void InitOffsets(mozilla::WritingMode aCBWM, nscoord aPercentBasis,
|
2020-09-11 21:17:51 +03:00
|
|
|
mozilla::LayoutFrameType aFrameType,
|
|
|
|
mozilla::ComputeSizeFlags aFlags = {},
|
2020-10-31 17:39:23 +03:00
|
|
|
const mozilla::Maybe<mozilla::LogicalMargin>& aBorder =
|
|
|
|
mozilla::Nothing(),
|
|
|
|
const mozilla::Maybe<mozilla::LogicalMargin>& aPadding =
|
|
|
|
mozilla::Nothing(),
|
2017-05-17 17:47:25 +03:00
|
|
|
const nsStyleDisplay* aDisplay = nullptr);
|
2007-08-21 00:07:50 +04:00
|
|
|
|
2007-05-04 03:11:00 +04:00
|
|
|
/*
|
2019-06-28 12:46:26 +03:00
|
|
|
* Convert StyleSize or StyleMaxSize to nscoord when percentages depend on the
|
|
|
|
* inline size of the containing block, and enumerated values are for inline
|
|
|
|
* size, min-inline-size, or max-inline-size. Does not handle auto inline
|
|
|
|
* sizes.
|
2007-05-04 03:11:00 +04:00
|
|
|
*/
|
2019-02-10 15:55:16 +03:00
|
|
|
template <typename SizeOrMaxSize>
|
2015-06-04 13:43:02 +03:00
|
|
|
inline nscoord ComputeISizeValue(nscoord aContainingBlockISize,
|
2007-05-04 03:11:00 +04:00
|
|
|
nscoord aContentEdgeToBoxSizing,
|
|
|
|
nscoord aBoxSizingToMarginEdge,
|
2019-02-10 15:55:16 +03:00
|
|
|
const SizeOrMaxSize&) const;
|
2007-05-04 03:11:00 +04:00
|
|
|
// same as previous, but using mComputedBorderPadding, mComputedPadding,
|
|
|
|
// and mComputedMargin
|
2019-02-10 15:55:16 +03:00
|
|
|
template <typename SizeOrMaxSize>
|
|
|
|
inline nscoord ComputeISizeValue(nscoord aContainingBlockISize,
|
|
|
|
mozilla::StyleBoxSizing aBoxSizing,
|
|
|
|
const SizeOrMaxSize&) const;
|
2012-08-08 19:58:26 +04:00
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
nscoord ComputeBSizeValue(nscoord aContainingBlockBSize,
|
2015-11-20 05:09:29 +03:00
|
|
|
mozilla::StyleBoxSizing aBoxSizing,
|
2019-02-10 15:55:16 +03:00
|
|
|
const mozilla::LengthPercentage& aCoord) 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
|
|
|
};
|
|
|
|
|
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
|
|
|
*/
|
2016-07-21 13:36:35 +03:00
|
|
|
struct ReflowInput : public SizeComputationInput {
|
2019-04-11 23:27:37 +03:00
|
|
|
// the reflow inputs are linked together. this is the pointer to the
|
|
|
|
// parent's reflow input
|
2019-04-24 03:20:05 +03:00
|
|
|
const ReflowInput* mParentReflowInput = nullptr;
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2017-02-09 12:57:16 +03:00
|
|
|
// A non-owning pointer to the float manager associated with this area,
|
|
|
|
// which points to the object owned by nsAutoFloatManager::mNew.
|
2019-04-24 03:20:05 +03:00
|
|
|
nsFloatManager* mFloatManager = nullptr;
|
2009-05-13 12:26:48 +04:00
|
|
|
|
2013-10-08 22:47:21 +04:00
|
|
|
// LineLayout object (only for inline reflow; set to nullptr otherwise)
|
2019-04-24 03:20:05 +03:00
|
|
|
nsLineLayout* mLineLayout = nullptr;
|
2009-05-13 12:26:48 +04:00
|
|
|
|
2019-04-11 23:27:37 +03:00
|
|
|
// The appropriate reflow input for the containing block (for
|
2019-04-24 20:35:05 +03:00
|
|
|
// percentage widths, etc.) of this reflow input's frame. It will be setup
|
|
|
|
// properly in InitCBReflowInput().
|
|
|
|
const ReflowInput* mCBReflowInput = nullptr;
|
2009-05-13 12:26:48 +04:00
|
|
|
|
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.
|
2019-04-24 20:35:31 +03:00
|
|
|
nsCSSFrameType mFrameType = NS_CSS_FRAME_TYPE_UNKNOWN;
|
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
|
2019-04-24 20:35:05 +03:00
|
|
|
nscoord mBlockDelta = 0;
|
2007-08-21 00:07:50 +04:00
|
|
|
|
2019-04-24 20:35:05 +03:00
|
|
|
// If a ReflowInput finds itself initialized with an unconstrained
|
|
|
|
// inline-size, it will look up its parentReflowInput chain for a reflow input
|
2014-09-03 19:43:03 +04:00
|
|
|
// with an orthogonal writing mode and a non-NS_UNCONSTRAINEDSIZE value for
|
2019-04-24 20:35:05 +03:00
|
|
|
// orthogonal limit; when it finds such a reflow input, it will use its
|
2014-09-03 19:43:03 +04:00
|
|
|
// orthogonal-limit value to constrain inline-size.
|
|
|
|
// This is initialized to NS_UNCONSTRAINEDSIZE (so it will be ignored),
|
2019-05-01 05:28:59 +03:00
|
|
|
// but reset to a suitable value for the reflow root by PresShell.
|
2019-04-24 20:35:05 +03:00
|
|
|
nscoord mOrthogonalLimit = NS_UNCONSTRAINEDSIZE;
|
2014-09-03 19:43:03 +04:00
|
|
|
|
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;
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-12-27 21:59:38 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-07-24 12:28:46 +04:00
|
|
|
mozilla::LogicalSize AvailableSize() const {
|
|
|
|
return mozilla::LogicalSize(mWritingMode, AvailableISize(),
|
|
|
|
AvailableBSize());
|
|
|
|
}
|
|
|
|
mozilla::LogicalSize ComputedSize() const {
|
|
|
|
return mozilla::LogicalSize(mWritingMode, ComputedISize(), ComputedBSize());
|
|
|
|
}
|
|
|
|
mozilla::LogicalSize ComputedMinSize() const {
|
|
|
|
return mozilla::LogicalSize(mWritingMode, ComputedMinISize(),
|
|
|
|
ComputedMinBSize());
|
|
|
|
}
|
|
|
|
mozilla::LogicalSize ComputedMaxSize() const {
|
|
|
|
return mozilla::LogicalSize(mWritingMode, ComputedMaxISize(),
|
|
|
|
ComputedMaxBSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::LogicalSize AvailableSize(mozilla::WritingMode aWM) const {
|
|
|
|
return AvailableSize().ConvertTo(aWM, mWritingMode);
|
|
|
|
}
|
|
|
|
mozilla::LogicalSize ComputedSize(mozilla::WritingMode aWM) const {
|
|
|
|
return ComputedSize().ConvertTo(aWM, mWritingMode);
|
|
|
|
}
|
|
|
|
mozilla::LogicalSize ComputedMinSize(mozilla::WritingMode aWM) const {
|
|
|
|
return ComputedMinSize().ConvertTo(aWM, mWritingMode);
|
|
|
|
}
|
|
|
|
mozilla::LogicalSize ComputedMaxSize(mozilla::WritingMode aWM) const {
|
|
|
|
return ComputedMaxSize().ConvertTo(aWM, mWritingMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::LogicalSize ComputedSizeWithPadding(mozilla::WritingMode aWM) const {
|
2020-11-03 23:04:40 +03:00
|
|
|
return ComputedSize(aWM) + ComputedLogicalPadding(aWM).Size(aWM);
|
2014-07-24 12:28:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::LogicalSize ComputedSizeWithBorderPadding(
|
|
|
|
mozilla::WritingMode aWM) const {
|
2020-11-03 23:07:18 +03:00
|
|
|
return ComputedSize(aWM) + ComputedLogicalBorderPadding(aWM).Size(aWM);
|
2014-07-24 12:28:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::LogicalSize ComputedSizeWithMarginBorderPadding() const {
|
|
|
|
mozilla::WritingMode wm = GetWritingMode();
|
|
|
|
return mozilla::LogicalSize(
|
|
|
|
wm,
|
2020-11-03 22:44:58 +03:00
|
|
|
ComputedISize() + ComputedLogicalMargin(wm).IStartEnd(wm) +
|
2020-11-03 22:57:40 +03:00
|
|
|
ComputedLogicalBorderPadding(wm).IStartEnd(wm),
|
2020-11-03 22:44:58 +03:00
|
|
|
ComputedBSize() + ComputedLogicalMargin(wm).BStartEnd(wm) +
|
2020-11-03 22:57:40 +03:00
|
|
|
ComputedLogicalBorderPadding(wm).BStartEnd(wm));
|
2014-07-24 12:28:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::LogicalSize ComputedSizeWithMarginBorderPadding(
|
|
|
|
mozilla::WritingMode aWM) const {
|
|
|
|
return ComputedSizeWithMarginBorderPadding().ConvertTo(aWM,
|
|
|
|
GetWritingMode());
|
|
|
|
}
|
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
nsSize ComputedPhysicalSize() const {
|
|
|
|
return nsSize(ComputedWidth(), ComputedHeight());
|
|
|
|
}
|
|
|
|
|
2013-12-27 21:59:38 +04:00
|
|
|
// 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; }
|
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
const LogicalMargin ComputedLogicalOffsets() const {
|
2013-12-27 21:59:38 +04:00
|
|
|
return LogicalMargin(mWritingMode, mComputedOffsets);
|
|
|
|
}
|
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
void SetComputedLogicalOffsets(const LogicalMargin& aOffsets) {
|
|
|
|
mComputedOffsets = aOffsets.GetPhysicalMargin(mWritingMode);
|
|
|
|
}
|
|
|
|
|
2015-07-16 12:07:46 +03:00
|
|
|
// Return the state's computed size including border-padding, with
|
|
|
|
// unconstrained dimensions replaced by zero.
|
|
|
|
nsSize ComputedSizeAsContainerIfConstrained() const {
|
|
|
|
const nscoord wd = ComputedWidth();
|
|
|
|
const nscoord ht = ComputedHeight();
|
|
|
|
return nsSize(wd == NS_UNCONSTRAINEDSIZE
|
|
|
|
? 0
|
|
|
|
: wd + ComputedPhysicalBorderPadding().LeftRight(),
|
|
|
|
ht == NS_UNCONSTRAINEDSIZE
|
|
|
|
? 0
|
|
|
|
: ht + ComputedPhysicalBorderPadding().TopBottom());
|
|
|
|
}
|
|
|
|
|
2020-08-17 10:02:25 +03:00
|
|
|
bool ComputedBSizeIsSetByAspectRatio() const {
|
|
|
|
return mFlags.mBSizeIsSetByAspectRatio;
|
|
|
|
}
|
|
|
|
|
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.
|
2019-04-24 20:35:05 +03:00
|
|
|
nscoord mAvailableWidth = 0;
|
2013-12-27 21:59:02 +04:00
|
|
|
|
|
|
|
// 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.
|
2019-04-24 20:35:05 +03:00
|
|
|
nscoord mAvailableHeight = 0;
|
2013-12-27 21:59:02 +04:00
|
|
|
|
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
|
|
|
//
|
2019-06-05 02:41:20 +03:00
|
|
|
// For replaced inline frames, a value of NS_UNCONSTRAINEDSIZE means you
|
|
|
|
// should use your intrinsic width as the computed width
|
1999-10-30 20:16:45 +04:00
|
|
|
//
|
|
|
|
// 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.
|
2016-08-23 15:51:45 +03:00
|
|
|
MOZ_INIT_OUTSIDE_CTOR
|
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
|
|
|
|
//
|
2019-06-05 02:41:20 +03:00
|
|
|
// For replaced inline frames, a value of NS_UNCONSTRAINEDSIZE means you
|
|
|
|
// should use your intrinsic height as the computed height
|
1999-10-30 20:16:45 +04:00
|
|
|
//
|
|
|
|
// For non-replaced block-level frames in the flow and floated, a value of
|
2019-06-05 02:41:20 +03:00
|
|
|
// NS_UNCONSTRAINEDSIZE 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
|
1999-10-30 20:16:45 +04:00
|
|
|
//
|
2019-06-05 02:41:20 +03:00
|
|
|
// For replaced block-level frames, a value of NS_UNCONSTRAINEDSIZE
|
1999-10-30 20:16:45 +04:00
|
|
|
// means you use your intrinsic height as the computed height
|
2016-08-23 15:51:45 +03:00
|
|
|
MOZ_INIT_OUTSIDE_CTOR
|
1999-10-30 20:16:45 +04:00
|
|
|
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
|
2019-07-20 17:54:33 +03:00
|
|
|
// internally, except for nsComboboxDisplayFrame, which still wants to honor
|
|
|
|
// min-inline-size even though it wants to trump inline-size.
|
2016-08-23 15:51:45 +03:00
|
|
|
MOZ_INIT_OUTSIDE_CTOR
|
1999-10-30 20:16:45 +04:00
|
|
|
nscoord mComputedMinWidth, mComputedMaxWidth;
|
2016-08-23 15:51:45 +03:00
|
|
|
MOZ_INIT_OUTSIDE_CTOR
|
1999-10-30 20:16:45 +04:00
|
|
|
nscoord mComputedMinHeight, mComputedMaxHeight;
|
|
|
|
|
2013-12-27 21:59:02 +04:00
|
|
|
public:
|
2011-06-25 09:21:47 +04:00
|
|
|
// Our saved containing block dimensions.
|
2019-04-24 20:35:05 +03:00
|
|
|
LogicalSize mContainingBlockSize = LogicalSize(mWritingMode);
|
2011-06-25 09:21:47 +04:00
|
|
|
|
2019-04-24 20:35:31 +03:00
|
|
|
// Cached pointers to the various style structs used during initialization.
|
|
|
|
const nsStyleDisplay* mStyleDisplay = nullptr;
|
|
|
|
const nsStyleVisibility* mStyleVisibility = nullptr;
|
|
|
|
const nsStylePosition* mStylePosition = nullptr;
|
|
|
|
const nsStyleBorder* mStyleBorder = nullptr;
|
|
|
|
const nsStyleMargin* mStyleMargin = nullptr;
|
|
|
|
const nsStylePadding* mStylePadding = nullptr;
|
|
|
|
const nsStyleText* mStyleText = nullptr;
|
2001-12-07 17:51:12 +03:00
|
|
|
|
2013-10-02 01:01:49 +04:00
|
|
|
bool IsFloating() const;
|
2012-08-02 15:38:49 +04:00
|
|
|
|
2001-12-07 17:51:12 +03:00
|
|
|
// a frame (e.g. nsTableCellFrame) which may need to generate a special
|
2015-06-22 12:33:34 +03:00
|
|
|
// reflow for percent bsize calculations
|
2019-04-24 03:20:05 +03:00
|
|
|
nsIPercentBSizeObserver* mPercentBSizeObserver = nullptr;
|
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.
|
2019-04-24 03:20:05 +03:00
|
|
|
nsIFrame** mDiscoveredClearance = nullptr;
|
2004-11-25 17:51:00 +03:00
|
|
|
|
2020-09-11 20:59:13 +03:00
|
|
|
struct Flags {
|
|
|
|
Flags() { memset(this, 0, sizeof(*this)); }
|
|
|
|
|
|
|
|
// used by tables to communicate special reflow (in process) to handle
|
|
|
|
// percent bsize frames inside cells which may not have computed bsizes
|
|
|
|
bool mSpecialBSizeReflow : 1;
|
|
|
|
|
|
|
|
// nothing in the frame's next-in-flow (or its descendants) is changing
|
|
|
|
bool mNextInFlowUntouched : 1;
|
|
|
|
|
|
|
|
// Is the current context at the top of a page? When true, we force
|
|
|
|
// something that's too tall for a page/column to fit anyway to avoid
|
|
|
|
// infinite loops.
|
|
|
|
bool mIsTopOfPage : 1;
|
|
|
|
|
|
|
|
// parent frame is an nsIScrollableFrame and it is assuming a horizontal
|
|
|
|
// scrollbar
|
|
|
|
bool mAssumingHScrollbar : 1;
|
|
|
|
|
|
|
|
// parent frame is an nsIScrollableFrame and it is assuming a vertical
|
|
|
|
// scrollbar
|
|
|
|
bool mAssumingVScrollbar : 1;
|
|
|
|
|
|
|
|
// Is frame a different inline-size than before?
|
|
|
|
bool mIsIResize : 1;
|
|
|
|
|
|
|
|
// Is frame (potentially) a different block-size than before?
|
|
|
|
// This includes cases where the block-size is 'auto' and the
|
|
|
|
// contents or width have changed.
|
|
|
|
bool mIsBResize : 1;
|
|
|
|
|
|
|
|
// Has this frame changed block-size in a way that affects
|
|
|
|
// block-size percentages on frames for which it is the containing
|
|
|
|
// block? This includes a change between 'auto' and a length that
|
|
|
|
// doesn't actually change the frame's block-size. It does not
|
|
|
|
// include cases where the block-size is 'auto' and the frame's
|
|
|
|
// contents have changed.
|
|
|
|
//
|
|
|
|
// In the current code, this is only true when mIsBResize is also
|
|
|
|
// true, although it doesn't necessarily need to be that way (e.g.,
|
|
|
|
// in the case of a frame changing from 'auto' to a length that
|
|
|
|
// produces the same height).
|
|
|
|
bool mIsBResizeForPercentages : 1;
|
|
|
|
|
|
|
|
// tables are splittable, this should happen only inside a page and never
|
|
|
|
// insider a column frame
|
|
|
|
bool mTableIsSplittable : 1;
|
|
|
|
|
|
|
|
// Does frame height depend on an ancestor table-cell?
|
|
|
|
bool mHeightDependsOnAncestorCell : 1;
|
|
|
|
|
|
|
|
// nsColumnSetFrame is balancing columns
|
|
|
|
bool mIsColumnBalancing : 1;
|
|
|
|
|
|
|
|
// True if ColumnSetWrapperFrame has a constrained block-size, and is going
|
|
|
|
// to consume all of its block-size in this fragment. This bit is passed to
|
|
|
|
// nsColumnSetFrame to determine whether to give up balancing and create
|
|
|
|
// overflow columns.
|
|
|
|
bool mColumnSetWrapperHasNoBSizeLeft : 1;
|
|
|
|
|
|
|
|
// nsFlexContainerFrame is reflowing this child to measure its intrinsic
|
|
|
|
// BSize.
|
|
|
|
bool mIsFlexContainerMeasuringBSize : 1;
|
|
|
|
|
|
|
|
// If this flag is set, the BSize of this frame should be considered
|
|
|
|
// indefinite for the purposes of percent resolution on child frames (we
|
|
|
|
// should behave as if ComputedBSize() were NS_UNCONSTRAINEDSIZE when doing
|
|
|
|
// percent resolution against this.ComputedBSize()). For example: flex
|
|
|
|
// items may have their ComputedBSize() resolved ahead-of-time by their
|
|
|
|
// flex container, and yet their BSize might have to be considered
|
|
|
|
// indefinite per https://drafts.csswg.org/css-flexbox/#definite-sizes
|
|
|
|
bool mTreatBSizeAsIndefinite : 1;
|
|
|
|
|
|
|
|
// a "fake" reflow input made in order to be the parent of a real one
|
|
|
|
bool mDummyParentReflowInput : 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.
|
|
|
|
bool mMustReflowPlaceholders : 1;
|
|
|
|
|
|
|
|
// the STATIC_POS_IS_CB_ORIGIN ctor flag
|
|
|
|
bool mStaticPosIsCBOrigin : 1;
|
|
|
|
|
|
|
|
// If set, the following two flags indicate that:
|
|
|
|
// (1) this frame is absolutely-positioned (or fixed-positioned).
|
|
|
|
// (2) this frame's static position depends on the CSS Box Alignment.
|
|
|
|
// (3) we do need to compute the static position, because the frame's
|
|
|
|
// {Inline and/or Block} offsets actually depend on it.
|
|
|
|
// When these bits are set, the offset values (IStart/IEnd, BStart/BEnd)
|
|
|
|
// represent the "start" edge of the frame's CSS Box Alignment container
|
|
|
|
// area, in that axis -- and these offsets need to be further-resolved
|
|
|
|
// (with CSS Box Alignment) after we know the OOF frame's size.
|
|
|
|
// NOTE: The "I" and "B" (for "Inline" and "Block") refer the axes of the
|
|
|
|
// *containing block's writing-mode*, NOT mFrame's own writing-mode. This
|
|
|
|
// is purely for convenience, since that's the writing-mode we're dealing
|
|
|
|
// with when we set & react to these bits.
|
|
|
|
bool mIOffsetsNeedCSSAlign : 1;
|
|
|
|
bool mBOffsetsNeedCSSAlign : 1;
|
|
|
|
|
|
|
|
// Are we somewhere inside an element with -webkit-line-clamp set?
|
|
|
|
// This flag is inherited into descendant ReflowInputs, but we don't bother
|
|
|
|
// resetting it to false when crossing over into a block descendant that
|
|
|
|
// -webkit-line-clamp skips over (such as a BFC).
|
|
|
|
bool mInsideLineClamp : 1;
|
|
|
|
|
|
|
|
// Is this a flex item, and should we add or remove a -webkit-line-clamp
|
|
|
|
// ellipsis on a descendant line? It's possible for this flag to be true
|
|
|
|
// when mInsideLineClamp is false if we previously had a numeric
|
|
|
|
// -webkit-line-clamp value, but now have 'none' and we need to find the
|
|
|
|
// line with the ellipsis flag and clear it.
|
|
|
|
// This flag is not inherited into descendant ReflowInputs.
|
|
|
|
bool mApplyLineClamp : 1;
|
|
|
|
|
|
|
|
// Is this frame or one of its ancestors being reflowed in a different
|
|
|
|
// continuation than the one in which it was previously reflowed? In
|
|
|
|
// other words, has it moved to a different column or page than it was in
|
|
|
|
// the previous reflow?
|
|
|
|
//
|
|
|
|
// FIXME: For now, we only ensure that this is set correctly for blocks.
|
|
|
|
// This is okay because the only thing that uses it only cares about
|
|
|
|
// whether there's been a fragment change within the same block formatting
|
|
|
|
// context.
|
|
|
|
bool mMovedBlockFragments : 1;
|
|
|
|
|
|
|
|
// If the block-size is replacd by aspect-ratio and inline size (i.e.
|
|
|
|
// block axis is the ratio-dependent axis). We set this flag, so we could
|
|
|
|
// apply Automatic content-based minimum sizes after we know the content
|
|
|
|
// size of child fraems.
|
|
|
|
// https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum
|
|
|
|
bool mBSizeIsSetByAspectRatio : 1;
|
|
|
|
};
|
|
|
|
Flags mFlags;
|
2020-09-11 21:17:51 +03:00
|
|
|
mozilla::ComputeSizeFlags mComputeSizeFlags;
|
2016-10-24 04:54:54 +03:00
|
|
|
|
2019-04-11 23:27:37 +03:00
|
|
|
// This value keeps track of how deeply nested a given reflow input
|
1999-10-30 20:16:45 +04:00
|
|
|
// is from the top of the frame tree.
|
2019-04-24 20:35:05 +03:00
|
|
|
int16_t mReflowDepth = 0;
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2014-11-28 12:44:02 +03:00
|
|
|
// Logical and physical accessors for the resize flags. All users should go
|
|
|
|
// via these accessors, so that in due course we can change the storage from
|
|
|
|
// physical to logical.
|
|
|
|
bool IsHResize() const {
|
2016-05-18 23:07:54 +03:00
|
|
|
return mWritingMode.IsVertical() ? mFlags.mIsBResize : mFlags.mIsIResize;
|
2014-11-28 12:44:02 +03:00
|
|
|
}
|
|
|
|
bool IsVResize() const {
|
2016-05-18 23:07:54 +03:00
|
|
|
return mWritingMode.IsVertical() ? mFlags.mIsIResize : mFlags.mIsBResize;
|
2014-11-28 12:44:02 +03:00
|
|
|
}
|
2016-05-18 23:07:54 +03:00
|
|
|
bool IsIResize() const { return mFlags.mIsIResize; }
|
|
|
|
bool IsBResize() const { return mFlags.mIsBResize; }
|
2016-05-18 23:07:54 +03:00
|
|
|
bool IsBResizeForWM(mozilla::WritingMode aWM) const {
|
2016-05-18 23:07:54 +03:00
|
|
|
return aWM.IsOrthogonalTo(mWritingMode) ? mFlags.mIsIResize
|
|
|
|
: mFlags.mIsBResize;
|
2016-05-18 23:07:54 +03:00
|
|
|
}
|
2019-07-14 04:04:31 +03:00
|
|
|
bool IsBResizeForPercentagesForWM(mozilla::WritingMode aWM) const {
|
|
|
|
// This uses the relatively-accurate mIsBResizeForPercentages flag
|
|
|
|
// when the writing modes are parallel, and is a bit more
|
|
|
|
// pessimistic when orthogonal.
|
|
|
|
return !aWM.IsOrthogonalTo(mWritingMode) ? mFlags.mIsBResizeForPercentages
|
|
|
|
: IsIResize();
|
|
|
|
}
|
2014-11-28 12:44:02 +03:00
|
|
|
void SetHResize(bool aValue) {
|
|
|
|
if (mWritingMode.IsVertical()) {
|
2016-05-18 23:07:54 +03:00
|
|
|
mFlags.mIsBResize = aValue;
|
2014-11-28 12:44:02 +03:00
|
|
|
} else {
|
2016-05-18 23:07:54 +03:00
|
|
|
mFlags.mIsIResize = aValue;
|
2014-11-28 12:44:02 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-18 23:07:54 +03:00
|
|
|
void SetVResize(bool aValue) {
|
2014-11-28 12:44:02 +03:00
|
|
|
if (mWritingMode.IsVertical()) {
|
2016-05-18 23:07:54 +03:00
|
|
|
mFlags.mIsIResize = aValue;
|
2014-11-28 12:44:02 +03:00
|
|
|
} else {
|
2016-05-18 23:07:54 +03:00
|
|
|
mFlags.mIsBResize = aValue;
|
2014-11-28 12:44:02 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-18 23:07:54 +03:00
|
|
|
void SetIResize(bool aValue) { mFlags.mIsIResize = aValue; }
|
|
|
|
void SetBResize(bool aValue) { mFlags.mIsBResize = aValue; }
|
2014-11-28 12:44:02 +03:00
|
|
|
|
2020-09-11 20:59:21 +03:00
|
|
|
// Values for |aFlags| passed to constructor
|
|
|
|
enum class InitFlag : uint8_t {
|
|
|
|
// Indicates that the parent of this reflow input is "fake" (see
|
|
|
|
// mDummyParentReflowInput in mFlags).
|
|
|
|
DummyParentReflowInput,
|
|
|
|
|
|
|
|
// Indicates that the calling function will initialize the reflow input, and
|
|
|
|
// that the constructor should not call Init().
|
|
|
|
CallerWillInit,
|
|
|
|
|
|
|
|
// The caller wants the abs.pos. static-position resolved at the origin of
|
|
|
|
// the containing block, i.e. at LogicalPoint(0, 0). (Note that this
|
|
|
|
// doesn't necessarily mean that (0, 0) is the *correct* static position
|
|
|
|
// for the frame in question.)
|
|
|
|
// @note In a Grid container's masonry axis we'll always use
|
|
|
|
// the placeholder's position in that axis regardless of this flag.
|
|
|
|
StaticPosIsCBOrigin,
|
|
|
|
};
|
|
|
|
using InitFlags = mozilla::EnumSet<InitFlag>;
|
|
|
|
|
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
|
|
|
/**
|
2019-04-11 23:27:37 +03:00
|
|
|
* Initialize a ROOT reflow input.
|
2013-09-10 00:29:05 +04:00
|
|
|
*
|
|
|
|
* @param aPresContext Must be equal to aFrame->PresContext().
|
2019-04-11 23:27:37 +03:00
|
|
|
* @param aFrame The frame for whose reflow input is being constructed.
|
2013-09-10 00:29:05 +04:00
|
|
|
* @param aRenderingContext The rendering context to be used for measurements.
|
2020-04-16 08:37:45 +03:00
|
|
|
* @param aAvailableSpace The available space to reflow aFrame (in aFrame's
|
|
|
|
* writing-mode). See comments for mAvailableHeight and mAvailableWidth
|
|
|
|
* members for more information.
|
2013-09-10 00:29:05 +04:00
|
|
|
* @param aFlags A set of flags used for additional boolean parameters (see
|
2020-09-11 20:59:21 +03:00
|
|
|
* InitFlags above).
|
2013-09-10 00:29:05 +04:00
|
|
|
*/
|
2016-07-21 13:36:35 +03:00
|
|
|
ReflowInput(nsPresContext* aPresContext, nsIFrame* aFrame,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aRenderingContext,
|
2020-09-11 20:59:21 +03:00
|
|
|
const mozilla::LogicalSize& aAvailableSpace,
|
|
|
|
InitFlags aFlags = {});
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2013-09-10 00:29:05 +04:00
|
|
|
/**
|
2019-04-11 23:27:37 +03:00
|
|
|
* Initialize a reflow input for a child frame's reflow. Some parts of the
|
|
|
|
* state are copied from the parent's reflow input. The remainder is computed.
|
2013-09-10 00:29:05 +04:00
|
|
|
*
|
|
|
|
* @param aPresContext Must be equal to aFrame->PresContext().
|
2016-07-21 13:36:39 +03:00
|
|
|
* @param aParentReflowInput A reference to an ReflowInput object that
|
2013-09-10 00:29:05 +04:00
|
|
|
* is to be the parent of this object.
|
2019-04-11 23:27:37 +03:00
|
|
|
* @param aFrame The frame for whose reflow input is being constructed.
|
2020-04-16 08:37:45 +03:00
|
|
|
* @param aAvailableSpace The available space to reflow aFrame (in aFrame's
|
|
|
|
* writing-mode). See comments for mAvailableHeight and mAvailableWidth
|
|
|
|
* members for more information.
|
2020-10-31 17:39:23 +03:00
|
|
|
* @param aContainingBlockSize An optional size (in aFrame's writing mode),
|
|
|
|
* specifying the containing block size to use instead of the default
|
|
|
|
* size computed by ComputeContainingBlockRectangle(). If
|
|
|
|
* InitFlag::CallerWillInit is used, this is ignored. Pass it via
|
|
|
|
* Init() instead.
|
2013-09-10 00:29:05 +04:00
|
|
|
* @param aFlags A set of flags used for additional boolean parameters (see
|
2020-09-11 20:59:21 +03:00
|
|
|
* InitFlags above).
|
2020-09-11 21:17:51 +03:00
|
|
|
* @param aComputeSizeFlags A set of flags used when we call
|
|
|
|
* nsIFrame::ComputeSize() internally.
|
2013-09-10 00:29:05 +04:00
|
|
|
*/
|
2016-07-21 13:36:35 +03:00
|
|
|
ReflowInput(nsPresContext* aPresContext,
|
2017-01-11 05:55:42 +03:00
|
|
|
const ReflowInput& aParentReflowInput, nsIFrame* aFrame,
|
|
|
|
const mozilla::LogicalSize& aAvailableSpace,
|
2019-04-24 20:35:31 +03:00
|
|
|
const mozilla::Maybe<mozilla::LogicalSize>& aContainingBlockSize =
|
|
|
|
mozilla::Nothing(),
|
2020-09-11 20:59:21 +03:00
|
|
|
InitFlags aFlags = {},
|
2020-09-11 21:17:51 +03:00
|
|
|
mozilla::ComputeSizeFlags aComputeSizeFlags = {});
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2020-10-31 17:39:23 +03:00
|
|
|
/**
|
|
|
|
* This method initializes various data members. It is automatically called by
|
|
|
|
* the constructors if InitFlags::CallerWillInit is *not* used.
|
|
|
|
*
|
|
|
|
* @param aContainingBlockSize An optional size (in mFrame's writing mode),
|
|
|
|
* specifying the containing block size to use instead of the default
|
|
|
|
* size computed by ComputeContainingBlockRectangle().
|
|
|
|
* @param aBorder An optional border (in mFrame's writing mode). If given, use
|
|
|
|
* it instead of the border computed from mFrame's StyleBorder.
|
|
|
|
* @param aPadding An optional padding (in mFrame's writing mode). If given,
|
|
|
|
* use it instead of the padding computing from mFrame's StylePadding.
|
|
|
|
*/
|
2015-06-04 13:43:02 +03:00
|
|
|
void Init(nsPresContext* aPresContext,
|
2019-04-24 20:35:31 +03:00
|
|
|
const mozilla::Maybe<mozilla::LogicalSize>& aContainingBlockSize =
|
|
|
|
mozilla::Nothing(),
|
2020-10-31 17:39:23 +03:00
|
|
|
const mozilla::Maybe<mozilla::LogicalMargin>& aBorder =
|
|
|
|
mozilla::Nothing(),
|
|
|
|
const mozilla::Maybe<mozilla::LogicalMargin>& aPadding =
|
|
|
|
mozilla::Nothing());
|
2015-04-19 21:03:27 +03:00
|
|
|
|
1999-10-30 20:16:45 +04:00
|
|
|
/**
|
2015-04-19 21:03:27 +03:00
|
|
|
* Find the content isize of our containing block for the given writing mode,
|
2019-04-11 23:27:37 +03:00
|
|
|
* which need not be the same as the reflow input's mode.
|
1999-10-30 20:16:45 +04:00
|
|
|
*/
|
2015-04-19 21:03:27 +03:00
|
|
|
nscoord GetContainingBlockContentISize(
|
|
|
|
mozilla::WritingMode aWritingMode) const;
|
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
|
|
|
/**
|
2019-04-11 23:27:37 +03:00
|
|
|
* Same as CalcLineHeight() above, but doesn't need a reflow input.
|
2009-05-19 02:13:12 +04:00
|
|
|
*
|
2015-06-04 13:43:02 +03:00
|
|
|
* @param aBlockBSize The computed block size of the content rect of the block
|
2009-05-19 02:13:12 +04:00
|
|
|
* that the line should fill.
|
|
|
|
* Only used with line-height:-moz-block-height.
|
2019-06-05 02:41:20 +03:00
|
|
|
* NS_UNCONSTRAINEDSIZE 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
|
|
|
*/
|
2014-03-13 07:33:21 +04:00
|
|
|
static nscoord CalcLineHeight(nsIContent* aContent,
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* aComputedStyle,
|
2018-04-06 15:52:12 +03:00
|
|
|
nsPresContext* aPresContext,
|
2011-11-24 06:48:23 +04:00
|
|
|
nscoord aBlockBSize, float aFontSizeInflation);
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
mozilla::LogicalSize ComputeContainingBlockRectangle(
|
2016-07-21 13:36:39 +03:00
|
|
|
nsPresContext* aPresContext, const ReflowInput* aContainingBlockRI) const;
|
2000-04-29 01:05:31 +04:00
|
|
|
|
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
|
|
|
|
2014-12-04 11:57:17 +03:00
|
|
|
/**
|
|
|
|
* Apply the mComputed(Min/Max)ISize constraints to the content
|
|
|
|
* size computed so far.
|
|
|
|
*/
|
|
|
|
nscoord ApplyMinMaxISize(nscoord aISize) const {
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != ComputedMaxISize()) {
|
|
|
|
aISize = std::min(aISize, ComputedMaxISize());
|
|
|
|
}
|
|
|
|
return std::max(aISize, ComputedMinISize());
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2014-12-04 11:57:17 +03:00
|
|
|
/**
|
|
|
|
* Apply the mComputed(Min/Max)BSize constraints to the content
|
|
|
|
* size computed so far.
|
|
|
|
*
|
|
|
|
* @param aBSize The block-size that we've computed an to which we want to
|
|
|
|
* apply min/max constraints.
|
|
|
|
* @param aConsumed The amount of the computed block-size that was consumed by
|
|
|
|
* our prev-in-flows.
|
|
|
|
*/
|
|
|
|
nscoord ApplyMinMaxBSize(nscoord aBSize, nscoord aConsumed = 0) const {
|
|
|
|
aBSize += aConsumed;
|
|
|
|
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != ComputedMaxBSize()) {
|
|
|
|
aBSize = std::min(aBSize, ComputedMaxBSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != ComputedMinBSize()) {
|
|
|
|
aBSize = std::max(aBSize, ComputedMinBSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
return aBSize - aConsumed;
|
|
|
|
}
|
|
|
|
|
2020-07-06 23:31:51 +03: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
|
|
|
|
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);
|
|
|
|
|
2014-07-24 12:28:46 +04:00
|
|
|
void SetComputedISize(nscoord aComputedISize) {
|
|
|
|
if (mWritingMode.IsVertical()) {
|
|
|
|
SetComputedHeight(aComputedISize);
|
|
|
|
} else {
|
|
|
|
SetComputedWidth(aComputedISize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetComputedBSize(nscoord aComputedBSize) {
|
|
|
|
if (mWritingMode.IsVertical()) {
|
|
|
|
SetComputedWidth(aComputedBSize);
|
|
|
|
} else {
|
|
|
|
SetComputedHeight(aComputedBSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-18 23:07:54 +03:00
|
|
|
void SetComputedBSizeWithoutResettingResizeFlags(nscoord aComputedBSize) {
|
|
|
|
// Viewport frames reset the computed block size on a copy of their reflow
|
2019-04-12 00:22:16 +03:00
|
|
|
// input when reflowing fixed-pos kids. In that case we actually don't
|
2009-01-29 23:39:22 +03:00
|
|
|
// want to mess with the resize flags, because comparing the frame's rect
|
2016-05-18 23:07:54 +03:00
|
|
|
// to the munged computed isize is pointless.
|
|
|
|
ComputedBSize() = aComputedBSize;
|
2009-01-29 23:39:22 +03:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:36:38 +03:00
|
|
|
void SetTruncated(const ReflowOutput& aMetrics,
|
|
|
|
nsReflowStatus* aStatus) const;
|
2007-03-11 23:34:15 +03:00
|
|
|
|
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
|
2015-06-04 13:43:02 +03:00
|
|
|
static void ComputeRelativeOffsets(mozilla::WritingMode aWM, nsIFrame* aFrame,
|
|
|
|
const mozilla::LogicalSize& aCBSize,
|
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
|
|
|
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 {
|
2016-07-21 13:36:38 +03:00
|
|
|
ApplyRelativePositioning(mFrame, ComputedPhysicalOffsets(), aPosition);
|
2013-07-16 04:28:09 +04:00
|
|
|
}
|
|
|
|
|
2015-01-07 10:10:07 +03:00
|
|
|
static void ApplyRelativePositioning(
|
|
|
|
nsIFrame* aFrame, mozilla::WritingMode aWritingMode,
|
|
|
|
const mozilla::LogicalMargin& aComputedOffsets,
|
2020-07-06 23:31:51 +03:00
|
|
|
mozilla::LogicalPoint* aPosition, const nsSize& aContainerSize);
|
2015-01-07 10:10:07 +03:00
|
|
|
|
|
|
|
void ApplyRelativePositioning(mozilla::LogicalPoint* aPosition,
|
2015-07-16 12:07:57 +03:00
|
|
|
const nsSize& aContainerSize) const {
|
2016-07-21 13:36:38 +03:00
|
|
|
ApplyRelativePositioning(mFrame, mWritingMode, ComputedLogicalOffsets(),
|
2015-07-16 12:07:57 +03:00
|
|
|
aPosition, aContainerSize);
|
2015-01-07 10:10:07 +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* DisplayInitConstraintsEnter(nsIFrame* aFrame,
|
2016-07-21 13:36:35 +03:00
|
|
|
ReflowInput* aState,
|
2015-06-04 13:43:02 +03:00
|
|
|
nscoord aCBISize, nscoord aCBBSize,
|
2010-05-02 01:40:16 +04:00
|
|
|
const nsMargin* aBorder,
|
|
|
|
const nsMargin* aPadding);
|
|
|
|
static void DisplayInitConstraintsExit(nsIFrame* aFrame, ReflowInput* aState,
|
|
|
|
void* aValue);
|
|
|
|
static void* DisplayInitFrameTypeEnter(nsIFrame* aFrame, ReflowInput* aState);
|
|
|
|
static void DisplayInitFrameTypeExit(nsIFrame* aFrame, ReflowInput* aState,
|
|
|
|
void* aValue);
|
|
|
|
#endif
|
|
|
|
|
1999-10-30 20:16:45 +04:00
|
|
|
protected:
|
2017-05-01 20:32:52 +03:00
|
|
|
void InitFrameType(LayoutFrameType aFrameType);
|
2016-07-21 13:36:39 +03:00
|
|
|
void InitCBReflowInput();
|
2017-04-30 18:30:08 +03:00
|
|
|
void InitResizeFlags(nsPresContext* aPresContext,
|
2017-05-01 20:32:52 +03:00
|
|
|
mozilla::LayoutFrameType aFrameType);
|
2018-12-11 23:33:29 +03:00
|
|
|
void InitDynamicReflowRoot();
|
2002-05-14 16:59:55 +04:00
|
|
|
|
2019-04-25 01:23:59 +03:00
|
|
|
void InitConstraints(
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
const mozilla::Maybe<mozilla::LogicalSize>& aContainingBlockSize,
|
2020-10-31 17:39:23 +03:00
|
|
|
const mozilla::Maybe<mozilla::LogicalMargin>& aBorder,
|
|
|
|
const mozilla::Maybe<mozilla::LogicalMargin>& aPadding,
|
2019-04-25 01:23:59 +03:00
|
|
|
mozilla::LayoutFrameType 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
|
2015-08-06 23:01:31 +03:00
|
|
|
// the inline-start edge and logical size of the containing block's
|
2015-06-04 13:43:02 +03:00
|
|
|
// 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,
|
2015-06-04 13:43:02 +03:00
|
|
|
nscoord& aCBIStartEdge,
|
2015-12-23 01:03:16 +03:00
|
|
|
mozilla::LogicalSize& aCBSize) const;
|
2006-12-18 06:34:05 +03:00
|
|
|
|
2015-08-06 23:01:31 +03:00
|
|
|
// Calculate a "hypothetical box" position where the placeholder frame
|
|
|
|
// (for a position:fixed/absolute element) would have been placed if it were
|
2015-08-12 13:02:02 +03:00
|
|
|
// positioned statically. The hypothetical box position will have a writing
|
|
|
|
// mode with the same block direction as the absolute containing block
|
2019-01-29 19:44:56 +03:00
|
|
|
// (aCBReflowInput->frame), though it may differ in inline direction.
|
2015-08-12 13:02:02 +03:00
|
|
|
void CalculateHypotheticalPosition(nsPresContext* aPresContext,
|
2017-05-23 20:09:26 +03:00
|
|
|
nsPlaceholderFrame* aPlaceholderFrame,
|
2019-01-29 19:44:56 +03:00
|
|
|
const ReflowInput* aCBReflowInput,
|
2015-08-12 13:02:02 +03:00
|
|
|
nsHypotheticalPosition& aHypotheticalPos,
|
2017-05-01 20:32:52 +03:00
|
|
|
mozilla::LayoutFrameType aFrameType) const;
|
2000-04-16 08:07:02 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void InitAbsoluteConstraints(nsPresContext* aPresContext,
|
2019-01-29 19:44:56 +03:00
|
|
|
const ReflowInput* aCBReflowInput,
|
2015-06-04 13:43:02 +03:00
|
|
|
const mozilla::LogicalSize& aContainingBlockSize,
|
2017-05-01 20:32:52 +03:00
|
|
|
mozilla::LayoutFrameType 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
|
2015-06-04 13:43:02 +03:00
|
|
|
void ComputeMinMaxValues(const mozilla::LogicalSize& aContainingBlockSize);
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2015-08-06 23:01:31 +03:00
|
|
|
// aInsideBoxSizing returns the part of the padding, border, and margin
|
|
|
|
// in the aAxis dimension that goes inside the edge given by box-sizing;
|
|
|
|
// aOutsideBoxSizing returns the rest.
|
|
|
|
void CalculateBorderPaddingMargin(mozilla::LogicalAxis aAxis,
|
|
|
|
nscoord aContainingBlockSize,
|
|
|
|
nscoord* aInsideBoxSizing,
|
2015-12-23 01:03:16 +03:00
|
|
|
nscoord* aOutsideBoxSizing) const;
|
2001-03-06 08:56:19 +03:00
|
|
|
|
2017-05-01 20:32:52 +03:00
|
|
|
void CalculateBlockSideMargins(LayoutFrameType aFrameType);
|
1999-10-30 20:16:45 +04:00
|
|
|
};
|
|
|
|
|
2016-07-21 13:36:34 +03:00
|
|
|
} // namespace mozilla
|
1999-10-30 20:16:45 +04:00
|
|
|
|
2016-07-21 13:36:35 +03:00
|
|
|
#endif // mozilla_ReflowInput_h
|