2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2001-10-25 01:08:40 +00:00
|
|
|
// vim:cindent:ts=2:et:sw=2:
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-03-29 18:29:03 +00:00
|
|
|
|
|
|
|
/* class that a parent frame uses to reflow a block frame */
|
|
|
|
|
1998-12-01 16:13:49 +00:00
|
|
|
#ifndef nsBlockReflowContext_h___
|
|
|
|
#define nsBlockReflowContext_h___
|
|
|
|
|
1999-10-30 02:52:11 +00:00
|
|
|
#include "nsIFrame.h"
|
2016-07-21 10:36:37 +00:00
|
|
|
#include "mozilla/ReflowOutput.h"
|
1998-12-01 16:13:49 +00:00
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
class nsLineBox;
|
2004-07-31 23:15:21 +00:00
|
|
|
class nsPresContext;
|
2016-07-21 10:36:36 +00:00
|
|
|
namespace mozilla {
|
2016-07-21 10:36:36 +00:00
|
|
|
class BlockReflowInput;
|
2016-07-21 10:36:36 +00:00
|
|
|
} // namespace mozilla
|
1998-12-01 16:13:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An encapsulation of the state and algorithm for reflowing block frames.
|
|
|
|
*/
|
|
|
|
class nsBlockReflowContext {
|
2016-07-21 10:36:36 +00:00
|
|
|
using BlockReflowInput = mozilla::BlockReflowInput;
|
2016-07-21 10:36:35 +00:00
|
|
|
using ReflowInput = mozilla::ReflowInput;
|
2016-07-21 10:36:38 +00:00
|
|
|
using ReflowOutput = mozilla::ReflowOutput;
|
2016-07-21 10:36:34 +00:00
|
|
|
|
1998-12-01 16:13:49 +00:00
|
|
|
public:
|
2004-07-31 23:15:21 +00:00
|
|
|
nsBlockReflowContext(nsPresContext* aPresContext,
|
2016-07-21 10:36:35 +00:00
|
|
|
const ReflowInput& aParentRS);
|
1998-12-01 16:13:49 +00:00
|
|
|
~nsBlockReflowContext() { }
|
|
|
|
|
2014-10-21 22:16:13 +00:00
|
|
|
void ReflowBlock(const mozilla::LogicalRect& aSpace,
|
|
|
|
bool aApplyBStartMargin,
|
|
|
|
nsCollapsingMargin& aPrevMargin,
|
|
|
|
nscoord aClearance,
|
|
|
|
bool aIsAdjacentWithBStart,
|
|
|
|
nsLineBox* aLine,
|
2016-07-21 10:36:39 +00:00
|
|
|
ReflowInput& aReflowInput,
|
2014-10-21 22:16:13 +00:00
|
|
|
nsReflowStatus& aReflowStatus,
|
2016-07-21 10:36:36 +00:00
|
|
|
BlockReflowInput& aState);
|
1998-12-01 16:13:49 +00:00
|
|
|
|
2016-07-21 10:36:39 +00:00
|
|
|
bool PlaceBlock(const ReflowInput& aReflowInput,
|
2014-04-16 08:03:28 +00:00
|
|
|
bool aForceFit,
|
|
|
|
nsLineBox* aLine,
|
2014-06-17 14:41:35 +00:00
|
|
|
nsCollapsingMargin& aBEndMarginResult /* out */,
|
2014-04-16 08:03:28 +00:00
|
|
|
nsOverflowAreas& aOverflowAreas,
|
2014-06-17 14:41:35 +00:00
|
|
|
nsReflowStatus aReflowStatus);
|
1998-12-01 16:13:49 +00:00
|
|
|
|
2014-06-17 14:41:35 +00:00
|
|
|
nsCollapsingMargin& GetCarriedOutBEndMargin() {
|
2014-11-17 08:49:38 +00:00
|
|
|
return mMetrics.mCarriedOutBEndMargin;
|
1998-12-01 16:13:49 +00:00
|
|
|
}
|
|
|
|
|
2016-07-21 10:36:38 +00:00
|
|
|
const ReflowOutput& GetMetrics() const {
|
1999-04-01 01:37:36 +00:00
|
|
|
return mMetrics;
|
|
|
|
}
|
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
/**
|
2014-10-24 11:24:38 +00:00
|
|
|
* Computes the collapsed block-start margin (in the context's parent's
|
2016-07-21 10:36:39 +00:00
|
|
|
* writing mode) for a block whose reflow state is in aRI.
|
2014-10-24 11:24:38 +00:00
|
|
|
* The computed margin is added into aMargin, whose writing mode is the
|
|
|
|
* parent's mode as found in mMetrics.GetWritingMode(); note this may not be
|
2016-07-21 10:36:39 +00:00
|
|
|
* the block's own writing mode as found in aRI.
|
2014-06-17 14:41:35 +00:00
|
|
|
* If aClearanceFrame is null then this is the first optimistic pass which
|
|
|
|
* shall assume that no frames have clearance, and we clear the HasClearance
|
|
|
|
* on all frames encountered.
|
|
|
|
* If non-null, this is the second pass and the caller has decided
|
|
|
|
* aClearanceFrame needs clearance (and we will therefore stop collapsing
|
|
|
|
* there); also, this function is responsible for marking it with
|
|
|
|
* SetHasClearance.
|
|
|
|
* If in the optimistic pass any frame is encountered that might possibly
|
|
|
|
* need clearance (i.e., if we really needed the optimism assumption) then
|
|
|
|
* we set aMayNeedRetry to true.
|
|
|
|
* We return true if we changed the clearance state of any line and marked it
|
|
|
|
* dirty.
|
2004-11-25 14:51:00 +00:00
|
|
|
*/
|
2016-07-21 10:36:39 +00:00
|
|
|
bool ComputeCollapsedBStartMargin(const ReflowInput& aRI,
|
2014-10-24 11:24:38 +00:00
|
|
|
nsCollapsingMargin* aMargin,
|
|
|
|
nsIFrame* aClearanceFrame,
|
|
|
|
bool* aMayNeedRetry,
|
|
|
|
bool* aIsEmpty = nullptr);
|
1999-04-03 18:58:32 +00:00
|
|
|
|
1998-12-01 16:13:49 +00:00
|
|
|
protected:
|
2004-07-31 23:15:21 +00:00
|
|
|
nsPresContext* mPresContext;
|
2016-07-21 10:36:39 +00:00
|
|
|
const ReflowInput& mOuterReflowInput;
|
1998-12-01 16:13:49 +00:00
|
|
|
|
|
|
|
nsIFrame* mFrame;
|
2014-06-17 14:41:35 +00:00
|
|
|
mozilla::LogicalRect mSpace;
|
2001-12-17 22:39:59 +00:00
|
|
|
|
2015-07-16 09:07:57 +00:00
|
|
|
nscoord mICoord, mBCoord;
|
|
|
|
nsSize mContainerSize;
|
2014-06-17 14:41:35 +00:00
|
|
|
mozilla::WritingMode mWritingMode;
|
2016-07-21 10:36:38 +00:00
|
|
|
ReflowOutput mMetrics;
|
2014-06-17 14:41:35 +00:00
|
|
|
nsCollapsingMargin mBStartMargin;
|
1998-12-01 16:13:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsBlockReflowContext_h___ */
|