Backed out changeset 496886cb30a5 (bug 1867152) for bc failures on browser_user_input...
[gecko.git] / layout / generic / CSSAlignUtils.h
blobae715f4081c7b70a98d1436fff00a0f5d38d4053
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 /* Utility code for performing CSS Box Alignment */
9 #ifndef mozilla_CSSAlignUtils_h
10 #define mozilla_CSSAlignUtils_h
12 #include "mozilla/WritingModes.h"
14 namespace mozilla {
16 struct ReflowInput;
17 struct StyleAlignFlags;
19 class CSSAlignUtils {
20 public:
21 /**
22 * Flags to customize the behavior of AlignJustifySelf:
24 enum class AlignJustifyFlags {
25 NoFlags = 0,
26 // Indicates that we have <overflow-position> = safe.
27 OverflowSafe = 1 << 0,
28 // Indicates that the container's start side in aAxis is the same
29 // as the child's start side in the child's parallel axis.
30 SameSide = 1 << 1,
31 // Indicates that AlignJustifySelf() shouldn't expand "auto" margins.
32 // (By default, AlignJustifySelf() *will* expand such margins, to fill the
33 // available space before any alignment is done.)
34 IgnoreAutoMargins = 1 << 2,
37 /**
38 * This computes the aligned offset of a CSS-aligned child within its
39 * alignment container. The returned offset is distance between the
40 * logical "start" edge of the alignment container & the logical "start" edge
41 * of the aligned child (in terms of the alignment container's writing mode).
43 * @param aAlignment An enumerated value representing a keyword for
44 * "align-self" or "justify-self". The values
45 * StyleAlignFlags::{AUTO,LEFT,RIGHT} must *not* be
46 * passed here; this method expects the caller to have
47 * already resolved those to 'start', 'end', or 'stretch'.
48 * @param aAxis The container's axis in which we're doing alignment.
49 * @param aBaselineAdjust The amount to offset baseline-aligned children.
50 * @param aCBSize The size of the alignment container, in its aAxis.
51 * @param aRI A ReflowInput for the child.
52 * @param aChildSize The child's LogicalSize (in its own writing mode).
54 static nscoord AlignJustifySelf(const StyleAlignFlags& aAlignment,
55 LogicalAxis aAxis, AlignJustifyFlags aFlags,
56 nscoord aBaselineAdjust, nscoord aCBSize,
57 const ReflowInput& aRI,
58 const LogicalSize& aChildSize);
61 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CSSAlignUtils::AlignJustifyFlags)
63 } // namespace mozilla
65 #endif // mozilla_CSSAlignUtils_h