nsGridContainerFrame.h (24664B)
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/. */ 6 7 /* rendering object for CSS "display: grid | inline-grid" */ 8 9 #ifndef nsGridContainerFrame_h___ 10 #define nsGridContainerFrame_h___ 11 12 #include "mozilla/CSSOrderAwareFrameIterator.h" 13 #include "mozilla/HashTable.h" 14 #include "mozilla/IntrinsicISizesCache.h" 15 #include "mozilla/Maybe.h" 16 #include "nsAtomHashKeys.h" 17 #include "nsContainerFrame.h" 18 #include "nsILineIterator.h" 19 20 namespace mozilla { 21 class PresShell; 22 namespace dom { 23 class Grid; 24 } 25 } // namespace mozilla 26 27 /** 28 * Factory function. 29 * @return a newly allocated nsGridContainerFrame (infallible) 30 */ 31 nsContainerFrame* NS_NewGridContainerFrame(mozilla::PresShell* aPresShell, 32 mozilla::ComputedStyle* aStyle); 33 34 namespace mozilla { 35 36 /** 37 * The number of implicit / explicit tracks and their sizes. 38 */ 39 struct ComputedGridTrackInfo { 40 ComputedGridTrackInfo( 41 uint32_t aNumLeadingImplicitTracks, uint32_t aNumExplicitTracks, 42 uint32_t aStartFragmentTrack, uint32_t aEndFragmentTrack, 43 nsTArray<nscoord>&& aPositions, nsTArray<nscoord>&& aSizes, 44 nsTArray<uint32_t>&& aStates, nsTArray<bool>&& aRemovedRepeatTracks, 45 uint32_t aRepeatFirstTrack, 46 nsTArray<nsTArray<StyleCustomIdent>>&& aResolvedLineNames, 47 bool aIsSubgrid, bool aIsMasonry) 48 : mNumLeadingImplicitTracks(aNumLeadingImplicitTracks), 49 mNumExplicitTracks(aNumExplicitTracks), 50 mStartFragmentTrack(aStartFragmentTrack), 51 mEndFragmentTrack(aEndFragmentTrack), 52 mPositions(std::move(aPositions)), 53 mSizes(std::move(aSizes)), 54 mStates(std::move(aStates)), 55 mRemovedRepeatTracks(std::move(aRemovedRepeatTracks)), 56 mResolvedLineNames(std::move(aResolvedLineNames)), 57 mRepeatFirstTrack(aRepeatFirstTrack), 58 mIsSubgrid(aIsSubgrid), 59 mIsMasonry(aIsMasonry) {} 60 uint32_t mNumLeadingImplicitTracks; 61 uint32_t mNumExplicitTracks; 62 uint32_t mStartFragmentTrack; 63 uint32_t mEndFragmentTrack; 64 nsTArray<nscoord> mPositions; 65 nsTArray<nscoord> mSizes; 66 nsTArray<uint32_t> mStates; 67 // Indicates if a track has been collapsed. This will be populated for each 68 // track in the repeat(auto-fit) and repeat(auto-fill), even if there are no 69 // collapsed tracks. 70 nsTArray<bool> mRemovedRepeatTracks; 71 // Contains lists of all line name lists, including the name lists inside 72 // repeats. When a repeat(auto) track exists, the internal track names will 73 // appear once each in this array. 74 nsTArray<nsTArray<StyleCustomIdent>> mResolvedLineNames; 75 uint32_t mRepeatFirstTrack; 76 bool mIsSubgrid; 77 bool mIsMasonry; 78 }; 79 80 struct ComputedGridLineInfo { 81 explicit ComputedGridLineInfo( 82 nsTArray<nsTArray<RefPtr<nsAtom>>>&& aNames, 83 const nsTArray<RefPtr<nsAtom>>& aNamesBefore, 84 const nsTArray<RefPtr<nsAtom>>& aNamesAfter, 85 nsTArray<RefPtr<nsAtom>>&& aNamesFollowingRepeat) 86 : mNames(std::move(aNames)), 87 mNamesBefore(aNamesBefore.Clone()), 88 mNamesAfter(aNamesAfter.Clone()), 89 mNamesFollowingRepeat(std::move(aNamesFollowingRepeat)) {} 90 nsTArray<nsTArray<RefPtr<nsAtom>>> mNames; 91 nsTArray<RefPtr<nsAtom>> mNamesBefore; 92 nsTArray<RefPtr<nsAtom>> mNamesAfter; 93 nsTArray<RefPtr<nsAtom>> mNamesFollowingRepeat; 94 }; 95 } // namespace mozilla 96 97 class nsGridContainerFrame final : public nsContainerFrame, 98 public nsILineIterator { 99 public: 100 NS_DECL_FRAMEARENA_HELPERS(nsGridContainerFrame) 101 NS_DECL_QUERYFRAME 102 using ComputedGridTrackInfo = mozilla::ComputedGridTrackInfo; 103 using ComputedGridLineInfo = mozilla::ComputedGridLineInfo; 104 using LogicalAxis = mozilla::LogicalAxis; 105 using BaselineSharingGroup = mozilla::BaselineSharingGroup; 106 using NamedArea = mozilla::StyleNamedArea; 107 108 template <typename T> 109 using PerBaseline = mozilla::EnumeratedArray<BaselineSharingGroup, T, 2>; 110 111 template <typename T> 112 using PerLogicalAxis = mozilla::EnumeratedArray<LogicalAxis, T, 2>; 113 114 // nsIFrame overrides 115 void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize, 116 const ReflowInput& aReflowInput, 117 nsReflowStatus& aStatus) override; 118 void Init(nsIContent* aContent, nsContainerFrame* aParent, 119 nsIFrame* aPrevInFlow) override; 120 void DidSetComputedStyle(ComputedStyle* aOldStyle) override; 121 122 nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput, 123 mozilla::IntrinsicISizeType aType) override; 124 125 void MarkIntrinsicISizesDirty() override; 126 127 void BuildDisplayList(nsDisplayListBuilder* aBuilder, 128 const nsDisplayListSet& aLists) override; 129 130 Maybe<nscoord> GetNaturalBaselineBOffset( 131 mozilla::WritingMode aWM, BaselineSharingGroup aBaselineGroup, 132 BaselineExportContext) const override { 133 if (StyleDisplay()->IsContainLayout() || 134 HasAnyStateBits(NS_STATE_GRID_SYNTHESIZE_BASELINE)) { 135 return Nothing{}; 136 } 137 return mozilla::Some(GetBBaseline(aBaselineGroup)); 138 } 139 140 #ifdef DEBUG_FRAME_DUMP 141 nsresult GetFrameName(nsAString& aResult) const override; 142 void ExtraContainerFrameInfo(nsACString& aTo, 143 bool aListOnlyDeterministic) const override; 144 #endif 145 146 // nsContainerFrame overrides 147 bool DrainSelfOverflowList() override; 148 void AppendFrames(ChildListID aListID, nsFrameList&& aFrameList) override; 149 void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame, 150 const nsLineList::iterator* aPrevFrameLine, 151 nsFrameList&& aFrameList) override; 152 void RemoveFrame(DestroyContext&, ChildListID, nsIFrame*) override; 153 154 #ifdef DEBUG 155 void SetInitialChildList(ChildListID aListID, 156 nsFrameList&& aChildList) override; 157 #endif 158 159 bool CanProvideLineIterator() const final { return true; } 160 nsILineIterator* GetLineIterator() final { return this; } 161 int32_t GetNumLines() const final; 162 bool IsLineIteratorFlowRTL() final; 163 mozilla::Result<LineInfo, nsresult> GetLine(int32_t aLineNumber) final; 164 int32_t FindLineContaining(const nsIFrame* aFrame, 165 int32_t aStartLine = 0) final; 166 NS_IMETHOD FindFrameAt(int32_t aLineNumber, nsPoint aPos, 167 nsIFrame** aFrameFound, bool* aPosIsBeforeFirstFrame, 168 bool* aPosIsAfterLastFrame) final; 169 NS_IMETHOD CheckLineOrder(int32_t aLine, bool* aIsReordered, 170 nsIFrame** aFirstVisual, 171 nsIFrame** aLastVisual) final; 172 173 /** 174 * Return the containing block for aChild which MUST be an abs.pos. child 175 * of a grid container and that container must have been reflowed. 176 */ 177 static const nsRect& GridItemCB(nsIFrame* aChild); 178 179 NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridItemContainingBlockRect, nsRect) 180 181 /** 182 * These properties are created by a call to 183 * nsGridContainerFrame::GetGridFrameWithComputedInfo, typically from 184 * Element::GetGridFragments. 185 */ 186 NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridColTrackInfo, ComputedGridTrackInfo) 187 const ComputedGridTrackInfo* GetComputedTemplateColumns() { 188 const ComputedGridTrackInfo* info = GetProperty(GridColTrackInfo()); 189 MOZ_ASSERT(info, "Property generation wasn't requested."); 190 return info; 191 } 192 193 NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridRowTrackInfo, ComputedGridTrackInfo) 194 const ComputedGridTrackInfo* GetComputedTemplateRows() { 195 const ComputedGridTrackInfo* info = GetProperty(GridRowTrackInfo()); 196 MOZ_ASSERT(info, "Property generation wasn't requested."); 197 return info; 198 } 199 200 NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridColumnLineInfo, ComputedGridLineInfo) 201 const ComputedGridLineInfo* GetComputedTemplateColumnLines() { 202 const ComputedGridLineInfo* info = GetProperty(GridColumnLineInfo()); 203 MOZ_ASSERT(info, "Property generation wasn't requested."); 204 return info; 205 } 206 207 NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridRowLineInfo, ComputedGridLineInfo) 208 const ComputedGridLineInfo* GetComputedTemplateRowLines() { 209 const ComputedGridLineInfo* info = GetProperty(GridRowLineInfo()); 210 MOZ_ASSERT(info, "Property generation wasn't requested."); 211 return info; 212 } 213 214 /** 215 * This property is set by the creation of a dom::Grid object, and cleared 216 * during GC unlink. Since the Grid object manages the lifecycle, the property 217 * itself is set without a destructor. The property is also cleared whenever 218 * new grid computed info is generated during reflow, ensuring that we aren't 219 * holding a stale dom::Grid object. 220 */ 221 NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(GridFragmentInfo, mozilla::dom::Grid) 222 mozilla::dom::Grid* GetGridFragmentInfo() { 223 return GetProperty(GridFragmentInfo()); 224 } 225 226 using ImplicitNamedAreas = 227 mozilla::HashMap<mozilla::AtomHashKey, NamedArea, mozilla::AtomHashKey>; 228 NS_DECLARE_FRAME_PROPERTY_DELETABLE(ImplicitNamedAreasProperty, 229 ImplicitNamedAreas) 230 ImplicitNamedAreas* GetImplicitNamedAreas() const { 231 return GetProperty(ImplicitNamedAreasProperty()); 232 } 233 234 using ExplicitNamedAreas = mozilla::StyleOwnedSlice<NamedArea>; 235 NS_DECLARE_FRAME_PROPERTY_DELETABLE(ExplicitNamedAreasProperty, 236 ExplicitNamedAreas) 237 ExplicitNamedAreas* GetExplicitNamedAreas() const { 238 return GetProperty(ExplicitNamedAreasProperty()); 239 } 240 241 using nsContainerFrame::IsMasonry; 242 243 /** 244 * Return true if this frame has masonry layout in aAxis (in this frame's own 245 * writing mode). 246 */ 247 bool IsMasonry(mozilla::LogicalAxis aAxis) const; 248 bool IsColMasonry() const { 249 return HasAnyStateBits(NS_STATE_GRID_IS_COL_MASONRY); 250 } 251 bool IsRowMasonry() const { 252 return HasAnyStateBits(NS_STATE_GRID_IS_ROW_MASONRY); 253 } 254 255 /** Return true if this frame has masonry layout in any axis. */ 256 bool IsMasonry() const { 257 return HasAnyStateBits(NS_STATE_GRID_IS_ROW_MASONRY | 258 NS_STATE_GRID_IS_COL_MASONRY); 259 } 260 261 /** Return true if this frame is subgridded in its aAxis. */ 262 bool IsSubgrid(LogicalAxis aAxis) const { 263 return HasAnyStateBits(aAxis == mozilla::LogicalAxis::Block 264 ? NS_STATE_GRID_IS_ROW_SUBGRID 265 : NS_STATE_GRID_IS_COL_SUBGRID); 266 } 267 bool IsColSubgrid() const { return IsSubgrid(mozilla::LogicalAxis::Inline); } 268 bool IsRowSubgrid() const { return IsSubgrid(mozilla::LogicalAxis::Block); } 269 /** Return true if this frame is subgridded in any axis. */ 270 bool IsSubgrid() const { 271 return HasAnyStateBits(NS_STATE_GRID_IS_ROW_SUBGRID | 272 NS_STATE_GRID_IS_COL_SUBGRID); 273 } 274 275 /** Return true if this frame has an item that is subgridded in our aAxis. */ 276 bool HasSubgridItems(LogicalAxis aAxis) const { 277 return HasAnyStateBits(aAxis == mozilla::LogicalAxis::Block 278 ? NS_STATE_GRID_HAS_ROW_SUBGRID_ITEM 279 : NS_STATE_GRID_HAS_COL_SUBGRID_ITEM); 280 } 281 /** Return true if this frame has any subgrid items. */ 282 bool HasSubgridItems() const { 283 return HasAnyStateBits(NS_STATE_GRID_HAS_ROW_SUBGRID_ITEM | 284 NS_STATE_GRID_HAS_COL_SUBGRID_ITEM); 285 } 286 /** 287 * Return true if the grid item aChild should stretch in its aAxis (i.e. aAxis 288 * is in the aChild's writing-mode). 289 * 290 * Note: this method does *not* consider the grid item's aspect-ratio and 291 * natural size in the axis when the self-alignment value is 'normal' per 292 * https://drafts.csswg.org/css-grid/#grid-item-sizing 293 */ 294 bool GridItemShouldStretch(const nsIFrame* aChild, LogicalAxis aAxis) const; 295 296 /** 297 * Returns true if aFrame forms an independent formatting context and hence 298 * should be inhibited from being a subgrid (i.e. if the used value of 299 * 'grid-template-{rows,columns}:subgrid' should be 'none'). 300 * https://drafts.csswg.org/css-grid-2/#subgrid-listing 301 * 302 * (Note this only makes sense to call if aFrame is itself either a grid 303 * container frame or a wrapper frame for a grid container frame, e.g. a 304 * scroll container frame for a scrollable grid. Having said that, this is 305 * technically safe to call on any non-null frame.) 306 */ 307 static bool ShouldInhibitSubgridDueToIFC(const nsIFrame* aFrame); 308 309 /** 310 * Return a container grid frame for the supplied frame, if available. 311 * @return nullptr if aFrame has no grid container. 312 */ 313 static nsGridContainerFrame* GetGridContainerFrame(nsIFrame* aFrame); 314 315 /** 316 * Return a container grid frame, and ensure it has computed grid info 317 * @return nullptr if aFrame has no grid container, or frame was destroyed 318 * @note this might destroy layout/style data since it may flush layout 319 */ 320 MOZ_CAN_RUN_SCRIPT_BOUNDARY 321 static nsGridContainerFrame* GetGridFrameWithComputedInfo(nsIFrame* aFrame); 322 323 /** 324 * Callback for nsIFrame::MarkIntrinsicISizesDirty() on a grid item. 325 */ 326 static void MarkCachedGridMeasurementsDirty(nsIFrame* aItemFrame); 327 328 class CachedBAxisMeasurement; 329 struct Subgrid; 330 struct UsedTrackSizes; 331 struct TrackSize; 332 struct GridItemInfo; 333 struct GridReflowInput; 334 struct FindItemInGridOrderResult { 335 // The first(last) item in (reverse) grid order. 336 const GridItemInfo* mItem; 337 // Does the above item span the first(last) track? 338 bool mIsInEdgeTrack; 339 }; 340 class TrackPlan; 341 class ItemPlan; 342 343 /** Return our parent grid container; |this| MUST be a subgrid. */ 344 nsGridContainerFrame* ParentGridContainerForSubgrid() const; 345 346 // https://drafts.csswg.org/css-sizing/#constraints 347 enum class SizingConstraint { 348 MinContent, // sizing under min-content constraint 349 MaxContent, // sizing under max-content constraint 350 NoConstraint // no constraint, used during Reflow 351 }; 352 353 protected: 354 typedef mozilla::LogicalRect LogicalRect; 355 typedef mozilla::WritingMode WritingMode; 356 struct Grid; 357 struct GridArea; 358 class LineNameMap; 359 struct LineRange; 360 struct SharedGridData; 361 struct SubgridFallbackTrackSizingFunctions; 362 struct TrackSizingFunctions; 363 struct Tracks; 364 struct TranslatedLineRange; 365 friend nsContainerFrame* NS_NewGridContainerFrame( 366 mozilla::PresShell* aPresShell, ComputedStyle* aStyle); 367 explicit nsGridContainerFrame(ComputedStyle* aStyle, 368 nsPresContext* aPresContext) 369 : nsContainerFrame(aStyle, aPresContext, kClassID) { 370 for (auto& perAxisBaseline : mBaseline) { 371 for (auto& baseline : perAxisBaseline) { 372 baseline = NS_INTRINSIC_ISIZE_UNKNOWN; 373 } 374 } 375 } 376 377 /** 378 * XXX temporary - move the ImplicitNamedAreas stuff to the style system. 379 * The implicit area names that come from x-start .. x-end lines in 380 * grid-template-columns / grid-template-rows are stored in this frame 381 * property when needed, as a ImplicitNamedAreas* value. 382 */ 383 void InitImplicitNamedAreas(const nsStylePosition* aStyle); 384 385 using LineNameList = 386 const mozilla::StyleOwnedSlice<mozilla::StyleCustomIdent>; 387 void AddImplicitNamedAreas(mozilla::Span<LineNameList>); 388 using StyleLineNameListValue = 389 const mozilla::StyleGenericLineNameListValue<mozilla::StyleInteger>; 390 void AddImplicitNamedAreas(mozilla::Span<StyleLineNameListValue>); 391 392 /** 393 * Reflow and place our children. 394 * @return the consumed size of all of this grid container's continuations 395 * so far including this frame 396 */ 397 nscoord ReflowChildren(GridReflowInput& aGridRI, 398 const LogicalRect& aContentArea, 399 const nsSize& aContainerSize, 400 ReflowOutput& aDesiredSize, nsReflowStatus& aStatus); 401 void ReflowAbsoluteChildren(GridReflowInput& aGridRI, 402 const LogicalRect& aContentArea, 403 nscoord aContentBSize, ReflowOutput& aDesiredSize, 404 nsReflowStatus& aStatus); 405 406 /** 407 * Helper to implement IntrinsicISize(). 408 */ 409 nscoord ComputeIntrinsicISize(const mozilla::IntrinsicSizeInput& aInput, 410 mozilla::IntrinsicISizeType aType); 411 412 nscoord GetBBaseline(BaselineSharingGroup aBaselineGroup) const { 413 return mBaseline[mozilla::LogicalAxis::Block][aBaselineGroup]; 414 } 415 nscoord GetIBaseline(BaselineSharingGroup aBaselineGroup) const { 416 return mBaseline[mozilla::LogicalAxis::Inline][aBaselineGroup]; 417 } 418 419 /** 420 * Calculate this grid container's baselines. 421 * @param aBaselineSet which baseline(s) to derive from a baseline-group or 422 * items; a baseline not included is synthesized from the border-box instead. 423 * @param aFragmentStartTrack is the first track in this fragment in the same 424 * axis as aMajor. Pass zero if that's not the axis we're fragmenting in. 425 * @param aFirstExcludedTrack should be the first track in the next fragment 426 * or one beyond the final track in the last fragment, in aMajor's axis. 427 * Pass the number of tracks if that's not the axis we're fragmenting in. 428 */ 429 enum BaselineSet : uint32_t { 430 eNone = 0x0, 431 eFirst = 0x1, 432 eLast = 0x2, 433 eBoth = eFirst | eLast, 434 }; 435 void CalculateBaselines(BaselineSet aBaselineSet, 436 mozilla::CSSOrderAwareFrameIterator* aIter, 437 const nsTArray<GridItemInfo>* aGridItems, 438 const Tracks& aTracks, uint32_t aFragmentStartTrack, 439 uint32_t aFirstExcludedTrack, WritingMode aWM, 440 const nsSize& aCBPhysicalSize, 441 nscoord aCBBorderPaddingStart, 442 nscoord aCBBorderPaddingStartEnd, nscoord aCBSize); 443 444 /** 445 * Synthesize a Grid container baseline for aGroup. 446 */ 447 nscoord SynthesizeBaseline(const FindItemInGridOrderResult& aGridOrderItem, 448 LogicalAxis aAxis, BaselineSharingGroup aGroup, 449 const nsSize& aCBPhysicalSize, nscoord aCBSize, 450 WritingMode aCBWM); 451 /** 452 * Find the first item in Grid Order in this fragment. 453 * https://drafts.csswg.org/css-grid/#grid-order 454 * @param aFragmentStartTrack is the first track in this fragment in the same 455 * axis as aMajor. Pass zero if that's not the axis we're fragmenting in. 456 */ 457 static FindItemInGridOrderResult FindFirstItemInGridOrder( 458 mozilla::CSSOrderAwareFrameIterator& aIter, 459 const nsTArray<GridItemInfo>& aGridItems, LineRange GridArea::* aMajor, 460 LineRange GridArea::* aMinor, uint32_t aFragmentStartTrack); 461 /** 462 * Find the last item in Grid Order in this fragment. 463 * @param aFragmentStartTrack is the first track in this fragment in the same 464 * axis as aMajor. Pass zero if that's not the axis we're fragmenting in. 465 * @param aFirstExcludedTrack should be the first track in the next fragment 466 * or one beyond the final track in the last fragment, in aMajor's axis. 467 * Pass the number of tracks if that's not the axis we're fragmenting in. 468 */ 469 static FindItemInGridOrderResult FindLastItemInGridOrder( 470 mozilla::ReverseCSSOrderAwareFrameIterator& aIter, 471 const nsTArray<GridItemInfo>& aGridItems, LineRange GridArea::* aMajor, 472 LineRange GridArea::* aMinor, uint32_t aFragmentStartTrack, 473 uint32_t aFirstExcludedTrack); 474 475 /** 476 * Update our NS_STATE_GRID_IS_COL/ROW_SUBGRID bits and related subgrid state 477 * on our entire continuation chain based on the current style. 478 * This is needed because grid-template-columns/rows style changes only 479 * trigger a reflow so we need to update this dynamically. 480 */ 481 void UpdateSubgridFrameState(); 482 483 /** 484 * Return the NS_STATE_GRID_IS_COL/ROW_SUBGRID and 485 * NS_STATE_GRID_IS_ROW/COL_MASONRY bits we ought to have. 486 */ 487 nsFrameState ComputeSelfSubgridMasonryBits() const; 488 489 private: 490 // Helpers for ReflowChildren 491 struct Fragmentainer { 492 /** 493 * The distance from the first grid container fragment's block-axis content 494 * edge to the fragmentainer end. 495 */ 496 nscoord mToFragmentainerEnd; 497 /** 498 * True if the current fragment is at the start of the fragmentainer. 499 */ 500 bool mIsTopOfPage; 501 /** 502 * Is there a Class C break opportunity at the start content edge? 503 */ 504 bool mCanBreakAtStart; 505 /** 506 * Is there a Class C break opportunity at the end content edge? 507 */ 508 bool mCanBreakAtEnd; 509 /** 510 * Is the grid container's block-size unconstrained? 511 */ 512 bool mIsAutoBSize; 513 }; 514 515 mozilla::Maybe<nsGridContainerFrame::Fragmentainer> GetNearestFragmentainer( 516 const GridReflowInput& aGridRI) const; 517 518 // @return the consumed size of all continuations so far including this frame 519 nscoord ReflowInFragmentainer(GridReflowInput& aGridRI, 520 const LogicalRect& aContentArea, 521 ReflowOutput& aDesiredSize, 522 nsReflowStatus& aStatus, 523 Fragmentainer& aFragmentainer, 524 const nsSize& aContainerSize); 525 526 // Helper for ReflowInFragmentainer 527 // @return the consumed size of all continuations so far including this frame 528 nscoord ReflowRowsInFragmentainer( 529 GridReflowInput& aGridRI, const LogicalRect& aContentArea, 530 ReflowOutput& aDesiredSize, nsReflowStatus& aStatus, 531 Fragmentainer& aFragmentainer, const nsSize& aContainerSize, 532 const nsTArray<const GridItemInfo*>& aItems, uint32_t aStartRow, 533 uint32_t aEndRow, nscoord aBSize, nscoord aAvailableSize); 534 535 // Helper for ReflowChildren / ReflowInFragmentainer 536 void ReflowInFlowChild(nsIFrame* aChild, const GridItemInfo* aGridItemInfo, 537 nsSize aContainerSize, 538 const mozilla::Maybe<nscoord>& aStretchBSize, 539 const Fragmentainer* aFragmentainer, 540 const GridReflowInput& aGridRI, 541 const LogicalRect& aContentArea, 542 ReflowOutput& aDesiredSize, nsReflowStatus& aStatus); 543 544 // Helper for Reflow. This is intended to be called *before* the first pass of 545 // CalculateTrackSizesForAxis() for the block-axis. 546 // 547 // @return The block-size that can be used to resolve row sizes in the first 548 // pass. 549 nscoord ComputeBSizeForResolvingRowSizes( 550 GridReflowInput& aGridRI, nscoord aComputedBSize, 551 const Maybe<nscoord>& aContainIntrinsicBSize) const; 552 553 // Helper for Reflow. This is intended to be called *after* the final call to 554 // CalculateTrackSizesForAxis() for the block-axis. 555 // 556 // @param aBSizeForResolvingRowSizes the definite block-size determined by 557 // ComputeBSizeForResolvingRowSizes() or after resolving row sizes in the 558 // first pass. 559 // @return The intrinsic content block-size that can be used with other 560 // logic in Reflow() to determine the content block-size. 561 nscoord ComputeIntrinsicContentBSize( 562 const GridReflowInput& aGridRI, nscoord aComputedBSize, 563 nscoord aBSizeForResolvingRowSizes, 564 const Maybe<nscoord>& aContainIntrinsicBSize) const; 565 566 /** 567 * Places and reflows items when we have masonry layout. 568 * It handles unconstrained reflow and also fragmentation when the row axis 569 * is the masonry axis. ReflowInFragmentainer handles the case when we're 570 * fragmenting and our row axis is a grid axis and it handles masonry layout 571 * in the column axis in that case. 572 * @return the intrinsic size in the masonry axis 573 */ 574 nscoord MasonryLayout(GridReflowInput& aGridRI, 575 const LogicalRect& aContentArea, 576 SizingConstraint aConstraint, 577 ReflowOutput& aDesiredSize, nsReflowStatus& aStatus, 578 Fragmentainer* aFragmentainer, 579 const nsSize& aContainerSize); 580 581 // Return the stored UsedTrackSizes, if any. 582 UsedTrackSizes* GetUsedTrackSizes() const; 583 584 // Store the given TrackSizes in aAxis on a UsedTrackSizes frame property. 585 void StoreUsedTrackSizes(LogicalAxis aAxis, const TrackPlan& aSizes); 586 587 // The internal implementation for AddImplicitNamedAreas(). 588 void AddImplicitNamedAreasInternal(LineNameList& aNameList, 589 ImplicitNamedAreas*& aAreas); 590 591 mozilla::IntrinsicISizesCache mCachedIntrinsicSizes; 592 593 // Our baselines, one per BaselineSharingGroup per axis. 594 PerLogicalAxis<PerBaseline<nscoord>> mBaseline; 595 }; 596 597 #endif /* nsGridContainerFrame_h___ */