effectively removed area frame

work troy was holding in his tree
r=buster
This commit is contained in:
buster%netscape.com 2000-05-09 05:11:12 +00:00
parent 0e193a8fad
commit c1c9bfa09b
16 changed files with 104 additions and 666 deletions

View File

@ -1211,6 +1211,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex
}
} else {
// XXX Don't assume default. Only use what is in 'quotes' property
contentString = '\"';
}
}
@ -4695,12 +4696,14 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresShell* aPresShell,
PRBool isAbsolutelyPositioned = PR_FALSE;
PRBool isFixedPositioned = PR_FALSE;
PRBool isFloating = PR_FALSE;
PRBool isRelativePositioned = PR_FALSE;
PRBool canBePositioned = PR_TRUE;
PRBool frameHasBeenInitialized = PR_FALSE;
nsIFrame* newFrame = nsnull; // the frame we construct
PRBool isReplaced = PR_FALSE;
PRBool addToHashTable = PR_TRUE;
PRBool isFloaterContainer = PR_FALSE;
PRBool isPositionedContainingBlock = PR_FALSE;
nsresult rv = NS_OK;
if (nsLayoutAtoms::textTagName == aTag) {
@ -4732,9 +4735,14 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresShell* aPresShell,
else if (NS_STYLE_POSITION_FIXED == position->mPosition) {
isFixedPositioned = PR_TRUE;
}
else if (NS_STYLE_FLOAT_NONE != display->mFloats) {
else {
if (NS_STYLE_FLOAT_NONE != display->mFloats) {
isFloating = PR_TRUE;
}
if (NS_STYLE_POSITION_RELATIVE == position->mPosition) {
isRelativePositioned = PR_TRUE;
}
}
// Create a frame based on the tag
if (nsHTMLAtoms::img == aTag) {
@ -4849,6 +4857,9 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresShell* aPresShell,
// A form frame is a block frame therefore it can contain floaters
isFloaterContainer = PR_TRUE;
// See if it's a containing block for absolutely positioned elements
isPositionedContainingBlock = isAbsolutelyPositioned || isFixedPositioned || isRelativePositioned;
}
else if (nsHTMLAtoms::frameset == aTag) {
if (!aState.mPseudoFrames.IsEmpty()) { // process pending pseudo frames
@ -4930,7 +4941,24 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresShell* aPresShell,
// Process the child content if requested
nsFrameItems childItems;
if (processChildren) {
if (isFloaterContainer) {
if (isPositionedContainingBlock) {
// The area frame becomes a container for child frames that are
// absolutely positioned
nsFrameConstructorSaveState absoluteSaveState;
aState.PushAbsoluteContainingBlock(newFrame, absoluteSaveState);
// Process the child frames
rv = ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame,
PR_TRUE, childItems, PR_FALSE);
// Set the frame's absolute list if there were any absolutely positioned children
if (aState.mAbsoluteItems.childList) {
newFrame->SetInitialChildList(aPresContext,
nsLayoutAtoms::absoluteList,
aState.mAbsoluteItems.childList);
}
}
else if (isFloaterContainer) {
// If the frame can contain floaters, then push a floater
// containing block
PRBool haveFirstLetterStyle, haveFirstLineStyle;

View File

@ -2348,7 +2348,7 @@ nsComboboxControlFrame::GetAdditionalChildListName(PRInt32 aIndex,
// of the combox's children because it would take up space, when it is suppose to
// be floating above the display.
NS_PRECONDITION(nsnull != aListName, "null OUT parameter pointer");
if (aIndex <= NS_AREA_FRAME_ABSOLUTE_LIST_INDEX) {
if (aIndex <= NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX) {
return nsAreaFrame::GetAdditionalChildListName(aIndex, aListName);
}

View File

@ -57,7 +57,7 @@ class nsIListControlFrame;
* Child list name indices
* @see #GetAdditionalChildListName()
*/
#define NS_COMBO_FRAME_POPUP_LIST_INDEX (NS_AREA_FRAME_ABSOLUTE_LIST_INDEX + 1)
#define NS_COMBO_FRAME_POPUP_LIST_INDEX (NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX + 1)
class nsComboboxControlFrame : public nsAreaFrame,
public nsIFormControlFrame,

View File

@ -328,7 +328,7 @@ nsAbsoluteContainingBlock::IncrementalReflow(nsIFrame* aDelegatin
CalculateChildBounds(aPresContext, aChildBounds);
}
} else {
} else if (mAbsoluteFrames.NotEmpty()) {
// Peek at the next frame in the reflow path
nsIFrame* nextFrame;
aReflowState.reflowCommand->GetNext(nextFrame, PR_FALSE);

View File

@ -100,6 +100,8 @@ public:
void DestroyFrames(nsIFrame* aDelegatingFrame,
nsIPresContext* aPresContext);
PRBool HasAbsoluteFrames() {return mAbsoluteFrames.NotEmpty();}
protected:
nsresult ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
nsIPresContext* aPresContext,

View File

@ -62,290 +62,6 @@ nsAreaFrame::nsAreaFrame()
/////////////////////////////////////////////////////////////////////////////
// nsIFrame
NS_IMETHODIMP
nsAreaFrame::Destroy(nsIPresContext* aPresContext)
{
mAbsoluteContainer.DestroyFrames(this, aPresContext);
return nsBlockFrame::Destroy(aPresContext);
}
NS_IMETHODIMP
nsAreaFrame::SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList)
{
nsresult rv;
if (nsLayoutAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.SetInitialChildList(this, aPresContext, aListName, aChildList);
} else {
rv = nsBlockFrame::SetInitialChildList(aPresContext, aListName, aChildList);
}
return rv;
}
NS_IMETHODIMP
nsAreaFrame::AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aFrameList)
{
nsresult rv;
if (nsLayoutAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.AppendFrames(this, aPresContext, aPresShell, aListName,
aFrameList);
} else {
rv = nsBlockFrame::AppendFrames(aPresContext, aPresShell, aListName,
aFrameList);
}
return rv;
}
NS_IMETHODIMP
nsAreaFrame::InsertFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
{
nsresult rv;
if (nsLayoutAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.InsertFrames(this, aPresContext, aPresShell, aListName,
aPrevFrame, aFrameList);
} else {
rv = nsBlockFrame::InsertFrames(aPresContext, aPresShell, aListName,
aPrevFrame, aFrameList);
}
return rv;
}
NS_IMETHODIMP
nsAreaFrame::RemoveFrame(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aOldFrame)
{
nsresult rv;
if (nsLayoutAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.RemoveFrame(this, aPresContext, aPresShell, aListName, aOldFrame);
} else {
rv = nsBlockFrame::RemoveFrame(aPresContext, aPresShell, aListName, aOldFrame);
}
return rv;
}
NS_IMETHODIMP
nsAreaFrame::GetAdditionalChildListName(PRInt32 aIndex,
nsIAtom** aListName) const
{
NS_PRECONDITION(nsnull != aListName, "null OUT parameter pointer");
if (aIndex <= NS_BLOCK_FRAME_LAST_LIST_INDEX) {
return nsBlockFrame::GetAdditionalChildListName(aIndex, aListName);
}
*aListName = nsnull;
if (NS_AREA_FRAME_ABSOLUTE_LIST_INDEX == aIndex) {
*aListName = nsLayoutAtoms::absoluteList;
NS_ADDREF(*aListName);
}
return NS_OK;
}
NS_IMETHODIMP
nsAreaFrame::FirstChild(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame** aFirstChild) const
{
NS_PRECONDITION(nsnull != aFirstChild, "null OUT parameter pointer");
if (aListName == nsLayoutAtoms::absoluteList) {
return mAbsoluteContainer.FirstChild(this, aListName, aFirstChild);
}
return nsBlockFrame::FirstChild(aPresContext, aListName, aFirstChild);
}
static void
CalculateContainingBlock(const nsHTMLReflowState& aReflowState,
nscoord aFrameWidth,
nscoord aFrameHeight,
nscoord& aContainingBlockWidth,
nscoord& aContainingBlockHeight)
{
aContainingBlockWidth = -1; // have reflow state calculate
aContainingBlockHeight = -1; // have reflow state calculate
// The issue there is that for a 'height' of 'auto' the reflow state code
// won't know how to calculate the containing block height because it's
// calculated bottom up. We don't really want to do this for the initial
// containing block so that's why we have the check for if the element
// is absolutely or relatively positioned
if (aReflowState.mStylePosition->IsAbsolutelyPositioned() ||
(NS_STYLE_POSITION_RELATIVE == aReflowState.mStylePosition->mPosition)) {
aContainingBlockWidth = aFrameWidth;
aContainingBlockHeight = aFrameHeight;
// Containing block is relative to the padding edge
nsMargin border;
if (!aReflowState.mStyleSpacing->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
aContainingBlockWidth -= border.left + border.right;
aContainingBlockHeight -= border.top + border.bottom;
}
}
NS_IMETHODIMP
nsAreaFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aMetrics,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsAreaFrame", aReflowState.reason);
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("enter nsAreaFrame::Reflow: maxSize=%d,%d reason=%d",
aReflowState.availableWidth,
aReflowState.availableHeight,
aReflowState.reason));
nsresult rv = NS_OK;
// See if it's an incremental reflow command
if (eReflowReason_Incremental == aReflowState.reason) {
// Give the absolute positioning code a chance to handle it
nscoord containingBlockWidth;
nscoord containingBlockHeight;
PRBool handled;
nsRect childBounds;
CalculateContainingBlock(aReflowState, mRect.width, mRect.height,
containingBlockWidth, containingBlockHeight);
mAbsoluteContainer.IncrementalReflow(this, aPresContext, aReflowState,
containingBlockWidth, containingBlockHeight,
handled, childBounds);
// If the incremental reflow command was handled by the absolute positioning
// code, then we're all done
if (handled) {
// Just return our current size as our desired size.
// XXX We need to know the overflow area for the flowed content, and
// we don't have a way to get that currently so for the time being pretend
// a resize reflow occured
#if 0
aMetrics.width = mRect.width;
aMetrics.height = mRect.height;
aMetrics.ascent = mRect.height;
aMetrics.descent = 0;
// Whether or not we're complete hasn't changed
aStatus = (nsnull != mNextInFlow) ? NS_FRAME_NOT_COMPLETE : NS_FRAME_COMPLETE;
#else
nsHTMLReflowState reflowState(aReflowState);
reflowState.reason = eReflowReason_Resize;
reflowState.reflowCommand = nsnull;
rv = nsBlockFrame::Reflow(aPresContext, aMetrics, reflowState, aStatus);
#endif
// Factor the absolutely positioned child bounds into the overflow area
aMetrics.mOverflowArea.UnionRect(aMetrics.mOverflowArea, childBounds);
// Make sure the NS_FRAME_OUTSIDE_CHILDREN flag is set correctly
if ((aMetrics.mOverflowArea.x < 0) ||
(aMetrics.mOverflowArea.y < 0) ||
(aMetrics.mOverflowArea.XMost() > aMetrics.width) ||
(aMetrics.mOverflowArea.YMost() > aMetrics.height)) {
mState |= NS_FRAME_OUTSIDE_CHILDREN;
} else {
mState &= ~NS_FRAME_OUTSIDE_CHILDREN;
}
return rv;
}
}
// Let the block frame do its reflow first
rv = nsBlockFrame::Reflow(aPresContext, aMetrics, aReflowState, aStatus);
// Let the absolutely positioned container reflow any absolutely positioned
// child frames that need to be reflowed, e.g., elements with a percentage
// based width/height
if (NS_SUCCEEDED(rv)) {
nscoord containingBlockWidth;
nscoord containingBlockHeight;
nsRect childBounds;
CalculateContainingBlock(aReflowState, aMetrics.width, aMetrics.height,
containingBlockWidth, containingBlockHeight);
rv = mAbsoluteContainer.Reflow(this, aPresContext, aReflowState,
containingBlockWidth, containingBlockHeight,
childBounds);
// Factor the absolutely positioned child bounds into the overflow area
aMetrics.mOverflowArea.UnionRect(aMetrics.mOverflowArea, childBounds);
// Make sure the NS_FRAME_OUTSIDE_CHILDREN flag is set correctly
if ((aMetrics.mOverflowArea.x < 0) ||
(aMetrics.mOverflowArea.y < 0) ||
(aMetrics.mOverflowArea.XMost() > aMetrics.width) ||
(aMetrics.mOverflowArea.YMost() > aMetrics.height)) {
mState |= NS_FRAME_OUTSIDE_CHILDREN;
} else {
mState &= ~NS_FRAME_OUTSIDE_CHILDREN;
}
}
#ifdef NOISY_MAX_ELEMENT_SIZE
ListTag(stdout);
printf(": maxElementSize=%d,%d desiredSize=%d,%d\n",
aMetrics.maxElementSize ? aMetrics.maxElementSize->width : 0,
aMetrics.maxElementSize ? aMetrics.maxElementSize->height : 0,
aMetrics.width, aMetrics.height);
#endif
return rv;
}
NS_IMETHODIMP
nsAreaFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
{
if (aChild) {
// See if the child is absolutely positioned
nsFrameState childState;
aChild->GetFrameState(&childState);
if (childState & NS_FRAME_OUT_OF_FLOW) {
const nsStylePosition* position;
aChild->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)position);
if (position->IsAbsolutelyPositioned()) {
// Generate a reflow command to reflow our dirty absolutely
// positioned child frames.
// XXX Note that we don't currently try and coalesce the reflow commands,
// although we should. We can't use the NS_FRAME_HAS_DIRTY_CHILDREN
// flag, because that's used to indicate whether in-flow children are
// dirty...
nsIReflowCommand* reflowCmd;
nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, this,
nsIReflowCommand::ReflowDirty);
if (NS_SUCCEEDED(rv)) {
reflowCmd->SetChildListName(nsLayoutAtoms::absoluteList);
aPresShell->AppendReflowCommand(reflowCmd);
NS_RELEASE(reflowCmd);
}
return rv;
}
}
}
return nsBlockFrame::ReflowDirtyChild(aPresShell, aChild);
}
NS_IMETHODIMP
nsAreaFrame::GetFrameType(nsIAtom** aType) const
{

View File

@ -31,11 +31,6 @@ class nsSpaceManager;
struct nsStyleDisplay;
struct nsStylePosition;
/**
* Child list name indices
* @see #GetAdditionalChildListName()
*/
#define NS_AREA_FRAME_ABSOLUTE_LIST_INDEX (NS_BLOCK_FRAME_LAST_LIST_INDEX + 1)
/**
* The area frame has an additional named child list:
@ -49,38 +44,6 @@ public:
friend nsresult NS_NewAreaFrame(nsIPresShell* aPresShell, nsIFrame** aResult, PRUint32 aFlags);
// nsIFrame
NS_IMETHOD Destroy(nsIPresContext* aPresContext);
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
NS_IMETHOD AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aFrameList);
NS_IMETHOD InsertFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
NS_IMETHOD RemoveFrame(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aOldFrame);
NS_IMETHOD GetAdditionalChildListName(PRInt32 aIndex,
nsIAtom** aListName) const;
NS_IMETHOD FirstChild(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame** aFirstChild) const;
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild);
/**
* Get the "type" of the frame
@ -97,8 +60,6 @@ public:
protected:
nsAreaFrame();
private:
nsAbsoluteContainingBlock mAbsoluteContainer;
};
#endif /* nsAreaFrame_h___ */

View File

@ -24,6 +24,7 @@
#include "nsHTMLContainerFrame.h"
#include "nsHTMLParts.h"
#include "nsAbsoluteContainingBlock.h"
class nsBlockReflowState;
class nsBulletFrame;
@ -37,7 +38,8 @@ class nsFirstLineFrame;
*/
#define NS_BLOCK_FRAME_FLOATER_LIST_INDEX 0
#define NS_BLOCK_FRAME_BULLET_LIST_INDEX 1
#define NS_BLOCK_FRAME_LAST_LIST_INDEX NS_BLOCK_FRAME_BULLET_LIST_INDEX
#define NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX 2
#define NS_BLOCK_FRAME_LAST_LIST_INDEX NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX
/**
* Additional frame-state bits. There are more of these bits
@ -54,7 +56,13 @@ class nsFirstLineFrame;
extern const nsIID kBlockFrameCID;
// Base class for block and inline frames
/*
* Base class for block and inline frames.
* The block frame has an additional named child list:
* - "Absolute-list" which contains the absolutely positioned frames
*
* @see nsLayoutAtoms::absoluteList
*/
class nsBlockFrame : public nsBlockFrameSuper
{
public:
@ -429,6 +437,10 @@ protected:
nsBulletFrame* mBullet;
friend class nsBlockReflowState;
private:
nsAbsoluteContainingBlock mAbsoluteContainer;
};
#endif /* nsBlockFrame_h___ */

View File

@ -328,7 +328,7 @@ nsAbsoluteContainingBlock::IncrementalReflow(nsIFrame* aDelegatin
CalculateChildBounds(aPresContext, aChildBounds);
}
} else {
} else if (mAbsoluteFrames.NotEmpty()) {
// Peek at the next frame in the reflow path
nsIFrame* nextFrame;
aReflowState.reflowCommand->GetNext(nextFrame, PR_FALSE);

View File

@ -100,6 +100,8 @@ public:
void DestroyFrames(nsIFrame* aDelegatingFrame,
nsIPresContext* aPresContext);
PRBool HasAbsoluteFrames() {return mAbsoluteFrames.NotEmpty();}
protected:
nsresult ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
nsIPresContext* aPresContext,

View File

@ -62,290 +62,6 @@ nsAreaFrame::nsAreaFrame()
/////////////////////////////////////////////////////////////////////////////
// nsIFrame
NS_IMETHODIMP
nsAreaFrame::Destroy(nsIPresContext* aPresContext)
{
mAbsoluteContainer.DestroyFrames(this, aPresContext);
return nsBlockFrame::Destroy(aPresContext);
}
NS_IMETHODIMP
nsAreaFrame::SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList)
{
nsresult rv;
if (nsLayoutAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.SetInitialChildList(this, aPresContext, aListName, aChildList);
} else {
rv = nsBlockFrame::SetInitialChildList(aPresContext, aListName, aChildList);
}
return rv;
}
NS_IMETHODIMP
nsAreaFrame::AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aFrameList)
{
nsresult rv;
if (nsLayoutAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.AppendFrames(this, aPresContext, aPresShell, aListName,
aFrameList);
} else {
rv = nsBlockFrame::AppendFrames(aPresContext, aPresShell, aListName,
aFrameList);
}
return rv;
}
NS_IMETHODIMP
nsAreaFrame::InsertFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
{
nsresult rv;
if (nsLayoutAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.InsertFrames(this, aPresContext, aPresShell, aListName,
aPrevFrame, aFrameList);
} else {
rv = nsBlockFrame::InsertFrames(aPresContext, aPresShell, aListName,
aPrevFrame, aFrameList);
}
return rv;
}
NS_IMETHODIMP
nsAreaFrame::RemoveFrame(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aOldFrame)
{
nsresult rv;
if (nsLayoutAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.RemoveFrame(this, aPresContext, aPresShell, aListName, aOldFrame);
} else {
rv = nsBlockFrame::RemoveFrame(aPresContext, aPresShell, aListName, aOldFrame);
}
return rv;
}
NS_IMETHODIMP
nsAreaFrame::GetAdditionalChildListName(PRInt32 aIndex,
nsIAtom** aListName) const
{
NS_PRECONDITION(nsnull != aListName, "null OUT parameter pointer");
if (aIndex <= NS_BLOCK_FRAME_LAST_LIST_INDEX) {
return nsBlockFrame::GetAdditionalChildListName(aIndex, aListName);
}
*aListName = nsnull;
if (NS_AREA_FRAME_ABSOLUTE_LIST_INDEX == aIndex) {
*aListName = nsLayoutAtoms::absoluteList;
NS_ADDREF(*aListName);
}
return NS_OK;
}
NS_IMETHODIMP
nsAreaFrame::FirstChild(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame** aFirstChild) const
{
NS_PRECONDITION(nsnull != aFirstChild, "null OUT parameter pointer");
if (aListName == nsLayoutAtoms::absoluteList) {
return mAbsoluteContainer.FirstChild(this, aListName, aFirstChild);
}
return nsBlockFrame::FirstChild(aPresContext, aListName, aFirstChild);
}
static void
CalculateContainingBlock(const nsHTMLReflowState& aReflowState,
nscoord aFrameWidth,
nscoord aFrameHeight,
nscoord& aContainingBlockWidth,
nscoord& aContainingBlockHeight)
{
aContainingBlockWidth = -1; // have reflow state calculate
aContainingBlockHeight = -1; // have reflow state calculate
// The issue there is that for a 'height' of 'auto' the reflow state code
// won't know how to calculate the containing block height because it's
// calculated bottom up. We don't really want to do this for the initial
// containing block so that's why we have the check for if the element
// is absolutely or relatively positioned
if (aReflowState.mStylePosition->IsAbsolutelyPositioned() ||
(NS_STYLE_POSITION_RELATIVE == aReflowState.mStylePosition->mPosition)) {
aContainingBlockWidth = aFrameWidth;
aContainingBlockHeight = aFrameHeight;
// Containing block is relative to the padding edge
nsMargin border;
if (!aReflowState.mStyleSpacing->GetBorder(border)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
aContainingBlockWidth -= border.left + border.right;
aContainingBlockHeight -= border.top + border.bottom;
}
}
NS_IMETHODIMP
nsAreaFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aMetrics,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsAreaFrame", aReflowState.reason);
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("enter nsAreaFrame::Reflow: maxSize=%d,%d reason=%d",
aReflowState.availableWidth,
aReflowState.availableHeight,
aReflowState.reason));
nsresult rv = NS_OK;
// See if it's an incremental reflow command
if (eReflowReason_Incremental == aReflowState.reason) {
// Give the absolute positioning code a chance to handle it
nscoord containingBlockWidth;
nscoord containingBlockHeight;
PRBool handled;
nsRect childBounds;
CalculateContainingBlock(aReflowState, mRect.width, mRect.height,
containingBlockWidth, containingBlockHeight);
mAbsoluteContainer.IncrementalReflow(this, aPresContext, aReflowState,
containingBlockWidth, containingBlockHeight,
handled, childBounds);
// If the incremental reflow command was handled by the absolute positioning
// code, then we're all done
if (handled) {
// Just return our current size as our desired size.
// XXX We need to know the overflow area for the flowed content, and
// we don't have a way to get that currently so for the time being pretend
// a resize reflow occured
#if 0
aMetrics.width = mRect.width;
aMetrics.height = mRect.height;
aMetrics.ascent = mRect.height;
aMetrics.descent = 0;
// Whether or not we're complete hasn't changed
aStatus = (nsnull != mNextInFlow) ? NS_FRAME_NOT_COMPLETE : NS_FRAME_COMPLETE;
#else
nsHTMLReflowState reflowState(aReflowState);
reflowState.reason = eReflowReason_Resize;
reflowState.reflowCommand = nsnull;
rv = nsBlockFrame::Reflow(aPresContext, aMetrics, reflowState, aStatus);
#endif
// Factor the absolutely positioned child bounds into the overflow area
aMetrics.mOverflowArea.UnionRect(aMetrics.mOverflowArea, childBounds);
// Make sure the NS_FRAME_OUTSIDE_CHILDREN flag is set correctly
if ((aMetrics.mOverflowArea.x < 0) ||
(aMetrics.mOverflowArea.y < 0) ||
(aMetrics.mOverflowArea.XMost() > aMetrics.width) ||
(aMetrics.mOverflowArea.YMost() > aMetrics.height)) {
mState |= NS_FRAME_OUTSIDE_CHILDREN;
} else {
mState &= ~NS_FRAME_OUTSIDE_CHILDREN;
}
return rv;
}
}
// Let the block frame do its reflow first
rv = nsBlockFrame::Reflow(aPresContext, aMetrics, aReflowState, aStatus);
// Let the absolutely positioned container reflow any absolutely positioned
// child frames that need to be reflowed, e.g., elements with a percentage
// based width/height
if (NS_SUCCEEDED(rv)) {
nscoord containingBlockWidth;
nscoord containingBlockHeight;
nsRect childBounds;
CalculateContainingBlock(aReflowState, aMetrics.width, aMetrics.height,
containingBlockWidth, containingBlockHeight);
rv = mAbsoluteContainer.Reflow(this, aPresContext, aReflowState,
containingBlockWidth, containingBlockHeight,
childBounds);
// Factor the absolutely positioned child bounds into the overflow area
aMetrics.mOverflowArea.UnionRect(aMetrics.mOverflowArea, childBounds);
// Make sure the NS_FRAME_OUTSIDE_CHILDREN flag is set correctly
if ((aMetrics.mOverflowArea.x < 0) ||
(aMetrics.mOverflowArea.y < 0) ||
(aMetrics.mOverflowArea.XMost() > aMetrics.width) ||
(aMetrics.mOverflowArea.YMost() > aMetrics.height)) {
mState |= NS_FRAME_OUTSIDE_CHILDREN;
} else {
mState &= ~NS_FRAME_OUTSIDE_CHILDREN;
}
}
#ifdef NOISY_MAX_ELEMENT_SIZE
ListTag(stdout);
printf(": maxElementSize=%d,%d desiredSize=%d,%d\n",
aMetrics.maxElementSize ? aMetrics.maxElementSize->width : 0,
aMetrics.maxElementSize ? aMetrics.maxElementSize->height : 0,
aMetrics.width, aMetrics.height);
#endif
return rv;
}
NS_IMETHODIMP
nsAreaFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
{
if (aChild) {
// See if the child is absolutely positioned
nsFrameState childState;
aChild->GetFrameState(&childState);
if (childState & NS_FRAME_OUT_OF_FLOW) {
const nsStylePosition* position;
aChild->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)position);
if (position->IsAbsolutelyPositioned()) {
// Generate a reflow command to reflow our dirty absolutely
// positioned child frames.
// XXX Note that we don't currently try and coalesce the reflow commands,
// although we should. We can't use the NS_FRAME_HAS_DIRTY_CHILDREN
// flag, because that's used to indicate whether in-flow children are
// dirty...
nsIReflowCommand* reflowCmd;
nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, this,
nsIReflowCommand::ReflowDirty);
if (NS_SUCCEEDED(rv)) {
reflowCmd->SetChildListName(nsLayoutAtoms::absoluteList);
aPresShell->AppendReflowCommand(reflowCmd);
NS_RELEASE(reflowCmd);
}
return rv;
}
}
}
return nsBlockFrame::ReflowDirtyChild(aPresShell, aChild);
}
NS_IMETHODIMP
nsAreaFrame::GetFrameType(nsIAtom** aType) const
{

View File

@ -31,11 +31,6 @@ class nsSpaceManager;
struct nsStyleDisplay;
struct nsStylePosition;
/**
* Child list name indices
* @see #GetAdditionalChildListName()
*/
#define NS_AREA_FRAME_ABSOLUTE_LIST_INDEX (NS_BLOCK_FRAME_LAST_LIST_INDEX + 1)
/**
* The area frame has an additional named child list:
@ -49,38 +44,6 @@ public:
friend nsresult NS_NewAreaFrame(nsIPresShell* aPresShell, nsIFrame** aResult, PRUint32 aFlags);
// nsIFrame
NS_IMETHOD Destroy(nsIPresContext* aPresContext);
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
NS_IMETHOD AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aFrameList);
NS_IMETHOD InsertFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
NS_IMETHOD RemoveFrame(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aOldFrame);
NS_IMETHOD GetAdditionalChildListName(PRInt32 aIndex,
nsIAtom** aListName) const;
NS_IMETHOD FirstChild(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame** aFirstChild) const;
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild);
/**
* Get the "type" of the frame
@ -97,8 +60,6 @@ public:
protected:
nsAreaFrame();
private:
nsAbsoluteContainingBlock mAbsoluteContainer;
};
#endif /* nsAreaFrame_h___ */

View File

@ -24,6 +24,7 @@
#include "nsHTMLContainerFrame.h"
#include "nsHTMLParts.h"
#include "nsAbsoluteContainingBlock.h"
class nsBlockReflowState;
class nsBulletFrame;
@ -37,7 +38,8 @@ class nsFirstLineFrame;
*/
#define NS_BLOCK_FRAME_FLOATER_LIST_INDEX 0
#define NS_BLOCK_FRAME_BULLET_LIST_INDEX 1
#define NS_BLOCK_FRAME_LAST_LIST_INDEX NS_BLOCK_FRAME_BULLET_LIST_INDEX
#define NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX 2
#define NS_BLOCK_FRAME_LAST_LIST_INDEX NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX
/**
* Additional frame-state bits. There are more of these bits
@ -54,7 +56,13 @@ class nsFirstLineFrame;
extern const nsIID kBlockFrameCID;
// Base class for block and inline frames
/*
* Base class for block and inline frames.
* The block frame has an additional named child list:
* - "Absolute-list" which contains the absolutely positioned frames
*
* @see nsLayoutAtoms::absoluteList
*/
class nsBlockFrame : public nsBlockFrameSuper
{
public:
@ -429,6 +437,10 @@ protected:
nsBulletFrame* mBullet;
friend class nsBlockReflowState;
private:
nsAbsoluteContainingBlock mAbsoluteContainer;
};
#endif /* nsBlockFrame_h___ */

View File

@ -2348,7 +2348,7 @@ nsComboboxControlFrame::GetAdditionalChildListName(PRInt32 aIndex,
// of the combox's children because it would take up space, when it is suppose to
// be floating above the display.
NS_PRECONDITION(nsnull != aListName, "null OUT parameter pointer");
if (aIndex <= NS_AREA_FRAME_ABSOLUTE_LIST_INDEX) {
if (aIndex <= NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX) {
return nsAreaFrame::GetAdditionalChildListName(aIndex, aListName);
}

View File

@ -57,7 +57,7 @@ class nsIListControlFrame;
* Child list name indices
* @see #GetAdditionalChildListName()
*/
#define NS_COMBO_FRAME_POPUP_LIST_INDEX (NS_AREA_FRAME_ABSOLUTE_LIST_INDEX + 1)
#define NS_COMBO_FRAME_POPUP_LIST_INDEX (NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX + 1)
class nsComboboxControlFrame : public nsAreaFrame,
public nsIFormControlFrame,

View File

@ -1211,6 +1211,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex
}
} else {
// XXX Don't assume default. Only use what is in 'quotes' property
contentString = '\"';
}
}
@ -4695,12 +4696,14 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresShell* aPresShell,
PRBool isAbsolutelyPositioned = PR_FALSE;
PRBool isFixedPositioned = PR_FALSE;
PRBool isFloating = PR_FALSE;
PRBool isRelativePositioned = PR_FALSE;
PRBool canBePositioned = PR_TRUE;
PRBool frameHasBeenInitialized = PR_FALSE;
nsIFrame* newFrame = nsnull; // the frame we construct
PRBool isReplaced = PR_FALSE;
PRBool addToHashTable = PR_TRUE;
PRBool isFloaterContainer = PR_FALSE;
PRBool isPositionedContainingBlock = PR_FALSE;
nsresult rv = NS_OK;
if (nsLayoutAtoms::textTagName == aTag) {
@ -4732,9 +4735,14 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresShell* aPresShell,
else if (NS_STYLE_POSITION_FIXED == position->mPosition) {
isFixedPositioned = PR_TRUE;
}
else if (NS_STYLE_FLOAT_NONE != display->mFloats) {
else {
if (NS_STYLE_FLOAT_NONE != display->mFloats) {
isFloating = PR_TRUE;
}
if (NS_STYLE_POSITION_RELATIVE == position->mPosition) {
isRelativePositioned = PR_TRUE;
}
}
// Create a frame based on the tag
if (nsHTMLAtoms::img == aTag) {
@ -4849,6 +4857,9 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresShell* aPresShell,
// A form frame is a block frame therefore it can contain floaters
isFloaterContainer = PR_TRUE;
// See if it's a containing block for absolutely positioned elements
isPositionedContainingBlock = isAbsolutelyPositioned || isFixedPositioned || isRelativePositioned;
}
else if (nsHTMLAtoms::frameset == aTag) {
if (!aState.mPseudoFrames.IsEmpty()) { // process pending pseudo frames
@ -4930,7 +4941,24 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresShell* aPresShell,
// Process the child content if requested
nsFrameItems childItems;
if (processChildren) {
if (isFloaterContainer) {
if (isPositionedContainingBlock) {
// The area frame becomes a container for child frames that are
// absolutely positioned
nsFrameConstructorSaveState absoluteSaveState;
aState.PushAbsoluteContainingBlock(newFrame, absoluteSaveState);
// Process the child frames
rv = ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame,
PR_TRUE, childItems, PR_FALSE);
// Set the frame's absolute list if there were any absolutely positioned children
if (aState.mAbsoluteItems.childList) {
newFrame->SetInitialChildList(aPresContext,
nsLayoutAtoms::absoluteList,
aState.mAbsoluteItems.childList);
}
}
else if (isFloaterContainer) {
// If the frame can contain floaters, then push a floater
// containing block
PRBool haveFirstLetterStyle, haveFirstLineStyle;