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/. */
8 * base class for rendering objects that can be split across lines,
12 #ifndef nsSplittableFrame_h___
13 #define nsSplittableFrame_h___
15 #include "mozilla/Attributes.h"
18 // Derived class that allows splitting
19 class nsSplittableFrame
: public nsIFrame
{
21 NS_DECL_ABSTRACT_FRAME(nsSplittableFrame
)
22 NS_DECL_QUERYFRAME_TARGET(nsSplittableFrame
)
25 void Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
26 nsIFrame
* aPrevInFlow
) override
;
28 void Destroy(DestroyContext
&) override
;
31 * Frame continuations can be either fluid or non-fluid.
33 * Fluid continuations ("in-flows") are the result of line breaking,
34 * column breaking, or page breaking.
36 * Non-fluid continuations can be the result of BiDi frame splitting,
37 * column-span splitting, or <col span="N"> where N > 1.
39 * A "flow" is a chain of fluid continuations.
41 * For more information, see https://wiki.mozilla.org/Gecko:Continuation_Model
44 // Get the previous/next continuation, regardless of its type (fluid or
46 nsIFrame
* GetPrevContinuation() const final
;
47 nsIFrame
* GetNextContinuation() const final
;
49 // Set a previous/next non-fluid continuation.
50 void SetPrevContinuation(nsIFrame
*) final
;
51 void SetNextContinuation(nsIFrame
*) final
;
53 // Get the first/last continuation for this frame.
54 nsIFrame
* FirstContinuation() const override
;
55 nsIFrame
* LastContinuation() const final
;
58 // Can aFrame2 be reached from aFrame1 by following prev/next continuations?
59 static bool IsInPrevContinuationChain(nsIFrame
* aFrame1
, nsIFrame
* aFrame2
);
60 static bool IsInNextContinuationChain(nsIFrame
* aFrame1
, nsIFrame
* aFrame2
);
63 // Get the previous/next continuation, only if it is fluid (an "in-flow").
64 nsIFrame
* GetPrevInFlow() const final
;
65 nsIFrame
* GetNextInFlow() const final
;
67 // Set a previous/next fluid continuation.
68 void SetPrevInFlow(nsIFrame
*) final
;
69 void SetNextInFlow(nsIFrame
*) final
;
71 // Get the first/last frame in the current flow.
72 nsIFrame
* FirstInFlow() const final
;
73 nsIFrame
* LastInFlow() const final
;
75 // Remove the frame from the flow. Connects the frame's prev-in-flow
76 // and its next-in-flow. This should only be called in frame Destroy()
78 static void RemoveFromFlow(nsIFrame
* aFrame
);
81 nsSplittableFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
,
83 : nsIFrame(aStyle
, aPresContext
, aID
) {}
86 * Return the sum of the block-axis content size of our previous
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();
99 * This static wrapper over CalcAndCacheConsumedBSize() is intended for a
100 * specific scenario where an nsSplittableFrame's subclass needs to access
101 * another subclass' consumed block-size. For ordinary use cases,
102 * CalcAndCacheConsumedBSize() should be called.
104 * This has the same requirements as CalcAndCacheConsumedBSize(). In
105 * particular, classes that call this are _required_ to call this at least
106 * once for each reflow.
108 static nscoord
ConsumedBSize(nsSplittableFrame
* aFrame
) {
109 return aFrame
->CalcAndCacheConsumedBSize();
113 * Retrieve the effective computed block size of this frame, which is the
114 * computed block size, minus the block size consumed by any previous
117 nscoord
GetEffectiveComputedBSize(const ReflowInput
& aReflowInput
,
118 nscoord aConsumed
) const;
121 * @see nsIFrame::GetLogicalSkipSides()
123 LogicalSides
GetLogicalSkipSides() const override
{
124 return GetBlockLevelLogicalSkipSides(true);
127 LogicalSides
GetBlockLevelLogicalSkipSides(bool aAfterReflow
) const;
130 * A version of GetLogicalSkipSides() that is intended to be used inside
131 * Reflow before it's known if |this| frame will be COMPLETE or not.
132 * It returns a result that assumes this fragment is the last and thus
133 * should apply the block-end border/padding etc (except for "true" overflow
134 * containers which always skip block sides). You're then expected to
135 * recalculate the block-end side (as needed) when you know |this| frame's
136 * reflow status is INCOMPLETE.
137 * This method is intended for frames that break in the block axis.
139 LogicalSides
PreReflowBlockLevelLogicalSkipSides() const {
140 return GetBlockLevelLogicalSkipSides(false);
143 nsIFrame
* mPrevContinuation
= nullptr;
144 nsIFrame
* mNextContinuation
= nullptr;
147 #endif /* nsSplittableFrame_h___ */