2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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
|
|
|
|
|
|
|
/*
|
|
|
|
* code for managing absolutely positioned children of a rendering
|
|
|
|
* object that is a containing block for them
|
|
|
|
*/
|
|
|
|
|
1999-04-16 05:39:45 +04:00
|
|
|
#include "nsAbsoluteContainingBlock.h"
|
2013-04-01 19:26:01 +04:00
|
|
|
|
1999-04-16 05:39:45 +04:00
|
|
|
#include "nsContainerFrame.h"
|
2013-04-01 19:26:01 +04:00
|
|
|
#include "nsGkAtoms.h"
|
1999-07-24 06:37:45 +04:00
|
|
|
#include "nsIPresShell.h"
|
2016-10-31 18:58:18 +03:00
|
|
|
#include "mozilla/CSSAlignUtils.h"
|
2016-07-21 13:36:34 +03:00
|
|
|
#include "mozilla/ReflowInput.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2009-09-18 15:09:35 +04:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
2015-03-26 21:57:39 +03:00
|
|
|
#include "nsGridContainerFrame.h"
|
1999-04-16 05:39:45 +04:00
|
|
|
|
2016-08-15 09:43:21 +03:00
|
|
|
#include "mozilla/Sprintf.h"
|
2015-05-26 21:33:55 +03:00
|
|
|
|
2002-11-16 13:41:10 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
#include "nsBlockFrame.h"
|
2013-04-01 19:26:01 +04:00
|
|
|
|
2015-05-26 21:33:55 +03:00
|
|
|
static void PrettyUC(nscoord aSize, char* aBuf, int aBufSize)
|
2013-04-01 19:26:01 +04:00
|
|
|
{
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == aSize) {
|
|
|
|
strcpy(aBuf, "UC");
|
|
|
|
} else {
|
|
|
|
if((int32_t)0xdeadbeef == aSize) {
|
|
|
|
strcpy(aBuf, "deadbeef");
|
|
|
|
} else {
|
2015-05-26 21:33:55 +03:00
|
|
|
snprintf(aBuf, aBufSize, "%d", aSize);
|
2013-04-01 19:26:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-11-16 13:41:10 +03:00
|
|
|
#endif
|
|
|
|
|
2014-07-24 12:28:46 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
1999-07-24 06:37:45 +04:00
|
|
|
nsAbsoluteContainingBlock::SetInitialChildList(nsIFrame* aDelegatingFrame,
|
2011-08-25 00:54:30 +04:00
|
|
|
ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList)
|
1999-04-16 05:39:45 +04:00
|
|
|
{
|
2013-04-01 19:26:01 +04:00
|
|
|
NS_PRECONDITION(mChildListID == aListID, "unexpected child list name");
|
2012-06-25 23:59:42 +04:00
|
|
|
#ifdef DEBUG
|
1999-07-24 06:37:45 +04:00
|
|
|
nsFrame::VerifyDirtyBitSet(aChildList);
|
|
|
|
#endif
|
1999-04-16 05:39:45 +04:00
|
|
|
mAbsoluteFrames.SetFrames(aChildList);
|
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2005-02-07 04:58:25 +03:00
|
|
|
nsAbsoluteContainingBlock::AppendFrames(nsIFrame* aDelegatingFrame,
|
2011-08-25 00:54:30 +04:00
|
|
|
ChildListID aListID,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
1999-07-24 06:37:45 +04:00
|
|
|
{
|
2013-04-01 19:26:01 +04:00
|
|
|
NS_ASSERTION(mChildListID == aListID, "unexpected child list");
|
2006-06-29 06:32:36 +04:00
|
|
|
|
1999-07-24 06:37:45 +04:00
|
|
|
// Append the frames to our list of absolutely positioned frames
|
2012-06-25 23:59:42 +04:00
|
|
|
#ifdef DEBUG
|
1999-07-24 06:37:45 +04:00
|
|
|
nsFrame::VerifyDirtyBitSet(aFrameList);
|
|
|
|
#endif
|
2012-07-30 18:20:58 +04:00
|
|
|
mAbsoluteFrames.AppendFrames(nullptr, aFrameList);
|
1999-07-24 06:37:45 +04:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// no damage to intrinsic widths, since absolutely positioned frames can't
|
|
|
|
// change them
|
2010-03-21 00:54:19 +03:00
|
|
|
aDelegatingFrame->PresContext()->PresShell()->
|
2007-05-06 23:16:51 +04:00
|
|
|
FrameNeedsReflow(aDelegatingFrame, nsIPresShell::eResize,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
1999-07-24 06:37:45 +04:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2005-02-07 04:58:25 +03:00
|
|
|
nsAbsoluteContainingBlock::InsertFrames(nsIFrame* aDelegatingFrame,
|
2011-08-25 00:54:30 +04:00
|
|
|
ChildListID aListID,
|
2005-02-07 04:58:25 +03:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
1999-07-24 06:37:45 +04:00
|
|
|
{
|
2013-04-01 19:26:01 +04:00
|
|
|
NS_ASSERTION(mChildListID == aListID, "unexpected child list");
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == aDelegatingFrame,
|
|
|
|
"inserting after sibling frame with different parent");
|
|
|
|
|
2012-06-25 23:59:42 +04:00
|
|
|
#ifdef DEBUG
|
1999-07-24 06:37:45 +04:00
|
|
|
nsFrame::VerifyDirtyBitSet(aFrameList);
|
|
|
|
#endif
|
2012-07-30 18:20:58 +04:00
|
|
|
mAbsoluteFrames.InsertFrames(nullptr, aPrevFrame, aFrameList);
|
1999-07-24 06:37:45 +04:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// no damage to intrinsic widths, since absolutely positioned frames can't
|
|
|
|
// change them
|
2010-03-21 00:54:19 +03:00
|
|
|
aDelegatingFrame->PresContext()->PresShell()->
|
2007-05-06 23:16:51 +04:00
|
|
|
FrameNeedsReflow(aDelegatingFrame, nsIPresShell::eResize,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
1999-07-24 06:37:45 +04:00
|
|
|
}
|
|
|
|
|
2009-09-18 15:09:36 +04:00
|
|
|
void
|
1999-07-24 06:37:45 +04:00
|
|
|
nsAbsoluteContainingBlock::RemoveFrame(nsIFrame* aDelegatingFrame,
|
2011-08-25 00:54:30 +04:00
|
|
|
ChildListID aListID,
|
1999-07-24 06:37:45 +04:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2013-04-01 19:26:01 +04:00
|
|
|
NS_ASSERTION(mChildListID == aListID, "unexpected child list");
|
2007-10-02 09:57:45 +04:00
|
|
|
nsIFrame* nif = aOldFrame->GetNextInFlow();
|
|
|
|
if (nif) {
|
2014-05-25 02:20:40 +04:00
|
|
|
nif->GetParent()->DeleteNextInFlowChild(nif, false);
|
2007-10-02 09:57:45 +04:00
|
|
|
}
|
2006-06-29 06:32:36 +04:00
|
|
|
|
2009-09-18 15:09:36 +04:00
|
|
|
mAbsoluteFrames.DestroyFrame(aOldFrame);
|
1999-07-24 06:37:45 +04:00
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:53 +04:00
|
|
|
void
|
2007-10-02 09:57:45 +04:00
|
|
|
nsAbsoluteContainingBlock::Reflow(nsContainerFrame* aDelegatingFrame,
|
|
|
|
nsPresContext* aPresContext,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2007-10-02 09:57:45 +04:00
|
|
|
nsReflowStatus& aReflowStatus,
|
2013-04-15 12:31:45 +04:00
|
|
|
const nsRect& aContainingBlock,
|
2015-12-23 01:03:16 +03:00
|
|
|
AbsPosReflowFlags aFlags,
|
2010-10-07 08:25:45 +04:00
|
|
|
nsOverflowAreas* aOverflowAreas)
|
1999-04-16 05:39:45 +04:00
|
|
|
{
|
2007-10-02 09:57:45 +04:00
|
|
|
nsReflowStatus reflowStatus = NS_FRAME_COMPLETE;
|
1999-12-06 18:49:53 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
const bool reflowAll = aReflowInput.ShouldReflowAllKids();
|
2015-12-23 01:03:16 +03:00
|
|
|
const bool isGrid = !!(aFlags & AbsPosReflowFlags::eIsGridContainerCB);
|
1999-04-16 05:39:45 +04:00
|
|
|
nsIFrame* kidFrame;
|
2014-02-07 02:07:47 +04:00
|
|
|
nsOverflowContinuationTracker tracker(aDelegatingFrame, true);
|
2003-06-26 15:30:17 +04:00
|
|
|
for (kidFrame = mAbsoluteFrames.FirstChild(); kidFrame; kidFrame = kidFrame->GetNextSibling()) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool kidNeedsReflow = reflowAll || NS_SUBTREE_DIRTY(kidFrame) ||
|
2015-12-23 01:03:16 +03:00
|
|
|
FrameDependsOnContainer(kidFrame,
|
|
|
|
!!(aFlags & AbsPosReflowFlags::eCBWidthChanged),
|
|
|
|
!!(aFlags & AbsPosReflowFlags::eCBHeightChanged));
|
2009-04-22 03:53:52 +04:00
|
|
|
if (kidNeedsReflow && !aPresContext->HasPendingInterrupt()) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// Reflow the frame
|
2007-10-02 09:57:45 +04:00
|
|
|
nsReflowStatus kidStatus = NS_FRAME_COMPLETE;
|
2015-03-26 21:57:39 +03:00
|
|
|
const nsRect& cb = isGrid ? nsGridContainerFrame::GridItemCB(kidFrame)
|
|
|
|
: aContainingBlock;
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowAbsoluteFrame(aDelegatingFrame, aPresContext, aReflowInput, cb,
|
2015-12-23 01:03:16 +03:00
|
|
|
aFlags, kidFrame, kidStatus, aOverflowAreas);
|
2007-10-02 09:57:45 +04:00
|
|
|
nsIFrame* nextFrame = kidFrame->GetNextInFlow();
|
2014-11-24 19:42:31 +03:00
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(kidStatus) &&
|
|
|
|
aDelegatingFrame->IsFrameOfType(nsIFrame::eCanContainOverflowContainers)) {
|
2007-10-02 09:57:45 +04:00
|
|
|
// Need a continuation
|
|
|
|
if (!nextFrame) {
|
2013-03-20 05:47:49 +04:00
|
|
|
nextFrame =
|
|
|
|
aPresContext->PresShell()->FrameConstructor()->
|
|
|
|
CreateContinuingFrame(aPresContext, kidFrame, aDelegatingFrame);
|
2007-10-02 09:57:45 +04: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 17:39:41 +04:00
|
|
|
NS_MergeReflowStatusInto(&reflowStatus, kidStatus);
|
2007-10-02 09:57:45 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Delete any continuations
|
|
|
|
if (nextFrame) {
|
2013-06-10 22:31:59 +04:00
|
|
|
nsOverflowContinuationTracker::AutoFinish fini(&tracker, kidFrame);
|
2014-05-25 02:20:40 +04:00
|
|
|
nextFrame->GetParent()->DeleteNextInFlowChild(nextFrame, true);
|
2007-10-02 09:57:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tracker.Skip(kidFrame, reflowStatus);
|
2010-10-07 08:25:45 +04:00
|
|
|
if (aOverflowAreas) {
|
|
|
|
aDelegatingFrame->ConsiderChildOverflow(*aOverflowAreas, kidFrame);
|
2007-10-02 09:57:45 +04:00
|
|
|
}
|
2000-02-16 04:05:38 +03:00
|
|
|
}
|
2009-04-22 03:53:52 +04:00
|
|
|
|
2009-05-10 07:57:47 +04: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-22 03:53:52 +04:00
|
|
|
if (aDelegatingFrame->GetStateBits() & NS_FRAME_IS_DIRTY) {
|
|
|
|
kidFrame->AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
} else {
|
|
|
|
kidFrame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
}
|
|
|
|
}
|
1999-04-16 05:39:45 +04:00
|
|
|
}
|
2009-04-22 03:53:52 +04:00
|
|
|
|
2007-10-02 09:57:45 +04: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 17:39:41 +04:00
|
|
|
NS_MergeReflowStatusInto(&aReflowStatus, reflowStatus);
|
1999-04-16 05:39:45 +04:00
|
|
|
}
|
|
|
|
|
2010-08-31 20:05:12 +04: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-04 03:11:00 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2005-01-24 00:44:46 +03:00
|
|
|
nsAbsoluteContainingBlock::FrameDependsOnContainer(nsIFrame* f,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aCBWidthChanged,
|
|
|
|
bool aCBHeightChanged)
|
2004-11-14 23:22:58 +03:00
|
|
|
{
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStylePosition* pos = f->StylePosition();
|
2005-01-24 00:44:46 +03: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).
|
2016-07-21 13:36:35 +03:00
|
|
|
// See ReflowInput::InitAbsoluteConstraints -- these are the
|
2005-01-24 00:44:46 +03:00
|
|
|
// 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 18:59:28 +04:00
|
|
|
return true;
|
2005-01-24 00:44:46 +03:00
|
|
|
}
|
|
|
|
if (!aCBWidthChanged && !aCBHeightChanged) {
|
|
|
|
// skip getting style data
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2005-01-24 00:44:46 +03:00
|
|
|
}
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStylePadding* padding = f->StylePadding();
|
|
|
|
const nsStyleMargin* margin = f->StyleMargin();
|
2015-06-05 10:47:09 +03:00
|
|
|
WritingMode wm = f->GetWritingMode();
|
|
|
|
if (wm.IsVertical() ? aCBHeightChanged : aCBWidthChanged) {
|
|
|
|
// See if f's inline-size might have changed.
|
|
|
|
// If margin-inline-start/end, padding-inline-start/end,
|
|
|
|
// inline-size, min/max-inline-size are all lengths, 'none', or enumerated,
|
|
|
|
// then our frame isize does not depend on the parent isize.
|
|
|
|
// Note that borders never depend on the parent isize.
|
2007-11-15 21:10:31 +03:00
|
|
|
// XXX All of the enumerated values except -moz-available are ok too.
|
2015-06-05 10:47:09 +03:00
|
|
|
if (pos->ISizeDependsOnContainer(wm) ||
|
|
|
|
pos->MinISizeDependsOnContainer(wm) ||
|
|
|
|
pos->MaxISizeDependsOnContainer(wm) ||
|
|
|
|
!IsFixedPaddingSize(padding->mPadding.GetIStart(wm)) ||
|
|
|
|
!IsFixedPaddingSize(padding->mPadding.GetIEnd(wm))) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
2005-01-24 00:44:46 +03: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
|
2015-06-05 10:47:09 +03:00
|
|
|
if (!IsFixedMarginSize(margin->mMargin.GetIStart(wm)) ||
|
|
|
|
!IsFixedMarginSize(margin->mMargin.GetIEnd(wm))) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
2015-06-05 10:47:09 +03:00
|
|
|
if (!wm.IsBidiLTR()) {
|
|
|
|
// Note that even if 'istart' is a length, our position can
|
|
|
|
// still depend on the containing block isze, because if
|
|
|
|
// 'iend' is also a length we will discard 'istart' and be
|
|
|
|
// positioned relative to the containing block iend edge.
|
|
|
|
// 'istart' length and 'iend' auto is the only combination
|
2005-01-24 00:44:46 +03:00
|
|
|
// we can be sure of.
|
2015-06-05 10:47:09 +03:00
|
|
|
if (!IsFixedOffset(pos->mOffset.GetIStart(wm)) ||
|
|
|
|
pos->mOffset.GetIEndUnit(wm) != eStyleUnit_Auto) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
2005-01-24 00:44:46 +03:00
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
if (!IsFixedOffset(pos->mOffset.GetIStart(wm))) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
|
|
|
}
|
2005-01-24 00:44:46 +03:00
|
|
|
}
|
2015-06-05 10:47:09 +03:00
|
|
|
if (wm.IsVertical() ? aCBWidthChanged : aCBHeightChanged) {
|
|
|
|
// See if f's block-size might have changed.
|
|
|
|
// If margin-block-start/end, padding-block-start/end,
|
|
|
|
// min-block-size, and max-block-size are all lengths or 'none',
|
|
|
|
// and bsize is a length or bsize and bend are auto and bstart is not auto,
|
|
|
|
// then our frame bsize does not depend on the parent bsize.
|
|
|
|
// Note that borders never depend on the parent bsize.
|
|
|
|
if ((pos->BSizeDependsOnContainer(wm) &&
|
|
|
|
!(pos->BSize(wm).GetUnit() == eStyleUnit_Auto &&
|
|
|
|
pos->mOffset.GetBEndUnit(wm) == eStyleUnit_Auto &&
|
|
|
|
pos->mOffset.GetBStartUnit(wm) != eStyleUnit_Auto)) ||
|
|
|
|
pos->MinBSizeDependsOnContainer(wm) ||
|
|
|
|
pos->MaxBSizeDependsOnContainer(wm) ||
|
|
|
|
!IsFixedPaddingSize(padding->mPadding.GetBStart(wm)) ||
|
|
|
|
!IsFixedPaddingSize(padding->mPadding.GetBEnd(wm))) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2005-01-24 00:44:46 +03:00
|
|
|
}
|
2004-11-14 23:22:58 +03:00
|
|
|
|
2005-01-24 00:44:46 +03:00
|
|
|
// See if f's position might have changed.
|
2015-06-05 10:47:09 +03:00
|
|
|
if (!IsFixedMarginSize(margin->mMargin.GetBStart(wm)) ||
|
|
|
|
!IsFixedMarginSize(margin->mMargin.GetBEnd(wm))) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2005-01-24 00:44:46 +03:00
|
|
|
}
|
2015-06-05 10:47:09 +03:00
|
|
|
if (!IsFixedOffset(pos->mOffset.GetBStart(wm))) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
|
|
|
|
1999-07-24 06:37:45 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsAbsoluteContainingBlock::DestroyFrames(nsIFrame* aDelegatingFrame,
|
|
|
|
nsIFrame* aDestructRoot)
|
1999-07-24 06:37:45 +04:00
|
|
|
{
|
2009-12-24 08:21:15 +03:00
|
|
|
mAbsoluteFrames.DestroyFramesFrom(aDestructRoot);
|
1999-07-24 06:37:45 +04:00
|
|
|
}
|
|
|
|
|
2008-10-16 00:30:42 +04:00
|
|
|
void
|
|
|
|
nsAbsoluteContainingBlock::MarkSizeDependentFramesDirty()
|
2009-04-22 03:53:52 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
DoMarkFramesDirty(false);
|
2009-04-22 03:53:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsAbsoluteContainingBlock::MarkAllFramesDirty()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
DoMarkFramesDirty(true);
|
2009-04-22 03:53:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsAbsoluteContainingBlock::DoMarkFramesDirty(bool aMarkAllDirty)
|
2008-10-16 00:30:42 +04:00
|
|
|
{
|
2015-06-29 23:02:21 +03:00
|
|
|
for (nsIFrame* kidFrame : mAbsoluteFrames) {
|
2009-04-22 03:53:52 +04:00
|
|
|
if (aMarkAllDirty) {
|
|
|
|
kidFrame->AddStateBits(NS_FRAME_IS_DIRTY);
|
2011-10-17 18:59:28 +04:00
|
|
|
} else if (FrameDependsOnContainer(kidFrame, true, true)) {
|
2008-10-16 00:30:42 +04:00
|
|
|
// Add the weakest flags that will make sure we reflow this frame later
|
|
|
|
kidFrame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-31 18:58:18 +03:00
|
|
|
// Given an out-of-flow frame, this method returns the parent frame of
|
|
|
|
// its placeholder frame, if that parent is a nsContainerFrame.
|
|
|
|
static nsContainerFrame*
|
|
|
|
GetPlaceholderContainer(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aPositionedFrame)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aPositionedFrame, "need non-null frame");
|
|
|
|
MOZ_ASSERT(aPositionedFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW),
|
|
|
|
"expecting abspos frame");
|
|
|
|
MOZ_ASSERT(aPresContext && aPresContext == aPositionedFrame->PresContext(),
|
|
|
|
"need non-null pres context which matches our frame");
|
|
|
|
|
|
|
|
nsIFrame* placeholder =
|
|
|
|
aPresContext->PresShell()->GetPlaceholderFrameFor(aPositionedFrame);
|
|
|
|
|
|
|
|
if (!placeholder) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return do_QueryFrame(placeholder->GetParent());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function returns the offset of an abs/fixed-pos child's static
|
|
|
|
* position, with respect to the "start" corner of its alignment container,
|
|
|
|
* according to CSS Box Alignment. This function only operates in a single
|
|
|
|
* axis at a time -- callers can choose which axis via the |aAbsPosCBAxis|
|
|
|
|
* parameter.
|
|
|
|
*
|
|
|
|
* @param aKidReflowInput The ReflowInput for the to-be-aligned abspos child.
|
|
|
|
* @param aKidSizeInAbsPosCBWM The child frame's size (after it's been given
|
|
|
|
* the opportunity to reflow), in terms of the
|
|
|
|
* containing block's WritingMode.
|
|
|
|
* @param aPlaceholderContainer The parent of the child frame's corresponding
|
|
|
|
* placeholder frame, cast to a nsContainerFrame.
|
|
|
|
* (This will help us choose which alignment enum
|
|
|
|
* we should use for the child.)
|
|
|
|
* @param aAbsPosCBWM The child frame's containing block's WritingMode.
|
|
|
|
* @param aAbsPosCBAxis The axis (of the containing block) that we should
|
|
|
|
* be doing this computation for.
|
|
|
|
*/
|
|
|
|
static nscoord
|
|
|
|
OffsetToAlignedStaticPos(const ReflowInput& aKidReflowInput,
|
|
|
|
const LogicalSize& aKidSizeInAbsPosCBWM,
|
|
|
|
nsContainerFrame* aPlaceholderContainer,
|
|
|
|
WritingMode aAbsPosCBWM,
|
|
|
|
LogicalAxis aAbsPosCBAxis)
|
|
|
|
{
|
|
|
|
if (!aPlaceholderContainer) {
|
|
|
|
// (The placeholder container should be the thing that kicks this whole
|
|
|
|
// process off, by setting PLACEHOLDER_STATICPOS_NEEDS_CSSALIGN. So it
|
|
|
|
// should exist... but bail gracefully if it doesn't.)
|
|
|
|
NS_ERROR("Missing placeholder-container when computing a "
|
|
|
|
"CSS Box Alignment static position");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// (Most of this function is simply preparing args that we'll pass to
|
|
|
|
// AlignJustifySelf at the end.)
|
|
|
|
|
|
|
|
// NOTE: Our alignment container is aPlaceholderContainer's content-box
|
|
|
|
// (or an area within it, if aPlaceholderContainer is a grid). So, we'll
|
|
|
|
// perform most of our arithmetic/alignment in aPlaceholderContainer's
|
|
|
|
// WritingMode. For brevity, we use the abbreviation "pc" for "placeholder
|
|
|
|
// container" in variables below.
|
|
|
|
WritingMode pcWM = aPlaceholderContainer->GetWritingMode();
|
|
|
|
|
|
|
|
// Find what axis aAbsPosCBAxis corresponds to, in placeholder's parent's
|
|
|
|
// writing-mode.
|
|
|
|
LogicalAxis pcAxis = (pcWM.IsOrthogonalTo(aAbsPosCBWM)
|
|
|
|
? GetOrthogonalAxis(aAbsPosCBAxis)
|
|
|
|
: aAbsPosCBAxis);
|
|
|
|
|
|
|
|
nsIAtom* parentType = aPlaceholderContainer->GetType();
|
|
|
|
LogicalSize alignAreaSize(pcWM);
|
|
|
|
if (parentType == nsGkAtoms::flexContainerFrame) {
|
|
|
|
alignAreaSize = aPlaceholderContainer->GetLogicalSize(pcWM);
|
|
|
|
LogicalMargin pcBorderPadding =
|
|
|
|
aPlaceholderContainer->GetLogicalUsedBorderAndPadding(pcWM);
|
|
|
|
alignAreaSize -= pcBorderPadding.Size(pcWM);
|
|
|
|
} else {
|
|
|
|
NS_ERROR("Unsupported container for abpsos CSS Box Alignment");
|
|
|
|
return 0; // (leave the child at the start of its alignment container)
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord alignAreaSizeInAxis = (pcAxis == eLogicalAxisInline)
|
|
|
|
? alignAreaSize.ISize(pcWM)
|
|
|
|
: alignAreaSize.BSize(pcWM);
|
|
|
|
// XXXdholbert: Handle <overflow-position> in bug 1311892. For now, behave
|
|
|
|
// as if "unsafe" was the specified value (which is basically equivalent to
|
|
|
|
// the default behavior, when no value is specified -- though the default
|
|
|
|
// behavior also has some [at-risk] extra nuance about scroll containers...)
|
|
|
|
const bool overflowSafe = false;
|
|
|
|
|
|
|
|
uint16_t alignConst =
|
|
|
|
aPlaceholderContainer->CSSAlignmentForAbsPosChild(aKidReflowInput, pcAxis);
|
|
|
|
// XXX strip off <overflow-position> bits until we implement it (bug 1311892)
|
|
|
|
alignConst &= ~NS_STYLE_ALIGN_FLAG_BITS;
|
|
|
|
|
|
|
|
// Find out if placeholder-container & the OOF child have the same start-sides
|
|
|
|
// in the placeholder-container's pcAxis.
|
|
|
|
WritingMode kidWM = aKidReflowInput.GetWritingMode();
|
|
|
|
bool sameSidePCAndKid = pcWM.ParallelAxisStartsOnSameSide(pcAxis, kidWM);
|
|
|
|
|
|
|
|
// (baselineAdjust is unused. CSSAlignmentForAbsPosChild() should've
|
|
|
|
// converted 'baseline'/'last-baseline' enums to their fallback values.)
|
|
|
|
const nscoord baselineAdjust = nscoord(0);
|
|
|
|
|
|
|
|
// AlignJustifySelf operates in the kid's writing mode, so we need to
|
|
|
|
// represent the child's size and the desired axis in that writing mode:
|
|
|
|
LogicalSize kidSizeInOwnWM = aKidSizeInAbsPosCBWM.ConvertTo(kidWM,
|
|
|
|
aAbsPosCBWM);
|
|
|
|
LogicalAxis kidAxis = (kidWM.IsOrthogonalTo(aAbsPosCBWM)
|
|
|
|
? GetOrthogonalAxis(aAbsPosCBAxis)
|
|
|
|
: aAbsPosCBAxis);
|
|
|
|
|
|
|
|
nscoord offset =
|
|
|
|
CSSAlignUtils::AlignJustifySelf(alignConst, overflowSafe,
|
|
|
|
kidAxis, sameSidePCAndKid, baselineAdjust,
|
|
|
|
alignAreaSizeInAxis, aKidReflowInput,
|
|
|
|
kidSizeInOwnWM);
|
|
|
|
|
|
|
|
// "offset" is in terms of the CSS Box Alignment container (i.e. it's in
|
|
|
|
// terms of pcWM). But our return value needs to in terms of the containing
|
|
|
|
// block's writing mode, which might have the opposite directionality in the
|
|
|
|
// given axis. In that case, we just need to negate "offset" when returning,
|
|
|
|
// to make it have the right effect as an offset for coordinates in the
|
|
|
|
// containing block's writing mode.
|
|
|
|
if (!pcWM.ParallelAxisStartsOnSameSide(pcAxis, aAbsPosCBWM)) {
|
|
|
|
return -offset;
|
|
|
|
}
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
2016-10-31 18:58:18 +03:00
|
|
|
void
|
|
|
|
nsAbsoluteContainingBlock::ResolveSizeDependentOffsets(
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
ReflowInput& aKidReflowInput,
|
|
|
|
const LogicalSize& aKidSize,
|
|
|
|
const LogicalMargin& aMargin,
|
|
|
|
LogicalMargin* aOffsets,
|
|
|
|
LogicalSize* aLogicalCBSize)
|
|
|
|
{
|
|
|
|
WritingMode wm = aKidReflowInput.GetWritingMode();
|
|
|
|
WritingMode outerWM = aKidReflowInput.mParentReflowInput->GetWritingMode();
|
|
|
|
|
2016-10-31 18:58:18 +03:00
|
|
|
// Now that we know the child's size, we resolve any sentinel values in its
|
|
|
|
// IStart/BStart offset coordinates that depend on that size.
|
|
|
|
// * NS_AUTOOFFSET indicates that the child's position in the given axis
|
|
|
|
// is determined by its end-wards offset property, combined with its size and
|
|
|
|
// available space. e.g.: "top: auto; height: auto; bottom: 50px"
|
|
|
|
// * m{I,B}OffsetsResolvedAfterSize indicate that the child is using its
|
|
|
|
// static position in that axis, *and* its static position is determined by
|
|
|
|
// the axis-appropriate css-align property (which may require the child's
|
|
|
|
// size, e.g. to center it within the parent).
|
2016-10-31 18:58:18 +03:00
|
|
|
if ((NS_AUTOOFFSET == aOffsets->IStart(outerWM)) ||
|
2016-10-31 18:58:18 +03:00
|
|
|
(NS_AUTOOFFSET == aOffsets->BStart(outerWM)) ||
|
|
|
|
aKidReflowInput.mFlags.mIOffsetsNeedCSSAlign ||
|
|
|
|
aKidReflowInput.mFlags.mBOffsetsNeedCSSAlign) {
|
2016-10-31 18:58:18 +03:00
|
|
|
if (-1 == aLogicalCBSize->ISize(wm)) {
|
|
|
|
// Get the containing block width/height
|
|
|
|
const ReflowInput* parentRI = aKidReflowInput.mParentReflowInput;
|
|
|
|
*aLogicalCBSize =
|
|
|
|
aKidReflowInput.ComputeContainingBlockRectangle(aPresContext,
|
|
|
|
parentRI);
|
|
|
|
}
|
|
|
|
|
2016-10-31 18:58:18 +03:00
|
|
|
const LogicalSize logicalCBSizeOuterWM = aLogicalCBSize->ConvertTo(outerWM,
|
|
|
|
wm);
|
|
|
|
|
|
|
|
// placeholderContainer is used in each of the m{I,B}OffsetsNeedCSSAlign
|
|
|
|
// clauses. We declare it at this scope so we can avoid having to look
|
|
|
|
// it up twice (and only look it up if it's needed).
|
|
|
|
nsContainerFrame* placeholderContainer = nullptr;
|
|
|
|
|
2016-10-31 18:58:18 +03:00
|
|
|
if (NS_AUTOOFFSET == aOffsets->IStart(outerWM)) {
|
|
|
|
NS_ASSERTION(NS_AUTOOFFSET != aOffsets->IEnd(outerWM),
|
|
|
|
"Can't solve for both start and end");
|
|
|
|
aOffsets->IStart(outerWM) =
|
2016-10-31 18:58:18 +03:00
|
|
|
logicalCBSizeOuterWM.ISize(outerWM) -
|
2016-10-31 18:58:18 +03:00
|
|
|
aOffsets->IEnd(outerWM) - aMargin.IStartEnd(outerWM) -
|
|
|
|
aKidSize.ISize(outerWM);
|
2016-10-31 18:58:18 +03:00
|
|
|
} else if (aKidReflowInput.mFlags.mIOffsetsNeedCSSAlign) {
|
|
|
|
placeholderContainer = GetPlaceholderContainer(aPresContext,
|
|
|
|
aKidReflowInput.mFrame);
|
|
|
|
nscoord offset = OffsetToAlignedStaticPos(aKidReflowInput, aKidSize,
|
|
|
|
placeholderContainer,
|
|
|
|
outerWM, eLogicalAxisInline);
|
|
|
|
// Shift IStart from its current position (at start corner of the
|
|
|
|
// alignment container) by the returned offset. And set IEnd to the
|
|
|
|
// distance between the kid's end edge to containing block's end edge.
|
|
|
|
aOffsets->IStart(outerWM) += offset;
|
|
|
|
aOffsets->IEnd(outerWM) =
|
|
|
|
logicalCBSizeOuterWM.ISize(outerWM) -
|
|
|
|
(aOffsets->IStart(outerWM) + aKidSize.ISize(outerWM));
|
2016-10-31 18:58:18 +03:00
|
|
|
}
|
2016-10-31 18:58:18 +03:00
|
|
|
|
2016-10-31 18:58:18 +03:00
|
|
|
if (NS_AUTOOFFSET == aOffsets->BStart(outerWM)) {
|
|
|
|
aOffsets->BStart(outerWM) =
|
2016-10-31 18:58:18 +03:00
|
|
|
logicalCBSizeOuterWM.BSize(outerWM) -
|
2016-10-31 18:58:18 +03:00
|
|
|
aOffsets->BEnd(outerWM) - aMargin.BStartEnd(outerWM) -
|
|
|
|
aKidSize.BSize(outerWM);
|
2016-10-31 18:58:18 +03:00
|
|
|
} else if (aKidReflowInput.mFlags.mBOffsetsNeedCSSAlign) {
|
|
|
|
if (!placeholderContainer) {
|
|
|
|
placeholderContainer = GetPlaceholderContainer(aPresContext,
|
|
|
|
aKidReflowInput.mFrame);
|
|
|
|
}
|
|
|
|
nscoord offset = OffsetToAlignedStaticPos(aKidReflowInput, aKidSize,
|
|
|
|
placeholderContainer,
|
|
|
|
outerWM, eLogicalAxisBlock);
|
|
|
|
// Shift BStart from its current position (at start corner of the
|
|
|
|
// alignment container) by the returned offset. And set BEnd to the
|
|
|
|
// distance between the kid's end edge to containing block's end edge.
|
|
|
|
aOffsets->BStart(outerWM) += offset;
|
|
|
|
aOffsets->BEnd(outerWM) =
|
|
|
|
logicalCBSizeOuterWM.BSize(outerWM) -
|
|
|
|
(aOffsets->BStart(outerWM) + aKidSize.BSize(outerWM));
|
2016-10-31 18:58:18 +03:00
|
|
|
}
|
|
|
|
aKidReflowInput.SetComputedLogicalOffsets(aOffsets->ConvertTo(wm, outerWM));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-16 05:39:45 +04: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...
|
2003-01-20 21:04:34 +03:00
|
|
|
|
|
|
|
// When bug 154892 is checked in, make sure that when
|
2013-04-01 19:26:01 +04:00
|
|
|
// mChildListID == kFixedList, the height is unconstrained.
|
2003-01-20 21:04:34 +03:00
|
|
|
// since we don't allow replicated frames to split.
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
1999-07-24 06:37:45 +04:00
|
|
|
nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
|
2013-04-15 12:31:45 +04:00
|
|
|
nsPresContext* aPresContext,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2013-04-15 12:31:45 +04:00
|
|
|
const nsRect& aContainingBlock,
|
2015-12-23 01:03:16 +03:00
|
|
|
AbsPosReflowFlags aFlags,
|
1999-04-16 05:39:45 +04:00
|
|
|
nsIFrame* aKidFrame,
|
2007-07-16 22:55:24 +04:00
|
|
|
nsReflowStatus& aStatus,
|
2010-10-07 08:25:45 +04:00
|
|
|
nsOverflowAreas* aOverflowAreas)
|
1999-04-16 05:39:45 +04:00
|
|
|
{
|
2002-11-16 13:41:10 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (nsBlockFrame::gNoisyReflow) {
|
|
|
|
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent);
|
|
|
|
printf("abs pos ");
|
2016-01-05 08:20:00 +03:00
|
|
|
nsAutoString name;
|
|
|
|
aKidFrame->GetFrameName(name);
|
|
|
|
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
|
2002-11-16 13:41:10 +03:00
|
|
|
|
|
|
|
char width[16];
|
|
|
|
char height[16];
|
2016-07-21 13:36:39 +03:00
|
|
|
PrettyUC(aReflowInput.AvailableWidth(), width, 16);
|
|
|
|
PrettyUC(aReflowInput.AvailableHeight(), height, 16);
|
2002-11-16 13:41:10 +03:00
|
|
|
printf(" a=%s,%s ", width, height);
|
2016-07-21 13:36:39 +03:00
|
|
|
PrettyUC(aReflowInput.ComputedWidth(), width, 16);
|
|
|
|
PrettyUC(aReflowInput.ComputedHeight(), height, 16);
|
2002-11-16 13:41:10 +03:00
|
|
|
printf("c=%s,%s \n", width, height);
|
|
|
|
}
|
2005-03-23 06:35:08 +03:00
|
|
|
AutoNoisyIndenter indent(nsBlockFrame::gNoisy);
|
2002-11-16 13:41:10 +03:00
|
|
|
#endif // DEBUG
|
|
|
|
|
2014-07-24 12:28:46 +04:00
|
|
|
WritingMode wm = aKidFrame->GetWritingMode();
|
2015-06-04 13:43:02 +03:00
|
|
|
LogicalSize logicalCBSize(wm, aContainingBlock.Size());
|
|
|
|
nscoord availISize = logicalCBSize.ISize(wm);
|
2014-07-24 12:28:46 +04:00
|
|
|
if (availISize == -1) {
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_ASSERTION(aReflowInput.ComputedSize(wm).ISize(wm) !=
|
2014-07-24 12:28:46 +04:00
|
|
|
NS_UNCONSTRAINEDSIZE,
|
|
|
|
"Must have a useful inline-size _somewhere_");
|
|
|
|
availISize =
|
2016-07-21 13:36:39 +03:00
|
|
|
aReflowInput.ComputedSizeWithPadding(wm).ISize(wm);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
2012-10-10 09:00:05 +04:00
|
|
|
|
2015-12-23 01:03:16 +03:00
|
|
|
uint32_t rsFlags = 0;
|
|
|
|
if (aFlags & AbsPosReflowFlags::eIsGridContainerCB) {
|
|
|
|
// When a grid container generates the abs.pos. CB for a *child* then
|
|
|
|
// the static-position is the CB origin (i.e. of the grid area rect).
|
|
|
|
// https://drafts.csswg.org/css-grid/#static-position
|
|
|
|
nsIFrame* placeholder =
|
|
|
|
aPresContext->PresShell()->GetPlaceholderFrameFor(aKidFrame);
|
|
|
|
if (placeholder && placeholder->GetParent() == aDelegatingFrame) {
|
2016-07-21 13:36:35 +03:00
|
|
|
rsFlags |= ReflowInput::STATIC_POS_IS_CB_ORIGIN;
|
2015-12-23 01:03:16 +03:00
|
|
|
}
|
|
|
|
}
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowInput kidReflowInput(aPresContext, aReflowInput, aKidFrame,
|
2014-07-24 12:28:46 +04:00
|
|
|
LogicalSize(wm, availISize,
|
|
|
|
NS_UNCONSTRAINEDSIZE),
|
2015-12-23 01:03:16 +03:00
|
|
|
&logicalCBSize, rsFlags);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2013-04-15 12:31:45 +04:00
|
|
|
// Get the border values
|
2016-07-21 13:36:39 +03:00
|
|
|
WritingMode outerWM = aReflowInput.GetWritingMode();
|
2015-06-05 10:47:09 +03:00
|
|
|
const LogicalMargin border(outerWM,
|
2016-07-21 13:36:39 +03:00
|
|
|
aReflowInput.mStyleBorder->GetComputedBorder());
|
2015-06-05 10:47:09 +03:00
|
|
|
const LogicalMargin margin =
|
2016-07-21 13:36:39 +03:00
|
|
|
kidReflowInput.ComputedLogicalMargin().ConvertTo(outerWM, wm);
|
|
|
|
bool constrainBSize = (aReflowInput.AvailableBSize() != NS_UNCONSTRAINEDSIZE)
|
2015-12-23 01:03:16 +03:00
|
|
|
&& (aFlags & AbsPosReflowFlags::eConstrainHeight)
|
2007-10-02 12:29:23 +04:00
|
|
|
// Don't split if told not to (e.g. for fixed frames)
|
2011-04-30 03:02:33 +04:00
|
|
|
&& (aDelegatingFrame->GetType() != nsGkAtoms::inlineFrame)
|
2007-10-02 09:57:45 +04:00
|
|
|
//XXX we don't handle splitting frames for inline absolute containing blocks yet
|
2015-07-16 12:07:57 +03:00
|
|
|
&& (aKidFrame->GetLogicalRect(aContainingBlock.Size()).BStart(wm) <=
|
2016-07-21 13:36:39 +03:00
|
|
|
aReflowInput.AvailableBSize());
|
2007-10-02 09:57:45 +04: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.
|
2015-06-05 10:47:09 +03:00
|
|
|
if (constrainBSize) {
|
2016-07-21 13:36:39 +03:00
|
|
|
kidReflowInput.AvailableBSize() =
|
|
|
|
aReflowInput.AvailableBSize() - border.ConvertTo(wm, outerWM).BStart(wm) -
|
|
|
|
kidReflowInput.ComputedLogicalMargin().BStart(wm);
|
|
|
|
if (NS_AUTOOFFSET != kidReflowInput.ComputedLogicalOffsets().BStart(wm)) {
|
|
|
|
kidReflowInput.AvailableBSize() -=
|
|
|
|
kidReflowInput.ComputedLogicalOffsets().BStart(wm);
|
2015-06-05 10:47:09 +03:00
|
|
|
}
|
2007-10-02 09:57:45 +04:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// Do the reflow
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowOutput kidDesiredSize(kidReflowInput);
|
|
|
|
aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowInput, aStatus);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
const LogicalSize kidSize = kidDesiredSize.Size(wm).ConvertTo(outerWM, wm);
|
2013-04-15 12:31:45 +04:00
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
LogicalMargin offsets =
|
2016-07-21 13:36:39 +03:00
|
|
|
kidReflowInput.ComputedLogicalOffsets().ConvertTo(outerWM, wm);
|
2015-06-05 10:47:09 +03:00
|
|
|
|
|
|
|
// If we're solving for start in either inline or block direction,
|
|
|
|
// then compute it now that we know the dimensions.
|
2016-10-31 18:58:18 +03:00
|
|
|
ResolveSizeDependentOffsets(aPresContext, kidReflowInput, kidSize, margin,
|
|
|
|
&offsets, &logicalCBSize);
|
2004-11-27 02:28:09 +03:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// Position the child relative to our padding edge
|
2015-06-05 10:47:09 +03:00
|
|
|
LogicalRect rect(outerWM,
|
|
|
|
border.IStart(outerWM) + offsets.IStart(outerWM) +
|
|
|
|
margin.IStart(outerWM),
|
|
|
|
border.BStart(outerWM) + offsets.BStart(outerWM) +
|
|
|
|
margin.BStart(outerWM),
|
|
|
|
kidSize.ISize(outerWM), kidSize.BSize(outerWM));
|
|
|
|
nsRect r =
|
2015-07-16 12:07:57 +03:00
|
|
|
rect.GetPhysicalRect(outerWM, logicalCBSize.GetPhysicalSize(wm) +
|
|
|
|
border.Size(outerWM).GetPhysicalSize(outerWM));
|
2013-04-15 12:31:45 +04: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
|
2015-12-23 01:03:16 +03:00
|
|
|
// positioned based on its containing block and we don't need to offset
|
|
|
|
// (unless the caller demands it (the STATIC_POS_IS_CB_ORIGIN case)).
|
2013-04-15 12:31:45 +04:00
|
|
|
if (aContainingBlock.TopLeft() != nsPoint(0, 0)) {
|
2016-07-21 13:36:39 +03:00
|
|
|
const nsStyleSides& offsets = kidReflowInput.mStylePosition->mOffset;
|
2015-06-05 10:47:09 +03:00
|
|
|
if (!(offsets.GetLeftUnit() == eStyleUnit_Auto &&
|
2015-12-23 01:03:16 +03:00
|
|
|
offsets.GetRightUnit() == eStyleUnit_Auto) ||
|
2016-07-21 13:36:35 +03:00
|
|
|
(rsFlags & ReflowInput::STATIC_POS_IS_CB_ORIGIN)) {
|
2015-06-05 10:47:09 +03:00
|
|
|
r.x += aContainingBlock.x;
|
2013-04-15 12:31:45 +04:00
|
|
|
}
|
2015-06-05 10:47:09 +03:00
|
|
|
if (!(offsets.GetTopUnit() == eStyleUnit_Auto &&
|
2015-12-23 01:03:16 +03:00
|
|
|
offsets.GetBottomUnit() == eStyleUnit_Auto) ||
|
2016-07-21 13:36:35 +03:00
|
|
|
(rsFlags & ReflowInput::STATIC_POS_IS_CB_ORIGIN)) {
|
2015-06-05 10:47:09 +03:00
|
|
|
r.y += aContainingBlock.y;
|
2013-04-15 12:31:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
aKidFrame->SetRect(r);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2013-01-03 17:23:11 +04:00
|
|
|
nsView* view = aKidFrame->GetView();
|
2007-05-02 04:07:51 +04:00
|
|
|
if (view) {
|
|
|
|
// Size and position the view and set its opacity, visibility, content
|
|
|
|
// transparency, and clip
|
2010-10-07 08:25:45 +04:00
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame, view,
|
|
|
|
kidDesiredSize.VisualOverflow());
|
2007-05-02 04:07:51 +04:00
|
|
|
} else {
|
|
|
|
nsContainerFrame::PositionChildViews(aKidFrame);
|
|
|
|
}
|
2007-02-26 17:00:21 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
aKidFrame->DidReflow(aPresContext, &kidReflowInput,
|
2015-06-05 10:47:09 +03:00
|
|
|
nsDidReflowStatus::FINISHED);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2002-11-16 13:41:10 +03:00
|
|
|
#ifdef DEBUG
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (nsBlockFrame::gNoisyReflow) {
|
|
|
|
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent - 1);
|
|
|
|
printf("abs pos ");
|
2016-01-05 08:20:00 +03:00
|
|
|
nsAutoString name;
|
|
|
|
aKidFrame->GetFrameName(name);
|
|
|
|
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
|
2009-09-18 15:09:35 +04:00
|
|
|
printf("%p rect=%d,%d,%d,%d\n", static_cast<void*>(aKidFrame),
|
2015-06-05 10:47:09 +03:00
|
|
|
r.x, r.y, r.width, r.height);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
2002-11-16 13:41:10 +03:00
|
|
|
#endif
|
2004-11-27 02:28:09 +03:00
|
|
|
|
2010-10-07 08:25:45 +04:00
|
|
|
if (aOverflowAreas) {
|
2015-06-05 10:47:09 +03:00
|
|
|
aOverflowAreas->UnionWith(kidDesiredSize.mOverflowAreas + r.TopLeft());
|
2010-10-07 08:25:45 +04:00
|
|
|
}
|
1999-04-16 05:39:45 +04:00
|
|
|
}
|