2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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
|
|
|
|
|
|
|
/*
|
|
|
|
* code for managing absolutely positioned children of a rendering
|
|
|
|
* object that is a containing block for them
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsAbsoluteContainingBlock.h"
|
2013-04-01 08:26:01 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsContainerFrame.h"
|
2013-04-01 08:26:01 -07:00
|
|
|
#include "nsGkAtoms.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIPresShell.h"
|
2013-04-01 08:26:01 -07:00
|
|
|
#include "nsHTMLReflowState.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsPresContext.h"
|
2009-09-18 04:09:35 -07:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#include "nsBlockFrame.h"
|
2013-04-01 08:26:01 -07:00
|
|
|
|
|
|
|
static void PrettyUC(nscoord aSize, char* aBuf)
|
|
|
|
{
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == aSize) {
|
|
|
|
strcpy(aBuf, "UC");
|
|
|
|
} else {
|
|
|
|
if((int32_t)0xdeadbeef == aSize) {
|
|
|
|
strcpy(aBuf, "deadbeef");
|
|
|
|
} else {
|
|
|
|
sprintf(aBuf, "%d", aSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsAbsoluteContainingBlock::SetInitialChildList(nsIFrame* aDelegatingFrame,
|
2011-08-24 13:54:30 -07:00
|
|
|
ChildListID aListID,
|
2009-07-28 05:53:20 -07:00
|
|
|
nsFrameList& aChildList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-04-01 08:26:01 -07:00
|
|
|
NS_PRECONDITION(mChildListID == aListID, "unexpected child list name");
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2007-03-22 10:30:00 -07:00
|
|
|
nsFrame::VerifyDirtyBitSet(aChildList);
|
|
|
|
#endif
|
|
|
|
mAbsoluteFrames.SetFrames(aChildList);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsAbsoluteContainingBlock::AppendFrames(nsIFrame* aDelegatingFrame,
|
2011-08-24 13:54:30 -07:00
|
|
|
ChildListID aListID,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-04-01 08:26:01 -07:00
|
|
|
NS_ASSERTION(mChildListID == aListID, "unexpected child list");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Append the frames to our list of absolutely positioned frames
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2007-03-22 10:30:00 -07:00
|
|
|
nsFrame::VerifyDirtyBitSet(aFrameList);
|
|
|
|
#endif
|
2012-07-30 07:20:58 -07:00
|
|
|
mAbsoluteFrames.AppendFrames(nullptr, aFrameList);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// no damage to intrinsic widths, since absolutely positioned frames can't
|
|
|
|
// change them
|
2010-03-20 14:54:19 -07:00
|
|
|
aDelegatingFrame->PresContext()->PresShell()->
|
2007-05-06 12:16:51 -07:00
|
|
|
FrameNeedsReflow(aDelegatingFrame, nsIPresShell::eResize,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2010-03-20 14:54:19 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsAbsoluteContainingBlock::InsertFrames(nsIFrame* aDelegatingFrame,
|
2011-08-24 13:54:30 -07:00
|
|
|
ChildListID aListID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-04-01 08:26:01 -07:00
|
|
|
NS_ASSERTION(mChildListID == aListID, "unexpected child list");
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == aDelegatingFrame,
|
|
|
|
"inserting after sibling frame with different parent");
|
|
|
|
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2007-03-22 10:30:00 -07:00
|
|
|
nsFrame::VerifyDirtyBitSet(aFrameList);
|
|
|
|
#endif
|
2012-07-30 07:20:58 -07:00
|
|
|
mAbsoluteFrames.InsertFrames(nullptr, aPrevFrame, aFrameList);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// no damage to intrinsic widths, since absolutely positioned frames can't
|
|
|
|
// change them
|
2010-03-20 14:54:19 -07:00
|
|
|
aDelegatingFrame->PresContext()->PresShell()->
|
2007-05-06 12:16:51 -07:00
|
|
|
FrameNeedsReflow(aDelegatingFrame, nsIPresShell::eResize,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2010-03-20 14:54:19 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-09-18 04:09:36 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsAbsoluteContainingBlock::RemoveFrame(nsIFrame* aDelegatingFrame,
|
2011-08-24 13:54:30 -07:00
|
|
|
ChildListID aListID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2013-04-01 08:26:01 -07:00
|
|
|
NS_ASSERTION(mChildListID == aListID, "unexpected child list");
|
2007-10-01 22:57:45 -07:00
|
|
|
nsIFrame* nif = aOldFrame->GetNextInFlow();
|
|
|
|
if (nif) {
|
|
|
|
static_cast<nsContainerFrame*>(nif->GetParent())
|
2014-02-06 14:07:47 -08:00
|
|
|
->DeleteNextInFlowChild(nif, false);
|
2007-10-01 22:57:45 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-18 04:09:36 -07:00
|
|
|
mAbsoluteFrames.DestroyFrame(aOldFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-05-12 15:47:41 -07:00
|
|
|
nsresult
|
2007-10-01 22:57:45 -07:00
|
|
|
nsAbsoluteContainingBlock::Reflow(nsContainerFrame* aDelegatingFrame,
|
|
|
|
nsPresContext* aPresContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
2007-10-01 22:57:45 -07:00
|
|
|
nsReflowStatus& aReflowStatus,
|
2013-04-15 01:31:45 -07:00
|
|
|
const nsRect& aContainingBlock,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aConstrainHeight,
|
|
|
|
bool aCBWidthChanged,
|
|
|
|
bool aCBHeightChanged,
|
2010-10-06 21:25:45 -07:00
|
|
|
nsOverflowAreas* aOverflowAreas)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-10-01 22:57:45 -07:00
|
|
|
nsReflowStatus reflowStatus = NS_FRAME_COMPLETE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool reflowAll = aReflowState.ShouldReflowAllKids();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsIFrame* kidFrame;
|
2014-02-06 14:07:47 -08:00
|
|
|
nsOverflowContinuationTracker tracker(aDelegatingFrame, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
for (kidFrame = mAbsoluteFrames.FirstChild(); kidFrame; kidFrame = kidFrame->GetNextSibling()) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool kidNeedsReflow = reflowAll || NS_SUBTREE_DIRTY(kidFrame) ||
|
2009-04-21 16:53:52 -07:00
|
|
|
FrameDependsOnContainer(kidFrame, aCBWidthChanged, aCBHeightChanged);
|
|
|
|
if (kidNeedsReflow && !aPresContext->HasPendingInterrupt()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Reflow the frame
|
2007-10-01 22:57:45 -07:00
|
|
|
nsReflowStatus kidStatus = NS_FRAME_COMPLETE;
|
|
|
|
ReflowAbsoluteFrame(aDelegatingFrame, aPresContext, aReflowState,
|
2013-04-15 01:31:45 -07:00
|
|
|
aContainingBlock,
|
2010-10-06 21:25:45 -07:00
|
|
|
aConstrainHeight, kidFrame, kidStatus,
|
|
|
|
aOverflowAreas);
|
2007-10-01 22:57:45 -07:00
|
|
|
nsIFrame* nextFrame = kidFrame->GetNextInFlow();
|
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(kidStatus)) {
|
|
|
|
// Need a continuation
|
|
|
|
if (!nextFrame) {
|
2013-03-19 18:47:49 -07:00
|
|
|
nextFrame =
|
|
|
|
aPresContext->PresShell()->FrameConstructor()->
|
|
|
|
CreateContinuingFrame(aPresContext, kidFrame, aDelegatingFrame);
|
2007-10-01 22:57:45 -07:00
|
|
|
}
|
|
|
|
// Add it as an overflow container.
|
|
|
|
//XXXfr This is a hack to fix some of our printing dataloss.
|
|
|
|
// See bug 154892. Not sure how to do it "right" yet; probably want
|
|
|
|
// to keep continuations within an nsAbsoluteContainingBlock eventually.
|
|
|
|
tracker.Insert(nextFrame, kidStatus);
|
2008-05-28 06:39:41 -07:00
|
|
|
NS_MergeReflowStatusInto(&reflowStatus, kidStatus);
|
2007-10-01 22:57:45 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Delete any continuations
|
|
|
|
if (nextFrame) {
|
2013-06-10 11:31:59 -07:00
|
|
|
nsOverflowContinuationTracker::AutoFinish fini(&tracker, kidFrame);
|
2007-10-01 22:57:45 -07:00
|
|
|
static_cast<nsContainerFrame*>(nextFrame->GetParent())
|
2014-02-06 14:07:47 -08:00
|
|
|
->DeleteNextInFlowChild(nextFrame, true);
|
2007-10-01 22:57:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tracker.Skip(kidFrame, reflowStatus);
|
2010-10-06 21:25:45 -07:00
|
|
|
if (aOverflowAreas) {
|
|
|
|
aDelegatingFrame->ConsiderChildOverflow(*aOverflowAreas, kidFrame);
|
2007-10-01 22:57:45 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-04-21 16:53:52 -07:00
|
|
|
|
2009-05-09 20:57:47 -07:00
|
|
|
// Make a CheckForInterrupt call, here, not just HasPendingInterrupt. That
|
|
|
|
// will make sure that we end up reflowing aDelegatingFrame in cases when
|
|
|
|
// one of our kids interrupted. Otherwise we'd set the dirty or
|
|
|
|
// dirty-children bit on the kid in the condition below, and then when
|
|
|
|
// reflow completes and we go to mark dirty bits on all ancestors of that
|
|
|
|
// kid we'll immediately bail out, because the kid already has a dirty bit.
|
|
|
|
// In particular, we won't set any dirty bits on aDelegatingFrame, so when
|
|
|
|
// the following reflow happens we won't reflow the kid in question. This
|
|
|
|
// might be slightly suboptimal in cases where |kidFrame| itself did not
|
|
|
|
// interrupt, since we'll trigger a reflow of it too when it's not strictly
|
|
|
|
// needed. But the logic to not do that is enough more complicated, and
|
|
|
|
// the case enough of an edge case, that this is probably better.
|
|
|
|
if (kidNeedsReflow && aPresContext->CheckForInterrupt(aDelegatingFrame)) {
|
2009-04-21 16:53:52 -07:00
|
|
|
if (aDelegatingFrame->GetStateBits() & NS_FRAME_IS_DIRTY) {
|
|
|
|
kidFrame->AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
} else {
|
|
|
|
kidFrame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-04-21 16:53:52 -07:00
|
|
|
|
2007-10-01 22:57:45 -07:00
|
|
|
// Abspos frames can't cause their parent to be incomplete,
|
|
|
|
// only overflow incomplete.
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(reflowStatus))
|
|
|
|
NS_FRAME_SET_OVERFLOW_INCOMPLETE(reflowStatus);
|
|
|
|
|
2008-05-28 06:39:41 -07:00
|
|
|
NS_MergeReflowStatusInto(&aReflowStatus, reflowStatus);
|
2014-05-12 15:47:41 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-08-31 09:05:12 -07:00
|
|
|
static inline bool IsFixedPaddingSize(const nsStyleCoord& aCoord)
|
|
|
|
{ return aCoord.ConvertsToLength(); }
|
|
|
|
static inline bool IsFixedMarginSize(const nsStyleCoord& aCoord)
|
|
|
|
{ return aCoord.ConvertsToLength(); }
|
|
|
|
static inline bool IsFixedOffset(const nsStyleCoord& aCoord)
|
|
|
|
{ return aCoord.ConvertsToLength(); }
|
2007-05-03 16:11:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsAbsoluteContainingBlock::FrameDependsOnContainer(nsIFrame* f,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aCBWidthChanged,
|
|
|
|
bool aCBHeightChanged)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStylePosition* pos = f->StylePosition();
|
2007-03-22 10:30:00 -07:00
|
|
|
// See if f's position might have changed because it depends on a
|
|
|
|
// placeholder's position
|
|
|
|
// This can happen in the following cases:
|
|
|
|
// 1) Vertical positioning. "top" must be auto and "bottom" must be auto
|
|
|
|
// (otherwise the vertical position is completely determined by
|
|
|
|
// whichever of them is not auto and the height).
|
|
|
|
// 2) Horizontal positioning. "left" must be auto and "right" must be auto
|
|
|
|
// (otherwise the horizontal position is completely determined by
|
|
|
|
// whichever of them is not auto and the width).
|
|
|
|
// See nsHTMLReflowState::InitAbsoluteConstraints -- these are the
|
|
|
|
// only cases when we call CalculateHypotheticalBox().
|
|
|
|
if ((pos->mOffset.GetTopUnit() == eStyleUnit_Auto &&
|
|
|
|
pos->mOffset.GetBottomUnit() == eStyleUnit_Auto) ||
|
|
|
|
(pos->mOffset.GetLeftUnit() == eStyleUnit_Auto &&
|
|
|
|
pos->mOffset.GetRightUnit() == eStyleUnit_Auto)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (!aCBWidthChanged && !aCBHeightChanged) {
|
|
|
|
// skip getting style data
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStylePadding* padding = f->StylePadding();
|
|
|
|
const nsStyleMargin* margin = f->StyleMargin();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aCBWidthChanged) {
|
|
|
|
// See if f's width might have changed.
|
|
|
|
// If border-left, border-right, padding-left, padding-right,
|
|
|
|
// width, min-width, and max-width are all lengths, 'none', or enumerated,
|
|
|
|
// then our frame width does not depend on the parent width.
|
|
|
|
// Note that borders never depend on the parent width
|
2007-11-15 10:10:31 -08:00
|
|
|
// XXX All of the enumerated values except -moz-available are ok too.
|
2010-08-11 12:32:52 -07:00
|
|
|
if (pos->WidthDependsOnContainer() ||
|
|
|
|
pos->MinWidthDependsOnContainer() ||
|
|
|
|
pos->MaxWidthDependsOnContainer() ||
|
2010-08-31 09:05:12 -07:00
|
|
|
!IsFixedPaddingSize(padding->mPadding.GetLeft()) ||
|
|
|
|
!IsFixedPaddingSize(padding->mPadding.GetRight())) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// See if f's position might have changed. If we're RTL then the
|
|
|
|
// rules are slightly different. We'll assume percentage or auto
|
|
|
|
// margins will always induce a dependency on the size
|
2010-08-31 09:05:12 -07:00
|
|
|
if (!IsFixedMarginSize(margin->mMargin.GetLeft()) ||
|
|
|
|
!IsFixedMarginSize(margin->mMargin.GetRight())) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2013-02-16 13:51:02 -08:00
|
|
|
if (f->StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Note that even if 'left' is a length, our position can
|
|
|
|
// still depend on the containing block width, because if
|
|
|
|
// 'right' is also a length we will discard 'left' and be
|
|
|
|
// positioned relative to the containing block right edge.
|
|
|
|
// 'left' length and 'right' auto is the only combination
|
|
|
|
// we can be sure of.
|
2010-08-25 03:17:56 -07:00
|
|
|
if (!IsFixedOffset(pos->mOffset.GetLeft()) ||
|
2007-03-22 10:30:00 -07:00
|
|
|
pos->mOffset.GetRightUnit() != eStyleUnit_Auto) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
} else {
|
2010-08-25 03:17:56 -07:00
|
|
|
if (!IsFixedOffset(pos->mOffset.GetLeft())) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aCBHeightChanged) {
|
|
|
|
// See if f's height might have changed.
|
|
|
|
// If border-top, border-bottom, padding-top, padding-bottom,
|
|
|
|
// min-height, and max-height are all lengths or 'none',
|
|
|
|
// and height is a length or height and bottom are auto and top is not auto,
|
|
|
|
// then our frame height does not depend on the parent height.
|
|
|
|
// Note that borders never depend on the parent height
|
2010-08-11 12:32:52 -07:00
|
|
|
if ((pos->HeightDependsOnContainer() &&
|
|
|
|
!(pos->mHeight.GetUnit() == eStyleUnit_Auto &&
|
2007-03-22 10:30:00 -07:00
|
|
|
pos->mOffset.GetBottomUnit() == eStyleUnit_Auto &&
|
|
|
|
pos->mOffset.GetTopUnit() != eStyleUnit_Auto)) ||
|
2010-08-11 12:32:52 -07:00
|
|
|
pos->MinHeightDependsOnContainer() ||
|
|
|
|
pos->MaxHeightDependsOnContainer() ||
|
2010-08-31 09:05:12 -07:00
|
|
|
!IsFixedPaddingSize(padding->mPadding.GetTop()) ||
|
|
|
|
!IsFixedPaddingSize(padding->mPadding.GetBottom())) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// See if f's position might have changed.
|
2010-08-31 09:05:12 -07:00
|
|
|
if (!IsFixedMarginSize(margin->mMargin.GetTop()) ||
|
|
|
|
!IsFixedMarginSize(margin->mMargin.GetBottom())) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-08-25 03:17:56 -07:00
|
|
|
if (!IsFixedOffset(pos->mOffset.GetTop())) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-23 21:21:15 -08:00
|
|
|
nsAbsoluteContainingBlock::DestroyFrames(nsIFrame* aDelegatingFrame,
|
|
|
|
nsIFrame* aDestructRoot)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-12-23 21:21:15 -08:00
|
|
|
mAbsoluteFrames.DestroyFramesFrom(aDestructRoot);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-10-15 13:30:42 -07:00
|
|
|
void
|
|
|
|
nsAbsoluteContainingBlock::MarkSizeDependentFramesDirty()
|
2009-04-21 16:53:52 -07:00
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
DoMarkFramesDirty(false);
|
2009-04-21 16:53:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsAbsoluteContainingBlock::MarkAllFramesDirty()
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
DoMarkFramesDirty(true);
|
2009-04-21 16:53:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-09-28 23:19:26 -07:00
|
|
|
nsAbsoluteContainingBlock::DoMarkFramesDirty(bool aMarkAllDirty)
|
2008-10-15 13:30:42 -07:00
|
|
|
{
|
|
|
|
for (nsIFrame* kidFrame = mAbsoluteFrames.FirstChild();
|
|
|
|
kidFrame;
|
|
|
|
kidFrame = kidFrame->GetNextSibling()) {
|
2009-04-21 16:53:52 -07:00
|
|
|
if (aMarkAllDirty) {
|
|
|
|
kidFrame->AddStateBits(NS_FRAME_IS_DIRTY);
|
2011-10-17 07:59:28 -07:00
|
|
|
} else if (FrameDependsOnContainer(kidFrame, true, true)) {
|
2008-10-15 13:30:42 -07:00
|
|
|
// Add the weakest flags that will make sure we reflow this frame later
|
|
|
|
kidFrame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// XXX Optimize the case where it's a resize reflow and the absolutely
|
|
|
|
// positioned child has the exact same size and position and skip the
|
|
|
|
// reflow...
|
|
|
|
|
|
|
|
// When bug 154892 is checked in, make sure that when
|
2013-04-01 08:26:01 -07:00
|
|
|
// mChildListID == kFixedList, the height is unconstrained.
|
2007-03-22 10:30:00 -07:00
|
|
|
// since we don't allow replicated frames to split.
|
|
|
|
|
2014-05-12 15:47:41 -07:00
|
|
|
nsresult
|
2007-03-22 10:30:00 -07:00
|
|
|
nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
|
2013-04-15 01:31:45 -07:00
|
|
|
nsPresContext* aPresContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
2013-04-15 01:31:45 -07:00
|
|
|
const nsRect& aContainingBlock,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aConstrainHeight,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aKidFrame,
|
2007-07-16 11:55:24 -07:00
|
|
|
nsReflowStatus& aStatus,
|
2010-10-06 21:25:45 -07:00
|
|
|
nsOverflowAreas* aOverflowAreas)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (nsBlockFrame::gNoisyReflow) {
|
|
|
|
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent);
|
|
|
|
printf("abs pos ");
|
2009-08-20 14:52:48 -07:00
|
|
|
if (aKidFrame) {
|
|
|
|
nsAutoString name;
|
|
|
|
aKidFrame->GetFrameName(name);
|
|
|
|
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
char width[16];
|
|
|
|
char height[16];
|
2013-12-27 09:59:21 -08:00
|
|
|
PrettyUC(aReflowState.AvailableWidth(), width);
|
|
|
|
PrettyUC(aReflowState.AvailableHeight(), height);
|
2007-03-22 10:30:00 -07:00
|
|
|
printf(" a=%s,%s ", width, height);
|
|
|
|
PrettyUC(aReflowState.ComputedWidth(), width);
|
2007-08-02 11:08:05 -07:00
|
|
|
PrettyUC(aReflowState.ComputedHeight(), height);
|
2007-03-22 10:30:00 -07:00
|
|
|
printf("c=%s,%s \n", width, height);
|
|
|
|
}
|
|
|
|
AutoNoisyIndenter indent(nsBlockFrame::gNoisy);
|
|
|
|
#endif // DEBUG
|
|
|
|
|
2013-04-15 01:31:45 -07:00
|
|
|
nscoord availWidth = aContainingBlock.width;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (availWidth == -1) {
|
|
|
|
NS_ASSERTION(aReflowState.ComputedWidth() != NS_UNCONSTRAINEDSIZE,
|
|
|
|
"Must have a useful width _somewhere_");
|
|
|
|
availWidth =
|
2013-12-27 09:59:21 -08:00
|
|
|
aReflowState.ComputedWidth() + aReflowState.ComputedPhysicalPadding().LeftRight();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-10-09 22:00:05 -07:00
|
|
|
|
2013-12-31 05:50:31 -08:00
|
|
|
nsHTMLReflowMetrics kidDesiredSize(aReflowState);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
|
|
|
|
nsSize(availWidth, NS_UNCONSTRAINEDSIZE),
|
2013-04-15 01:31:45 -07:00
|
|
|
aContainingBlock.width,
|
|
|
|
aContainingBlock.height);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Send the WillReflow() notification and position the frame
|
|
|
|
aKidFrame->WillReflow(aPresContext);
|
|
|
|
|
2013-04-15 01:31:45 -07:00
|
|
|
// Get the border values
|
|
|
|
const nsMargin& border = aReflowState.mStyleBorder->GetComputedBorder();
|
|
|
|
|
2013-12-27 09:59:21 -08:00
|
|
|
bool constrainHeight = (aReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE)
|
2007-10-02 01:29:23 -07:00
|
|
|
&& aConstrainHeight
|
|
|
|
// Don't split if told not to (e.g. for fixed frames)
|
2011-04-29 16:02:33 -07:00
|
|
|
&& (aDelegatingFrame->GetType() != nsGkAtoms::inlineFrame)
|
2007-10-01 22:57:45 -07:00
|
|
|
//XXX we don't handle splitting frames for inline absolute containing blocks yet
|
2013-12-27 09:59:21 -08:00
|
|
|
&& (aKidFrame->GetRect().y <= aReflowState.AvailableHeight());
|
2007-10-01 22:57:45 -07:00
|
|
|
// Don't split things below the fold. (Ideally we shouldn't *have*
|
|
|
|
// anything totally below the fold, but we can't position frames
|
|
|
|
// across next-in-flow breaks yet.
|
|
|
|
if (constrainHeight) {
|
2013-12-27 09:59:21 -08:00
|
|
|
kidReflowState.AvailableHeight() = aReflowState.AvailableHeight() - border.top
|
|
|
|
- kidReflowState.ComputedPhysicalMargin().top;
|
|
|
|
if (NS_AUTOOFFSET != kidReflowState.ComputedPhysicalOffsets().top)
|
|
|
|
kidReflowState.AvailableHeight() -= kidReflowState.ComputedPhysicalOffsets().top;
|
2007-10-01 22:57:45 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Do the reflow
|
2014-05-12 15:47:41 -07:00
|
|
|
nsresult rv = aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// If we're solving for 'left' or 'top', then compute it now that we know the
|
|
|
|
// width/height
|
2013-12-27 09:59:21 -08:00
|
|
|
if ((NS_AUTOOFFSET == kidReflowState.ComputedPhysicalOffsets().left) ||
|
|
|
|
(NS_AUTOOFFSET == kidReflowState.ComputedPhysicalOffsets().top)) {
|
2013-04-15 01:31:45 -07:00
|
|
|
nscoord aContainingBlockWidth = aContainingBlock.width;
|
|
|
|
nscoord aContainingBlockHeight = aContainingBlock.height;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (-1 == aContainingBlockWidth) {
|
|
|
|
// Get the containing block width/height
|
|
|
|
kidReflowState.ComputeContainingBlockRectangle(aPresContext,
|
|
|
|
&aReflowState,
|
|
|
|
aContainingBlockWidth,
|
|
|
|
aContainingBlockHeight);
|
|
|
|
}
|
|
|
|
|
2013-12-27 09:59:21 -08:00
|
|
|
if (NS_AUTOOFFSET == kidReflowState.ComputedPhysicalOffsets().left) {
|
|
|
|
NS_ASSERTION(NS_AUTOOFFSET != kidReflowState.ComputedPhysicalOffsets().right,
|
2007-03-22 10:30:00 -07:00
|
|
|
"Can't solve for both left and right");
|
2013-12-27 09:59:21 -08:00
|
|
|
kidReflowState.ComputedPhysicalOffsets().left = aContainingBlockWidth -
|
|
|
|
kidReflowState.ComputedPhysicalOffsets().right -
|
|
|
|
kidReflowState.ComputedPhysicalMargin().right -
|
2013-12-27 09:59:52 -08:00
|
|
|
kidDesiredSize.Width() -
|
2013-12-27 09:59:21 -08:00
|
|
|
kidReflowState.ComputedPhysicalMargin().left;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2013-12-27 09:59:21 -08:00
|
|
|
if (NS_AUTOOFFSET == kidReflowState.ComputedPhysicalOffsets().top) {
|
|
|
|
kidReflowState.ComputedPhysicalOffsets().top = aContainingBlockHeight -
|
|
|
|
kidReflowState.ComputedPhysicalOffsets().bottom -
|
|
|
|
kidReflowState.ComputedPhysicalMargin().bottom -
|
2013-12-27 09:59:52 -08:00
|
|
|
kidDesiredSize.Height() -
|
2013-12-27 09:59:21 -08:00
|
|
|
kidReflowState.ComputedPhysicalMargin().top;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Position the child relative to our padding edge
|
2013-12-27 09:59:21 -08:00
|
|
|
nsRect rect(border.left + kidReflowState.ComputedPhysicalOffsets().left + kidReflowState.ComputedPhysicalMargin().left,
|
|
|
|
border.top + kidReflowState.ComputedPhysicalOffsets().top + kidReflowState.ComputedPhysicalMargin().top,
|
2013-12-27 09:59:52 -08:00
|
|
|
kidDesiredSize.Width(), kidDesiredSize.Height());
|
2013-04-15 01:31:45 -07:00
|
|
|
|
|
|
|
// Offset the frame rect by the given origin of the absolute containing block.
|
|
|
|
// If the frame is auto-positioned on both sides of an axis, it will be
|
|
|
|
// positioned based on its containing block and we don't need to offset.
|
|
|
|
if (aContainingBlock.TopLeft() != nsPoint(0, 0)) {
|
|
|
|
if (!(kidReflowState.mStylePosition->mOffset.GetLeftUnit() == eStyleUnit_Auto &&
|
|
|
|
kidReflowState.mStylePosition->mOffset.GetRightUnit() == eStyleUnit_Auto)) {
|
|
|
|
rect.x += aContainingBlock.x;
|
|
|
|
}
|
|
|
|
if (!(kidReflowState.mStylePosition->mOffset.GetTopUnit() == eStyleUnit_Auto &&
|
|
|
|
kidReflowState.mStylePosition->mOffset.GetBottomUnit() == eStyleUnit_Auto)) {
|
|
|
|
rect.y += aContainingBlock.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
aKidFrame->SetRect(rect);
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* view = aKidFrame->GetView();
|
2007-05-01 17:07:51 -07:00
|
|
|
if (view) {
|
|
|
|
// Size and position the view and set its opacity, visibility, content
|
|
|
|
// transparency, and clip
|
2010-10-06 21:25:45 -07:00
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame, view,
|
|
|
|
kidDesiredSize.VisualOverflow());
|
2007-05-01 17:07:51 -07:00
|
|
|
} else {
|
|
|
|
nsContainerFrame::PositionChildViews(aKidFrame);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-11-13 22:47:33 -08:00
|
|
|
aKidFrame->DidReflow(aPresContext, &kidReflowState, nsDidReflowStatus::FINISHED);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (nsBlockFrame::gNoisyReflow) {
|
|
|
|
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent - 1);
|
|
|
|
printf("abs pos ");
|
2009-08-20 14:52:48 -07:00
|
|
|
if (aKidFrame) {
|
|
|
|
nsAutoString name;
|
|
|
|
aKidFrame->GetFrameName(name);
|
|
|
|
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-09-18 04:09:35 -07:00
|
|
|
printf("%p rect=%d,%d,%d,%d\n", static_cast<void*>(aKidFrame),
|
2009-08-20 14:52:48 -07:00
|
|
|
rect.x, rect.y, rect.width, rect.height);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-10-06 21:25:45 -07:00
|
|
|
if (aOverflowAreas) {
|
|
|
|
aOverflowAreas->UnionWith(kidDesiredSize.mOverflowAreas + rect.TopLeft());
|
|
|
|
}
|
2014-05-12 15:47:41 -07:00
|
|
|
|
|
|
|
return rv;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|