Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / generic / nsSplittableFrame.h
blobbe1d9faaf2fdfba0afb803be068240238f3ee1be
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 /*
8 * base class for rendering objects that can be split across lines,
9 * columns, or pages
12 #ifndef nsSplittableFrame_h___
13 #define nsSplittableFrame_h___
15 #include "mozilla/Attributes.h"
16 #include "nsIFrame.h"
18 // Derived class that allows splitting
19 class nsSplittableFrame : public nsIFrame {
20 public:
21 NS_DECL_ABSTRACT_FRAME(nsSplittableFrame)
23 void Init(nsIContent* aContent, nsContainerFrame* aParent,
24 nsIFrame* aPrevInFlow) override;
26 void Destroy(DestroyContext&) override;
29 * Frame continuations can be either fluid or non-fluid.
31 * Fluid continuations ("in-flows") are the result of line breaking,
32 * column breaking, or page breaking.
34 * Non-fluid continuations can be the result of BiDi frame splitting,
35 * column-span splitting, or <col span="N"> where N > 1.
37 * A "flow" is a chain of fluid continuations.
39 * For more information, see https://wiki.mozilla.org/Gecko:Continuation_Model
42 // Get the previous/next continuation, regardless of its type (fluid or
43 // non-fluid).
44 nsIFrame* GetPrevContinuation() const final;
45 nsIFrame* GetNextContinuation() const final;
47 // Set a previous/next non-fluid continuation.
48 void SetPrevContinuation(nsIFrame*) final;
49 void SetNextContinuation(nsIFrame*) final;
51 // Get the first/last continuation for this frame.
52 nsIFrame* FirstContinuation() const override;
53 nsIFrame* LastContinuation() const final;
55 #ifdef DEBUG
56 // Can aFrame2 be reached from aFrame1 by following prev/next continuations?
57 static bool IsInPrevContinuationChain(nsIFrame* aFrame1, nsIFrame* aFrame2);
58 static bool IsInNextContinuationChain(nsIFrame* aFrame1, nsIFrame* aFrame2);
59 #endif
61 // Get the previous/next continuation, only if it is fluid (an "in-flow").
62 nsIFrame* GetPrevInFlow() const final;
63 nsIFrame* GetNextInFlow() const final;
65 // Set a previous/next fluid continuation.
66 void SetPrevInFlow(nsIFrame*) final;
67 void SetNextInFlow(nsIFrame*) final;
69 // Get the first/last frame in the current flow.
70 nsIFrame* FirstInFlow() const final;
71 nsIFrame* LastInFlow() const final;
73 // Remove the frame from the flow. Connects the frame's prev-in-flow
74 // and its next-in-flow. This should only be called in frame Destroy()
75 // methods.
76 static void RemoveFromFlow(nsIFrame* aFrame);
78 protected:
79 nsSplittableFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
80 ClassID aID)
81 : nsIFrame(aStyle, aPresContext, aID),
82 mPrevContinuation(nullptr),
83 mNextContinuation(nullptr) {}
85 /**
86 * Return the sum of the block-axis content size of our previous
87 * continuations.
89 * Classes that call this are _required_ to call this at least once for each
90 * reflow (unless you're the first continuation, in which case you can skip
91 * it, because as an optimization we don't cache it there).
93 * This guarantees that the internal cache works, by refreshing it. Calling it
94 * multiple times in the same reflow is wasteful, but not an error.
96 nscoord CalcAndCacheConsumedBSize();
98 /**
99 * Retrieve the effective computed block size of this frame, which is the
100 * computed block size, minus the block size consumed by any previous
101 * continuations.
103 nscoord GetEffectiveComputedBSize(const ReflowInput& aReflowInput,
104 nscoord aConsumed) const;
107 * @see nsIFrame::GetLogicalSkipSides()
109 LogicalSides GetLogicalSkipSides() const override {
110 return GetBlockLevelLogicalSkipSides(true);
113 LogicalSides GetBlockLevelLogicalSkipSides(bool aAfterReflow) const;
116 * A version of GetLogicalSkipSides() that is intended to be used inside
117 * Reflow before it's known if |this| frame will be COMPLETE or not.
118 * It returns a result that assumes this fragment is the last and thus
119 * should apply the block-end border/padding etc (except for "true" overflow
120 * containers which always skip block sides). You're then expected to
121 * recalculate the block-end side (as needed) when you know |this| frame's
122 * reflow status is INCOMPLETE.
123 * This method is intended for frames that break in the block axis.
125 LogicalSides PreReflowBlockLevelLogicalSkipSides() const {
126 return GetBlockLevelLogicalSkipSides(false);
129 nsIFrame* mPrevContinuation;
130 nsIFrame* mNextContinuation;
133 #endif /* nsSplittableFrame_h___ */