|
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/. */ |
|
5 |
|
6 /* |
|
7 * base class for rendering objects that can be split across lines, |
|
8 * columns, or pages |
|
9 */ |
|
10 |
|
11 #ifndef nsSplittableFrame_h___ |
|
12 #define nsSplittableFrame_h___ |
|
13 |
|
14 #include "mozilla/Attributes.h" |
|
15 #include "nsFrame.h" |
|
16 |
|
17 // Derived class that allows splitting |
|
18 class nsSplittableFrame : public nsFrame |
|
19 { |
|
20 public: |
|
21 NS_DECL_FRAMEARENA_HELPERS |
|
22 |
|
23 virtual void Init(nsIContent* aContent, |
|
24 nsIFrame* aParent, |
|
25 nsIFrame* aPrevInFlow) MOZ_OVERRIDE; |
|
26 |
|
27 virtual nsSplittableType GetSplittableType() const MOZ_OVERRIDE; |
|
28 |
|
29 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; |
|
30 |
|
31 /* |
|
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. |
|
37 */ |
|
38 |
|
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; |
|
42 |
|
43 // Set a previous/next non-fluid continuation. |
|
44 virtual void SetPrevContinuation(nsIFrame*) MOZ_OVERRIDE; |
|
45 virtual void SetNextContinuation(nsIFrame*) MOZ_OVERRIDE; |
|
46 |
|
47 // Get the first/last continuation for this frame. |
|
48 virtual nsIFrame* FirstContinuation() const MOZ_OVERRIDE; |
|
49 virtual nsIFrame* LastContinuation() const MOZ_OVERRIDE; |
|
50 |
|
51 #ifdef DEBUG |
|
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); |
|
55 #endif |
|
56 |
|
57 // Get the previous/next continuation, only if it is fluid (an "in-flow"). |
|
58 nsIFrame* GetPrevInFlow() const; |
|
59 nsIFrame* GetNextInFlow() const; |
|
60 |
|
61 virtual nsIFrame* GetPrevInFlowVirtual() const MOZ_OVERRIDE { return GetPrevInFlow(); } |
|
62 virtual nsIFrame* GetNextInFlowVirtual() const MOZ_OVERRIDE { return GetNextInFlow(); } |
|
63 |
|
64 // Set a previous/next fluid continuation. |
|
65 virtual void SetPrevInFlow(nsIFrame*) MOZ_OVERRIDE; |
|
66 virtual void SetNextInFlow(nsIFrame*) MOZ_OVERRIDE; |
|
67 |
|
68 // Get the first/last frame in the current flow. |
|
69 virtual nsIFrame* FirstInFlow() const MOZ_OVERRIDE; |
|
70 virtual nsIFrame* LastInFlow() const MOZ_OVERRIDE; |
|
71 |
|
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); |
|
75 |
|
76 protected: |
|
77 nsSplittableFrame(nsStyleContext* aContext) : nsFrame(aContext) {} |
|
78 |
|
79 /** |
|
80 * Determine the height consumed by our previous-in-flows. |
|
81 * |
|
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. |
|
85 */ |
|
86 nscoord GetConsumedHeight() const; |
|
87 |
|
88 /** |
|
89 * Retrieve the effective computed height of this frame, which is the computed |
|
90 * height, minus the height consumed by any previous in-flows. |
|
91 */ |
|
92 nscoord GetEffectiveComputedHeight(const nsHTMLReflowState& aReflowState, |
|
93 nscoord aConsumed = NS_INTRINSICSIZE) const; |
|
94 |
|
95 /** |
|
96 * @see nsIFrame::GetLogicalSkipSides() |
|
97 * @see nsIFrame::ApplyLogicalSkipSides() |
|
98 */ |
|
99 virtual int GetLogicalSkipSides(const nsHTMLReflowState* aReflowState = nullptr) const MOZ_OVERRIDE; |
|
100 |
|
101 #ifdef DEBUG |
|
102 virtual void DumpBaseRegressionData(nsPresContext* aPresContext, FILE* out, int32_t aIndent) MOZ_OVERRIDE; |
|
103 #endif |
|
104 |
|
105 nsIFrame* mPrevContinuation; |
|
106 nsIFrame* mNextContinuation; |
|
107 }; |
|
108 |
|
109 #endif /* nsSplittableFrame_h___ */ |