1999-04-16 05:39:45 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
#include "nsAbsoluteContainingBlock.h"
|
|
|
|
#include "nsContainerFrame.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
|
|
|
#include "nsIAreaFrame.h"
|
|
|
|
#include "nsIReflowCommand.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsLayoutAtoms.h"
|
1999-07-24 06:37:45 +04:00
|
|
|
#include "nsIReflowCommand.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsHTMLParts.h"
|
1999-04-16 05:39:45 +04:00
|
|
|
|
|
|
|
static NS_DEFINE_IID(kAreaFrameIID, NS_IAREAFRAME_IID);
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsLayoutAtoms::absoluteList == aListName, "unexpected child list name");
|
|
|
|
*aFirstChild = mAbsoluteFrames.FirstChild();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-07-24 06:37:45 +04:00
|
|
|
nsAbsoluteContainingBlock::SetInitialChildList(nsIFrame* aDelegatingFrame,
|
|
|
|
nsIPresContext& aPresContext,
|
1999-04-16 05:39:45 +04:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsLayoutAtoms::absoluteList == 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,
|
|
|
|
nsIPresContext& aPresContext,
|
|
|
|
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
|
|
|
|
nsIReflowCommand* reflowCmd;
|
|
|
|
rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, nsIReflowCommand::ReflowDirty);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
reflowCmd->SetChildListName(nsLayoutAtoms::absoluteList);
|
|
|
|
aPresShell.AppendReflowCommand(reflowCmd);
|
|
|
|
NS_RELEASE(reflowCmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsAbsoluteContainingBlock::InsertFrames(nsIFrame* aDelegatingFrame,
|
|
|
|
nsIPresContext& aPresContext,
|
|
|
|
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
|
|
|
|
nsIReflowCommand* reflowCmd;
|
|
|
|
rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, nsIReflowCommand::ReflowDirty);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
reflowCmd->SetChildListName(nsLayoutAtoms::absoluteList);
|
|
|
|
aPresShell.AppendReflowCommand(reflowCmd);
|
|
|
|
NS_RELEASE(reflowCmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsAbsoluteContainingBlock::RemoveFrame(nsIFrame* aDelegatingFrame,
|
|
|
|
nsIPresContext& aPresContext,
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsAbsoluteContainingBlock::Reflow(nsIFrame* aDelegatingFrame,
|
|
|
|
nsIPresContext& aPresContext,
|
1999-04-16 05:39:45 +04:00
|
|
|
const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
// Make a copy of the reflow state. If the reason is eReflowReason_Incremental,
|
|
|
|
// then change it to eReflowReason_Resize
|
|
|
|
nsHTMLReflowState reflowState(aReflowState);
|
|
|
|
if (eReflowReason_Incremental == reflowState.reason) {
|
|
|
|
reflowState.reason = eReflowReason_Resize;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* kidFrame;
|
|
|
|
for (kidFrame = mAbsoluteFrames.FirstChild(); nsnull != kidFrame; kidFrame->GetNextSibling(&kidFrame)) {
|
|
|
|
// Reflow the frame
|
|
|
|
nsReflowStatus kidStatus;
|
1999-07-24 06:37:45 +04:00
|
|
|
ReflowAbsoluteFrame(aDelegatingFrame, aPresContext, reflowState, kidFrame,
|
|
|
|
PR_FALSE, kidStatus);
|
1999-04-16 05:39:45 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-07-24 06:37:45 +04:00
|
|
|
nsAbsoluteContainingBlock::IncrementalReflow(nsIFrame* aDelegatingFrame,
|
|
|
|
nsIPresContext& aPresContext,
|
1999-04-16 05:39:45 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
PRBool& aWasHandled)
|
|
|
|
{
|
|
|
|
// Initialize the OUT paremeter
|
|
|
|
aWasHandled = PR_FALSE;
|
|
|
|
|
|
|
|
// See if the reflow command is targeted at us
|
|
|
|
nsIFrame* targetFrame;
|
|
|
|
aReflowState.reflowCommand->GetTarget(targetFrame);
|
|
|
|
|
|
|
|
if (aReflowState.frame == targetFrame) {
|
|
|
|
nsIAtom* listName;
|
|
|
|
PRBool isAbsoluteChild;
|
|
|
|
|
1999-07-24 06:37:45 +04:00
|
|
|
// It's targeted at us. See if it's for the positioned child frames
|
1999-04-16 05:39:45 +04:00
|
|
|
aReflowState.reflowCommand->GetChildListName(listName);
|
|
|
|
isAbsoluteChild = nsLayoutAtoms::absoluteList == listName;
|
|
|
|
NS_IF_RELEASE(listName);
|
|
|
|
|
|
|
|
if (isAbsoluteChild) {
|
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
|
|
|
|
// Get the type of reflow command
|
|
|
|
aReflowState.reflowCommand->GetType(type);
|
|
|
|
|
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
|
|
|
|
NS_ASSERTION(nsIReflowCommand::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;
|
1999-07-27 18:15:42 +04:00
|
|
|
|
|
|
|
// Note: the only reason the frame would be dirty would be if it had
|
|
|
|
// just been inserted or appended
|
|
|
|
NS_ASSERTION(frameState & NS_FRAME_FIRST_REFLOW, "unexpected frame state");
|
1999-07-24 06:37:45 +04:00
|
|
|
ReflowAbsoluteFrame(aDelegatingFrame, aPresContext, aReflowState,
|
1999-07-27 04:48:47 +04:00
|
|
|
f, PR_TRUE, status);
|
1999-04-16 05:39:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Indicate we handled the reflow command
|
|
|
|
aWasHandled = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// Peek at the next frame in the reflow path
|
|
|
|
nsIFrame* nextFrame;
|
|
|
|
aReflowState.reflowCommand->GetNext(nextFrame, PR_FALSE);
|
|
|
|
|
|
|
|
// See if it's one of our absolutely positioned child frames
|
|
|
|
NS_ASSERTION(nsnull != nextFrame, "next frame in reflow command is null");
|
|
|
|
if (mAbsoluteFrames.ContainsFrame(nextFrame)) {
|
|
|
|
// Remove the next frame from the reflow path
|
|
|
|
aReflowState.reflowCommand->GetNext(nextFrame, PR_TRUE);
|
|
|
|
|
|
|
|
nsReflowStatus kidStatus;
|
1999-07-24 06:37:45 +04:00
|
|
|
ReflowAbsoluteFrame(aDelegatingFrame, aPresContext, aReflowState,
|
|
|
|
nextFrame, PR_FALSE, 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
|
1999-04-16 05:39:45 +04:00
|
|
|
aWasHandled = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-24 06:37:45 +04:00
|
|
|
void
|
|
|
|
nsAbsoluteContainingBlock::DestroyFrames(nsIFrame* aDelegatingFrame,
|
|
|
|
nsIPresContext& aPresContext)
|
|
|
|
{
|
|
|
|
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...
|
|
|
|
nsresult
|
1999-07-24 06:37:45 +04:00
|
|
|
nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
|
|
|
|
nsIPresContext& aPresContext,
|
1999-04-16 05:39:45 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
PRBool aInitialReflow,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsMargin border;
|
|
|
|
|
|
|
|
// Get the border values
|
1999-07-28 08:48:34 +04:00
|
|
|
if (!aReflowState.mStyleSpacing->GetBorder(border)) {
|
|
|
|
NS_NOTYETIMPLEMENTED("percentage border");
|
|
|
|
}
|
1999-04-16 05:39:45 +04:00
|
|
|
|
|
|
|
nsIHTMLReflow* htmlReflow;
|
|
|
|
rv = aKidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
htmlReflow->WillReflow(aPresContext);
|
|
|
|
|
1999-07-20 07:41:03 +04:00
|
|
|
nsSize availSize(aReflowState.mComputedWidth, NS_UNCONSTRAINEDSIZE);
|
1999-04-16 05:39:45 +04:00
|
|
|
nsHTMLReflowMetrics kidDesiredSize(nsnull);
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
|
|
|
|
availSize);
|
|
|
|
|
|
|
|
// If it's the initial reflow, then override the reflow reason. This is
|
|
|
|
// used when frames are inserted incrementally
|
|
|
|
if (aInitialReflow) {
|
|
|
|
kidReflowState.reason = eReflowReason_Initial;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = htmlReflow->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
|
|
|
|
|
1999-07-20 06:48:18 +04:00
|
|
|
// Because we don't know the size of a replaced element until after we reflow
|
1999-07-27 04:48:47 +04:00
|
|
|
// it 'auto' margins must be computed now, and we need to take into account
|
|
|
|
// min-max information
|
1999-07-20 07:41:03 +04:00
|
|
|
if (NS_FRAME_IS_REPLACED(kidReflowState.mFrameType)) {
|
1999-07-27 04:48:47 +04:00
|
|
|
// Factor in any minimum and maximum size information
|
|
|
|
if (kidDesiredSize.width > kidReflowState.mComputedMaxWidth) {
|
|
|
|
kidDesiredSize.width = kidReflowState.mComputedMaxWidth;
|
|
|
|
} else if (kidDesiredSize.width < kidReflowState.mComputedMinWidth) {
|
|
|
|
kidDesiredSize.width = kidReflowState.mComputedMinWidth;
|
|
|
|
}
|
|
|
|
if (kidDesiredSize.height > kidReflowState.mComputedMaxHeight) {
|
|
|
|
kidDesiredSize.height = kidReflowState.mComputedMaxHeight;
|
|
|
|
} else if (kidDesiredSize.height < kidReflowState.mComputedMinHeight) {
|
|
|
|
kidDesiredSize.height = kidReflowState.mComputedMinHeight;
|
|
|
|
}
|
|
|
|
|
1999-07-20 06:48:18 +04:00
|
|
|
// Get the containing block width/height
|
|
|
|
nscoord containingBlockWidth, containingBlockHeight;
|
|
|
|
kidReflowState.ComputeContainingBlockRectangle(&aReflowState,
|
|
|
|
containingBlockWidth,
|
|
|
|
containingBlockHeight);
|
|
|
|
|
|
|
|
// XXX This code belongs in nsHTMLReflowState...
|
1999-07-20 07:41:03 +04:00
|
|
|
if ((NS_AUTOMARGIN == kidReflowState.mComputedMargin.left) ||
|
|
|
|
(NS_AUTOMARGIN == kidReflowState.mComputedMargin.right)) {
|
1999-07-20 06:48:18 +04:00
|
|
|
// Calculate the amount of space for margins
|
|
|
|
nscoord availMarginSpace = containingBlockWidth -
|
1999-07-20 07:51:46 +04:00
|
|
|
kidReflowState.mComputedOffsets.left - kidReflowState.mComputedBorderPadding.left -
|
1999-07-20 06:48:18 +04:00
|
|
|
kidDesiredSize.width - kidReflowState.mComputedBorderPadding.right -
|
1999-07-20 07:51:46 +04:00
|
|
|
kidReflowState.mComputedOffsets.right;
|
1999-07-20 06:48:18 +04:00
|
|
|
|
1999-07-20 07:41:03 +04:00
|
|
|
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.left) {
|
|
|
|
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.right) {
|
1999-07-20 06:48:18 +04:00
|
|
|
// Both 'margin-left' and 'margin-right' are 'auto', so they get
|
|
|
|
// equal values
|
1999-07-20 07:41:03 +04:00
|
|
|
kidReflowState.mComputedMargin.left = availMarginSpace / 2;
|
|
|
|
kidReflowState.mComputedMargin.right = availMarginSpace -
|
|
|
|
kidReflowState.mComputedMargin.left;
|
1999-07-20 06:48:18 +04:00
|
|
|
} else {
|
|
|
|
// Just 'margin-left' is 'auto'
|
1999-07-20 07:41:03 +04:00
|
|
|
kidReflowState.mComputedMargin.left = availMarginSpace -
|
|
|
|
kidReflowState.mComputedMargin.right;
|
1999-07-20 06:48:18 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Just 'margin-right' is 'auto'
|
1999-07-20 07:41:03 +04:00
|
|
|
kidReflowState.mComputedMargin.right = availMarginSpace -
|
|
|
|
kidReflowState.mComputedMargin.left;
|
1999-07-20 06:48:18 +04:00
|
|
|
}
|
|
|
|
}
|
1999-07-20 07:41:03 +04:00
|
|
|
if ((NS_AUTOMARGIN == kidReflowState.mComputedMargin.top) ||
|
|
|
|
(NS_AUTOMARGIN == kidReflowState.mComputedMargin.bottom)) {
|
1999-07-20 06:48:18 +04:00
|
|
|
// Calculate the amount of space for margins
|
|
|
|
nscoord availMarginSpace = containingBlockHeight -
|
1999-07-20 07:51:46 +04:00
|
|
|
kidReflowState.mComputedOffsets.top - kidReflowState.mComputedBorderPadding.top -
|
1999-07-20 06:48:18 +04:00
|
|
|
kidDesiredSize.height - kidReflowState.mComputedBorderPadding.bottom -
|
1999-07-20 07:51:46 +04:00
|
|
|
kidReflowState.mComputedOffsets.bottom;
|
1999-07-20 06:48:18 +04:00
|
|
|
|
1999-07-20 07:41:03 +04:00
|
|
|
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.top) {
|
|
|
|
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.bottom) {
|
1999-07-20 06:48:18 +04:00
|
|
|
// Both 'margin-top' and 'margin-bottom' are 'auto', so they get
|
|
|
|
// equal values
|
1999-07-20 07:41:03 +04:00
|
|
|
kidReflowState.mComputedMargin.top = availMarginSpace / 2;
|
|
|
|
kidReflowState.mComputedMargin.bottom = availMarginSpace -
|
|
|
|
kidReflowState.mComputedMargin.top;
|
1999-07-20 06:48:18 +04:00
|
|
|
} else {
|
|
|
|
// Just 'margin-top' is 'auto'
|
1999-07-20 07:41:03 +04:00
|
|
|
kidReflowState.mComputedMargin.top = availMarginSpace -
|
|
|
|
kidReflowState.mComputedMargin.bottom;
|
1999-07-20 06:48:18 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Just 'margin-bottom' is 'auto'
|
1999-07-20 07:41:03 +04:00
|
|
|
kidReflowState.mComputedMargin.bottom = availMarginSpace -
|
|
|
|
kidReflowState.mComputedMargin.top;
|
1999-07-20 06:48:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-16 05:39:45 +04:00
|
|
|
// XXX If the child had a fixed height, then make sure it respected it...
|
1999-07-20 07:41:03 +04:00
|
|
|
if (NS_AUTOHEIGHT != kidReflowState.mComputedHeight) {
|
|
|
|
if (kidDesiredSize.height < kidReflowState.mComputedHeight) {
|
|
|
|
kidDesiredSize.height = kidReflowState.mComputedHeight;
|
1999-04-16 05:39:45 +04:00
|
|
|
kidDesiredSize.height += kidReflowState.mComputedBorderPadding.top +
|
|
|
|
kidReflowState.mComputedBorderPadding.bottom;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Position the child relative to our padding edge
|
1999-07-20 07:51:46 +04:00
|
|
|
nsRect rect(border.left + kidReflowState.mComputedOffsets.left + kidReflowState.mComputedMargin.left,
|
|
|
|
border.top + kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top,
|
1999-04-16 05:39:45 +04:00
|
|
|
kidDesiredSize.width, kidDesiredSize.height);
|
|
|
|
aKidFrame->SetRect(rect);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-07-24 06:37:45 +04:00
|
|
|
nsAbsoluteContainingBlock::GetPositionedInfo(const nsIFrame* aDelegatingFrame,
|
|
|
|
nscoord& aXMost,
|
|
|
|
nscoord& aYMost) const
|
1999-04-16 05:39:45 +04:00
|
|
|
{
|
|
|
|
aXMost = aYMost = 0;
|
|
|
|
for (nsIFrame* f = mAbsoluteFrames.FirstChild(); nsnull != f; f->GetNextSibling(&f)) {
|
|
|
|
// Get the frame's x-most and y-most. This is for its flowed content only
|
|
|
|
nsRect rect;
|
|
|
|
f->GetRect(rect);
|
|
|
|
|
|
|
|
if (rect.XMost() > aXMost) {
|
|
|
|
aXMost = rect.XMost();
|
|
|
|
}
|
|
|
|
if (rect.YMost() > aYMost) {
|
|
|
|
aYMost = rect.YMost();
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the child frame is also an area frame, then take into account its child
|
|
|
|
// absolutely positioned elements
|
|
|
|
nsIAreaFrame* areaFrame;
|
|
|
|
if (NS_SUCCEEDED(f->QueryInterface(kAreaFrameIID, (void**)&areaFrame))) {
|
|
|
|
nscoord xMost, yMost;
|
|
|
|
|
|
|
|
areaFrame->GetPositionedInfo(xMost, yMost);
|
|
|
|
// Convert to our coordinate space
|
|
|
|
xMost += rect.x;
|
|
|
|
yMost += rect.y;
|
|
|
|
|
|
|
|
if (xMost > aXMost) {
|
|
|
|
aXMost = xMost;
|
|
|
|
}
|
|
|
|
if (yMost > aYMost) {
|
|
|
|
aYMost = yMost;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|