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 #ifndef nsContainerFrameInlines_h___
8 #define nsContainerFrameInlines_h___
10 #include "nsContainerFrame.h"
12 template <typename ISizeData
, typename F
>
13 void nsContainerFrame::DoInlineIntrinsicISize(ISizeData
* aData
,
15 using namespace mozilla
;
17 auto GetMargin
= [](const LengthPercentageOrAuto
& aCoord
) -> nscoord
{
18 return aCoord
.IsAuto() ? 0 : aCoord
.AsLengthPercentage().Resolve(0);
21 if (GetPrevInFlow()) return; // Already added.
23 WritingMode wm
= GetWritingMode();
24 Side startSide
= wm
.PhysicalSideForInlineAxis(eLogicalEdgeStart
);
25 Side endSide
= wm
.PhysicalSideForInlineAxis(eLogicalEdgeEnd
);
27 const nsStylePadding
* stylePadding
= StylePadding();
28 const nsStyleBorder
* styleBorder
= StyleBorder();
29 const nsStyleMargin
* styleMargin
= StyleMargin();
31 // This goes at the beginning no matter how things are broken and how
32 // messy the bidi situations are, since per CSS2.1 section 8.6
33 // (implemented in bug 328168), the startSide border is always on the
35 // This frame is a first-in-flow, but it might have a previous bidi
36 // continuation, in which case that continuation should handle the startSide
38 // For box-decoration-break:clone we setup clonePBM = startPBM + endPBM and
39 // add that to each line. For box-decoration-break:slice clonePBM is zero.
40 nscoord clonePBM
= 0; // PBM = PaddingBorderMargin
41 const bool sliceBreak
=
42 styleBorder
->mBoxDecorationBreak
== StyleBoxDecorationBreak::Slice
;
43 if (!GetPrevContinuation() || MOZ_UNLIKELY(!sliceBreak
)) {
45 // clamp negative calc() to 0
46 std::max(stylePadding
->mPadding
.Get(startSide
).Resolve(0), 0) +
47 styleBorder
->GetComputedBorderWidth(startSide
) +
48 GetMargin(styleMargin
->mMargin
.Get(startSide
));
49 if (MOZ_LIKELY(sliceBreak
)) {
50 aData
->mCurrentLine
+= startPBM
;
57 // clamp negative calc() to 0
58 std::max(stylePadding
->mPadding
.Get(endSide
).Resolve(0), 0) +
59 styleBorder
->GetComputedBorderWidth(endSide
) +
60 GetMargin(styleMargin
->mMargin
.Get(endSide
));
61 if (MOZ_UNLIKELY(!sliceBreak
)) {
63 aData
->mCurrentLine
+= clonePBM
;
66 const nsLineList_iterator
* savedLine
= aData
->mLine
;
67 nsIFrame
* const savedLineContainer
= aData
->LineContainer();
69 nsContainerFrame
* lastInFlow
;
70 for (nsContainerFrame
* nif
= this; nif
;
71 nif
= static_cast<nsContainerFrame
*>(nif
->GetNextInFlow())) {
72 if (aData
->mCurrentLine
== 0) {
73 aData
->mCurrentLine
= clonePBM
;
75 aHandleChildren(nif
, aData
);
77 // After we advance to our next-in-flow, the stored line and line container
78 // may no longer be correct. Just forget them.
79 aData
->mLine
= nullptr;
80 aData
->SetLineContainer(nullptr);
85 aData
->mLine
= savedLine
;
86 aData
->SetLineContainer(savedLineContainer
);
88 // This goes at the end no matter how things are broken and how
89 // messy the bidi situations are, since per CSS2.1 section 8.6
90 // (implemented in bug 328168), the endSide border is always on the
92 // We reached the last-in-flow, but it might have a next bidi
93 // continuation, in which case that continuation should handle
94 // the endSide border.
95 if (MOZ_LIKELY(!lastInFlow
->GetNextContinuation() && sliceBreak
)) {
96 aData
->mCurrentLine
+= endPBM
;
100 #endif // nsContainerFrameInlines_h___