2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-04-16 05:39:45 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-04-16 05:39:45 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-04-16 05:39:45 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
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-12-06 18:49:53 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1999-04-16 05:39:45 +04:00
|
|
|
#include "nsAbsoluteContainingBlock.h"
|
|
|
|
#include "nsContainerFrame.h"
|
1999-07-24 06:37:45 +04:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsHTMLParts.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1999-04-16 05:39:45 +04:00
|
|
|
|
2002-11-16 13:41:10 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
#include "nsBlockFrame.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1999-04-16 05:39:45 +04:00
|
|
|
nsresult
|
1999-07-24 06:37:45 +04:00
|
|
|
nsAbsoluteContainingBlock::FirstChild(const nsIFrame* aDelegatingFrame,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame** aFirstChild) const
|
1999-04-16 05:39:45 +04:00
|
|
|
{
|
2003-01-20 21:04:34 +03:00
|
|
|
NS_PRECONDITION(GetChildListName() == aListName, "unexpected child list name");
|
1999-04-16 05:39:45 +04:00
|
|
|
*aFirstChild = mAbsoluteFrames.FirstChild();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-07-24 06:37:45 +04:00
|
|
|
nsAbsoluteContainingBlock::SetInitialChildList(nsIFrame* aDelegatingFrame,
|
1999-04-16 05:39:45 +04:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
|
|
|
{
|
2003-01-20 21:04:34 +03:00
|
|
|
NS_PRECONDITION(GetChildListName() == aListName, "unexpected child list name");
|
1999-07-24 06:37:45 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsFrame::VerifyDirtyBitSet(aChildList);
|
|
|
|
#endif
|
1999-04-16 05:39:45 +04:00
|
|
|
mAbsoluteFrames.SetFrames(aChildList);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2005-02-07 04:58:25 +03:00
|
|
|
nsAbsoluteContainingBlock::AppendFrames(nsIFrame* aDelegatingFrame,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
1999-07-24 06:37:45 +04:00
|
|
|
{
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(GetChildListName() == aListName, "unexpected child list");
|
|
|
|
|
1999-07-24 06:37:45 +04:00
|
|
|
// Append the frames to our list of absolutely positioned frames
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsFrame::VerifyDirtyBitSet(aFrameList);
|
|
|
|
#endif
|
|
|
|
mAbsoluteFrames.AppendFrames(nsnull, aFrameList);
|
|
|
|
|
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
|
2007-03-31 01:11:41 +04:00
|
|
|
return 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
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2005-02-07 04:58:25 +03:00
|
|
|
nsAbsoluteContainingBlock::InsertFrames(nsIFrame* aDelegatingFrame,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
1999-07-24 06:37:45 +04:00
|
|
|
{
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(GetChildListName() == aListName, "unexpected child list");
|
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == aDelegatingFrame,
|
|
|
|
"inserting after sibling frame with different parent");
|
|
|
|
|
1999-07-24 06:37:45 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsFrame::VerifyDirtyBitSet(aFrameList);
|
|
|
|
#endif
|
|
|
|
mAbsoluteFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
|
|
|
|
|
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
|
2007-03-31 01:11:41 +04:00
|
|
|
return 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
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsAbsoluteContainingBlock::RemoveFrame(nsIFrame* aDelegatingFrame,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(GetChildListName() == aListName, "unexpected child list");
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
PRBool result = mAbsoluteFrames.DestroyFrame(aOldFrame);
|
1999-07-24 06:37:45 +04:00
|
|
|
NS_ASSERTION(result, "didn't find frame to delete");
|
|
|
|
// Because positioned frames aren't part of a flow, there's no additional
|
|
|
|
// work to do, e.g. reflowing sibling frames. And because positioned frames
|
|
|
|
// have a view, we don't need to repaint
|
1999-07-27 18:15:42 +04:00
|
|
|
return result ? NS_OK : NS_ERROR_FAILURE;
|
1999-07-24 06:37:45 +04:00
|
|
|
}
|
|
|
|
|
2005-01-24 00:44:46 +03:00
|
|
|
static void
|
|
|
|
AddFrameToChildBounds(nsIFrame* aKidFrame, nsRect* aChildBounds)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aKidFrame, "Must have kid frame");
|
|
|
|
|
|
|
|
if (!aChildBounds) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add in the child's bounds
|
|
|
|
nsRect kidBounds = aKidFrame->GetRect();
|
|
|
|
nsRect* kidOverflow = aKidFrame->GetOverflowAreaProperty();
|
|
|
|
if (kidOverflow) {
|
|
|
|
// Put it in the parent's coordinate system
|
|
|
|
kidBounds = *kidOverflow + kidBounds.TopLeft();
|
|
|
|
}
|
|
|
|
aChildBounds->UnionRect(*aChildBounds, kidBounds);
|
|
|
|
}
|
|
|
|
|
1999-07-24 06:37:45 +04:00
|
|
|
nsresult
|
|
|
|
nsAbsoluteContainingBlock::Reflow(nsIFrame* aDelegatingFrame,
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* aPresContext,
|
1999-09-16 18:33:19 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nscoord aContainingBlockWidth,
|
1999-12-06 18:49:53 +03:00
|
|
|
nscoord aContainingBlockHeight,
|
2005-01-24 00:44:46 +03:00
|
|
|
PRBool aCBWidthChanged,
|
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
|
|
|
PRBool aCBHeightChanged,
|
|
|
|
nsRect* aChildBounds)
|
1999-04-16 05:39:45 +04:00
|
|
|
{
|
1999-12-06 18:49:53 +03:00
|
|
|
// Initialize OUT parameter
|
2003-01-20 21:04:34 +03:00
|
|
|
if (aChildBounds)
|
|
|
|
aChildBounds->SetRect(0, 0, 0, 0);
|
1999-12-06 18:49:53 +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
|
|
|
PRBool reflowAll = aReflowState.ShouldReflowAllKids();
|
1999-04-16 05:39:45 +04:00
|
|
|
|
|
|
|
nsIFrame* kidFrame;
|
2003-06-26 15:30:17 +04:00
|
|
|
for (kidFrame = mAbsoluteFrames.FirstChild(); kidFrame; kidFrame = kidFrame->GetNextSibling()) {
|
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 (reflowAll ||
|
2007-05-06 23:16:51 +04:00
|
|
|
NS_SUBTREE_DIRTY(kidFrame) ||
|
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
|
|
|
FrameDependsOnContainer(kidFrame, aCBWidthChanged, aCBHeightChanged)) {
|
|
|
|
// Reflow the frame
|
|
|
|
nsReflowStatus kidStatus;
|
|
|
|
ReflowAbsoluteFrame(aDelegatingFrame, aPresContext, aReflowState, aContainingBlockWidth,
|
|
|
|
aContainingBlockHeight, kidFrame, kidStatus);
|
2000-05-02 06:23:31 +04:00
|
|
|
|
2000-02-16 04:05:38 +03:00
|
|
|
}
|
2005-01-24 00:44:46 +03:00
|
|
|
AddFrameToChildBounds(kidFrame, aChildBounds);
|
1999-04-16 05:39:45 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-05-04 03:11:00 +04:00
|
|
|
static inline PRBool IsFixedPaddingSize(nsStyleUnit aUnit) {
|
2007-05-05 21:01:51 +04:00
|
|
|
return aUnit == eStyleUnit_Coord || aUnit == eStyleUnit_Null ||
|
|
|
|
aUnit == eStyleUnit_Chars;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
2007-05-04 03:11:00 +04:00
|
|
|
static inline PRBool IsFixedMarginSize(nsStyleUnit aUnit) {
|
2007-05-05 21:01:51 +04:00
|
|
|
return aUnit == eStyleUnit_Coord || aUnit == eStyleUnit_Null ||
|
|
|
|
aUnit == eStyleUnit_Chars;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
2007-05-04 03:11:00 +04:00
|
|
|
static inline PRBool IsFixedMaxSize(nsStyleUnit aUnit) {
|
2007-05-05 21:01:51 +04:00
|
|
|
return aUnit == eStyleUnit_Null || aUnit == eStyleUnit_Coord ||
|
|
|
|
aUnit == eStyleUnit_Chars;
|
|
|
|
}
|
|
|
|
static inline PRBool IsFixedOffset(nsStyleUnit aUnit) {
|
|
|
|
return aUnit == eStyleUnit_Coord || aUnit == eStyleUnit_Chars;
|
|
|
|
}
|
|
|
|
static inline PRBool IsFixedHeight(nsStyleUnit aUnit) {
|
|
|
|
return aUnit == eStyleUnit_Coord || aUnit == eStyleUnit_Chars;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
|
|
|
|
2007-05-04 03:11:00 +04:00
|
|
|
static inline PRBool IsFixedWidth(const nsStyleCoord& aCoord)
|
|
|
|
{
|
|
|
|
return aCoord.GetUnit() == eStyleUnit_Coord ||
|
2007-05-05 21:01:51 +04:00
|
|
|
aCoord.GetUnit() == eStyleUnit_Chars ||
|
2007-05-04 03:11:00 +04:00
|
|
|
(aCoord.GetUnit() == eStyleUnit_Enumerated &&
|
2007-05-10 06:55:15 +04:00
|
|
|
(aCoord.GetIntValue() == NS_STYLE_WIDTH_INTRINSIC ||
|
|
|
|
aCoord.GetIntValue() == NS_STYLE_WIDTH_MIN_INTRINSIC));
|
2007-05-04 03:11:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline PRBool IsFixedMaxWidth(const nsStyleCoord& aCoord)
|
|
|
|
{
|
|
|
|
return aCoord.GetUnit() == eStyleUnit_Null ||
|
|
|
|
IsFixedWidth(aCoord);
|
|
|
|
}
|
|
|
|
|
2004-11-14 23:22:58 +03:00
|
|
|
PRBool
|
2005-01-24 00:44:46 +03:00
|
|
|
nsAbsoluteContainingBlock::FrameDependsOnContainer(nsIFrame* f,
|
|
|
|
PRBool aCBWidthChanged,
|
|
|
|
PRBool aCBHeightChanged)
|
2004-11-14 23:22:58 +03:00
|
|
|
{
|
2005-01-24 00:44:46 +03:00
|
|
|
const nsStylePosition* pos = f->GetStylePosition();
|
|
|
|
// 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)) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
if (!aCBWidthChanged && !aCBHeightChanged) {
|
|
|
|
// skip getting style data
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
const nsStylePadding* padding = f->GetStylePadding();
|
|
|
|
const nsStyleMargin* margin = f->GetStyleMargin();
|
|
|
|
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.
|
2005-04-29 19:44:38 +04:00
|
|
|
// Note that borders never depend on the parent width
|
2007-05-04 03:11:00 +04:00
|
|
|
// XXX All of the enumerated values except -moz-fill are ok too.
|
|
|
|
if (!IsFixedWidth(pos->mWidth) ||
|
|
|
|
!IsFixedWidth(pos->mMinWidth) ||
|
|
|
|
!IsFixedMaxWidth(pos->mMaxWidth) ||
|
2005-01-24 00:44:46 +03:00
|
|
|
!IsFixedPaddingSize(padding->mPadding.GetLeftUnit()) ||
|
|
|
|
!IsFixedPaddingSize(padding->mPadding.GetRightUnit())) {
|
2004-11-14 23:22:58 +03:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
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
|
|
|
|
if (!IsFixedMarginSize(margin->mMargin.GetLeftUnit()) ||
|
|
|
|
!IsFixedMarginSize(margin->mMargin.GetRightUnit())) {
|
|
|
|
return PR_TRUE;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
2005-01-24 00:44:46 +03:00
|
|
|
if (f->GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
|
|
|
|
// 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.
|
2007-05-05 21:01:51 +04:00
|
|
|
if (!IsFixedOffset(pos->mOffset.GetLeftUnit()) ||
|
2005-01-24 00:44:46 +03:00
|
|
|
pos->mOffset.GetRightUnit() != eStyleUnit_Auto) {
|
2004-11-14 23:22:58 +03:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
2005-01-24 00:44:46 +03:00
|
|
|
} else {
|
2007-05-05 21:01:51 +04:00
|
|
|
if (!IsFixedOffset(pos->mOffset.GetLeftUnit())) {
|
2004-11-14 23:22:58 +03:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
2005-01-24 00:44:46 +03: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.
|
2005-04-29 19:44:38 +04:00
|
|
|
// Note that borders never depend on the parent height
|
2007-05-05 21:01:51 +04:00
|
|
|
if (!(IsFixedHeight(pos->mHeight.GetUnit()) ||
|
2005-01-24 00:44:46 +03:00
|
|
|
(pos->mHeight.GetUnit() == eStyleUnit_Auto &&
|
|
|
|
pos->mOffset.GetBottomUnit() == eStyleUnit_Auto &&
|
|
|
|
pos->mOffset.GetTopUnit() != eStyleUnit_Auto)) ||
|
2007-05-05 21:01:51 +04:00
|
|
|
!IsFixedHeight(pos->mMinHeight.GetUnit()) ||
|
2005-01-24 00:44:46 +03:00
|
|
|
!IsFixedMaxSize(pos->mMaxHeight.GetUnit()) ||
|
|
|
|
!IsFixedPaddingSize(padding->mPadding.GetTopUnit()) ||
|
|
|
|
!IsFixedPaddingSize(padding->mPadding.GetBottomUnit())) {
|
|
|
|
return PR_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 (!IsFixedMarginSize(margin->mMargin.GetTopUnit()) ||
|
|
|
|
!IsFixedMarginSize(margin->mMargin.GetBottomUnit())) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
2007-05-05 21:01:51 +04:00
|
|
|
if (!IsFixedOffset(pos->mOffset.GetTopUnit())) {
|
2005-01-24 00:44:46 +03:00
|
|
|
return PR_TRUE;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-07-24 06:37:45 +04:00
|
|
|
void
|
2006-04-10 04:16:29 +04:00
|
|
|
nsAbsoluteContainingBlock::DestroyFrames(nsIFrame* aDelegatingFrame)
|
1999-07-24 06:37:45 +04:00
|
|
|
{
|
2006-04-10 04:16:29 +04:00
|
|
|
mAbsoluteFrames.DestroyFrames();
|
1999-07-24 06:37:45 +04:00
|
|
|
}
|
|
|
|
|
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
|
2007-01-30 03:06:41 +03:00
|
|
|
// GetChildListName() == nsGkAtoms::fixedList, the height is unconstrained.
|
2003-01-20 21:04:34 +03:00
|
|
|
// since we don't allow replicated frames to split.
|
|
|
|
|
1999-04-16 05:39:45 +04:00
|
|
|
nsresult
|
1999-07-24 06:37:45 +04:00
|
|
|
nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* aPresContext,
|
1999-04-16 05:39:45 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-09-16 18:33:19 +04:00
|
|
|
nscoord aContainingBlockWidth,
|
|
|
|
nscoord aContainingBlockHeight,
|
1999-04-16 05:39:45 +04:00
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2002-11-16 13:41:10 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (nsBlockFrame::gNoisyReflow) {
|
|
|
|
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent);
|
|
|
|
printf("abs pos ");
|
|
|
|
if (nsnull != aKidFrame) {
|
|
|
|
nsIFrameDebug* frameDebug;
|
|
|
|
if (NS_SUCCEEDED(CallQueryInterface(aKidFrame, &frameDebug))) {
|
|
|
|
nsAutoString name;
|
|
|
|
frameDebug->GetFrameName(name);
|
2006-02-03 17:18:39 +03:00
|
|
|
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
|
2002-11-16 13:41:10 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char width[16];
|
|
|
|
char height[16];
|
|
|
|
PrettyUC(aReflowState.availableWidth, width);
|
|
|
|
PrettyUC(aReflowState.availableHeight, height);
|
|
|
|
printf(" a=%s,%s ", width, height);
|
2007-01-26 03:05:12 +03:00
|
|
|
PrettyUC(aReflowState.ComputedWidth(), width);
|
2002-11-16 13:41:10 +03:00
|
|
|
PrettyUC(aReflowState.mComputedHeight, height);
|
|
|
|
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
|
|
|
|
|
2007-02-26 17:00:21 +03:00
|
|
|
// Store position and overflow rect so taht we can invalidate the correct
|
|
|
|
// area if the position changes
|
|
|
|
nsRect oldOverflowRect(aKidFrame->GetOverflowRect() +
|
|
|
|
aKidFrame->GetPosition());
|
|
|
|
nsRect oldRect = aKidFrame->GetRect();
|
|
|
|
|
1999-04-16 05:39:45 +04:00
|
|
|
nsresult rv;
|
|
|
|
// Get the border values
|
2005-04-29 19:44:38 +04:00
|
|
|
const nsMargin& border = aReflowState.mStyleBorder->GetBorder();
|
2002-09-24 15:43:48 +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
|
|
|
nscoord availWidth = aContainingBlockWidth;
|
|
|
|
if (availWidth == -1) {
|
2007-01-26 03:05:12 +03:00
|
|
|
NS_ASSERTION(aReflowState.ComputedWidth() != NS_UNCONSTRAINEDSIZE,
|
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
|
|
|
"Must have a useful width _somewhere_");
|
|
|
|
availWidth =
|
2007-01-26 03:05:12 +03:00
|
|
|
aReflowState.ComputedWidth() + aReflowState.mComputedPadding.LeftRight();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
nsHTMLReflowMetrics kidDesiredSize;
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
|
|
|
|
nsSize(availWidth, NS_UNCONSTRAINEDSIZE),
|
|
|
|
aContainingBlockWidth,
|
|
|
|
aContainingBlockHeight);
|
|
|
|
|
|
|
|
// Send the WillReflow() notification and position the frame
|
|
|
|
aKidFrame->WillReflow(aPresContext);
|
|
|
|
|
|
|
|
// XXXldb We can simplify this if we come up with a better way to
|
|
|
|
// position views.
|
|
|
|
nscoord x;
|
|
|
|
if (NS_AUTOOFFSET == kidReflowState.mComputedOffsets.left) {
|
|
|
|
// Just use the current x-offset
|
|
|
|
x = aKidFrame->GetPosition().x;
|
|
|
|
} else {
|
|
|
|
x = border.left + kidReflowState.mComputedOffsets.left + kidReflowState.mComputedMargin.left;
|
|
|
|
}
|
|
|
|
aKidFrame->SetPosition(nsPoint(x, border.top +
|
|
|
|
kidReflowState.mComputedOffsets.top +
|
|
|
|
kidReflowState.mComputedMargin.top));
|
|
|
|
|
|
|
|
// Do the reflow
|
|
|
|
rv = aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
|
|
|
|
|
|
|
|
// If we're solving for 'left' or 'top', then compute it now that we know the
|
|
|
|
// width/height
|
|
|
|
if ((NS_AUTOOFFSET == kidReflowState.mComputedOffsets.left) ||
|
|
|
|
(NS_AUTOOFFSET == kidReflowState.mComputedOffsets.top)) {
|
|
|
|
if (-1 == aContainingBlockWidth) {
|
|
|
|
// Get the containing block width/height
|
|
|
|
kidReflowState.ComputeContainingBlockRectangle(aPresContext,
|
|
|
|
&aReflowState,
|
|
|
|
aContainingBlockWidth,
|
|
|
|
aContainingBlockHeight);
|
2004-12-06 03:27:21 +03:00
|
|
|
}
|
|
|
|
|
2004-11-27 02:28:09 +03:00
|
|
|
if (NS_AUTOOFFSET == kidReflowState.mComputedOffsets.left) {
|
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
|
|
|
NS_ASSERTION(NS_AUTOOFFSET != kidReflowState.mComputedOffsets.right,
|
|
|
|
"Can't solve for both left and right");
|
|
|
|
kidReflowState.mComputedOffsets.left = aContainingBlockWidth -
|
|
|
|
kidReflowState.mComputedOffsets.right -
|
|
|
|
kidReflowState.mComputedMargin.right -
|
|
|
|
kidDesiredSize.width -
|
|
|
|
kidReflowState.mComputedMargin.left;
|
1999-10-30 06:52:11 +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
|
|
|
if (NS_AUTOOFFSET == kidReflowState.mComputedOffsets.top) {
|
|
|
|
kidReflowState.mComputedOffsets.top = aContainingBlockHeight -
|
|
|
|
kidReflowState.mComputedOffsets.bottom -
|
|
|
|
kidReflowState.mComputedMargin.bottom -
|
|
|
|
kidDesiredSize.height -
|
|
|
|
kidReflowState.mComputedMargin.top;
|
1999-04-16 05:39: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
|
|
|
}
|
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
|
|
|
|
nsRect rect(border.left + kidReflowState.mComputedOffsets.left + kidReflowState.mComputedMargin.left,
|
|
|
|
border.top + kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top,
|
|
|
|
kidDesiredSize.width, kidDesiredSize.height);
|
|
|
|
aKidFrame->SetRect(rect);
|
|
|
|
|
2007-05-02 04:07:51 +04:00
|
|
|
nsIView* view = aKidFrame->GetView();
|
|
|
|
if (view) {
|
|
|
|
// Size and position the view and set its opacity, visibility, content
|
|
|
|
// transparency, and clip
|
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame,
|
|
|
|
view,
|
|
|
|
&kidDesiredSize.mOverflowArea);
|
|
|
|
} else {
|
|
|
|
nsContainerFrame::PositionChildViews(aKidFrame);
|
|
|
|
}
|
2007-02-26 17:00:21 +03:00
|
|
|
|
|
|
|
if (oldRect.TopLeft() != rect.TopLeft() ||
|
2007-03-27 07:58:17 +04:00
|
|
|
(aDelegatingFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) ||
|
|
|
|
((aKidFrame->GetStyleDisplay()->mClipFlags & NS_STYLE_CLIP_RECT) &&
|
|
|
|
(kidDesiredSize.mOverflowArea != oldOverflowRect))) {
|
2007-02-26 17:00:21 +03:00
|
|
|
// The frame moved; we have to invalidate the whole frame
|
|
|
|
// because the children may have moved after they were reflowed
|
2007-03-27 07:58:17 +04:00
|
|
|
// We also have to invalidate when we're clipping and the overflow
|
|
|
|
// changes; the style code doesn't know how to deal with this case
|
|
|
|
// XXX This could be optimized in some cases, especially clipping changes
|
2007-02-26 17:00:21 +03:00
|
|
|
aKidFrame->GetParent()->Invalidate(oldOverflowRect);
|
|
|
|
aKidFrame->GetParent()->Invalidate(kidDesiredSize.mOverflowArea +
|
|
|
|
rect.TopLeft());
|
|
|
|
} else if (oldRect.Size() != rect.Size()) {
|
|
|
|
// Invalidate the area where the frame changed size.
|
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
|
|
|
nscoord innerWidth = PR_MIN(oldRect.width, rect.width);
|
|
|
|
nscoord innerHeight = PR_MIN(oldRect.height, rect.height);
|
|
|
|
nscoord outerWidth = PR_MAX(oldRect.width, rect.width);
|
|
|
|
nscoord outerHeight = PR_MAX(oldRect.height, rect.height);
|
|
|
|
aKidFrame->GetParent()->Invalidate(
|
|
|
|
nsRect(rect.x + innerWidth, rect.y, outerWidth - innerWidth, outerHeight));
|
|
|
|
// Invalidate the horizontal strip
|
|
|
|
aKidFrame->GetParent()->Invalidate(
|
|
|
|
nsRect(rect.x, rect.y + innerHeight, outerWidth, outerHeight - innerHeight));
|
|
|
|
}
|
|
|
|
aKidFrame->DidReflow(aPresContext, &kidReflowState, NS_FRAME_REFLOW_FINISHED);
|
|
|
|
|
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 ");
|
|
|
|
if (nsnull != aKidFrame) {
|
|
|
|
nsIFrameDebug* frameDebug;
|
|
|
|
if (NS_SUCCEEDED(CallQueryInterface(aKidFrame, &frameDebug))) {
|
|
|
|
nsAutoString name;
|
|
|
|
frameDebug->GetFrameName(name);
|
|
|
|
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
|
2002-11-16 13:41:10 +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
|
|
|
printf("%p rect=%d,%d,%d,%d", aKidFrame, rect.x, rect.y, rect.width, rect.height);
|
|
|
|
printf("\n");
|
|
|
|
}
|
2002-11-16 13:41:10 +03:00
|
|
|
#endif
|
2004-11-27 02:28:09 +03:00
|
|
|
|
1999-12-06 18:49:53 +03:00
|
|
|
return rv;
|
1999-04-16 05:39:45 +04:00
|
|
|
}
|
2002-11-16 13:41:10 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void nsAbsoluteContainingBlock::PrettyUC(nscoord aSize,
|
|
|
|
char* aBuf)
|
|
|
|
{
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == aSize) {
|
|
|
|
strcpy(aBuf, "UC");
|
|
|
|
}
|
|
|
|
else {
|
2004-11-14 23:22:58 +03:00
|
|
|
if((PRInt32)0xdeadbeef == aSize)
|
2002-11-16 13:41:10 +03:00
|
|
|
{
|
|
|
|
strcpy(aBuf, "deadbeef");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sprintf(aBuf, "%d", aSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|