Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : /* Utility code for performing CSS Box Alignment */
7 :
8 : #ifndef mozilla_CSSAlignUtils_h
9 : #define mozilla_CSSAlignUtils_h
10 :
11 : #include "mozilla/WritingModes.h"
12 :
13 : namespace mozilla {
14 :
15 : struct ReflowInput;
16 :
17 : class CSSAlignUtils {
18 : public:
19 : /**
20 : * Flags to customize the behavior of AlignJustifySelf:
21 : */
22 : enum class AlignJustifyFlags {
23 : eNoFlags = 0,
24 : // Indicates that we have <overflow-position> = safe.
25 : eOverflowSafe = 1 << 0,
26 : // Indicates that the container's start side in aAxis is the same
27 : // as the child's start side in the child's parallel axis.
28 : eSameSide = 1 << 1,
29 : // Indicates that AlignJustifySelf() shouldn't expand "auto" margins.
30 : // (By default, AlignJustifySelf() *will* expand such margins, to fill the
31 : // available space before any alignment is done.)
32 : eIgnoreAutoMargins = 1 << 2,
33 : };
34 :
35 : /**
36 : * This computes the aligned offset of a CSS-aligned child within its
37 : * alignment container. The returned offset is distance between the
38 : * logical "start" edge of the alignment container & the logical "start" edge
39 : * of the aligned child (in terms of the alignment container's writing mode).
40 : *
41 : * @param aAlignment An enumerated value representing a keyword for
42 : * "align-self" or "justify-self". The values
43 : * NS_STYLE_ALIGN_{AUTO,LEFT,RIGHT} must *not* be
44 : * passed here; this method expects the caller to have
45 : * already resolved those to 'start', 'end', or 'stretch'.
46 : * @param aAxis The container's axis in which we're doing alignment.
47 : * @param aBaselineAdjust The amount to offset baseline-aligned children.
48 : * @param aCBSize The size of the alignment container, in its aAxis.
49 : * @param aRI A ReflowInput for the child.
50 : * @param aChildSize The child's LogicalSize (in its own writing mode).
51 : */
52 : static nscoord AlignJustifySelf(uint8_t aAlignment, LogicalAxis aAxis,
53 : AlignJustifyFlags aFlags,
54 : nscoord aBaselineAdjust, nscoord aCBSize,
55 : const ReflowInput& aRI,
56 : const LogicalSize& aChildSize);
57 : };
58 :
59 0 : MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CSSAlignUtils::AlignJustifyFlags)
60 :
61 : } // namespace mozilla
62 :
63 : #endif // mozilla_CSSAlignUtils_h
|