ColumnSetWrapperFrame.h (3292B)
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 https://mozilla.org/MPL/2.0/. */ 6 7 // A frame for CSS multi-column layout that wraps nsColumnSetFrames and 8 // column-span frames. 9 10 #ifndef mozilla_ColumnSetWrapperFrame_h 11 #define mozilla_ColumnSetWrapperFrame_h 12 13 #include "nsBlockFrame.h" 14 15 namespace mozilla { 16 17 class PresShell; 18 19 // This class is a wrapper for nsColumnSetFrames and column-span frame. 20 // Essentially, we divide the *original* nsColumnSetFrame into multiple 21 // nsColumnSetFrames on the basis of the number and position of spanning 22 // elements. 23 // 24 // This wrapper is necessary for implementing column-span as it allows us to 25 // maintain each nsColumnSetFrame as an independent set of columns, and each 26 // column-span element then becomes just a block level element. 27 // 28 class ColumnSetWrapperFrame final : public nsBlockFrame { 29 public: 30 NS_DECL_FRAMEARENA_HELPERS(ColumnSetWrapperFrame) 31 NS_DECL_QUERYFRAME 32 33 friend nsBlockFrame* ::NS_NewColumnSetWrapperFrame( 34 mozilla::PresShell* aPresShell, ComputedStyle* aStyle, 35 nsFrameState aStateFlags); 36 37 void Init(nsIContent* aContent, nsContainerFrame* aParent, 38 nsIFrame* aPrevInFlow) override; 39 40 nsContainerFrame* GetContentInsertionFrame() override; 41 42 void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override; 43 44 #ifdef DEBUG_FRAME_DUMP 45 nsresult GetFrameName(nsAString& aResult) const override; 46 #endif 47 48 void AppendFrames(ChildListID aListID, nsFrameList&& aFrameList) override; 49 50 void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame, 51 const nsLineList::iterator* aPrevFrameLine, 52 nsFrameList&& aFrameList) override; 53 54 void RemoveFrame(DestroyContext&, ChildListID, nsIFrame*) override; 55 56 void MarkIntrinsicISizesDirty() override; 57 58 nscoord IntrinsicISize(const IntrinsicSizeInput& aInput, 59 IntrinsicISizeType aType) override; 60 61 Maybe<nscoord> GetNaturalBaselineBOffset( 62 WritingMode aWM, BaselineSharingGroup aBaselineGroup, 63 BaselineExportContext aExportContext) const override; 64 65 private: 66 explicit ColumnSetWrapperFrame(ComputedStyle* aStyle, 67 nsPresContext* aPresContext); 68 ~ColumnSetWrapperFrame() override = default; 69 70 // MinISize() and PrefISize() are helpers to implement IntrinsicISize(). 71 nscoord MinISize(const IntrinsicSizeInput& aInput); 72 nscoord PrefISize(const IntrinsicSizeInput& aInput); 73 74 #ifdef DEBUG 75 static void AssertColumnSpanWrapperSubtreeIsSane(const nsIFrame* aFrame); 76 77 // True if frame constructor has finished building this frame and all of 78 // its descendants. 79 bool mFinishedBuildingColumns = false; 80 #endif 81 82 template <typename Iterator> 83 Maybe<nscoord> GetBaselineBOffset(Iterator aStart, Iterator aEnd, 84 WritingMode aWM, 85 BaselineSharingGroup aBaselineGroup, 86 BaselineExportContext aExportContext) const; 87 }; 88 89 } // namespace mozilla 90 91 #endif // mozilla_ColumnSetWrapperFrame_h