2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2001-10-25 05:08:40 +04:00
|
|
|
// vim:cindent:ts=2:et:sw=2:
|
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
|
|
|
#include "nsBlockReflowContext.h"
|
2016-07-21 13:36:36 +03:00
|
|
|
#include "BlockReflowInput.h"
|
2009-01-05 03:39:54 +03:00
|
|
|
#include "nsFloatManager.h"
|
2014-08-25 06:25:00 +04:00
|
|
|
#include "nsColumnSetFrame.h"
|
2011-12-28 00:18:48 +04:00
|
|
|
#include "nsContainerFrame.h"
|
1999-03-27 04:22:45 +03:00
|
|
|
#include "nsBlockFrame.h"
|
2002-11-28 22:29:28 +03:00
|
|
|
#include "nsLineBox.h"
|
2004-11-25 17:51:00 +03:00
|
|
|
#include "nsLayoutUtils.h"
|
1998-12-01 19:13:49 +03:00
|
|
|
|
2014-06-17 18:41:35 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2012-06-25 23:59:42 +04:00
|
|
|
#ifdef DEBUG
|
1999-03-20 22:38:50 +03:00
|
|
|
#undef NOISY_MAX_ELEMENT_SIZE
|
1999-03-24 18:42:38 +03:00
|
|
|
#undef REALLY_NOISY_MAX_ELEMENT_SIZE
|
2014-06-17 18:41:35 +04:00
|
|
|
#undef NOISY_BLOCK_DIR_MARGINS
|
1999-02-12 20:45:58 +03:00
|
|
|
#else
|
1999-03-20 22:38:50 +03:00
|
|
|
#undef NOISY_MAX_ELEMENT_SIZE
|
1999-03-24 18:42:38 +03:00
|
|
|
#undef REALLY_NOISY_MAX_ELEMENT_SIZE
|
2014-06-17 18:41:35 +04:00
|
|
|
#undef NOISY_BLOCK_DIR_MARGINS
|
1999-02-12 20:45:58 +03:00
|
|
|
#endif
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsBlockReflowContext::nsBlockReflowContext(nsPresContext* aPresContext,
|
2016-07-21 13:36:35 +03:00
|
|
|
const ReflowInput& aParentRS)
|
1998-12-01 19:13:49 +03:00
|
|
|
: mPresContext(aPresContext),
|
2016-07-21 13:36:39 +03:00
|
|
|
mOuterReflowInput(aParentRS),
|
2014-06-17 18:41:35 +04:00
|
|
|
mSpace(aParentRS.GetWritingMode()),
|
|
|
|
mMetrics(aParentRS)
|
1998-12-01 19:13:49 +03:00
|
|
|
{
|
1999-03-27 04:22:45 +03:00
|
|
|
}
|
|
|
|
|
2005-08-03 00:05:52 +04:00
|
|
|
static nsIFrame* DescendIntoBlockLevelFrame(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsIAtom* type = aFrame->GetType();
|
2014-08-25 06:25:00 +04:00
|
|
|
if (type == nsGkAtoms::columnSetFrame) {
|
|
|
|
static_cast<nsColumnSetFrame*>(aFrame)->DrainOverflowColumns();
|
2016-01-29 17:42:14 +03:00
|
|
|
nsIFrame* child = aFrame->PrincipalChildList().FirstChild();
|
2014-08-25 06:25:00 +04:00
|
|
|
if (child) {
|
|
|
|
return DescendIntoBlockLevelFrame(child);
|
|
|
|
}
|
|
|
|
}
|
2005-08-03 00:05:52 +04:00
|
|
|
return aFrame;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2016-07-21 13:36:39 +03:00
|
|
|
nsBlockReflowContext::ComputeCollapsedBStartMargin(const ReflowInput& aRI,
|
2014-06-17 18:41:35 +04:00
|
|
|
nsCollapsingMargin* aMargin,
|
|
|
|
nsIFrame* aClearanceFrame,
|
|
|
|
bool* aMayNeedRetry,
|
|
|
|
bool* aBlockIsEmpty)
|
1999-03-27 04:22:45 +03:00
|
|
|
{
|
2016-07-21 13:36:39 +03:00
|
|
|
WritingMode wm = aRI.GetWritingMode();
|
2014-10-24 15:24:38 +04:00
|
|
|
WritingMode parentWM = mMetrics.GetWritingMode();
|
|
|
|
|
|
|
|
// Include block-start element of frame's margin
|
2016-07-21 13:36:39 +03:00
|
|
|
aMargin->Include(aRI.ComputedLogicalMargin().ConvertTo(parentWM, wm).BStart(parentWM));
|
2001-10-25 05:08:40 +04:00
|
|
|
|
2014-06-17 18:41:35 +04:00
|
|
|
// The inclusion of the block-end margin when empty is done by the caller
|
2002-11-28 22:29:28 +03:00
|
|
|
// since it doesn't need to be done by the top-level (non-recursive)
|
|
|
|
// caller.
|
|
|
|
|
2014-06-17 18:41:35 +04:00
|
|
|
#ifdef NOISY_BLOCKDIR_MARGINS
|
2016-07-21 13:36:39 +03:00
|
|
|
nsFrame::ListTag(stdout, aRI.mFrame);
|
|
|
|
printf(": %d => %d\n", aRI.ComputedLogicalMargin().BStart(wm), aMargin->get());
|
2001-10-25 05:08:40 +04:00
|
|
|
#endif
|
1999-03-27 04:22:45 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool dirtiedLine = false;
|
|
|
|
bool setBlockIsEmpty = false;
|
2004-11-25 17:51:00 +03:00
|
|
|
|
2014-06-17 18:41:35 +04:00
|
|
|
// Calculate the frame's generational block-start-margin from its child
|
|
|
|
// blocks. Note that if the frame has a non-zero block-start-border or
|
|
|
|
// block-start-padding then this step is skipped because it will be a margin
|
2000-06-30 02:03:42 +04:00
|
|
|
// root. It is also skipped if the frame is a margin root for other
|
|
|
|
// reasons.
|
2016-07-21 13:36:39 +03:00
|
|
|
nsIFrame* frame = DescendIntoBlockLevelFrame(aRI.mFrame);
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext* prescontext = frame->PresContext();
|
2012-07-30 18:20:58 +04:00
|
|
|
nsBlockFrame* block = nullptr;
|
2016-07-21 13:36:39 +03:00
|
|
|
if (0 == aRI.ComputedLogicalBorderPadding().BStart(wm)) {
|
2012-07-20 22:27:04 +04:00
|
|
|
block = nsLayoutUtils::GetAsBlock(frame);
|
|
|
|
if (block) {
|
2014-06-17 18:41:35 +04:00
|
|
|
bool bStartMarginRoot, unused;
|
|
|
|
block->IsMarginRoot(&bStartMarginRoot, &unused);
|
|
|
|
if (bStartMarginRoot) {
|
2012-07-30 18:20:58 +04:00
|
|
|
block = nullptr;
|
2012-07-20 22:27:04 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// iterate not just through the lines of 'block' but also its
|
|
|
|
// overflow lines and the normal and overflow lines of its next in
|
|
|
|
// flows. Note that this will traverse some frames more than once:
|
|
|
|
// for example, if A contains B and A->nextinflow contains
|
|
|
|
// B->nextinflow, we'll traverse B->nextinflow twice. But this is
|
|
|
|
// OK because our traversal is idempotent.
|
|
|
|
for ( ;block; block = static_cast<nsBlockFrame*>(block->GetNextInFlow())) {
|
2013-04-28 14:02:35 +04:00
|
|
|
for (int overflowLines = 0; overflowLines <= 1; ++overflowLines) {
|
2016-10-22 14:41:04 +03:00
|
|
|
nsBlockFrame::LineIterator line;
|
|
|
|
nsBlockFrame::LineIterator line_end;
|
2012-07-20 22:27:04 +04:00
|
|
|
bool anyLines = true;
|
|
|
|
if (overflowLines) {
|
|
|
|
nsBlockFrame::FrameLines* frames = block->GetOverflowLines();
|
2012-07-30 18:20:58 +04:00
|
|
|
nsLineList* lines = frames ? &frames->mLines : nullptr;
|
2012-07-20 22:27:04 +04:00
|
|
|
if (!lines) {
|
|
|
|
anyLines = false;
|
2005-03-23 06:35:08 +03:00
|
|
|
} else {
|
2012-07-20 22:27:04 +04:00
|
|
|
line = lines->begin();
|
|
|
|
line_end = lines->end();
|
2004-11-25 17:51:00 +03:00
|
|
|
}
|
2012-07-20 22:27:04 +04:00
|
|
|
} else {
|
2016-10-24 10:01:25 +03:00
|
|
|
line = block->LinesBegin();
|
|
|
|
line_end = block->LinesEnd();
|
2012-07-20 22:27:04 +04:00
|
|
|
}
|
|
|
|
for (; anyLines && line != line_end; ++line) {
|
|
|
|
if (!aClearanceFrame && line->HasClearance()) {
|
|
|
|
// If we don't have a clearance frame, then we're computing
|
|
|
|
// the collapsed margin in the first pass, assuming that all
|
|
|
|
// lines have no clearance. So clear their clearance flags.
|
|
|
|
line->ClearHasClearance();
|
|
|
|
line->MarkDirty();
|
|
|
|
dirtiedLine = true;
|
|
|
|
}
|
2014-06-17 18:41:35 +04:00
|
|
|
|
2012-07-20 22:27:04 +04:00
|
|
|
bool isEmpty;
|
|
|
|
if (line->IsInline()) {
|
|
|
|
isEmpty = line->IsEmpty();
|
|
|
|
} else {
|
|
|
|
nsIFrame* kid = line->mFirstChild;
|
|
|
|
if (kid == aClearanceFrame) {
|
|
|
|
line->SetHasClearance();
|
2005-03-23 06:35:08 +03:00
|
|
|
line->MarkDirty();
|
2011-10-17 18:59:28 +04:00
|
|
|
dirtiedLine = true;
|
2015-08-06 07:04:38 +03:00
|
|
|
if (!setBlockIsEmpty && aBlockIsEmpty) {
|
|
|
|
setBlockIsEmpty = true;
|
|
|
|
*aBlockIsEmpty = false;
|
|
|
|
}
|
2012-07-20 22:27:04 +04:00
|
|
|
goto done;
|
2005-03-23 06:35:08 +03:00
|
|
|
}
|
2012-07-20 22:27:04 +04:00
|
|
|
// Here is where we recur. Now that we have determined that a
|
|
|
|
// generational collapse is required we need to compute the
|
|
|
|
// child blocks margin and so in so that we can look into
|
|
|
|
// it. For its margins to be computed we need to have a reflow
|
|
|
|
// state for it.
|
2014-06-17 18:41:35 +04:00
|
|
|
|
2012-07-20 22:27:04 +04:00
|
|
|
// We may have to construct an extra reflow state here if
|
|
|
|
// we drilled down through a block wrapper. At the moment
|
|
|
|
// we can only drill down one level so we only have to support
|
|
|
|
// one extra reflow state.
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput* outerReflowInput = &aRI;
|
|
|
|
if (frame != aRI.mFrame) {
|
|
|
|
NS_ASSERTION(frame->GetParent() == aRI.mFrame,
|
2012-07-20 22:27:04 +04:00
|
|
|
"Can only drill through one level of block wrapper");
|
2016-07-21 13:36:39 +03:00
|
|
|
LogicalSize availSpace = aRI.ComputedSize(frame->GetWritingMode());
|
2016-07-21 13:36:39 +03:00
|
|
|
outerReflowInput = new ReflowInput(prescontext,
|
2016-07-21 13:36:39 +03:00
|
|
|
aRI, frame, availSpace);
|
2012-07-20 22:27:04 +04:00
|
|
|
}
|
|
|
|
{
|
2014-07-24 12:28:46 +04:00
|
|
|
LogicalSize availSpace =
|
2016-07-21 13:36:39 +03:00
|
|
|
outerReflowInput->ComputedSize(kid->GetWritingMode());
|
|
|
|
ReflowInput innerReflowInput(prescontext,
|
|
|
|
*outerReflowInput, kid,
|
2012-07-20 22:27:04 +04:00
|
|
|
availSpace);
|
|
|
|
// Record that we're being optimistic by assuming the kid
|
|
|
|
// has no clearance
|
2016-09-03 21:46:58 +03:00
|
|
|
if (kid->StyleDisplay()->mBreakType != StyleClear::None ||
|
2015-07-28 06:23:56 +03:00
|
|
|
!nsBlockFrame::BlockCanIntersectFloats(kid)) {
|
2012-07-20 22:27:04 +04:00
|
|
|
*aMayNeedRetry = true;
|
|
|
|
}
|
2016-07-21 13:36:39 +03:00
|
|
|
if (ComputeCollapsedBStartMargin(innerReflowInput, aMargin,
|
2014-06-17 18:41:35 +04:00
|
|
|
aClearanceFrame, aMayNeedRetry,
|
|
|
|
&isEmpty)) {
|
2005-03-23 06:35:08 +03:00
|
|
|
line->MarkDirty();
|
2011-10-17 18:59:28 +04:00
|
|
|
dirtiedLine = true;
|
2005-03-23 06:35:08 +03:00
|
|
|
}
|
2014-06-17 18:41:35 +04:00
|
|
|
if (isEmpty) {
|
2016-07-21 13:36:39 +03:00
|
|
|
WritingMode innerWM = innerReflowInput.GetWritingMode();
|
2014-06-17 18:41:35 +04:00
|
|
|
LogicalMargin innerMargin =
|
2016-07-21 13:36:39 +03:00
|
|
|
innerReflowInput.ComputedLogicalMargin().ConvertTo(parentWM, innerWM);
|
2014-10-24 15:24:38 +04:00
|
|
|
aMargin->Include(innerMargin.BEnd(parentWM));
|
2014-06-17 18:41:35 +04:00
|
|
|
}
|
2005-03-23 06:35:08 +03:00
|
|
|
}
|
2016-07-21 13:36:39 +03:00
|
|
|
if (outerReflowInput != &aRI) {
|
2016-07-21 13:36:39 +03:00
|
|
|
delete const_cast<ReflowInput*>(outerReflowInput);
|
2006-02-27 07:15:05 +03:00
|
|
|
}
|
|
|
|
}
|
2012-07-20 22:27:04 +04:00
|
|
|
if (!isEmpty) {
|
|
|
|
if (!setBlockIsEmpty && aBlockIsEmpty) {
|
|
|
|
setBlockIsEmpty = true;
|
|
|
|
*aBlockIsEmpty = false;
|
|
|
|
}
|
|
|
|
goto done;
|
2004-11-25 17:51:00 +03:00
|
|
|
}
|
1999-03-27 04:22:45 +03:00
|
|
|
}
|
2012-07-20 22:27:04 +04:00
|
|
|
if (!setBlockIsEmpty && aBlockIsEmpty) {
|
|
|
|
// The first time we reach here is when this is the first block
|
|
|
|
// and we have processed all its normal lines.
|
|
|
|
setBlockIsEmpty = true;
|
|
|
|
// All lines are empty, or we wouldn't be here!
|
2016-07-21 13:36:39 +03:00
|
|
|
*aBlockIsEmpty = aRI.mFrame->IsSelfEmpty();
|
2012-07-20 22:27:04 +04:00
|
|
|
}
|
1999-03-27 04:22:45 +03:00
|
|
|
}
|
|
|
|
}
|
2012-07-20 22:27:04 +04:00
|
|
|
done:
|
2006-02-27 07:15:05 +03:00
|
|
|
|
|
|
|
if (!setBlockIsEmpty && aBlockIsEmpty) {
|
2016-07-21 13:36:39 +03:00
|
|
|
*aBlockIsEmpty = aRI.mFrame->IsEmpty();
|
2006-02-27 07:15:05 +03:00
|
|
|
}
|
2004-11-25 17:51:00 +03:00
|
|
|
|
2014-06-17 18:41:35 +04:00
|
|
|
#ifdef NOISY_BLOCKDIR_MARGINS
|
2016-07-21 13:36:39 +03:00
|
|
|
nsFrame::ListTag(stdout, aRI.mFrame);
|
2005-01-27 23:54:27 +03:00
|
|
|
printf(": => %d\n", aMargin->get());
|
1999-03-27 04:22:45 +03:00
|
|
|
#endif
|
2004-11-25 17:51:00 +03:00
|
|
|
|
|
|
|
return dirtiedLine;
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2014-10-22 02:16:13 +04:00
|
|
|
nsBlockReflowContext::ReflowBlock(const LogicalRect& aSpace,
|
2014-06-17 18:41:35 +04:00
|
|
|
bool aApplyBStartMargin,
|
2004-11-25 17:51:00 +03:00
|
|
|
nsCollapsingMargin& aPrevMargin,
|
|
|
|
nscoord aClearance,
|
2014-06-17 18:41:35 +04:00
|
|
|
bool aIsAdjacentWithBStart,
|
2007-08-21 00:07:50 +04:00
|
|
|
nsLineBox* aLine,
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowInput& aFrameRI,
|
2007-10-02 09:57:45 +04:00
|
|
|
nsReflowStatus& aFrameReflowStatus,
|
2016-07-21 13:36:36 +03:00
|
|
|
BlockReflowInput& aState)
|
2000-06-20 07:47:49 +04:00
|
|
|
{
|
2016-07-21 13:36:39 +03:00
|
|
|
mFrame = aFrameRI.mFrame;
|
2016-07-21 13:36:39 +03:00
|
|
|
mWritingMode = aState.mReflowInput.GetWritingMode();
|
2015-07-16 12:07:57 +03:00
|
|
|
mContainerSize = aState.ContainerSize();
|
2014-10-22 02:16:13 +04:00
|
|
|
mSpace = aSpace;
|
2002-09-04 10:55:40 +04:00
|
|
|
|
2014-06-17 18:41:35 +04:00
|
|
|
if (!aIsAdjacentWithBStart) {
|
2016-07-21 13:36:39 +03:00
|
|
|
aFrameRI.mFlags.mIsTopOfPage = false; // make sure this is cleared
|
1998-12-12 20:59:30 +03:00
|
|
|
}
|
1999-03-05 07:22:11 +03:00
|
|
|
|
2014-06-17 18:41:35 +04:00
|
|
|
if (aApplyBStartMargin) {
|
|
|
|
mBStartMargin = aPrevMargin;
|
1999-09-10 22:52:56 +04:00
|
|
|
|
2014-06-17 18:41:35 +04:00
|
|
|
#ifdef NOISY_BLOCKDIR_MARGINS
|
2016-07-21 13:36:39 +03:00
|
|
|
nsFrame::ListTag(stdout, mOuterReflowInput.mFrame);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(": reflowing ");
|
2002-09-04 10:55:40 +04:00
|
|
|
nsFrame::ListTag(stdout, mFrame);
|
2014-06-17 18:41:35 +04:00
|
|
|
printf(" margin => %d, clearance => %d\n", mBStartMargin.get(), aClearance);
|
1999-03-27 04:22:45 +03:00
|
|
|
#endif
|
|
|
|
|
2015-04-07 17:35:30 +03:00
|
|
|
// Adjust the available size if it's constrained so that the
|
1999-03-27 04:22:45 +03:00
|
|
|
// child frame doesn't think it can reflow into its margin area.
|
2015-04-07 17:35:30 +03:00
|
|
|
if (mWritingMode.IsOrthogonalTo(mFrame->GetWritingMode())) {
|
2016-07-21 13:36:39 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aFrameRI.AvailableISize()) {
|
|
|
|
aFrameRI.AvailableISize() -= mBStartMargin.get() + aClearance;
|
2015-04-07 17:35:30 +03:00
|
|
|
}
|
|
|
|
} else {
|
2016-07-21 13:36:39 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aFrameRI.AvailableBSize()) {
|
|
|
|
aFrameRI.AvailableBSize() -= mBStartMargin.get() + aClearance;
|
2015-04-07 17:35:30 +03:00
|
|
|
}
|
1999-03-27 04:22:45 +03:00
|
|
|
}
|
2015-08-03 07:03:09 +03:00
|
|
|
} else {
|
|
|
|
// nsBlockFrame::ReflowBlock might call us multiple times with
|
|
|
|
// *different* values of aApplyBStartMargin.
|
|
|
|
mBStartMargin.Zero();
|
1999-03-27 04:22:45 +03:00
|
|
|
}
|
|
|
|
|
2015-03-22 12:44:48 +03:00
|
|
|
nscoord tI = 0, tB = 0;
|
2014-06-17 18:41:35 +04:00
|
|
|
// The values of x and y do not matter for floats, so don't bother
|
|
|
|
// calculating them. Floats are guaranteed to have their own float
|
|
|
|
// manager, so tI and tB don't matter. mICoord and mBCoord don't
|
|
|
|
// matter becacuse they are only used in PlaceBlock, which is not used
|
|
|
|
// for floats.
|
2007-08-21 00:07:50 +04:00
|
|
|
if (aLine) {
|
2014-06-17 18:41:35 +04:00
|
|
|
// Compute inline/block coordinate where reflow will begin. Use the
|
|
|
|
// rules from 10.3.3 to determine what to apply. At this point in the
|
|
|
|
// reflow auto inline-start/end margins will have a zero value.
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
WritingMode frameWM = aFrameRI.GetWritingMode();
|
2015-03-22 12:44:48 +03:00
|
|
|
LogicalMargin usedMargin =
|
2016-07-21 13:36:39 +03:00
|
|
|
aFrameRI.ComputedLogicalMargin().ConvertTo(mWritingMode, frameWM);
|
2015-03-22 12:44:48 +03:00
|
|
|
mICoord = mSpace.IStart(mWritingMode) + usedMargin.IStart(mWritingMode);
|
|
|
|
mBCoord = mSpace.BStart(mWritingMode) + mBStartMargin.get() + aClearance;
|
|
|
|
|
|
|
|
LogicalRect space(mWritingMode, mICoord, mBCoord,
|
|
|
|
mSpace.ISize(mWritingMode) -
|
|
|
|
usedMargin.IStartEnd(mWritingMode),
|
|
|
|
mSpace.BSize(mWritingMode) -
|
|
|
|
usedMargin.BStartEnd(mWritingMode));
|
2015-07-16 12:07:57 +03:00
|
|
|
tI = space.LineLeft(mWritingMode, mContainerSize);
|
2015-03-22 12:44:48 +03:00
|
|
|
tB = mBCoord;
|
2007-08-21 00:07:50 +04:00
|
|
|
|
2009-01-05 03:39:54 +03:00
|
|
|
if ((mFrame->GetStateBits() & NS_BLOCK_FLOAT_MGR) == 0)
|
2016-07-21 13:36:39 +03:00
|
|
|
aFrameRI.mBlockDelta =
|
2016-07-21 13:36:39 +03:00
|
|
|
mOuterReflowInput.mBlockDelta + mBCoord - aLine->BStart();
|
2000-01-26 06:44:36 +03:00
|
|
|
}
|
|
|
|
|
1999-03-08 22:25:03 +03:00
|
|
|
#ifdef DEBUG
|
2014-07-24 12:30:07 +04:00
|
|
|
mMetrics.ISize(mWritingMode) = nscoord(0xdeadbeef);
|
|
|
|
mMetrics.BSize(mWritingMode) = nscoord(0xdeadbeef);
|
1999-03-08 22:25:03 +03:00
|
|
|
#endif
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
mOuterReflowInput.mFloatManager->Translate(tI, tB);
|
2016-07-21 13:36:39 +03:00
|
|
|
mFrame->Reflow(mPresContext, mMetrics, aFrameRI, aFrameReflowStatus);
|
2016-07-21 13:36:39 +03:00
|
|
|
mOuterReflowInput.mFloatManager->Translate(-tI, -tB);
|
1998-12-01 19:13:49 +03:00
|
|
|
|
1999-03-08 22:25:03 +03:00
|
|
|
#ifdef DEBUG
|
1999-03-24 18:42:38 +03:00
|
|
|
if (!NS_INLINE_IS_BREAK_BEFORE(aFrameReflowStatus)) {
|
2015-09-04 23:06:57 +03:00
|
|
|
if ((CRAZY_SIZE(mMetrics.ISize(mWritingMode)) ||
|
|
|
|
CRAZY_SIZE(mMetrics.BSize(mWritingMode))) &&
|
|
|
|
!mFrame->GetParent()->IsCrazySizeAssertSuppressed()) {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("nsBlockReflowContext: ");
|
2002-09-04 10:55:40 +04:00
|
|
|
nsFrame::ListTag(stdout, mFrame);
|
2014-07-24 12:30:07 +04:00
|
|
|
printf(" metrics=%d,%d!\n",
|
|
|
|
mMetrics.ISize(mWritingMode), mMetrics.BSize(mWritingMode));
|
1999-03-24 18:42:38 +03:00
|
|
|
}
|
2014-07-24 12:30:07 +04:00
|
|
|
if ((mMetrics.ISize(mWritingMode) == nscoord(0xdeadbeef)) ||
|
|
|
|
(mMetrics.BSize(mWritingMode) == nscoord(0xdeadbeef))) {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("nsBlockReflowContext: ");
|
2002-09-04 10:55:40 +04:00
|
|
|
nsFrame::ListTag(stdout, mFrame);
|
2014-07-24 12:30:07 +04:00
|
|
|
printf(" didn't set i/b %d,%d!\n",
|
|
|
|
mMetrics.ISize(mWritingMode), mMetrics.BSize(mWritingMode));
|
1999-03-24 18:42:38 +03:00
|
|
|
}
|
1999-03-20 02:06:20 +03:00
|
|
|
}
|
1999-03-08 22:25:03 +03:00
|
|
|
#endif
|
1999-03-05 07:22:11 +03:00
|
|
|
|
2010-10-07 08:25:47 +04:00
|
|
|
if (!mFrame->HasOverflowAreas()) {
|
|
|
|
mMetrics.SetOverflowAreasToDesiredBounds();
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
if (!NS_INLINE_IS_BREAK_BEFORE(aFrameReflowStatus) ||
|
2003-06-27 22:13:48 +04:00
|
|
|
(mFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
|
1998-12-01 19:13:49 +03:00
|
|
|
// If frame is complete and has a next-in-flow, we need to delete
|
|
|
|
// them now. Do not do this when a break-before is signaled because
|
|
|
|
// the frame is going to get reflowed again (and may end up wanting
|
2002-05-29 02:50:43 +04:00
|
|
|
// a next-in-flow where it ends up), unless it is an out of flow frame.
|
2007-07-26 08:03:29 +04:00
|
|
|
if (NS_FRAME_IS_FULLY_COMPLETE(aFrameReflowStatus)) {
|
2004-09-14 06:28:03 +04:00
|
|
|
nsIFrame* kidNextInFlow = mFrame->GetNextInFlow();
|
2012-07-30 18:20:58 +04:00
|
|
|
if (nullptr != kidNextInFlow) {
|
1998-12-01 19:13:49 +03:00
|
|
|
// Remove all of the childs next-in-flows. Make sure that we ask
|
|
|
|
// the right parent to do the removal (it's possible that the
|
2005-03-23 06:35:08 +03:00
|
|
|
// parent is not this because we are executing pullup code).
|
|
|
|
// Floats will eventually be removed via nsBlockFrame::RemoveFloat
|
|
|
|
// which detaches the placeholder from the float.
|
2013-06-10 22:31:59 +04:00
|
|
|
nsOverflowContinuationTracker::AutoFinish fini(aState.mOverflowTracker, mFrame);
|
2014-05-25 02:20:40 +04:00
|
|
|
kidNextInFlow->GetParent()->DeleteNextInFlowChild(kidNextInFlow, true);
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempt to place the block frame within the available space. If
|
2014-06-17 18:41:35 +04:00
|
|
|
* it fits, apply inline-dir ("horizontal") positioning (CSS 10.3.3),
|
|
|
|
* collapse margins (CSS2 8.3.1). Also apply relative positioning.
|
1998-12-01 19:13:49 +03:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2016-07-21 13:36:39 +03:00
|
|
|
nsBlockReflowContext::PlaceBlock(const ReflowInput& aReflowInput,
|
2014-04-16 12:03:28 +04:00
|
|
|
bool aForceFit,
|
|
|
|
nsLineBox* aLine,
|
2014-06-17 18:41:35 +04:00
|
|
|
nsCollapsingMargin& aBEndMarginResult,
|
2014-04-16 12:03:28 +04:00
|
|
|
nsOverflowAreas& aOverflowAreas,
|
2014-06-17 18:41:35 +04:00
|
|
|
nsReflowStatus aReflowStatus)
|
1998-12-01 19:13:49 +03:00
|
|
|
{
|
2014-06-17 18:41:35 +04:00
|
|
|
// Compute collapsed block-end margin value.
|
2016-07-21 13:36:39 +03:00
|
|
|
WritingMode wm = aReflowInput.GetWritingMode();
|
2014-06-17 18:41:35 +04:00
|
|
|
WritingMode parentWM = mMetrics.GetWritingMode();
|
2005-03-23 06:35:08 +03:00
|
|
|
if (NS_FRAME_IS_COMPLETE(aReflowStatus)) {
|
2014-11-17 11:49:38 +03:00
|
|
|
aBEndMarginResult = mMetrics.mCarriedOutBEndMargin;
|
2016-07-21 13:36:39 +03:00
|
|
|
aBEndMarginResult.Include(aReflowInput.ComputedLogicalMargin().
|
2014-11-26 13:24:16 +03:00
|
|
|
ConvertTo(parentWM, wm).BEnd(parentWM));
|
2005-03-23 06:35:08 +03:00
|
|
|
} else {
|
2015-01-08 13:10:24 +03:00
|
|
|
// The used block-end-margin is set to zero before a break.
|
2014-06-17 18:41:35 +04:00
|
|
|
aBEndMarginResult.Zero();
|
2005-03-23 06:35:08 +03:00
|
|
|
}
|
1998-12-01 19:13:49 +03:00
|
|
|
|
2005-02-02 04:33:20 +03:00
|
|
|
nscoord backupContainingBlockAdvance = 0;
|
|
|
|
|
2014-06-17 18:41:35 +04:00
|
|
|
// Check whether the block's block-end margin collapses with its block-start
|
2004-11-25 17:51:00 +03:00
|
|
|
// margin. See CSS 2.1 section 8.3.1; those rules seem to match
|
2014-06-17 18:41:35 +04:00
|
|
|
// nsBlockFrame::IsEmpty(). Any such block must have zero block-size so
|
2005-01-27 23:54:27 +03:00
|
|
|
// check that first. Note that a block can have clearance and still
|
2014-06-17 18:41:35 +04:00
|
|
|
// have adjoining block-start/end margins, because the clearance goes
|
|
|
|
// above the block-start margin.
|
2006-03-27 01:02:19 +04:00
|
|
|
// Mark the frame as non-dirty; it has been reflowed (or we wouldn't
|
|
|
|
// be here), and we don't want to assert in CachedIsEmpty()
|
|
|
|
mFrame->RemoveStateBits(NS_FRAME_IS_DIRTY);
|
2014-06-17 18:41:35 +04:00
|
|
|
bool empty = 0 == mMetrics.BSize(parentWM) && aLine->CachedIsEmpty();
|
2005-03-23 06:35:08 +03:00
|
|
|
if (empty) {
|
2014-06-17 18:41:35 +04:00
|
|
|
// Collapse the block-end margin with the block-start margin that was
|
|
|
|
// already applied.
|
|
|
|
aBEndMarginResult.Include(mBStartMargin);
|
2005-03-23 06:35:08 +03:00
|
|
|
|
2014-06-17 18:41:35 +04:00
|
|
|
#ifdef NOISY_BLOCKDIR_MARGINS
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(" ");
|
2016-07-21 13:36:39 +03:00
|
|
|
nsFrame::ListTag(stdout, mOuterReflowInput.mFrame);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(": ");
|
2000-06-30 02:03:42 +04:00
|
|
|
nsFrame::ListTag(stdout, mFrame);
|
2014-06-17 18:41:35 +04:00
|
|
|
printf(" -- collapsing block start & end margin together; BStart=%d spaceBStart=%d\n",
|
|
|
|
mBCoord, mSpace.BStart(mWritingMode));
|
1999-05-11 02:28:04 +04:00
|
|
|
#endif
|
2005-01-27 23:54:27 +03:00
|
|
|
// Section 8.3.1 of CSS 2.1 says that blocks with adjoining
|
2014-06-17 18:41:35 +04:00
|
|
|
// "top/bottom" (i.e. block-start/end) margins whose top margin collapses
|
|
|
|
// with their parent's top margin should have their top border-edge at the
|
2005-01-27 23:54:27 +03:00
|
|
|
// top border-edge of their parent. We actually don't have to do
|
|
|
|
// anything special to make this happen. In that situation,
|
2014-06-17 18:41:35 +04:00
|
|
|
// nsBlockFrame::ShouldApplyBStartMargin will have returned false,
|
|
|
|
// and mBStartMargin and aClearance will have been zero in
|
2005-01-27 23:54:27 +03:00
|
|
|
// ReflowBlock.
|
2005-02-02 04:33:20 +03:00
|
|
|
|
2014-06-17 18:41:35 +04:00
|
|
|
// If we did apply our block-start margin, but now we're collapsing it
|
|
|
|
// into the block-end margin, we need to back up the containing
|
|
|
|
// block's bCoord-advance by our block-start margin so that it doesn't get
|
2005-02-02 04:33:20 +03:00
|
|
|
// counted twice. Note that here we're allowing the line's bounds
|
|
|
|
// to become different from the block's position; we do this
|
|
|
|
// because the containing block will place the next line at the
|
2014-06-17 18:41:35 +04:00
|
|
|
// line's BEnd, and it must place the next line at a different
|
2005-02-02 04:33:20 +03:00
|
|
|
// point from where this empty block will be.
|
2014-06-17 18:41:35 +04:00
|
|
|
backupContainingBlockAdvance = mBStartMargin.get();
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|
2000-08-12 00:08:15 +04:00
|
|
|
|
2005-03-23 06:35:08 +03:00
|
|
|
// See if the frame fit. If it's the first frame or empty then it
|
2014-06-17 18:41:35 +04:00
|
|
|
// always fits. If the block-size is unconstrained then it always fits,
|
|
|
|
// even if there's some sort of integer overflow that makes bCoord +
|
2015-01-08 13:10:24 +03:00
|
|
|
// mMetrics.BSize() appear to go beyond the available block size.
|
2014-06-17 18:41:35 +04:00
|
|
|
if (!empty && !aForceFit &&
|
|
|
|
mSpace.BSize(mWritingMode) != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
nscoord bEnd = mBCoord -
|
|
|
|
backupContainingBlockAdvance + mMetrics.BSize(mWritingMode);
|
|
|
|
if (bEnd > mSpace.BEnd(mWritingMode)) {
|
2005-03-23 06:35:08 +03:00
|
|
|
// didn't fit, we must acquit.
|
2016-07-21 13:36:39 +03:00
|
|
|
mFrame->DidReflow(mPresContext, &aReflowInput,
|
2014-06-17 18:41:35 +04:00
|
|
|
nsDidReflowStatus::FINISHED);
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-17 18:41:35 +04:00
|
|
|
aLine->SetBounds(mWritingMode,
|
|
|
|
mICoord, mBCoord - backupContainingBlockAdvance,
|
|
|
|
mMetrics.ISize(mWritingMode), mMetrics.BSize(mWritingMode),
|
2015-07-16 12:07:57 +03:00
|
|
|
mContainerSize);
|
2014-06-17 18:41:35 +04:00
|
|
|
|
2015-01-07 10:10:07 +03:00
|
|
|
WritingMode frameWM = mFrame->GetWritingMode();
|
|
|
|
LogicalPoint logPos =
|
|
|
|
LogicalPoint(mWritingMode, mICoord, mBCoord).
|
2015-07-16 12:07:57 +03:00
|
|
|
ConvertTo(frameWM, mWritingMode,
|
|
|
|
mContainerSize - mMetrics.PhysicalSize());
|
2015-01-19 09:01:57 +03:00
|
|
|
|
|
|
|
// ApplyRelativePositioning in right-to-left writing modes needs to
|
|
|
|
// know the updated frame width
|
|
|
|
mFrame->SetSize(mWritingMode, mMetrics.Size(mWritingMode));
|
2016-07-21 13:36:39 +03:00
|
|
|
aReflowInput.ApplyRelativePositioning(&logPos, mContainerSize);
|
2014-04-16 12:03:28 +04:00
|
|
|
|
2005-03-23 06:35:08 +03:00
|
|
|
// Now place the frame and complete the reflow process
|
2014-01-17 05:34:44 +04:00
|
|
|
nsContainerFrame::FinishReflowChild(mFrame, mPresContext, mMetrics,
|
2016-07-21 13:36:39 +03:00
|
|
|
&aReflowInput, frameWM, logPos,
|
2015-07-16 12:07:57 +03:00
|
|
|
mContainerSize, 0);
|
2010-10-07 08:25:45 +04:00
|
|
|
|
2015-01-07 10:10:07 +03:00
|
|
|
aOverflowAreas = mMetrics.mOverflowAreas + mFrame->GetPosition();
|
2005-01-26 01:29:59 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1998-12-01 19:13:49 +03:00
|
|
|
}
|