Bug 1709347 - Add CanvasRenderingContext2D.reset(). r=lsalzman,webidl,smaug
[gecko.git] / layout / base / Baseline.h
blob8eae2e1140623603f637443ffb53a0f98c278300
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef LAYOUT_BASE_BASELINE_H_
6 #define LAYOUT_BASE_BASELINE_H_
8 #include "nsCoord.h"
9 #include "mozilla/WritingModes.h"
11 class nsIFrame;
13 namespace mozilla {
15 // https://drafts.csswg.org/css-align-3/#baseline-sharing-group
16 enum class BaselineSharingGroup : uint8_t {
17 // NOTE Used as an array index so must be 0 and 1.
18 First = 0,
19 Last = 1,
22 class Baseline {
23 public:
24 /**
25 * Synthesize a first(last) inline-axis baseline in aWM based on aFrame's
26 * margin-box.
28 * An alphabetical baseline is at the end edge of aFrame's margin-box with
29 * respect to aWM's block-axis, and a central baseline is halfway between the
30 * start and end edges. (aWM tells which baseline to use.)
31 * https://drafts.csswg.org/css-align-3/#synthesize-baseline
33 * @note This works only when aFrame's writing-mode is parallel to aWM.
34 * @param aWM the writing-mode of the alignment context.
35 * @return an offset from aFrame's border-box start(end) edge in aWM's
36 * block-axis for a first(last) baseline, respectively.
38 static nscoord SynthesizeBOffsetFromMarginBox(const nsIFrame* aFrame,
39 WritingMode aWM,
40 BaselineSharingGroup);
42 /**
43 * Synthesize a first(last) inline-axis baseline in aWM based on aFrame's
44 * border-box.
46 * An alphabetical baseline is at the end edge of aFrame's border-box with
47 * respect to aWM's block-axis, and a central baseline is halfway between the
48 * start and end edges. (aWM tells which baseline to use.)
49 * https://drafts.csswg.org/css-align-3/#synthesize-baseline
51 * @param aWM the writing-mode of the alignment context.
52 * @return an offset from aFrame's border-box start(end) edge in aWM's
53 * block-axis for a first(last) baseline, respectively.
55 static nscoord SynthesizeBOffsetFromBorderBox(const nsIFrame* aFrame,
56 WritingMode aWM,
57 BaselineSharingGroup);
59 /**
60 * Synthesize a first(last) inline-axis baseline in aWM based on aFrame's
61 * content-box.
63 * An alphabetical baseline is at the end edge of aFrame's content-box with
64 * respect to aWM's block-axis, and a central baseline is halfway between the
65 * start and end edges. (aWM tells which baseline to use.)
66 * https://drafts.csswg.org/css-align-3/#synthesize-baseline
68 * @note This works only when aFrame's writing-mode is parallel to aWM.
69 * @param aWM the writing-mode of the alignment context.
70 * @return an offset from aFrame's border-box start(end) edge in aWM's
71 * block-axis for a first(last) baseline, respectively.
73 static nscoord SynthesizeBOffsetFromContentBox(const nsIFrame* aFrame,
74 WritingMode aWM,
75 BaselineSharingGroup);
78 } // namespace mozilla
80 #endif // LAYOUT_BASE_BASELINE_H_