1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* constants used throughout the Layout module */
9 #ifndef LayoutConstants_h___
10 #define LayoutConstants_h___
12 #include "mozilla/EnumSet.h"
13 #include "nsSize.h" // for NS_MAXSIZE
17 * Constant used to indicate an unconstrained size.
19 * NOTE: The constants defined in this file are semantically used as symbolic
20 * values, so user should not depend on the underlying numeric values. If
21 * new specific use cases arise, define a new constant here.
23 #define NS_UNCONSTRAINEDSIZE NS_MAXSIZE
25 // NS_AUTOOFFSET is assumed to have the same value as NS_UNCONSTRAINEDSIZE.
26 #define NS_AUTOOFFSET NS_UNCONSTRAINEDSIZE
28 // +1 is to avoid clamped huge margin values being processed as auto margins
29 #define NS_AUTOMARGIN (NS_UNCONSTRAINEDSIZE + 1)
31 #define NS_INTRINSIC_ISIZE_UNKNOWN nscoord_MIN
36 * Bit-flags to pass to various functions that compute sizes like
37 * nsIFrame::ComputeSize().
39 enum class ComputeSizeFlag
: uint8_t {
41 * Set if the frame is in a context where non-replaced blocks should
42 * shrink-wrap (e.g., it's floating, absolutely positioned, or
48 * Set if this is a grid measuring reflow, to prevent stretching.
50 IsGridMeasuringReflow
,
53 * Indicates that we should clamp the margin-box min-size to the given CB
54 * size. This is used for implementing the grid area clamping here:
55 * https://drafts.csswg.org/css-grid/#min-size-auto
57 IClampMarginBoxMinSize
, // clamp in our inline axis
58 BClampMarginBoxMinSize
, // clamp in our block axis
61 * The frame is stretching (per CSS Box Alignment) and doesn't have an
62 * Automatic Minimum Size in the indicated axis.
63 * (may be used for both flex/grid items, but currently only used for Grid)
64 * https://drafts.csswg.org/css-grid/#min-size-auto
65 * https://drafts.csswg.org/css-align-3/#valdef-justify-self-stretch
67 IApplyAutoMinSize
, // only has an effect when eShrinkWrap is false
69 using ComputeSizeFlags
= mozilla::EnumSet
<ComputeSizeFlag
>;
72 * The fallback size of width is 300px and the aspect-ratio is 2:1, based on
73 * CSS2 section 10.3.2 and CSS Sizing Level 3 section 5.1:
74 * https://drafts.csswg.org/css2/visudet.html#inline-replaced-width
75 * https://drafts.csswg.org/css-sizing-3/#intrinsic-sizes
77 inline constexpr CSSIntCoord
kFallbackIntrinsicWidthInPixels(300);
78 inline constexpr CSSIntCoord
kFallbackIntrinsicHeightInPixels(150);
79 inline constexpr CSSIntSize
kFallbackIntrinsicSizeInPixels(
80 kFallbackIntrinsicWidthInPixels
, kFallbackIntrinsicHeightInPixels
);
82 inline constexpr nscoord kFallbackIntrinsicWidth
=
83 kFallbackIntrinsicWidthInPixels
* AppUnitsPerCSSPixel();
84 inline constexpr nscoord kFallbackIntrinsicHeight
=
85 kFallbackIntrinsicHeightInPixels
* AppUnitsPerCSSPixel();
86 inline constexpr nsSize
kFallbackIntrinsicSize(kFallbackIntrinsicWidth
,
87 kFallbackIntrinsicHeight
);
90 * This is used in some nsLayoutUtils functions.
91 * Declared here so that fewer files need to include nsLayoutUtils.h.
93 enum class IntrinsicISizeType
{ MinISize
, PrefISize
};
95 enum class ContentRelevancyReason
{
96 // If the content of this Frame is on screen or nearly on screen.
99 // If this Frame's element has focus in its subtree.
102 // If this Frame's content is part of a selection.
105 using ContentRelevancy
= EnumSet
<ContentRelevancyReason
, uint8_t>;
107 } // namespace mozilla
109 #endif // LayoutConstants_h___