Backed out changeset 496886cb30a5 (bug 1867152) for bc failures on browser_user_input...
[gecko.git] / layout / generic / nsFlexContainerFrame.h
blob30e440b401cc23cc1f4a802a8e66407c737c6826
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___
12 #include <tuple>
14 #include "mozilla/dom/FlexBinding.h"
15 #include "mozilla/UniquePtr.h"
16 #include "nsContainerFrame.h"
17 #include "nsILineIterator.h"
19 namespace mozilla {
20 class LogicalPoint;
21 class PresShell;
22 } // namespace mozilla
24 nsContainerFrame* NS_NewFlexContainerFrame(mozilla::PresShell* aPresShell,
25 mozilla::ComputedStyle* aStyle);
27 /**
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;
36 nsRect mFrameRect;
37 /**
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;
44 /**
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;
54 nscoord mMainMinSize;
55 nscoord mMainMaxSize;
56 nscoord mCrossMinSize;
57 nscoord mCrossMaxSize;
58 mozilla::dom::FlexItemClampState mClampState;
61 struct ComputedFlexLineInfo {
62 nsTArray<ComputedFlexItemInfo> mItems;
63 nscoord mCrossStart;
64 nscoord mCrossSize;
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;
76 /**
77 * Helper class to get the orientation of a flex container's axes.
79 class MOZ_STACK_CLASS FlexboxAxisInfo final {
80 public:
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?
87 // (e.g. RTL vs LTR)
88 bool mIsMainAxisReversed = false;
90 // Is our cross axis in the opposite direction as mWM's corresponding axis?
91 // (e.g. BTT vs TTB)
92 bool mIsCrossAxisReversed = false;
94 private:
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 {
124 public:
125 NS_DECL_FRAMEARENA_HELPERS(nsFlexContainerFrame)
126 NS_DECL_QUERYFRAME
128 // Factory method:
129 friend nsContainerFrame* NS_NewFlexContainerFrame(
130 mozilla::PresShell* aPresShell, ComputedStyle* aStyle);
132 // Forward-decls of helper classes
133 class FlexItem;
134 class FlexLine;
135 class FlexboxAxisTracker;
136 struct StrutInfo;
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 void BuildDisplayList(nsDisplayListBuilder* aBuilder,
148 const nsDisplayListSet& aLists) override;
150 void MarkIntrinsicISizesDirty() override;
152 void Reflow(nsPresContext* aPresContext, ReflowOutput& aReflowOutput,
153 const ReflowInput& aReflowInput,
154 nsReflowStatus& aStatus) override;
156 nscoord GetMinISize(gfxContext* aRenderingContext) override;
157 nscoord GetPrefISize(gfxContext* aRenderingContext) override;
159 #ifdef DEBUG_FRAME_DUMP
160 nsresult GetFrameName(nsAString& aResult) const override;
161 #endif
163 Maybe<nscoord> GetNaturalBaselineBOffset(
164 mozilla::WritingMode aWM, BaselineSharingGroup aBaselineGroup,
165 BaselineExportContext) const override;
167 // Unions the child overflow from our in-flow children.
168 void UnionInFlowChildOverflow(mozilla::OverflowAreas&);
170 // Unions the child overflow from all our children, including out of flows.
171 void UnionChildOverflow(mozilla::OverflowAreas&) final;
173 // nsContainerFrame overrides
174 bool DrainSelfOverflowList() override;
175 void AppendFrames(ChildListID aListID, nsFrameList&& aFrameList) override;
176 void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
177 const nsLineList::iterator* aPrevFrameLine,
178 nsFrameList&& aFrameList) override;
179 void RemoveFrame(DestroyContext&, ChildListID, nsIFrame*) override;
180 mozilla::StyleAlignFlags CSSAlignmentForAbsPosChild(
181 const ReflowInput& aChildRI,
182 mozilla::LogicalAxis aLogicalAxis) const override;
185 * Helper function to calculate packing space and initial offset of alignment
186 * subjects in MainAxisPositionTracker() and CrossAxisPositionTracker() for
187 * space-between, space-around, and space-evenly.
188 * * @param aNumThingsToPack Number of alignment subjects.
189 * @param aAlignVal Value for align-content or
190 * justify-content.
191 * @param aFirstSubjectOffset Outparam for first subject offset.
192 * @param aNumPackingSpacesRemaining Outparam for number of equal-sized
193 * packing spaces to apply between each
194 * alignment subject.
195 * @param aPackingSpaceRemaining Outparam for total amount of packing
196 * space to be divided up.
198 static void CalculatePackingSpace(
199 uint32_t aNumThingsToPack,
200 const mozilla::StyleContentDistribution& aAlignVal,
201 nscoord* aFirstSubjectOffset, uint32_t* aNumPackingSpacesRemaining,
202 nscoord* aPackingSpaceRemaining);
205 * This property is created by a call to
206 * nsFlexContainerFrame::GetFlexFrameWithComputedInfo.
208 NS_DECLARE_FRAME_PROPERTY_DELETABLE(FlexContainerInfo,
209 ComputedFlexContainerInfo)
211 * This function should only be called on a nsFlexContainerFrame
212 * that has just been returned by a call to
213 * GetFlexFrameWithComputedInfo.
215 const ComputedFlexContainerInfo* GetFlexContainerInfo() {
216 const ComputedFlexContainerInfo* info = GetProperty(FlexContainerInfo());
217 NS_WARNING_ASSERTION(info,
218 "Property generation wasn't requested. "
219 "This is a known issue in Print Preview. "
220 "See Bug 1157012.");
221 return info;
225 * Return aFrame as a flex frame after ensuring it has computed flex info.
226 * @return nullptr if aFrame is null or doesn't have a flex frame
227 * as its content insertion frame.
228 * @note this might destroy layout/style data since it may flush layout.
230 MOZ_CAN_RUN_SCRIPT_BOUNDARY
231 static nsFlexContainerFrame* GetFlexFrameWithComputedInfo(nsIFrame* aFrame);
234 * Given a frame for a flex item, this method returns true IFF that flex
235 * item's inline axis is the same as (i.e. not orthogonal to) its flex
236 * container's main axis.
238 * (This method is only intended to be used from external
239 * callers. Inside of flex reflow code, FlexItem::IsInlineAxisMainAxis() is
240 * equivalent & more optimal.)
242 * @param aFrame a flex item (must return true from IsFlexItem)
243 * @return true iff aFrame's inline axis is the same as (i.e. not orthogonal
244 * to) its flex container's main axis. Otherwise, false.
246 static bool IsItemInlineAxisMainAxis(nsIFrame* aFrame);
249 * Returns true iff the given computed 'flex-basis' & main-size property
250 * values collectively represent a used flex-basis of 'content'.
251 * See https://drafts.csswg.org/css-flexbox-1/#valdef-flex-basis-auto
253 * @param aFlexBasis the computed 'flex-basis' for a flex item.
254 * @param aMainSize the computed main-size property for a flex item.
256 static bool IsUsedFlexBasisContent(const mozilla::StyleFlexBasis& aFlexBasis,
257 const mozilla::StyleSize& aMainSize);
260 * Callback for nsIFrame::MarkIntrinsicISizesDirty() on a flex item.
262 static void MarkCachedFlexMeasurementsDirty(nsIFrame* aItemFrame);
264 bool CanProvideLineIterator() const final { return true; }
265 nsILineIterator* GetLineIterator() final { return this; }
266 int32_t GetNumLines() const final;
267 bool IsLineIteratorFlowRTL() final;
268 mozilla::Result<LineInfo, nsresult> GetLine(int32_t aLineNumber) final;
269 int32_t FindLineContaining(nsIFrame* aFrame, int32_t aStartLine = 0) final;
270 NS_IMETHOD FindFrameAt(int32_t aLineNumber, nsPoint aPos,
271 nsIFrame** aFrameFound, bool* aPosIsBeforeFirstFrame,
272 bool* aPosIsAfterLastFrame) final;
273 NS_IMETHOD CheckLineOrder(int32_t aLine, bool* aIsReordered,
274 nsIFrame** aFirstVisual,
275 nsIFrame** aLastVisual) final;
277 protected:
278 // Protected constructor & destructor
279 explicit nsFlexContainerFrame(ComputedStyle* aStyle,
280 nsPresContext* aPresContext)
281 : nsContainerFrame(aStyle, aPresContext, kClassID) {}
283 virtual ~nsFlexContainerFrame();
285 // Protected flex-container-specific methods / member-vars
288 * This method does the bulk of the flex layout, implementing the algorithm
289 * described at: https://drafts.csswg.org/css-flexbox-1/#layout-algorithm
290 * (with a few initialization pieces happening in the caller, Reflow().
292 * (The logic behind the division of work between Reflow and DoFlexLayout is
293 * as follows: DoFlexLayout() begins at the step that we have to jump back
294 * to, if we find any visibility:collapse children, and Reflow() does
295 * everything before that point.)
297 * @param aTentativeContentBoxMainSize the "tentative" content-box main-size
298 * of the flex container; "tentative"
299 * because it may be unconstrained or may
300 * run off the page.
301 * @param aTentativeContentBoxCrossSize the "tentative" content-box cross-size
302 * of the flex container; "tentative"
303 * because it may be unconstrained or may
304 * run off the page.
306 struct FlexLayoutResult final {
307 // The flex lines of the flex container.
308 nsTArray<FlexLine> mLines;
310 // The absolutely-positioned flex children.
311 nsTArray<nsIFrame*> mPlaceholders;
313 bool mHasCollapsedItems = false;
315 // The final content-box main-size of the flex container as if there's no
316 // fragmentation.
317 nscoord mContentBoxMainSize = NS_UNCONSTRAINEDSIZE;
319 // The final content-box cross-size of the flex container as if there's no
320 // fragmentation.
321 nscoord mContentBoxCrossSize = NS_UNCONSTRAINEDSIZE;
323 // The flex container's ascent for the "first baseline" alignment, derived
324 // from any baseline-aligned flex items in the startmost (from the
325 // perspective of the flex container's WM) flex line, if any such items
326 // exist. Otherwise, nscoord_MIN.
328 // Note: this is a distance from the border-box block-start edge.
329 nscoord mAscent = NS_UNCONSTRAINEDSIZE;
331 // The flex container's ascent for the "last baseline" alignment, derived
332 // from any baseline-aligned flex items in the endmost (from the perspective
333 // of the flex container's WM) flex line, if any such items exist.
334 // Otherwise, nscoord_MIN.
336 // Note: this is a distance from the border-box block-end edge. It's
337 // different from the identically-named-member FlexItem::mAscentForLast,
338 // which is a distance from the item frame's border-box block-start edge.
339 nscoord mAscentForLast = NS_UNCONSTRAINEDSIZE;
341 FlexLayoutResult DoFlexLayout(
342 const ReflowInput& aReflowInput,
343 const nscoord aTentativeContentBoxMainSize,
344 const nscoord aTentativeContentBoxCrossSize,
345 const FlexboxAxisTracker& aAxisTracker, nscoord aMainGapSize,
346 nscoord aCrossGapSize, nsTArray<StrutInfo>& aStruts,
347 ComputedFlexContainerInfo* const aContainerInfo);
350 * If our devtools have requested a ComputedFlexContainerInfo for this flex
351 * container, this method ensures that we have one (and if one already exists,
352 * this method reinitializes it to look like a freshly-created one).
354 * @return the pointer to a freshly created or reinitialized
355 * ComputedFlexContainerInfo if our devtools have requested it;
356 * otherwise nullptr.
358 ComputedFlexContainerInfo* CreateOrClearFlexContainerInfo();
361 * Helpers for DoFlexLayout to computed fields in ComputedFlexContainerInfo.
363 static void CreateFlexLineAndFlexItemInfo(
364 ComputedFlexContainerInfo& aContainerInfo,
365 const nsTArray<FlexLine>& aLines);
367 static void ComputeFlexDirections(ComputedFlexContainerInfo& aContainerInfo,
368 const FlexboxAxisTracker& aAxisTracker);
370 static void UpdateFlexLineAndItemInfo(
371 ComputedFlexContainerInfo& aContainerInfo,
372 const nsTArray<FlexLine>& aLines);
375 * Helper to query flex item's consumed block-size.
377 static nscoord FlexItemConsumedBSize(const FlexItem& aItem);
379 #ifdef DEBUG
380 void SanityCheckAnonymousFlexItems() const;
381 #endif // DEBUG
384 * Construct a new FlexItem for the given child frame, directly at the end of
385 * aLine.
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);
435 * This method:
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
521 * first-in-flow.
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
526 * prev-in-flows.
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
533 * ReflowChildren()).
534 * @param aChildrenStatus the reflow status of children (as returned by
535 * ReflowChildren()).
536 * @param aFlr the result returned by DoFlexLayout.
537 * Note: aFlr is mostly an "input" parameter, but we use
538 * aFlr.mAscent as an "in/out" parameter; it's initially the
539 * "tentative" flex container ascent computed in DoFlexLayout; or
540 * nscoord_MIN if the ascent hasn't been established yet. If the
541 * latter, this will be updated with an ascent derived from the
542 * (WM-relative) startmost flex item (if there are any flex
543 * items). Similar for aFlr.mAscentForLast.
545 void PopulateReflowOutput(
546 ReflowOutput& aReflowOutput, const ReflowInput& aReflowInput,
547 nsReflowStatus& aStatus, const mozilla::LogicalSize& aContentBoxSize,
548 const mozilla::LogicalMargin& aBorderPadding,
549 const nscoord aConsumedBSize, const bool aMayNeedNextInFlow,
550 const nscoord aMaxBlockEndEdgeOfChildren,
551 const nsReflowStatus& aChildrenStatus,
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 nsReflowStatus the reflow status of children (i.e. flex items). If
575 * any child had an incomplete reflow status, then this
576 * will be Incomplete. Otherwise, if any child had an
577 * overflow-incomplete reflow status, this will be
578 * OverflowIncomplete.
580 std::tuple<nscoord, nsReflowStatus> ReflowChildren(
581 const ReflowInput& aReflowInput, const nsSize& aContainerSize,
582 const mozilla::LogicalSize& aAvailableSizeForItems,
583 const mozilla::LogicalMargin& aBorderPadding,
584 const FlexboxAxisTracker& aAxisTracker, FlexLayoutResult& aFlr,
585 PerFragmentFlexData& aFragmentData);
588 * Moves the given flex item's frame to the given LogicalPosition (modulo any
589 * relative positioning).
591 * This can be used in cases where we've already done a "measuring reflow"
592 * for the flex item at the correct size, and hence can skip its final reflow
593 * (but still need to move it to the right final position).
595 * @param aItem The flex item whose frame should be moved.
596 * @param aFramePos The position where the flex item's frame should
597 * be placed. (pre-relative positioning)
598 * @param aContainerSize The flex container's size (required by some methods
599 * that we call, to interpret aFramePos correctly).
601 void MoveFlexItemToFinalPosition(const FlexItem& aItem,
602 const mozilla::LogicalPoint& aFramePos,
603 const nsSize& aContainerSize);
605 * Helper-function to reflow a child frame, at its final position determined
606 * by flex layout.
608 * @param aAxisTracker A FlexboxAxisTracker with the flex container's axes.
609 * @param aReflowInput The flex container's reflow input.
610 * @param aItem The flex item to be reflowed.
611 * @param aFramePos The position where the flex item's frame should
612 * be placed. (pre-relative positioning)
613 * @param aAvailableSize The available size to reflow the child frame (in the
614 * child frame's writing-mode).
615 * @param aContainerSize The flex container's size (required by some methods
616 * that we call, to interpret aFramePos correctly).
617 * @return the child frame's reflow status.
619 nsReflowStatus ReflowFlexItem(const FlexboxAxisTracker& aAxisTracker,
620 const ReflowInput& aReflowInput,
621 const FlexItem& aItem,
622 const mozilla::LogicalPoint& aFramePos,
623 const mozilla::LogicalSize& aAvailableSize,
624 const nsSize& aContainerSize);
627 * Helper-function to perform a "dummy reflow" on all our nsPlaceholderFrame
628 * children, at the container's content-box origin.
630 * This doesn't actually represent the static position of the placeholders'
631 * out-of-flow (OOF) frames -- we can't compute that until we've reflowed the
632 * OOF, because (depending on the CSS Align properties) the static position
633 * may be influenced by the OOF's size. So for now, we just co-opt the
634 * placeholder to store the flex container's logical content-box origin, and
635 * we defer to nsAbsoluteContainingBlock to determine the OOF's actual static
636 * position (using this origin, the OOF's size, and the CSS Align
637 * properties).
639 * @param aReflowInput The flex container's reflow input.
640 * @param aPlaceholders An array of all the flex container's
641 * nsPlaceholderFrame children.
642 * @param aContentBoxOrigin The flex container's logical content-box
643 * origin (in its own coordinate space).
644 * @param aContainerSize The flex container's size (required by some
645 * reflow methods to interpret positions correctly).
647 void ReflowPlaceholders(const ReflowInput& aReflowInput,
648 nsTArray<nsIFrame*>& aPlaceholders,
649 const mozilla::LogicalPoint& aContentBoxOrigin,
650 const nsSize& aContainerSize);
653 * Helper for GetMinISize / GetPrefISize.
655 nscoord IntrinsicISize(gfxContext* aRenderingContext,
656 mozilla::IntrinsicISizeType aType);
659 * Cached values to optimize GetMinISize/GetPrefISize.
661 nscoord mCachedMinISize = NS_INTRINSIC_ISIZE_UNKNOWN;
662 nscoord mCachedPrefISize = NS_INTRINSIC_ISIZE_UNKNOWN;
665 * Cached baselines computed in our last reflow to optimize
666 * GetNaturalBaselineBOffset().
668 // Note: the first baseline is a distance from our border-box block-start
669 // edge.
670 nscoord mFirstBaseline = NS_INTRINSIC_ISIZE_UNKNOWN;
671 // Note: the last baseline is a distance from our border-box block-end edge.
672 nscoord mLastBaseline = NS_INTRINSIC_ISIZE_UNKNOWN;
675 #endif /* nsFlexContainerFrame_h___ */