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 /* rendering object for CSS "display: flex" and "display: -webkit-box" */
9 #ifndef nsFlexContainerFrame_h___
10 #define nsFlexContainerFrame_h___
14 #include "mozilla/dom/FlexBinding.h"
15 #include "mozilla/UniquePtr.h"
16 #include "nsContainerFrame.h"
17 #include "nsILineIterator.h"
22 } // namespace mozilla
24 nsContainerFrame
* NS_NewFlexContainerFrame(mozilla::PresShell
* aPresShell
,
25 mozilla::ComputedStyle
* aStyle
);
28 * These structures are used to capture data during reflow to be
29 * extracted by devtools via Chrome APIs. The structures are only
30 * created when requested in GetFlexFrameWithComputedInfo(), and
31 * the structures are attached to the nsFlexContainerFrame via the
32 * FlexContainerInfo property.
34 struct ComputedFlexItemInfo
{
35 nsCOMPtr
<nsINode
> mNode
;
38 * mMainBaseSize is a measure of the size of the item in the main
39 * axis before the flex sizing algorithm is applied. In the spec,
40 * this is called "flex base size", but we use this name to connect
41 * the value to the other main axis sizes.
43 nscoord mMainBaseSize
;
45 * mMainDeltaSize is the amount that the flex sizing algorithm
46 * adds to the mMainBaseSize, before clamping to mMainMinSize and
47 * mMainMaxSize. This can be thought of as the amount by which the
48 * flex layout algorithm "wants" to shrink or grow the item, and
49 * would do, if it was unconstrained. Since the flex sizing
50 * algorithm proceeds linearly, the mMainDeltaSize for an item only
51 * respects the resolved size of items already frozen.
53 nscoord mMainDeltaSize
;
56 nscoord mCrossMinSize
;
57 nscoord mCrossMaxSize
;
58 mozilla::dom::FlexItemClampState mClampState
;
61 struct ComputedFlexLineInfo
{
62 nsTArray
<ComputedFlexItemInfo
> mItems
;
65 nscoord mFirstBaselineOffset
;
66 nscoord mLastBaselineOffset
;
67 mozilla::dom::FlexLineGrowthState mGrowthState
;
70 struct ComputedFlexContainerInfo
{
71 nsTArray
<ComputedFlexLineInfo
> mLines
;
72 mozilla::dom::FlexPhysicalDirection mMainAxisDirection
;
73 mozilla::dom::FlexPhysicalDirection mCrossAxisDirection
;
77 * Helper class to get the orientation of a flex container's axes.
79 class MOZ_STACK_CLASS FlexboxAxisInfo final
{
81 explicit FlexboxAxisInfo(const nsIFrame
* aFlexContainer
);
83 // Is our main axis the inline axis? (Are we 'flex-direction:row[-reverse]'?)
84 bool mIsRowOriented
= true;
86 // Is our main axis in the opposite direction as mWM's corresponding axis?
88 bool mIsMainAxisReversed
= false;
90 // Is our cross axis in the opposite direction as mWM's corresponding axis?
92 bool mIsCrossAxisReversed
= false;
95 // Helpers for constructor which determine the orientation of our axes, based
96 // on legacy box properties (-webkit-box-orient, -webkit-box-direction) or
97 // modern flexbox properties (flex-direction, flex-wrap) depending on whether
98 // the flex container is a "legacy box" (as determined by IsLegacyBox).
99 void InitAxesFromLegacyProps(const nsIFrame
* aFlexContainer
);
100 void InitAxesFromModernProps(const nsIFrame
* aFlexContainer
);
104 * This is the rendering object used for laying out elements with
105 * "display: flex" or "display: inline-flex".
107 * We also use this class for elements with "display: -webkit-box" or
108 * "display: -webkit-inline-box" (but not "-moz-box" / "-moz-inline-box" --
109 * those are rendered with old-school XUL frame classes).
111 * Note: we represent the -webkit-box family of properties (-webkit-box-orient,
112 * -webkit-box-flex, etc.) as aliases for their -moz equivalents. And for
113 * -webkit-{inline-}box containers, nsFlexContainerFrame will honor those
114 * "legacy" properties for alignment/flexibility/etc. *instead of* honoring the
115 * modern flexbox & alignment properties. For brevity, many comments in
116 * nsFlexContainerFrame.cpp simply refer to these properties using their
117 * "-webkit" versions, since we're mostly expecting to encounter them in that
118 * form. (Technically, the "-moz" versions of these properties *can* influence
119 * layout here as well (since that's what the -webkit versions are aliased to)
120 * -- but only inside of a "display:-webkit-{inline-}box" container.)
122 class nsFlexContainerFrame final
: public nsContainerFrame
,
123 public nsILineIterator
{
125 NS_DECL_FRAMEARENA_HELPERS(nsFlexContainerFrame
)
129 friend nsContainerFrame
* NS_NewFlexContainerFrame(
130 mozilla::PresShell
* aPresShell
, ComputedStyle
* aStyle
);
132 // Forward-decls of helper classes
135 class FlexboxAxisTracker
;
137 class CachedBAxisMeasurement
;
138 class CachedFlexItemData
;
139 struct SharedFlexData
;
140 struct PerFragmentFlexData
;
141 class FlexItemIterator
;
143 // nsIFrame overrides
144 void Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
145 nsIFrame
* aPrevInFlow
) override
;
147 bool IsFrameOfType(uint32_t aFlags
) const override
{
148 return nsContainerFrame::IsFrameOfType(
149 aFlags
& ~(nsIFrame::eCanContainOverflowContainers
));
152 void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
153 const nsDisplayListSet
& aLists
) override
;
155 void MarkIntrinsicISizesDirty() override
;
157 void Reflow(nsPresContext
* aPresContext
, ReflowOutput
& aReflowOutput
,
158 const ReflowInput
& aReflowInput
,
159 nsReflowStatus
& aStatus
) override
;
161 nscoord
GetMinISize(gfxContext
* aRenderingContext
) override
;
162 nscoord
GetPrefISize(gfxContext
* aRenderingContext
) override
;
164 #ifdef DEBUG_FRAME_DUMP
165 nsresult
GetFrameName(nsAString
& aResult
) const override
;
168 Maybe
<nscoord
> GetNaturalBaselineBOffset(
169 mozilla::WritingMode aWM
, BaselineSharingGroup aBaselineGroup
,
170 BaselineExportContext
) const override
;
172 // Unions the child overflow from our in-flow children.
173 void UnionInFlowChildOverflow(mozilla::OverflowAreas
&);
175 // Unions the child overflow from all our children, including out of flows.
176 void UnionChildOverflow(mozilla::OverflowAreas
&) final
;
178 // nsContainerFrame overrides
179 bool DrainSelfOverflowList() override
;
180 void AppendFrames(ChildListID aListID
, nsFrameList
&& aFrameList
) override
;
181 void InsertFrames(ChildListID aListID
, nsIFrame
* aPrevFrame
,
182 const nsLineList::iterator
* aPrevFrameLine
,
183 nsFrameList
&& aFrameList
) override
;
184 void RemoveFrame(DestroyContext
&, ChildListID
, nsIFrame
*) override
;
185 mozilla::StyleAlignFlags
CSSAlignmentForAbsPosChild(
186 const ReflowInput
& aChildRI
,
187 mozilla::LogicalAxis aLogicalAxis
) const override
;
190 * Helper function to calculate packing space and initial offset of alignment
191 * subjects in MainAxisPositionTracker() and CrossAxisPositionTracker() for
192 * space-between, space-around, and space-evenly.
193 * * @param aNumThingsToPack Number of alignment subjects.
194 * @param aAlignVal Value for align-content or
196 * @param aFirstSubjectOffset Outparam for first subject offset.
197 * @param aNumPackingSpacesRemaining Outparam for number of equal-sized
198 * packing spaces to apply between each
200 * @param aPackingSpaceRemaining Outparam for total amount of packing
201 * space to be divided up.
203 static void CalculatePackingSpace(
204 uint32_t aNumThingsToPack
,
205 const mozilla::StyleContentDistribution
& aAlignVal
,
206 nscoord
* aFirstSubjectOffset
, uint32_t* aNumPackingSpacesRemaining
,
207 nscoord
* aPackingSpaceRemaining
);
210 * This property is created by a call to
211 * nsFlexContainerFrame::GetFlexFrameWithComputedInfo.
213 NS_DECLARE_FRAME_PROPERTY_DELETABLE(FlexContainerInfo
,
214 ComputedFlexContainerInfo
)
216 * This function should only be called on a nsFlexContainerFrame
217 * that has just been returned by a call to
218 * GetFlexFrameWithComputedInfo.
220 const ComputedFlexContainerInfo
* GetFlexContainerInfo() {
221 const ComputedFlexContainerInfo
* info
= GetProperty(FlexContainerInfo());
222 NS_WARNING_ASSERTION(info
,
223 "Property generation wasn't requested. "
224 "This is a known issue in Print Preview. "
230 * Return aFrame as a flex frame after ensuring it has computed flex info.
231 * @return nullptr if aFrame is null or doesn't have a flex frame
232 * as its content insertion frame.
233 * @note this might destroy layout/style data since it may flush layout.
235 MOZ_CAN_RUN_SCRIPT_BOUNDARY
236 static nsFlexContainerFrame
* GetFlexFrameWithComputedInfo(nsIFrame
* aFrame
);
239 * Given a frame for a flex item, this method returns true IFF that flex
240 * item's inline axis is the same as (i.e. not orthogonal to) its flex
241 * container's main axis.
243 * (This method is only intended to be used from external
244 * callers. Inside of flex reflow code, FlexItem::IsInlineAxisMainAxis() is
245 * equivalent & more optimal.)
247 * @param aFrame a flex item (must return true from IsFlexItem)
248 * @return true iff aFrame's inline axis is the same as (i.e. not orthogonal
249 * to) its flex container's main axis. Otherwise, false.
251 static bool IsItemInlineAxisMainAxis(nsIFrame
* aFrame
);
254 * Returns true iff the given computed 'flex-basis' & main-size property
255 * values collectively represent a used flex-basis of 'content'.
256 * See https://drafts.csswg.org/css-flexbox-1/#valdef-flex-basis-auto
258 * @param aFlexBasis the computed 'flex-basis' for a flex item.
259 * @param aMainSize the computed main-size property for a flex item.
261 static bool IsUsedFlexBasisContent(const mozilla::StyleFlexBasis
& aFlexBasis
,
262 const mozilla::StyleSize
& aMainSize
);
265 * Callback for nsIFrame::MarkIntrinsicISizesDirty() on a flex item.
267 static void MarkCachedFlexMeasurementsDirty(nsIFrame
* aItemFrame
);
269 bool CanProvideLineIterator() const final
{ return true; }
270 nsILineIterator
* GetLineIterator() final
{ return this; }
271 int32_t GetNumLines() const final
;
272 bool IsLineIteratorFlowRTL() final
;
273 mozilla::Result
<LineInfo
, nsresult
> GetLine(int32_t aLineNumber
) final
;
274 int32_t FindLineContaining(nsIFrame
* aFrame
, int32_t aStartLine
= 0) final
;
275 NS_IMETHOD
FindFrameAt(int32_t aLineNumber
, nsPoint aPos
,
276 nsIFrame
** aFrameFound
, bool* aPosIsBeforeFirstFrame
,
277 bool* aPosIsAfterLastFrame
) final
;
278 NS_IMETHOD
CheckLineOrder(int32_t aLine
, bool* aIsReordered
,
279 nsIFrame
** aFirstVisual
,
280 nsIFrame
** aLastVisual
) final
;
283 // Protected constructor & destructor
284 explicit nsFlexContainerFrame(ComputedStyle
* aStyle
,
285 nsPresContext
* aPresContext
)
286 : nsContainerFrame(aStyle
, aPresContext
, kClassID
) {}
288 virtual ~nsFlexContainerFrame();
290 // Protected flex-container-specific methods / member-vars
293 * This method does the bulk of the flex layout, implementing the algorithm
294 * described at: https://drafts.csswg.org/css-flexbox-1/#layout-algorithm
295 * (with a few initialization pieces happening in the caller, Reflow().
297 * (The logic behind the division of work between Reflow and DoFlexLayout is
298 * as follows: DoFlexLayout() begins at the step that we have to jump back
299 * to, if we find any visibility:collapse children, and Reflow() does
300 * everything before that point.)
302 * @param aTentativeContentBoxMainSize the "tentative" content-box main-size
303 * of the flex container; "tentative"
304 * because it may be unconstrained or may
306 * @param aTentativeContentBoxCrossSize the "tentative" content-box cross-size
307 * of the flex container; "tentative"
308 * because it may be unconstrained or may
311 struct FlexLayoutResult final
{
312 // The flex lines of the flex container.
313 nsTArray
<FlexLine
> mLines
;
315 // The absolutely-positioned flex children.
316 nsTArray
<nsIFrame
*> mPlaceholders
;
318 bool mHasCollapsedItems
= false;
320 // The final content-box main-size of the flex container as if there's no
322 nscoord mContentBoxMainSize
= NS_UNCONSTRAINEDSIZE
;
324 // The final content-box cross-size of the flex container as if there's no
326 nscoord mContentBoxCrossSize
= NS_UNCONSTRAINEDSIZE
;
328 // The flex container's ascent for the "first baseline" alignment, derived
329 // from any baseline-aligned flex items in the startmost (from the
330 // perspective of the flex container's WM) flex line, if any such items
331 // exist. Otherwise, nscoord_MIN.
333 // Note: this is a distance from the border-box block-start edge.
334 nscoord mAscent
= NS_UNCONSTRAINEDSIZE
;
336 // The flex container's ascent for the "last baseline" alignment, derived
337 // from any baseline-aligned flex items in the endmost (from the perspective
338 // of the flex container's WM) flex line, if any such items exist.
339 // Otherwise, nscoord_MIN.
341 // Note: this is a distance from the border-box block-end edge. It's
342 // different from the identically-named-member FlexItem::mAscentForLast,
343 // which is a distance from the item frame's border-box block-start edge.
344 nscoord mAscentForLast
= NS_UNCONSTRAINEDSIZE
;
346 FlexLayoutResult
DoFlexLayout(
347 const ReflowInput
& aReflowInput
,
348 const nscoord aTentativeContentBoxMainSize
,
349 const nscoord aTentativeContentBoxCrossSize
,
350 const FlexboxAxisTracker
& aAxisTracker
, nscoord aMainGapSize
,
351 nscoord aCrossGapSize
, nsTArray
<StrutInfo
>& aStruts
,
352 ComputedFlexContainerInfo
* const aContainerInfo
);
355 * If our devtools have requested a ComputedFlexContainerInfo for this flex
356 * container, this method ensures that we have one (and if one already exists,
357 * this method reinitializes it to look like a freshly-created one).
359 * @return the pointer to a freshly created or reinitialized
360 * ComputedFlexContainerInfo if our devtools have requested it;
363 ComputedFlexContainerInfo
* CreateOrClearFlexContainerInfo();
366 * Helpers for DoFlexLayout to computed fields in ComputedFlexContainerInfo.
368 static void CreateFlexLineAndFlexItemInfo(
369 ComputedFlexContainerInfo
& aContainerInfo
,
370 const nsTArray
<FlexLine
>& aLines
);
372 static void ComputeFlexDirections(ComputedFlexContainerInfo
& aContainerInfo
,
373 const FlexboxAxisTracker
& aAxisTracker
);
375 static void UpdateFlexLineAndItemInfo(
376 ComputedFlexContainerInfo
& aContainerInfo
,
377 const nsTArray
<FlexLine
>& aLines
);
380 void SanityCheckAnonymousFlexItems() const;
384 * Construct a new FlexItem for the given child frame, directly at the end of
387 * Before returning, this method also processes the FlexItem to resolve its
388 * flex basis (including e.g. auto-height) as well as to resolve
389 * "min-height:auto", via ResolveAutoFlexBasisAndMinSize(). (Basically, the
390 * constructed FlexItem will be ready to participate in the "Resolve the
391 * Flexible Lengths" step of the Flex Layout Algorithm.)
392 * https://drafts.csswg.org/css-flexbox-1/#algo-flex
394 * Note that this method **does not** update aLine's main-size bookkeeping to
395 * account for the newly-constructed flex item. The caller is responsible for
396 * determining whether this line is a good fit for the new item. If so, the
397 * caller should update aLine's bookkeeping (via
398 * FlexLine::AddLastItemToMainSizeTotals), or move the new item to a new line.
400 void GenerateFlexItemForChild(FlexLine
& aLine
, nsIFrame
* aChildFrame
,
401 const ReflowInput
& aParentReflowInput
,
402 const FlexboxAxisTracker
& aAxisTracker
,
403 const nscoord aTentativeContentBoxCrossSize
);
406 * This method looks up cached block-axis measurements for a flex item, or
407 * does a measuring reflow and caches those measurements.
409 * This avoids exponential reflows - see the comment above the
410 * CachedBAxisMeasurement struct.
412 const CachedBAxisMeasurement
& MeasureBSizeForFlexItem(
413 FlexItem
& aItem
, ReflowInput
& aChildReflowInput
);
416 * This method performs a "measuring" reflow to get the content BSize of
417 * aFlexItem.Frame() (treating it as if it had a computed BSize of "auto"),
418 * and returns the resulting BSize measurement.
419 * (Helper for ResolveAutoFlexBasisAndMinSize().)
421 nscoord
MeasureFlexItemContentBSize(FlexItem
& aFlexItem
,
422 bool aForceBResizeForMeasuringReflow
,
423 const ReflowInput
& aParentReflowInput
);
426 * This method resolves an "auto" flex-basis and/or min-main-size value
427 * on aFlexItem, if needed.
428 * (Helper for GenerateFlexItemForChild().)
430 void ResolveAutoFlexBasisAndMinSize(FlexItem
& aFlexItem
,
431 const ReflowInput
& aItemReflowInput
,
432 const FlexboxAxisTracker
& aAxisTracker
);
436 * - Creates FlexItems for all of our child frames (except placeholders).
437 * - Groups those FlexItems into FlexLines.
438 * - Returns those FlexLines in the outparam |aLines|.
440 * This corresponds to "Collect flex items into flex lines" step in the spec.
441 * https://drafts.csswg.org/css-flexbox-1/#algo-line-break
443 * For any child frames which are placeholders, this method will instead just
444 * append that child to the outparam |aPlaceholders| for separate handling.
445 * (Absolutely positioned children of a flex container are *not* flex items.)
447 void GenerateFlexLines(const ReflowInput
& aReflowInput
,
448 const nscoord aTentativeContentBoxMainSize
,
449 const nscoord aTentativeContentBoxCrossSize
,
450 const nsTArray
<StrutInfo
>& aStruts
,
451 const FlexboxAxisTracker
& aAxisTracker
,
452 nscoord aMainGapSize
,
453 nsTArray
<nsIFrame
*>& aPlaceholders
,
454 nsTArray
<FlexLine
>& aLines
, bool& aHasCollapsedItems
);
457 * Generates and returns a FlexLayoutResult that contains the FlexLines and
458 * some sizing metrics that should be used to lay out a particular flex
459 * container continuation (i.e. don't call this on the first-in-flow).
461 FlexLayoutResult
GenerateFlexLayoutResult();
464 * Resolves the content-box main-size of a flex container frame,
465 * primarily based on:
466 * - the "tentative" main size, taken from the reflow input ("tentative"
467 * because it may be unconstrained or may run off the page).
468 * - the sizes of our lines of flex items.
470 * We assume the available block-size is always *unconstrained* because this
471 * is called only in flex algorithm to measure the flex container's size
472 * without regards to pagination.
474 * Guaranteed to return a definite length, i.e. not NS_UNCONSTRAINEDSIZE,
475 * aside from cases with huge lengths which happen to compute to that value.
477 * This corresponds to "Determine the main size of the flex container" step in
478 * the spec. https://drafts.csswg.org/css-flexbox-1/#algo-main-container
480 * (Note: This function should be structurally similar to
481 * ComputeCrossSize().)
483 nscoord
ComputeMainSize(const ReflowInput
& aReflowInput
,
484 const FlexboxAxisTracker
& aAxisTracker
,
485 const nscoord aTentativeContentBoxMainSize
,
486 nsTArray
<FlexLine
>& aLines
) const;
488 nscoord
ComputeCrossSize(const ReflowInput
& aReflowInput
,
489 const FlexboxAxisTracker
& aAxisTracker
,
490 const nscoord aTentativeContentBoxCrossSize
,
491 nscoord aSumLineCrossSizes
, bool* aIsDefinite
) const;
494 * Compute the size of the available space that we'll give to our children to
495 * reflow into. In particular, compute the available size that we would give
496 * to a hypothetical child placed at the IStart/BStart corner of this flex
497 * container's content-box.
499 * @param aReflowInput the flex container's reflow input.
500 * @param aBorderPadding the border and padding of this frame with the
501 * assumption that this is the last fragment.
503 * @return the size of the available space for our children to reflow into.
505 mozilla::LogicalSize
ComputeAvailableSizeForItems(
506 const ReflowInput
& aReflowInput
,
507 const mozilla::LogicalMargin
& aBorderPadding
) const;
509 void SizeItemInCrossAxis(ReflowInput
& aChildReflowInput
, FlexItem
& aItem
);
512 * This method computes the metrics to be reported via the flex container's
513 * ReflowOutput & nsReflowStatus output parameters in Reflow().
515 * @param aContentBoxSize the final content-box size for the flex container as
516 * a whole, converted from the flex container's
517 * main/cross sizes. The main/cross sizes are computed
518 * by DoFlexLayout() if this frame is the
519 * first-in-flow, or are the stored ones in
520 * SharedFlexData if this frame is a not the
522 * @param aBorderPadding the border and padding for this frame (possibly with
523 * some sides skipped as-appropriate, if we're in a
524 * continuation chain).
525 * @param aConsumedBSize the sum of our content-box block-size consumed by our
527 * @param aMayNeedNextInFlow true if we may need a next-in-flow because our
528 * effective content-box block-size exceeds the
529 * available block-size.
530 * @param aMaxBlockEndEdgeOfChildren the maximum block-end edge of the
531 * children of this fragment in this frame's
532 * coordinate space (as returned by
534 * @param aAnyChildIncomplete true if any child being reflowed is incomplete;
535 * false otherwise (as returned by
537 * @param aFlr the result returned by DoFlexLayout.
538 * Note: aFlr is mostly an "input" parameter, but we use
539 * aFlr.mAscent as an "in/out" parameter; it's initially the
540 * "tentative" flex container ascent computed in DoFlexLayout; or
541 * nscoord_MIN if the ascent hasn't been established yet. If the
542 * latter, this will be updated with an ascent derived from the
543 * (WM-relative) startmost flex item (if there are any flex
544 * items). Similar for aFlr.mAscentForLast.
546 void PopulateReflowOutput(
547 ReflowOutput
& aReflowOutput
, const ReflowInput
& aReflowInput
,
548 nsReflowStatus
& aStatus
, const mozilla::LogicalSize
& aContentBoxSize
,
549 const mozilla::LogicalMargin
& aBorderPadding
,
550 const nscoord aConsumedBSize
, const bool aMayNeedNextInFlow
,
551 const nscoord aMaxBlockEndEdgeOfChildren
, const bool aAnyChildIncomplete
,
552 const FlexboxAxisTracker
& aAxisTracker
, FlexLayoutResult
& aFlr
);
555 * Perform a final Reflow for our child frames.
557 * @param aContainerSize this frame's tentative physical border-box size, used
558 * only for logical to physical coordinate conversion.
559 * @param aAvailableSizeForItems the size of the available space for our
560 * children to reflow into.
561 * @param aBorderPadding the border and padding for this frame (possibly with
562 * some sides skipped as-appropriate, if we're in a
563 * continuation chain).
564 * @param aSumOfPrevInFlowsChildrenBlockSize See the comment for
565 * SumOfChildrenBlockSizeProperty.
566 * @param aFlr the result returned by DoFlexLayout.
567 * @param aFragmentData See the comment for PerFragmentFlexData.
568 * Note: aFragmentData is an "in/out" parameter. It is
569 * initialized by the data stored in our prev-in-flow's
570 * PerFragmentFlexData::Prop(); its fields will then be
571 * updated and become our PerFragmentFlexData.
572 * @return nscoord the maximum block-end edge of children of this fragment in
573 * flex container's coordinate space.
574 * @return bool true if any child being reflowed is incomplete; false
577 std::tuple
<nscoord
, bool> ReflowChildren(
578 const ReflowInput
& aReflowInput
, const nsSize
& aContainerSize
,
579 const mozilla::LogicalSize
& aAvailableSizeForItems
,
580 const mozilla::LogicalMargin
& aBorderPadding
,
581 const FlexboxAxisTracker
& aAxisTracker
, FlexLayoutResult
& aFlr
,
582 PerFragmentFlexData
& aFragmentData
);
585 * Moves the given flex item's frame to the given LogicalPosition (modulo any
586 * relative positioning).
588 * This can be used in cases where we've already done a "measuring reflow"
589 * for the flex item at the correct size, and hence can skip its final reflow
590 * (but still need to move it to the right final position).
592 * @param aItem The flex item whose frame should be moved.
593 * @param aFramePos The position where the flex item's frame should
594 * be placed. (pre-relative positioning)
595 * @param aContainerSize The flex container's size (required by some methods
596 * that we call, to interpret aFramePos correctly).
598 void MoveFlexItemToFinalPosition(const FlexItem
& aItem
,
599 const mozilla::LogicalPoint
& aFramePos
,
600 const nsSize
& aContainerSize
);
602 * Helper-function to reflow a child frame, at its final position determined
605 * @param aAxisTracker A FlexboxAxisTracker with the flex container's axes.
606 * @param aReflowInput The flex container's reflow input.
607 * @param aItem The flex item to be reflowed.
608 * @param aFramePos The position where the flex item's frame should
609 * be placed. (pre-relative positioning)
610 * @param aAvailableSize The available size to reflow the child frame (in the
611 * child frame's writing-mode).
612 * @param aContainerSize The flex container's size (required by some methods
613 * that we call, to interpret aFramePos correctly).
614 * @return the child frame's reflow status.
616 nsReflowStatus
ReflowFlexItem(const FlexboxAxisTracker
& aAxisTracker
,
617 const ReflowInput
& aReflowInput
,
618 const FlexItem
& aItem
,
619 const mozilla::LogicalPoint
& aFramePos
,
620 const mozilla::LogicalSize
& aAvailableSize
,
621 const nsSize
& aContainerSize
);
624 * Helper-function to perform a "dummy reflow" on all our nsPlaceholderFrame
625 * children, at the container's content-box origin.
627 * This doesn't actually represent the static position of the placeholders'
628 * out-of-flow (OOF) frames -- we can't compute that until we've reflowed the
629 * OOF, because (depending on the CSS Align properties) the static position
630 * may be influenced by the OOF's size. So for now, we just co-opt the
631 * placeholder to store the flex container's logical content-box origin, and
632 * we defer to nsAbsoluteContainingBlock to determine the OOF's actual static
633 * position (using this origin, the OOF's size, and the CSS Align
636 * @param aReflowInput The flex container's reflow input.
637 * @param aPlaceholders An array of all the flex container's
638 * nsPlaceholderFrame children.
639 * @param aContentBoxOrigin The flex container's logical content-box
640 * origin (in its own coordinate space).
641 * @param aContainerSize The flex container's size (required by some
642 * reflow methods to interpret positions correctly).
644 void ReflowPlaceholders(const ReflowInput
& aReflowInput
,
645 nsTArray
<nsIFrame
*>& aPlaceholders
,
646 const mozilla::LogicalPoint
& aContentBoxOrigin
,
647 const nsSize
& aContainerSize
);
650 * Helper for GetMinISize / GetPrefISize.
652 nscoord
IntrinsicISize(gfxContext
* aRenderingContext
,
653 mozilla::IntrinsicISizeType aType
);
656 * Cached values to optimize GetMinISize/GetPrefISize.
658 nscoord mCachedMinISize
= NS_INTRINSIC_ISIZE_UNKNOWN
;
659 nscoord mCachedPrefISize
= NS_INTRINSIC_ISIZE_UNKNOWN
;
662 * Cached baselines computed in our last reflow to optimize
663 * GetNaturalBaselineBOffset().
665 // Note: the first baseline is a distance from our border-box block-start
667 nscoord mFirstBaseline
= NS_INTRINSIC_ISIZE_UNKNOWN
;
668 // Note: the last baseline is a distance from our border-box block-end edge.
669 nscoord mLastBaseline
= NS_INTRINSIC_ISIZE_UNKNOWN
;
672 #endif /* nsFlexContainerFrame_h___ */