2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
// vim:cindent:ts=2:et:sw=2:
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* class that a parent frame uses to reflow a block frame */
|
|
|
|
|
|
|
|
#include "nsBlockReflowContext.h"
|
2013-08-22 11:32:52 -07:00
|
|
|
#include "nsBlockReflowState.h"
|
2009-01-04 16:39:54 -08:00
|
|
|
#include "nsFloatManager.h"
|
2011-12-27 12:18:48 -08:00
|
|
|
#include "nsContainerFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsBlockFrame.h"
|
|
|
|
#include "nsLineBox.h"
|
|
|
|
#include "nsLayoutUtils.h"
|
|
|
|
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2007-03-22 10:30:00 -07:00
|
|
|
#undef NOISY_MAX_ELEMENT_SIZE
|
|
|
|
#undef REALLY_NOISY_MAX_ELEMENT_SIZE
|
|
|
|
#undef NOISY_VERTICAL_MARGINS
|
|
|
|
#else
|
|
|
|
#undef NOISY_MAX_ELEMENT_SIZE
|
|
|
|
#undef REALLY_NOISY_MAX_ELEMENT_SIZE
|
|
|
|
#undef NOISY_VERTICAL_MARGINS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsBlockReflowContext::nsBlockReflowContext(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aParentRS)
|
|
|
|
: mPresContext(aPresContext),
|
|
|
|
mOuterReflowState(aParentRS),
|
|
|
|
mMetrics()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsIFrame* DescendIntoBlockLevelFrame(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsIAtom* type = aFrame->GetType();
|
|
|
|
if (type == nsGkAtoms::columnSetFrame)
|
2011-08-24 13:54:30 -07:00
|
|
|
return DescendIntoBlockLevelFrame(aFrame->GetFirstPrincipalChild());
|
2007-03-22 10:30:00 -07:00
|
|
|
return aFrame;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockReflowContext::ComputeCollapsedTopMargin(const nsHTMLReflowState& aRS,
|
|
|
|
nsCollapsingMargin* aMargin, nsIFrame* aClearanceFrame,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aMayNeedRetry, bool* aBlockIsEmpty)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Include frame's top margin
|
|
|
|
aMargin->Include(aRS.mComputedMargin.top);
|
|
|
|
|
|
|
|
// The inclusion of the bottom margin when empty is done by the caller
|
|
|
|
// since it doesn't need to be done by the top-level (non-recursive)
|
|
|
|
// caller.
|
|
|
|
|
|
|
|
#ifdef NOISY_VERTICAL_MARGINS
|
|
|
|
nsFrame::ListTag(stdout, aRS.frame);
|
|
|
|
printf(": %d => %d\n", aRS.mComputedMargin.top, aMargin->get());
|
|
|
|
#endif
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool dirtiedLine = false;
|
|
|
|
bool setBlockIsEmpty = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Calculate the frame's generational top-margin from its child
|
|
|
|
// blocks. Note that if the frame has a non-zero top-border or
|
|
|
|
// top-padding then this step is skipped because it will be a margin
|
|
|
|
// root. It is also skipped if the frame is a margin root for other
|
|
|
|
// reasons.
|
|
|
|
nsIFrame* frame = DescendIntoBlockLevelFrame(aRS.frame);
|
2007-03-30 14:11:41 -07:00
|
|
|
nsPresContext* prescontext = frame->PresContext();
|
2012-07-30 07:20:58 -07:00
|
|
|
nsBlockFrame* block = nullptr;
|
2012-07-20 11:27:04 -07:00
|
|
|
if (0 == aRS.mComputedBorderPadding.top) {
|
|
|
|
block = nsLayoutUtils::GetAsBlock(frame);
|
|
|
|
if (block) {
|
|
|
|
bool topMarginRoot, unused;
|
|
|
|
block->IsMarginRoot(&topMarginRoot, &unused);
|
|
|
|
if (topMarginRoot) {
|
2012-07-30 07:20:58 -07:00
|
|
|
block = nullptr;
|
2012-07-20 11:27:04 -07: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 03:02:35 -07:00
|
|
|
for (int overflowLines = 0; overflowLines <= 1; ++overflowLines) {
|
2012-07-20 11:27:04 -07:00
|
|
|
nsBlockFrame::line_iterator line;
|
|
|
|
nsBlockFrame::line_iterator line_end;
|
|
|
|
bool anyLines = true;
|
|
|
|
if (overflowLines) {
|
|
|
|
nsBlockFrame::FrameLines* frames = block->GetOverflowLines();
|
2012-07-30 07:20:58 -07:00
|
|
|
nsLineList* lines = frames ? &frames->mLines : nullptr;
|
2012-07-20 11:27:04 -07:00
|
|
|
if (!lines) {
|
|
|
|
anyLines = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
2012-07-20 11:27:04 -07:00
|
|
|
line = lines->begin();
|
|
|
|
line_end = lines->end();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-07-20 11:27:04 -07:00
|
|
|
} else {
|
|
|
|
line = block->begin_lines();
|
|
|
|
line_end = block->end_lines();
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isEmpty;
|
|
|
|
if (line->IsInline()) {
|
|
|
|
isEmpty = line->IsEmpty();
|
|
|
|
} else {
|
|
|
|
nsIFrame* kid = line->mFirstChild;
|
|
|
|
if (kid == aClearanceFrame) {
|
|
|
|
line->SetHasClearance();
|
2007-03-22 10:30:00 -07:00
|
|
|
line->MarkDirty();
|
2011-10-17 07:59:28 -07:00
|
|
|
dirtiedLine = true;
|
2012-07-20 11:27:04 -07:00
|
|
|
goto done;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-07-20 11:27:04 -07: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.
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-20 11:27:04 -07: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.
|
|
|
|
const nsHTMLReflowState* outerReflowState = &aRS;
|
|
|
|
if (frame != aRS.frame) {
|
|
|
|
NS_ASSERTION(frame->GetParent() == aRS.frame,
|
|
|
|
"Can only drill through one level of block wrapper");
|
|
|
|
nsSize availSpace(aRS.ComputedWidth(), aRS.ComputedHeight());
|
|
|
|
outerReflowState = new nsHTMLReflowState(prescontext,
|
|
|
|
aRS, frame, availSpace);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
nsSize availSpace(outerReflowState->ComputedWidth(),
|
|
|
|
outerReflowState->ComputedHeight());
|
|
|
|
nsHTMLReflowState innerReflowState(prescontext,
|
|
|
|
*outerReflowState, kid,
|
|
|
|
availSpace);
|
|
|
|
// Record that we're being optimistic by assuming the kid
|
|
|
|
// has no clearance
|
2013-02-16 13:51:02 -08:00
|
|
|
if (kid->StyleDisplay()->mBreakType != NS_STYLE_CLEAR_NONE) {
|
2012-07-20 11:27:04 -07:00
|
|
|
*aMayNeedRetry = true;
|
|
|
|
}
|
|
|
|
if (ComputeCollapsedTopMargin(innerReflowState, aMargin, aClearanceFrame, aMayNeedRetry, &isEmpty)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
line->MarkDirty();
|
2011-10-17 07:59:28 -07:00
|
|
|
dirtiedLine = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-07-20 11:27:04 -07:00
|
|
|
if (isEmpty)
|
|
|
|
aMargin->Include(innerReflowState.mComputedMargin.bottom);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-07-20 11:27:04 -07:00
|
|
|
if (outerReflowState != &aRS) {
|
|
|
|
delete const_cast<nsHTMLReflowState*>(outerReflowState);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2012-07-20 11:27:04 -07:00
|
|
|
if (!isEmpty) {
|
|
|
|
if (!setBlockIsEmpty && aBlockIsEmpty) {
|
|
|
|
setBlockIsEmpty = true;
|
|
|
|
*aBlockIsEmpty = false;
|
|
|
|
}
|
|
|
|
goto done;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2012-07-20 11:27:04 -07: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!
|
|
|
|
*aBlockIsEmpty = aRS.frame->IsSelfEmpty();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2012-07-20 11:27:04 -07:00
|
|
|
done:
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (!setBlockIsEmpty && aBlockIsEmpty) {
|
|
|
|
*aBlockIsEmpty = aRS.frame->IsEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NOISY_VERTICAL_MARGINS
|
|
|
|
nsFrame::ListTag(stdout, aRS.frame);
|
|
|
|
printf(": => %d\n", aMargin->get());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return dirtiedLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBlockReflowContext::ReflowBlock(const nsRect& aSpace,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aApplyTopMargin,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCollapsingMargin& aPrevMargin,
|
|
|
|
nscoord aClearance,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aIsAdjacentWithTop,
|
2007-08-20 13:07:50 -07:00
|
|
|
nsLineBox* aLine,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsHTMLReflowState& aFrameRS,
|
2007-10-01 22:57:45 -07:00
|
|
|
nsReflowStatus& aFrameReflowStatus,
|
|
|
|
nsBlockReflowState& aState)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
mFrame = aFrameRS.frame;
|
|
|
|
mSpace = aSpace;
|
|
|
|
|
|
|
|
if (!aIsAdjacentWithTop) {
|
2011-10-17 07:59:28 -07:00
|
|
|
aFrameRS.mFlags.mIsTopOfPage = false; // make sure this is cleared
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aApplyTopMargin) {
|
|
|
|
mTopMargin = aPrevMargin;
|
|
|
|
|
|
|
|
#ifdef NOISY_VERTICAL_MARGINS
|
|
|
|
nsFrame::ListTag(stdout, mOuterReflowState.frame);
|
|
|
|
printf(": reflowing ");
|
|
|
|
nsFrame::ListTag(stdout, mFrame);
|
|
|
|
printf(" margin => %d, clearance => %d\n", mTopMargin.get(), aClearance);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Adjust the available height if its constrained so that the
|
|
|
|
// child frame doesn't think it can reflow into its margin area.
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != aFrameRS.availableHeight) {
|
|
|
|
aFrameRS.availableHeight -= mTopMargin.get() + aClearance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-20 13:07:50 -07:00
|
|
|
nscoord tx = 0, ty = 0;
|
|
|
|
// The values of x and y do not matter for floats, so don't bother calculating
|
2009-01-04 16:39:54 -08:00
|
|
|
// them. Floats are guaranteed to have their own float manager, so tx and ty
|
2007-08-20 13:07:50 -07:00
|
|
|
// don't matter. mX and mY don't matter becacuse they are only used in
|
|
|
|
// PlaceBlock, which is not used for floats.
|
|
|
|
if (aLine) {
|
|
|
|
// Compute x/y coordinate where reflow will begin. Use the rules
|
|
|
|
// from 10.3.3 to determine what to apply. At this point in the
|
|
|
|
// reflow auto left/right margins will have a zero value.
|
|
|
|
|
2010-08-11 12:32:53 -07:00
|
|
|
mX = tx = mSpace.x + aFrameRS.mComputedMargin.left;
|
|
|
|
mY = ty = mSpace.y + mTopMargin.get() + aClearance;
|
2007-08-20 13:07:50 -07:00
|
|
|
|
2009-01-04 16:39:54 -08:00
|
|
|
if ((mFrame->GetStateBits() & NS_BLOCK_FLOAT_MGR) == 0)
|
2010-08-11 12:32:53 -07:00
|
|
|
aFrameRS.mBlockDelta = mOuterReflowState.mBlockDelta + ty - aLine->mBounds.y;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Let frame know that we are reflowing it
|
|
|
|
mFrame->WillReflow(mPresContext);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
mMetrics.width = nscoord(0xdeadbeef);
|
|
|
|
mMetrics.height = nscoord(0xdeadbeef);
|
|
|
|
#endif
|
|
|
|
|
2009-01-04 16:39:54 -08:00
|
|
|
mOuterReflowState.mFloatManager->Translate(tx, ty);
|
2007-03-22 10:30:00 -07:00
|
|
|
rv = mFrame->Reflow(mPresContext, mMetrics, aFrameRS, aFrameReflowStatus);
|
2009-01-04 16:39:54 -08:00
|
|
|
mOuterReflowState.mFloatManager->Translate(-tx, -ty);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (!NS_INLINE_IS_BREAK_BEFORE(aFrameReflowStatus)) {
|
|
|
|
if (CRAZY_WIDTH(mMetrics.width) || CRAZY_HEIGHT(mMetrics.height)) {
|
|
|
|
printf("nsBlockReflowContext: ");
|
|
|
|
nsFrame::ListTag(stdout, mFrame);
|
|
|
|
printf(" metrics=%d,%d!\n", mMetrics.width, mMetrics.height);
|
|
|
|
}
|
|
|
|
if ((mMetrics.width == nscoord(0xdeadbeef)) ||
|
|
|
|
(mMetrics.height == nscoord(0xdeadbeef))) {
|
|
|
|
printf("nsBlockReflowContext: ");
|
|
|
|
nsFrame::ListTag(stdout, mFrame);
|
|
|
|
printf(" didn't set w/h %d,%d!\n", mMetrics.width, mMetrics.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-10-06 21:25:47 -07:00
|
|
|
if (!mFrame->HasOverflowAreas()) {
|
|
|
|
mMetrics.SetOverflowAreasToDesiredBounds();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!NS_INLINE_IS_BREAK_BEFORE(aFrameReflowStatus) ||
|
|
|
|
(mFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
|
|
|
|
// 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
|
|
|
|
// a next-in-flow where it ends up), unless it is an out of flow frame.
|
2007-07-25 21:03:29 -07:00
|
|
|
if (NS_FRAME_IS_FULLY_COMPLETE(aFrameReflowStatus)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* kidNextInFlow = mFrame->GetNextInFlow();
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr != kidNextInFlow) {
|
2007-03-22 10:30:00 -07: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
|
|
|
|
// 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 11:31:59 -07:00
|
|
|
nsOverflowContinuationTracker::AutoFinish fini(aState.mOverflowTracker, mFrame);
|
2011-12-27 12:18:48 -08:00
|
|
|
static_cast<nsContainerFrame*>(kidNextInFlow->GetParent())
|
2011-10-17 07:59:28 -07:00
|
|
|
->DeleteNextInFlowChild(mPresContext, kidNextInFlow, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempt to place the block frame within the available space. If
|
|
|
|
* it fits, apply horizontal positioning (CSS 10.3.3), collapse
|
|
|
|
* margins (CSS2 8.3.1). Also apply relative positioning.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockReflowContext::PlaceBlock(const nsHTMLReflowState& aReflowState,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aForceFit,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsLineBox* aLine,
|
|
|
|
nsCollapsingMargin& aBottomMarginResult,
|
|
|
|
nsRect& aInFlowBounds,
|
2010-10-06 21:25:45 -07:00
|
|
|
nsOverflowAreas& aOverflowAreas,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsReflowStatus aReflowStatus)
|
|
|
|
{
|
|
|
|
// Compute collapsed bottom margin value.
|
|
|
|
if (NS_FRAME_IS_COMPLETE(aReflowStatus)) {
|
|
|
|
aBottomMarginResult = mMetrics.mCarriedOutBottomMargin;
|
2007-08-20 13:07:50 -07:00
|
|
|
aBottomMarginResult.Include(aReflowState.mComputedMargin.bottom);
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
|
|
|
// The used bottom-margin is set to zero above a break.
|
|
|
|
aBottomMarginResult.Zero();
|
|
|
|
}
|
|
|
|
|
2013-07-15 17:28:09 -07:00
|
|
|
nsPoint position(mX, mY);
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord backupContainingBlockAdvance = 0;
|
|
|
|
|
|
|
|
// Check whether the block's bottom margin collapses with its top
|
|
|
|
// margin. See CSS 2.1 section 8.3.1; those rules seem to match
|
|
|
|
// nsBlockFrame::IsEmpty(). Any such block must have zero height so
|
|
|
|
// check that first. Note that a block can have clearance and still
|
|
|
|
// have adjoining top/bottom margins, because the clearance goes
|
|
|
|
// above the top margin.
|
|
|
|
// 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);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool empty = 0 == mMetrics.height && aLine->CachedIsEmpty();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (empty) {
|
|
|
|
// Collapse the bottom margin with the top margin that was already
|
|
|
|
// applied.
|
|
|
|
aBottomMarginResult.Include(mTopMargin);
|
|
|
|
|
|
|
|
#ifdef NOISY_VERTICAL_MARGINS
|
|
|
|
printf(" ");
|
|
|
|
nsFrame::ListTag(stdout, mOuterReflowState.frame);
|
|
|
|
printf(": ");
|
|
|
|
nsFrame::ListTag(stdout, mFrame);
|
|
|
|
printf(" -- collapsing top & bottom margin together; y=%d spaceY=%d\n",
|
2013-07-15 17:28:09 -07:00
|
|
|
position.y, mSpace.y);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
// Section 8.3.1 of CSS 2.1 says that blocks with adjoining
|
|
|
|
// top/bottom margins whose top margin collapses with their
|
|
|
|
// parent's top margin should have their top border-edge at the
|
|
|
|
// top border-edge of their parent. We actually don't have to do
|
|
|
|
// anything special to make this happen. In that situation,
|
2011-10-17 07:59:28 -07:00
|
|
|
// nsBlockFrame::ShouldApplyTopMargin will have returned false,
|
2007-03-22 10:30:00 -07:00
|
|
|
// and mTopMargin and aClearance will have been zero in
|
|
|
|
// ReflowBlock.
|
|
|
|
|
|
|
|
// If we did apply our top margin, but now we're collapsing it
|
|
|
|
// into the bottom margin, we need to back up the containing
|
|
|
|
// block's y-advance by our top margin so that it doesn't get
|
|
|
|
// 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
|
|
|
|
// line's YMost, and it must place the next line at a different
|
|
|
|
// point from where this empty block will be.
|
|
|
|
backupContainingBlockAdvance = mTopMargin.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if the frame fit. If it's the first frame or empty then it
|
|
|
|
// always fits. If the height is unconstrained then it always fits,
|
|
|
|
// even if there's some sort of integer overflow that makes y +
|
|
|
|
// mMetrics.height appear to go beyond the available height.
|
|
|
|
if (!empty && !aForceFit && mSpace.height != NS_UNCONSTRAINEDSIZE) {
|
2013-07-15 17:28:09 -07:00
|
|
|
nscoord yMost = position.y - backupContainingBlockAdvance + mMetrics.height;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (yMost > mSpace.YMost()) {
|
|
|
|
// didn't fit, we must acquit.
|
2012-11-13 22:47:33 -08:00
|
|
|
mFrame->DidReflow(mPresContext, &aReflowState, nsDidReflowStatus::FINISHED);
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-15 17:28:09 -07:00
|
|
|
aInFlowBounds = nsRect(position.x, position.y - backupContainingBlockAdvance,
|
2007-03-22 10:30:00 -07:00
|
|
|
mMetrics.width, mMetrics.height);
|
|
|
|
|
2013-07-15 17:28:09 -07:00
|
|
|
aReflowState.ApplyRelativePositioning(&position);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Now place the frame and complete the reflow process
|
2013-07-15 17:28:09 -07:00
|
|
|
nsContainerFrame::FinishReflowChild(mFrame, mPresContext, &aReflowState,
|
|
|
|
mMetrics, position.x, position.y, 0);
|
2010-10-06 21:25:45 -07:00
|
|
|
|
2013-07-15 17:28:09 -07:00
|
|
|
aOverflowAreas = mMetrics.mOverflowAreas + position;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|