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(ChildListID aListID, nsIFrame* aOldFrame) override;
55 
56   void MarkIntrinsicISizesDirty() override;
57 
58   nscoord GetMinISize(gfxContext* aRenderingContext) override;
59 
60   nscoord GetPrefISize(gfxContext* aRenderingContext) override;
61 
62  private:
63   explicit ColumnSetWrapperFrame(ComputedStyle* aStyle,
64                                  nsPresContext* aPresContext);
65   ~ColumnSetWrapperFrame() override = default;
66 
67 #ifdef DEBUG
68   static void AssertColumnSpanWrapperSubtreeIsSane(const nsIFrame* aFrame);
69 
70   // True if frame constructor has finished building this frame and all of
71   // its descendants.
72   bool mFinishedBuildingColumns = false;
73 #endif
74 };
75 
76 }  // namespace mozilla
77 
78 #endif  // mozilla_ColumnSetWrapperFrame_h
79