1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 * base class for rendering objects that can be split across lines,
11 #ifndef nsSplittableFrame_h___
12 #define nsSplittableFrame_h___
14 #include "mozilla/Attributes.h"
17 // Derived class that allows splitting
18 class nsSplittableFrame
: public nsFrame
21 NS_DECL_FRAMEARENA_HELPERS
23 virtual void Init(nsIContent
* aContent
,
24 nsContainerFrame
* aParent
,
25 nsIFrame
* aPrevInFlow
) MOZ_OVERRIDE
;
27 virtual nsSplittableType
GetSplittableType() const MOZ_OVERRIDE
;
29 virtual void DestroyFrom(nsIFrame
* aDestructRoot
) MOZ_OVERRIDE
;
32 * Frame continuations can be either fluid or not:
33 * Fluid continuations ("in-flows") are the result of line breaking,
34 * column breaking, or page breaking.
35 * Other (non-fluid) continuations can be the result of BiDi frame splitting.
36 * A "flow" is a chain of fluid continuations.
39 // Get the previous/next continuation, regardless of its type (fluid or non-fluid).
40 virtual nsIFrame
* GetPrevContinuation() const MOZ_OVERRIDE
;
41 virtual nsIFrame
* GetNextContinuation() const MOZ_OVERRIDE
;
43 // Set a previous/next non-fluid continuation.
44 virtual void SetPrevContinuation(nsIFrame
*) MOZ_OVERRIDE
;
45 virtual void SetNextContinuation(nsIFrame
*) MOZ_OVERRIDE
;
47 // Get the first/last continuation for this frame.
48 virtual nsIFrame
* FirstContinuation() const MOZ_OVERRIDE
;
49 virtual nsIFrame
* LastContinuation() const MOZ_OVERRIDE
;
52 // Can aFrame2 be reached from aFrame1 by following prev/next continuations?
53 static bool IsInPrevContinuationChain(nsIFrame
* aFrame1
, nsIFrame
* aFrame2
);
54 static bool IsInNextContinuationChain(nsIFrame
* aFrame1
, nsIFrame
* aFrame2
);
57 // Get the previous/next continuation, only if it is fluid (an "in-flow").
58 nsIFrame
* GetPrevInFlow() const;
59 nsIFrame
* GetNextInFlow() const;
61 virtual nsIFrame
* GetPrevInFlowVirtual() const MOZ_OVERRIDE
{ return GetPrevInFlow(); }
62 virtual nsIFrame
* GetNextInFlowVirtual() const MOZ_OVERRIDE
{ return GetNextInFlow(); }
64 // Set a previous/next fluid continuation.
65 virtual void SetPrevInFlow(nsIFrame
*) MOZ_OVERRIDE
;
66 virtual void SetNextInFlow(nsIFrame
*) MOZ_OVERRIDE
;
68 // Get the first/last frame in the current flow.
69 virtual nsIFrame
* FirstInFlow() const MOZ_OVERRIDE
;
70 virtual nsIFrame
* LastInFlow() const MOZ_OVERRIDE
;
72 // Remove the frame from the flow. Connects the frame's prev-in-flow
73 // and its next-in-flow. This should only be called in frame Destroy() methods.
74 static void RemoveFromFlow(nsIFrame
* aFrame
);
77 explicit nsSplittableFrame(nsStyleContext
* aContext
) : nsFrame(aContext
) {}
80 * Determine the height consumed by our previous-in-flows.
82 * @note (bz) This makes laying out a splittable frame with N in-flows
83 * O(N^2)! So, use this function with caution and minimize the number
84 * of calls to this method.
86 nscoord
GetConsumedBSize() const;
89 * Retrieve the effective computed block size of this frame, which is the
90 * computed block size, minus the block size consumed by any previous in-flows.
92 nscoord
GetEffectiveComputedBSize(const nsHTMLReflowState
& aReflowState
,
93 nscoord aConsumed
= NS_INTRINSICSIZE
) const;
96 * @see nsIFrame::GetLogicalSkipSides()
98 virtual LogicalSides
GetLogicalSkipSides(const nsHTMLReflowState
* aReflowState
= nullptr) const MOZ_OVERRIDE
;
101 virtual void DumpBaseRegressionData(nsPresContext
* aPresContext
, FILE* out
, int32_t aIndent
) MOZ_OVERRIDE
;
104 nsIFrame
* mPrevContinuation
;
105 nsIFrame
* mNextContinuation
;
108 #endif /* nsSplittableFrame_h___ */