2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1999-04-16 05:39:45 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
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.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* 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
|
|
|
|
* either 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"),
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
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"
|
2002-05-10 22:22:41 +04:00
|
|
|
#include "nsReflowPath.h"
|
1999-04-16 05:39:45 +04:00
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsLayoutAtoms.h"
|
1999-07-24 06:37:45 +04:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsHTMLParts.h"
|
1999-12-06 18:49:53 +03:00
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIFrameManager.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-11-24 09:03:41 +03:00
|
|
|
nsIPresContext* aPresContext,
|
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
|
1999-07-24 06:37:45 +04:00
|
|
|
nsAbsoluteContainingBlock::AppendFrames(nsIFrame* aDelegatingFrame,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsIPresContext* aPresContext,
|
1999-07-24 06:37:45 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// Append the frames to our list of absolutely positioned frames
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsFrame::VerifyDirtyBitSet(aFrameList);
|
|
|
|
#endif
|
|
|
|
mAbsoluteFrames.AppendFrames(nsnull, aFrameList);
|
|
|
|
|
|
|
|
// Generate a reflow command to reflow the dirty frames
|
2001-12-18 01:39:59 +03:00
|
|
|
nsHTMLReflowCommand* reflowCmd;
|
|
|
|
rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, eReflowType_ReflowDirty);
|
1999-07-24 06:37:45 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2003-01-20 21:04:34 +03:00
|
|
|
reflowCmd->SetChildListName(GetChildListName());
|
1999-07-24 06:37:45 +04:00
|
|
|
aPresShell.AppendReflowCommand(reflowCmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsAbsoluteContainingBlock::InsertFrames(nsIFrame* aDelegatingFrame,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsIPresContext* aPresContext,
|
1999-07-24 06:37:45 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// Insert the new frames
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsFrame::VerifyDirtyBitSet(aFrameList);
|
|
|
|
#endif
|
|
|
|
mAbsoluteFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
|
|
|
|
|
|
|
|
// Generate a reflow command to reflow the dirty frames
|
2001-12-18 01:39:59 +03:00
|
|
|
nsHTMLReflowCommand* reflowCmd;
|
|
|
|
rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, eReflowType_ReflowDirty);
|
1999-07-24 06:37:45 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2003-01-20 21:04:34 +03:00
|
|
|
reflowCmd->SetChildListName(GetChildListName());
|
1999-07-24 06:37:45 +04:00
|
|
|
aPresShell.AppendReflowCommand(reflowCmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsAbsoluteContainingBlock::RemoveFrame(nsIFrame* aDelegatingFrame,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsIPresContext* aPresContext,
|
1999-07-24 06:37:45 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
|
|
|
PRBool result = mAbsoluteFrames.DestroyFrame(aPresContext, aOldFrame);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2002-11-12 06:30:13 +03:00
|
|
|
nsresult
|
|
|
|
nsAbsoluteContainingBlock::ReplaceFrame(nsIFrame* aDelegatingFrame,
|
|
|
|
nsIPresContext* aPresContext,
|
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame,
|
|
|
|
nsIFrame* aNewFrame)
|
|
|
|
{
|
|
|
|
PRBool result = mAbsoluteFrames.ReplaceFrame(aPresContext, aDelegatingFrame,
|
|
|
|
aOldFrame, aNewFrame, PR_TRUE);
|
|
|
|
NS_ASSERTION(result, "Problems replacing a frame");
|
|
|
|
return result ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-07-24 06:37:45 +04:00
|
|
|
nsresult
|
|
|
|
nsAbsoluteContainingBlock::Reflow(nsIFrame* aDelegatingFrame,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsIPresContext* aPresContext,
|
1999-09-16 18:33:19 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nscoord aContainingBlockWidth,
|
1999-12-06 18:49:53 +03:00
|
|
|
nscoord aContainingBlockHeight,
|
2003-01-20 21:04:34 +03:00
|
|
|
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
|
|
|
|
2002-06-12 07:21:00 +04:00
|
|
|
// Make a copy of the reflow state. If the reason is
|
|
|
|
// eReflowReason_Incremental (which should mean either that the target
|
|
|
|
// is the frame for which this is the absolute container or that the
|
|
|
|
// container changed size due to incremental reflow of its children),
|
|
|
|
// then change it to eReflowReason_Resize.
|
2002-09-24 15:43:48 +04:00
|
|
|
// XXXldb If the target is this frame, shouldn't we be setting it
|
|
|
|
// appropriately (which might mean to StyleChanged)?
|
1999-04-16 05:39:45 +04:00
|
|
|
nsHTMLReflowState reflowState(aReflowState);
|
|
|
|
if (eReflowReason_Incremental == reflowState.reason) {
|
|
|
|
reflowState.reason = eReflowReason_Resize;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* kidFrame;
|
|
|
|
for (kidFrame = mAbsoluteFrames.FirstChild(); nsnull != kidFrame; kidFrame->GetNextSibling(&kidFrame)) {
|
2000-05-04 04:39:01 +04:00
|
|
|
nsReflowReason reason = reflowState.reason;
|
2000-05-02 06:23:31 +04:00
|
|
|
|
2000-02-16 04:05:38 +03:00
|
|
|
nsFrameState kidState;
|
|
|
|
kidFrame->GetFrameState(&kidState);
|
|
|
|
if (NS_FRAME_FIRST_REFLOW & kidState) {
|
2000-05-02 06:23:31 +04:00
|
|
|
// The frame has never had a reflow, so change the reason to eReflowReason_Initial
|
|
|
|
reason = eReflowReason_Initial;
|
|
|
|
|
|
|
|
} else if (NS_FRAME_IS_DIRTY & kidState) {
|
|
|
|
// The frame is dirty so give it the correct reflow reason
|
|
|
|
reason = eReflowReason_Dirty;
|
2000-02-16 04:05:38 +03:00
|
|
|
}
|
|
|
|
|
1999-04-16 05:39:45 +04:00
|
|
|
// Reflow the frame
|
|
|
|
nsReflowStatus kidStatus;
|
1999-09-16 18:33:19 +04:00
|
|
|
ReflowAbsoluteFrame(aDelegatingFrame, aPresContext, reflowState, aContainingBlockWidth,
|
2000-05-02 06:23:31 +04:00
|
|
|
aContainingBlockHeight, kidFrame, reason, kidStatus);
|
1999-12-06 18:49:53 +03:00
|
|
|
|
2003-01-20 21:04:34 +03:00
|
|
|
if (aChildBounds) {
|
|
|
|
// Add in the child's bounds
|
|
|
|
nsRect kidBounds;
|
|
|
|
kidFrame->GetRect(kidBounds);
|
|
|
|
aChildBounds->UnionRect(*aChildBounds, kidBounds);
|
|
|
|
|
|
|
|
// If the frame has visible overflow, then take it into account, too.
|
|
|
|
nsFrameState kidFrameState;
|
|
|
|
kidFrame->GetFrameState(&kidFrameState);
|
|
|
|
if (kidFrameState & NS_FRAME_OUTSIDE_CHILDREN) {
|
|
|
|
// Get the property
|
2003-05-31 14:32:19 +04:00
|
|
|
nsRect* overflowArea = kidFrame->GetOverflowAreaProperty(aPresContext);
|
2003-01-20 21:04:34 +03:00
|
|
|
|
|
|
|
if (overflowArea) {
|
|
|
|
// The overflow area is in the child's coordinate space, so translate
|
|
|
|
// it into the parent's coordinate space
|
|
|
|
nsRect rect(*overflowArea);
|
|
|
|
|
|
|
|
rect.MoveBy(kidBounds.x, kidBounds.y);
|
|
|
|
aChildBounds->UnionRect(*aChildBounds, rect);
|
|
|
|
}
|
1999-12-06 18:49:53 +03:00
|
|
|
}
|
|
|
|
}
|
1999-04-16 05:39:45 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-12-06 18:49:53 +03:00
|
|
|
void
|
|
|
|
nsAbsoluteContainingBlock::CalculateChildBounds(nsIPresContext* aPresContext,
|
|
|
|
nsRect& aChildBounds)
|
|
|
|
{
|
2002-09-24 15:43:48 +04:00
|
|
|
// Initialize the OUT parameters
|
|
|
|
aChildBounds.SetRect(0, 0, 0, 0);
|
|
|
|
|
1999-12-06 18:49:53 +03:00
|
|
|
for (nsIFrame* f = mAbsoluteFrames.FirstChild(); f; f->GetNextSibling(&f)) {
|
|
|
|
// Add in the child's bounds
|
|
|
|
nsRect bounds;
|
|
|
|
f->GetRect(bounds);
|
|
|
|
aChildBounds.UnionRect(aChildBounds, bounds);
|
|
|
|
|
|
|
|
// If the frame has visible overflow, then take it into account, too.
|
|
|
|
nsFrameState frameState;
|
|
|
|
f->GetFrameState(&frameState);
|
|
|
|
if (frameState & NS_FRAME_OUTSIDE_CHILDREN) {
|
|
|
|
// Get the property
|
2003-05-31 14:32:19 +04:00
|
|
|
nsRect* overflowArea = f->GetOverflowAreaProperty(aPresContext);
|
1999-12-06 18:49:53 +03:00
|
|
|
|
|
|
|
if (overflowArea) {
|
|
|
|
// The overflow area is in the child's coordinate space, so translate
|
|
|
|
// it into the parent's coordinate space
|
|
|
|
nsRect rect(*overflowArea);
|
|
|
|
|
|
|
|
rect.MoveBy(bounds.x, bounds.y);
|
|
|
|
aChildBounds.UnionRect(aChildBounds, rect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-16 05:39:45 +04:00
|
|
|
nsresult
|
1999-07-24 06:37:45 +04:00
|
|
|
nsAbsoluteContainingBlock::IncrementalReflow(nsIFrame* aDelegatingFrame,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsIPresContext* aPresContext,
|
1999-04-16 05:39:45 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-09-16 18:33:19 +04:00
|
|
|
nscoord aContainingBlockWidth,
|
|
|
|
nscoord aContainingBlockHeight,
|
2002-09-24 15:43:48 +04:00
|
|
|
PRBool& aWasHandled)
|
1999-04-16 05:39:45 +04:00
|
|
|
{
|
2002-09-24 15:43:48 +04:00
|
|
|
// Initialize the OUT parameters
|
2002-10-24 06:39:31 +04:00
|
|
|
// Assume we handled the incremental reflow
|
|
|
|
// until we find something that requires a full block reflow
|
|
|
|
aWasHandled = PR_TRUE;
|
1999-04-16 05:39:45 +04:00
|
|
|
|
2002-05-10 22:22:41 +04:00
|
|
|
// See if the reflow command is targeted at us.
|
|
|
|
nsReflowPath *path = aReflowState.path;
|
|
|
|
nsHTMLReflowCommand *command = path->mReflowCommand;
|
1999-04-16 05:39:45 +04:00
|
|
|
|
2002-05-10 22:22:41 +04:00
|
|
|
if (command) {
|
1999-07-24 06:37:45 +04:00
|
|
|
// It's targeted at us. See if it's for the positioned child frames
|
2002-05-10 22:22:41 +04:00
|
|
|
nsCOMPtr<nsIAtom> listName;
|
|
|
|
command->GetChildListName(*getter_AddRefs(listName));
|
1999-04-16 05:39:45 +04:00
|
|
|
|
2003-01-20 21:04:34 +03:00
|
|
|
if (GetChildListName() == listName) {
|
2001-12-18 01:39:59 +03:00
|
|
|
nsReflowType type;
|
1999-04-16 05:39:45 +04:00
|
|
|
|
|
|
|
// Get the type of reflow command
|
2002-05-10 22:22:41 +04:00
|
|
|
command->GetType(type);
|
1999-04-16 05:39:45 +04:00
|
|
|
|
1999-07-24 06:37:45 +04:00
|
|
|
// The only type of reflow command we expect is that we have dirty
|
|
|
|
// child frames to reflow
|
2002-09-24 15:43:48 +04:00
|
|
|
NS_ASSERTION(type == eReflowType_ReflowDirty, "unexpected reflow type");
|
1999-04-16 05:39:45 +04:00
|
|
|
|
1999-07-24 06:37:45 +04:00
|
|
|
// Walk the positioned frames and reflow the dirty frames
|
|
|
|
for (nsIFrame* f = mAbsoluteFrames.FirstChild(); f; f->GetNextSibling(&f)) {
|
|
|
|
nsFrameState frameState;
|
1999-04-16 05:39:45 +04:00
|
|
|
|
1999-07-24 06:37:45 +04:00
|
|
|
f->GetFrameState(&frameState);
|
|
|
|
if (frameState & NS_FRAME_IS_DIRTY) {
|
1999-04-16 05:39:45 +04:00
|
|
|
nsReflowStatus status;
|
2000-05-02 06:23:31 +04:00
|
|
|
nsReflowReason reason;
|
1999-07-27 18:15:42 +04:00
|
|
|
|
2002-05-10 22:22:41 +04:00
|
|
|
reason = (frameState & NS_FRAME_FIRST_REFLOW)
|
|
|
|
? eReflowReason_Initial
|
|
|
|
: eReflowReason_Dirty;
|
|
|
|
|
1999-07-24 06:37:45 +04:00
|
|
|
ReflowAbsoluteFrame(aDelegatingFrame, aPresContext, aReflowState,
|
1999-09-16 18:33:19 +04:00
|
|
|
aContainingBlockWidth, aContainingBlockHeight, f,
|
2000-05-02 06:23:31 +04:00
|
|
|
reason, status);
|
1999-04-16 05:39:45 +04:00
|
|
|
}
|
|
|
|
}
|
2002-09-24 15:43:48 +04:00
|
|
|
} else {
|
2002-10-24 06:39:31 +04:00
|
|
|
// A reflow command is targeted directly at this block.
|
|
|
|
// The block will have to do a proper reflow.
|
|
|
|
// But keep going to make sure that we process any dirty absolute frames, below.
|
|
|
|
aWasHandled = PR_FALSE;
|
1999-04-16 05:39:45 +04:00
|
|
|
}
|
2002-05-10 22:22:41 +04:00
|
|
|
}
|
1999-04-16 05:39:45 +04:00
|
|
|
|
2002-05-10 22:22:41 +04:00
|
|
|
nsReflowPath::iterator iter = path->FirstChild();
|
|
|
|
nsReflowPath::iterator end = path->EndChildren();
|
|
|
|
|
|
|
|
if (iter != end && mAbsoluteFrames.NotEmpty()) {
|
|
|
|
for ( ; iter != end; ++iter) {
|
|
|
|
// See if it's one of our absolutely positioned child frames
|
|
|
|
if (mAbsoluteFrames.ContainsFrame(*iter)) {
|
|
|
|
// Remove the next frame from the reflow path
|
|
|
|
nsReflowStatus kidStatus;
|
|
|
|
ReflowAbsoluteFrame(aDelegatingFrame, aPresContext, aReflowState,
|
|
|
|
aContainingBlockWidth, aContainingBlockHeight, *iter,
|
|
|
|
aReflowState.reason, kidStatus);
|
|
|
|
|
|
|
|
// We don't need to invalidate anything because the frame
|
|
|
|
// should invalidate any area within its frame that needs
|
|
|
|
// repainting, and because it has a view if it changes size
|
|
|
|
// the view manager will damage the dirty area
|
|
|
|
|
|
|
|
// Prune the path so we don't flow the block frame _again_
|
|
|
|
// when returning to the caller.
|
|
|
|
aReflowState.path->Remove(iter);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// At least one of the frames along the reflow path wasn't
|
|
|
|
// absolutely positioned, so we'll need to deal with it in
|
|
|
|
// normal block reflow.
|
|
|
|
aWasHandled = PR_FALSE;
|
|
|
|
}
|
1999-04-16 05:39:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-24 06:37:45 +04:00
|
|
|
void
|
|
|
|
nsAbsoluteContainingBlock::DestroyFrames(nsIFrame* aDelegatingFrame,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsIPresContext* aPresContext)
|
1999-07-24 06:37:45 +04:00
|
|
|
{
|
|
|
|
mAbsoluteFrames.DestroyFrames(aPresContext);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
// GetChildListName() == nsLayoutAtoms::fixedList, the height is unconstrained.
|
|
|
|
// 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,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsIPresContext* 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,
|
2000-05-02 06:23:31 +04:00
|
|
|
nsReflowReason aReason,
|
1999-04-16 05:39:45 +04:00
|
|
|
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);
|
|
|
|
printf("%s ", NS_LossyConvertUCS2toASCII(name).get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("r=%d",aReflowState.reason);
|
|
|
|
|
|
|
|
if (aReflowState.reason == eReflowReason_Incremental) {
|
|
|
|
nsHTMLReflowCommand *command = aReflowState.path->mReflowCommand;
|
|
|
|
|
|
|
|
if (command) {
|
|
|
|
// We're the target.
|
|
|
|
nsReflowType type;
|
|
|
|
command->GetType(type);
|
|
|
|
printf("(%d)", type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
char width[16];
|
|
|
|
char height[16];
|
|
|
|
PrettyUC(aReflowState.availableWidth, width);
|
|
|
|
PrettyUC(aReflowState.availableHeight, height);
|
|
|
|
printf(" a=%s,%s ", width, height);
|
|
|
|
PrettyUC(aReflowState.mComputedWidth, width);
|
|
|
|
PrettyUC(aReflowState.mComputedHeight, height);
|
|
|
|
printf("c=%s,%s \n", width, height);
|
|
|
|
}
|
|
|
|
if (nsBlockFrame::gNoisy) {
|
|
|
|
nsBlockFrame::gNoiseIndent++;
|
|
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
|
1999-04-16 05:39:45 +04:00
|
|
|
nsresult rv;
|
|
|
|
nsMargin border;
|
|
|
|
// Get the border values
|
2001-02-07 12:57:26 +03:00
|
|
|
if (!aReflowState.mStyleBorder->GetBorder(border)) {
|
1999-07-28 08:48:34 +04:00
|
|
|
NS_NOTYETIMPLEMENTED("percentage border");
|
|
|
|
}
|
2002-09-24 15:43:48 +04:00
|
|
|
|
2000-05-02 06:23:31 +04:00
|
|
|
nsFrameState kidFrameState;
|
1999-10-30 06:52:11 +04:00
|
|
|
nsSize availSize(aReflowState.mComputedWidth, NS_UNCONSTRAINEDSIZE);
|
|
|
|
nsHTMLReflowMetrics kidDesiredSize(nsnull);
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
|
|
|
|
availSize, aContainingBlockWidth,
|
2002-05-10 22:22:41 +04:00
|
|
|
aContainingBlockHeight,
|
|
|
|
aReason);
|
1999-04-16 05:39:45 +04:00
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
// Send the WillReflow() notification and position the frame
|
|
|
|
aKidFrame->WillReflow(aPresContext);
|
2001-09-18 03:55:58 +04:00
|
|
|
|
|
|
|
// XXXldb We can simplify this if we come up with a better way to
|
|
|
|
// position views.
|
|
|
|
nscoord x;
|
2000-04-16 08:07:02 +04:00
|
|
|
if (NS_AUTOOFFSET == kidReflowState.mComputedOffsets.left) {
|
2000-05-02 06:23:31 +04:00
|
|
|
// Just use the current x-offset
|
2000-04-16 08:07:02 +04:00
|
|
|
nsPoint origin;
|
|
|
|
aKidFrame->GetOrigin(origin);
|
|
|
|
x = origin.x;
|
|
|
|
} else {
|
|
|
|
x = border.left + kidReflowState.mComputedOffsets.left + kidReflowState.mComputedMargin.left;
|
|
|
|
}
|
1999-11-24 09:03:41 +03:00
|
|
|
aKidFrame->MoveTo(aPresContext,
|
2000-04-16 08:07:02 +04:00
|
|
|
x, border.top + kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2001-09-06 00:27:19 +04:00
|
|
|
// Position its view, but don't bother it doing it now if we haven't
|
|
|
|
// yet determined the left offset
|
2000-04-16 08:07:02 +04:00
|
|
|
if (NS_AUTOOFFSET != kidReflowState.mComputedOffsets.left) {
|
2001-09-06 00:27:19 +04:00
|
|
|
nsContainerFrame::PositionFrameView(aPresContext, aKidFrame);
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
1999-11-19 18:33:29 +03:00
|
|
|
|
|
|
|
// Do the reflow
|
1999-10-30 06:52:11 +04:00
|
|
|
rv = aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
|
|
|
|
|
2000-04-16 08:07:02 +04:00
|
|
|
// 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
|
2000-04-29 01:05:31 +04:00
|
|
|
kidReflowState.ComputeContainingBlockRectangle(aPresContext,
|
|
|
|
&aReflowState,
|
2000-04-16 08:07:02 +04:00
|
|
|
aContainingBlockWidth,
|
|
|
|
aContainingBlockHeight);
|
1999-10-30 06:52:11 +04:00
|
|
|
}
|
1999-07-27 04:48:47 +04:00
|
|
|
|
2000-04-16 08:07:02 +04:00
|
|
|
if (NS_AUTOOFFSET == kidReflowState.mComputedOffsets.left) {
|
|
|
|
kidReflowState.mComputedOffsets.left = aContainingBlockWidth -
|
2002-05-17 04:05:27 +04:00
|
|
|
kidReflowState.mComputedOffsets.right -
|
|
|
|
kidReflowState.mComputedMargin.right -
|
|
|
|
kidDesiredSize.width -
|
|
|
|
kidReflowState.mComputedMargin.left;
|
1999-07-20 06:48:18 +04:00
|
|
|
}
|
2000-04-16 08:07:02 +04:00
|
|
|
if (NS_AUTOOFFSET == kidReflowState.mComputedOffsets.top) {
|
|
|
|
kidReflowState.mComputedOffsets.top = aContainingBlockHeight -
|
2002-05-17 04:05:27 +04:00
|
|
|
kidReflowState.mComputedOffsets.bottom -
|
|
|
|
kidReflowState.mComputedMargin.bottom -
|
|
|
|
kidDesiredSize.height -
|
|
|
|
kidReflowState.mComputedMargin.top;
|
1999-04-16 05:39:45 +04:00
|
|
|
}
|
|
|
|
}
|
1999-10-30 06:52:11 +04: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);
|
1999-11-24 09:03:41 +03:00
|
|
|
aKidFrame->SetRect(aPresContext, rect);
|
1999-04-16 05:39:45 +04:00
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
// Size and position the view and set its opacity, visibility, content
|
|
|
|
// transparency, and clip
|
2003-06-20 03:44:01 +04:00
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame,
|
|
|
|
aKidFrame->GetView(aPresContext),
|
1999-12-06 18:49:53 +03:00
|
|
|
&kidDesiredSize.mOverflowArea);
|
2001-12-07 17:51:12 +03:00
|
|
|
aKidFrame->DidReflow(aPresContext, &kidReflowState, NS_FRAME_REFLOW_FINISHED);
|
1999-04-16 05:39:45 +04:00
|
|
|
|
1999-12-06 18:49:53 +03:00
|
|
|
// If the frame has visible overflow, then store it as a property on the
|
|
|
|
// frame. This allows us to be able to recover it without having to reflow
|
|
|
|
// the frame
|
|
|
|
aKidFrame->GetFrameState(&kidFrameState);
|
|
|
|
if (kidFrameState & NS_FRAME_OUTSIDE_CHILDREN) {
|
|
|
|
// Get the property (creating a rect struct if necessary)
|
2003-05-31 14:32:19 +04:00
|
|
|
nsRect* overflowArea = aKidFrame->GetOverflowAreaProperty(aPresContext, PR_TRUE);
|
1999-12-06 18:49:53 +03:00
|
|
|
|
2002-09-24 15:43:48 +04:00
|
|
|
NS_ASSERTION(overflowArea, "should have created rect");
|
1999-12-06 18:49:53 +03:00
|
|
|
if (overflowArea) {
|
|
|
|
*overflowArea = kidDesiredSize.mOverflowArea;
|
1999-04-16 05:39:45 +04:00
|
|
|
}
|
|
|
|
}
|
2002-11-16 13:41:10 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (nsBlockFrame::gNoisy) {
|
|
|
|
nsBlockFrame::gNoiseIndent--;
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
printf("%s ", NS_LossyConvertUCS2toASCII(name).get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("%p rect=%d,%d,%d,%d", aKidFrame, rect.x, rect.y, rect.width, rect.height);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
#endif
|
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 {
|
|
|
|
if(0xdeadbeef == aSize)
|
|
|
|
{
|
|
|
|
strcpy(aBuf, "deadbeef");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sprintf(aBuf, "%d", aSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|