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