2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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 22:29:03 +04:00
|
|
|
|
|
|
|
/* class that a parent frame uses to reflow a block frame */
|
|
|
|
|
1998-12-01 19:13:49 +03:00
|
|
|
#ifndef nsBlockReflowContext_h___
|
|
|
|
#define nsBlockReflowContext_h___
|
|
|
|
|
2016-07-21 13:36:37 +03:00
|
|
|
#include "mozilla/ReflowOutput.h"
|
1998-12-01 19:13:49 +03:00
|
|
|
|
2020-07-15 16:44:39 +03:00
|
|
|
class nsIFrame;
|
2004-11-25 17:51:00 +03:00
|
|
|
class nsLineBox;
|
2004-08-01 03:15:21 +04:00
|
|
|
class nsPresContext;
|
2021-09-15 19:15:02 +03:00
|
|
|
class nsReflowStatus;
|
2016-07-21 13:36:36 +03:00
|
|
|
namespace mozilla {
|
2022-02-24 00:22:43 +03:00
|
|
|
class BlockReflowState;
|
2016-07-21 13:36:36 +03:00
|
|
|
} // namespace mozilla
|
1998-12-01 19:13:49 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An encapsulation of the state and algorithm for reflowing block frames.
|
|
|
|
*/
|
|
|
|
class nsBlockReflowContext {
|
2022-02-24 00:22:43 +03:00
|
|
|
using BlockReflowState = mozilla::BlockReflowState;
|
2016-07-21 13:36:35 +03:00
|
|
|
using ReflowInput = mozilla::ReflowInput;
|
2016-07-21 13:36:38 +03:00
|
|
|
using ReflowOutput = mozilla::ReflowOutput;
|
2016-07-21 13:36:34 +03:00
|
|
|
|
1998-12-01 19:13:49 +03:00
|
|
|
public:
|
2004-08-01 03:15:21 +04:00
|
|
|
nsBlockReflowContext(nsPresContext* aPresContext,
|
2017-07-25 14:02:35 +03:00
|
|
|
const ReflowInput& aParentRI);
|
2020-03-17 12:38:32 +03:00
|
|
|
~nsBlockReflowContext() = default;
|
1998-12-01 19:13:49 +03:00
|
|
|
|
2014-10-22 02:16:13 +04:00
|
|
|
void ReflowBlock(const mozilla::LogicalRect& aSpace, bool aApplyBStartMargin,
|
|
|
|
nsCollapsingMargin& aPrevMargin, nscoord aClearance,
|
|
|
|
bool aIsAdjacentWithBStart, nsLineBox* aLine,
|
|
|
|
ReflowInput& aReflowInput, nsReflowStatus& aReflowStatus,
|
2022-02-24 00:22:43 +03:00
|
|
|
BlockReflowState& aState);
|
1998-12-01 19:13:49 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
bool PlaceBlock(const ReflowInput& aReflowInput, bool aForceFit,
|
2017-09-13 10:47:51 +03:00
|
|
|
nsLineBox* aLine,
|
|
|
|
nsCollapsingMargin& aBEndMarginResult /* out */,
|
2020-11-18 03:08:12 +03:00
|
|
|
mozilla::OverflowAreas& aOverflowAreas,
|
2017-09-13 10:47:51 +03:00
|
|
|
const nsReflowStatus& aReflowStatus);
|
1998-12-01 19:13:49 +03:00
|
|
|
|
2014-06-17 18:41:35 +04:00
|
|
|
nsCollapsingMargin& GetCarriedOutBEndMargin() {
|
2014-11-17 11:49:38 +03:00
|
|
|
return mMetrics.mCarriedOutBEndMargin;
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:36:38 +03:00
|
|
|
const ReflowOutput& GetMetrics() const { return mMetrics; }
|
1999-04-01 05:37:36 +04:00
|
|
|
|
2004-11-25 17:51:00 +03:00
|
|
|
/**
|
2014-10-24 15:24:38 +04:00
|
|
|
* Computes the collapsed block-start margin (in the context's parent's
|
2019-04-11 23:27:37 +03:00
|
|
|
* writing mode) for a block whose reflow input is in aRI.
|
2014-10-24 15:24:38 +04: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 13:36:39 +03:00
|
|
|
* the block's own writing mode as found in aRI.
|
2014-06-17 18:41:35 +04: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 17:51:00 +03:00
|
|
|
*/
|
2016-07-21 13:36:39 +03:00
|
|
|
bool ComputeCollapsedBStartMargin(const ReflowInput& aRI,
|
2014-10-24 15:24:38 +04:00
|
|
|
nsCollapsingMargin* aMargin,
|
|
|
|
nsIFrame* aClearanceFrame,
|
|
|
|
bool* aMayNeedRetry,
|
|
|
|
bool* aIsEmpty = nullptr);
|
1999-04-03 22:58:32 +04:00
|
|
|
|
1998-12-01 19:13:49 +03:00
|
|
|
protected:
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* mPresContext;
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& mOuterReflowInput;
|
1998-12-01 19:13:49 +03:00
|
|
|
|
|
|
|
nsIFrame* mFrame;
|
2014-06-17 18:41:35 +04:00
|
|
|
mozilla::LogicalRect mSpace;
|
2001-12-18 01:39:59 +03:00
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
nscoord mICoord, mBCoord;
|
|
|
|
nsSize mContainerSize;
|
2014-06-17 18:41:35 +04:00
|
|
|
mozilla::WritingMode mWritingMode;
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput mMetrics;
|
2014-06-17 18:41:35 +04:00
|
|
|
nsCollapsingMargin mBStartMargin;
|
1998-12-01 19:13:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsBlockReflowContext_h___ */
|