Bug 386801 - nsAbsoluteContainingBlock doesn't need to store a child list name; this shaves four bytes off nsViewportFrame, nsBlockFrame, and nsPositionedInlineFrame. r+sr+a=dbaron

This commit is contained in:
jwalden@mit.edu 2007-08-02 15:44:36 -07:00
Родитель fd898a1065
Коммит bf1a450729
7 изменённых файлов: 53 добавлений и 39 удалений

Просмотреть файл

@ -52,24 +52,36 @@ class nsIFrame;
class nsPresContext;
/**
* This class contains the logic for being an absolute containing block.
* This class contains the logic for being an absolute containing block. This
* class is used within viewport frames (for frames representing content with
* fixed position) and blocks (for frames representing absolutely positioned
* content), since each set of frames is absolutely positioned with respect to
* its parent.
*
* There is no principal child list, just a named child list which contains
* the absolutely positioned frames
* the absolutely positioned frames.
*
* All functions include as the first argument the frame that is delegating
* the request
* the request.
*
* @see nsGkAtoms::absoluteList
* @see nsGkAtoms::absoluteList and nsGkAtoms::fixedList
*/
class nsAbsoluteContainingBlock
{
public:
nsAbsoluteContainingBlock() { } // useful for debugging
nsAbsoluteContainingBlock(nsIAtom* aChildListName)
#ifdef DEBUG
: mChildListName(aChildListName)
#endif
{
NS_ASSERTION(mChildListName == nsGkAtoms::absoluteList ||
mChildListName == nsGkAtoms::fixedList,
"should either represent position:fixed or absolute content");
}
virtual ~nsAbsoluteContainingBlock() { } // useful for debugging
virtual nsIAtom* GetChildListName() const { return nsGkAtoms::absoluteList; }
#ifdef DEBUG
nsIAtom* GetChildListName() const { return mChildListName; }
#endif
nsresult FirstChild(const nsIFrame* aDelegatingFrame,
nsIAtom* aListName,
@ -135,6 +147,8 @@ protected:
nsFrameList mAbsoluteFrames; // additional named child list
#ifdef DEBUG
nsIAtom* const mChildListName; // nsGkAtoms::fixedList or nsGkAtoms::absoluteList
// helper routine for debug printout
void PrettyUC(nscoord aSize,
char* aBuf);

Просмотреть файл

@ -517,7 +517,7 @@ nsBlockFrame::GetBaseline() const
nsIFrame*
nsBlockFrame::GetFirstChild(nsIAtom* aListName) const
{
if (mAbsoluteContainer.GetChildListName() == aListName) {
if (nsGkAtoms::absoluteList == aListName) {
nsIFrame* result = nsnull;
mAbsoluteContainer.FirstChild(this, aListName, &result);
return result;
@ -561,7 +561,7 @@ nsBlockFrame::GetAdditionalChildListName(PRInt32 aIndex) const
case NS_BLOCK_FRAME_OVERFLOW_OOF_LIST_INDEX:
return nsGkAtoms::overflowOutOfFlowList;
case NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX:
return mAbsoluteContainer.GetChildListName();
return nsGkAtoms::absoluteList;
default:
return nsnull;
}
@ -4639,7 +4639,7 @@ nsBlockFrame::AppendFrames(nsIAtom* aListName,
return NS_OK;
}
if (aListName) {
if (mAbsoluteContainer.GetChildListName() == aListName) {
if (nsGkAtoms::absoluteList == aListName) {
return mAbsoluteContainer.AppendFrames(this, aListName, aFrameList);
}
else if (nsGkAtoms::floatList == aListName) {
@ -4688,7 +4688,7 @@ nsBlockFrame::InsertFrames(nsIAtom* aListName,
"inserting after sibling frame with different parent");
if (aListName) {
if (mAbsoluteContainer.GetChildListName() == aListName) {
if (nsGkAtoms::absoluteList == aListName) {
return mAbsoluteContainer.InsertFrames(this, aListName, aPrevFrame,
aFrameList);
}
@ -4981,7 +4981,7 @@ nsBlockFrame::RemoveFrame(nsIAtom* aListName,
MarkSameSpaceManagerLinesDirty(this);
}
}
else if (mAbsoluteContainer.GetChildListName() == aListName) {
else if (nsGkAtoms::absoluteList == aListName) {
return mAbsoluteContainer.RemoveFrame(this, aListName, aOldFrame);
}
else if (nsGkAtoms::floatList == aListName) {
@ -5024,7 +5024,7 @@ nsBlockFrame::DoRemoveOutOfFlowFrame(nsIFrame* aFrame)
// Remove aFrame from the appropriate list.
if (display->IsAbsolutelyPositioned()) {
block->mAbsoluteContainer.RemoveFrame(block,
block->mAbsoluteContainer.GetChildListName(),
nsGkAtoms::absoluteList,
aFrame);
aFrame->Destroy();
}
@ -6096,7 +6096,7 @@ nsBlockFrame::SetInitialChildList(nsIAtom* aListName,
{
nsresult rv = NS_OK;
if (mAbsoluteContainer.GetChildListName() == aListName) {
if (nsGkAtoms::absoluteList == aListName) {
mAbsoluteContainer.SetInitialChildList(this, aListName, aChildList);
}
else if (nsGkAtoms::floatList == aListName) {

Просмотреть файл

@ -289,6 +289,7 @@ protected:
: nsHTMLContainerFrame(aContext)
, mMinWidth(NS_INTRINSIC_WIDTH_UNKNOWN)
, mPrefWidth(NS_INTRINSIC_WIDTH_UNKNOWN)
, mAbsoluteContainer(nsGkAtoms::absoluteList)
{
#ifdef DEBUG
InitDebugFlags();

Просмотреть файл

@ -993,7 +993,7 @@ nsPositionedInlineFrame::SetInitialChildList(nsIAtom* aListName,
{
nsresult rv;
if (mAbsoluteContainer.GetChildListName() == aListName) {
if (nsGkAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.SetInitialChildList(this, aListName, aChildList);
} else {
rv = nsInlineFrame::SetInitialChildList(aListName, aChildList);
@ -1008,7 +1008,7 @@ nsPositionedInlineFrame::AppendFrames(nsIAtom* aListName,
{
nsresult rv;
if (mAbsoluteContainer.GetChildListName() == aListName) {
if (nsGkAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.AppendFrames(this, aListName, aFrameList);
} else {
rv = nsInlineFrame::AppendFrames(aListName, aFrameList);
@ -1024,7 +1024,7 @@ nsPositionedInlineFrame::InsertFrames(nsIAtom* aListName,
{
nsresult rv;
if (mAbsoluteContainer.GetChildListName() == aListName) {
if (nsGkAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.InsertFrames(this, aListName, aPrevFrame,
aFrameList);
} else {
@ -1040,7 +1040,7 @@ nsPositionedInlineFrame::RemoveFrame(nsIAtom* aListName,
{
nsresult rv;
if (mAbsoluteContainer.GetChildListName() == aListName) {
if (nsGkAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.RemoveFrame(this, aListName, aOldFrame);
} else {
rv = nsInlineFrame::RemoveFrame(aListName, aOldFrame);
@ -1062,7 +1062,7 @@ nsIAtom*
nsPositionedInlineFrame::GetAdditionalChildListName(PRInt32 aIndex) const
{
if (0 == aIndex) {
return mAbsoluteContainer.GetChildListName();
return nsGkAtoms::absoluteList;
}
return nsnull;
}
@ -1070,7 +1070,7 @@ nsPositionedInlineFrame::GetAdditionalChildListName(PRInt32 aIndex) const
nsIFrame*
nsPositionedInlineFrame::GetFirstChild(nsIAtom* aListName) const
{
if (mAbsoluteContainer.GetChildListName() == aListName) {
if (nsGkAtoms::absoluteList == aListName) {
nsIFrame* result = nsnull;
mAbsoluteContainer.FirstChild(this, aListName, &result);
return result;

Просмотреть файл

@ -245,7 +245,10 @@ protected:
class nsPositionedInlineFrame : public nsInlineFrame
{
public:
nsPositionedInlineFrame(nsStyleContext* aContext) : nsInlineFrame(aContext) {}
nsPositionedInlineFrame(nsStyleContext* aContext)
: nsInlineFrame(aContext)
, mAbsoluteContainer(nsGkAtoms::absoluteList)
{}
virtual ~nsPositionedInlineFrame() { } // useful for debugging

Просмотреть файл

@ -78,7 +78,7 @@ ViewportFrame::SetInitialChildList(nsIAtom* aListName,
#ifdef NS_DEBUG
nsFrame::VerifyDirtyBitSet(aChildList);
#endif
if (mFixedContainer.GetChildListName() == aListName) {
if (nsGkAtoms::fixedList == aListName) {
rv = mFixedContainer.SetInitialChildList(this, aListName, aChildList);
}
else {
@ -115,7 +115,7 @@ ViewportFrame::AppendFrames(nsIAtom* aListName,
{
nsresult rv = NS_OK;
if (mFixedContainer.GetChildListName() == aListName) {
if (nsGkAtoms::fixedList == aListName) {
rv = mFixedContainer.AppendFrames(this, aListName, aFrameList);
}
else {
@ -134,7 +134,7 @@ ViewportFrame::InsertFrames(nsIAtom* aListName,
{
nsresult rv = NS_OK;
if (mFixedContainer.GetChildListName() == aListName) {
if (nsGkAtoms::fixedList == aListName) {
rv = mFixedContainer.InsertFrames(this, aListName, aPrevFrame, aFrameList);
}
else {
@ -152,7 +152,7 @@ ViewportFrame::RemoveFrame(nsIAtom* aListName,
{
nsresult rv = NS_OK;
if (mFixedContainer.GetChildListName() == aListName) {
if (nsGkAtoms::fixedList == aListName) {
rv = mFixedContainer.RemoveFrame(this, aListName, aOldFrame);
}
else {
@ -170,7 +170,7 @@ ViewportFrame::GetAdditionalChildListName(PRInt32 aIndex) const
NS_PRECONDITION(aIndex >= 0, "illegal index");
if (0 == aIndex) {
return mFixedContainer.GetChildListName();
return nsGkAtoms::fixedList;
}
return nsnull;
@ -179,7 +179,7 @@ ViewportFrame::GetAdditionalChildListName(PRInt32 aIndex) const
nsIFrame*
ViewportFrame::GetFirstChild(nsIAtom* aListName) const
{
if (mFixedContainer.GetChildListName() == aListName) {
if (nsGkAtoms::fixedList == aListName) {
nsIFrame* result = nsnull;
mFixedContainer.FirstChild(this, aListName, &result);
return result;

Просмотреть файл

@ -49,15 +49,6 @@
#include "nsIPresShell.h"
#include "nsAbsoluteContainingBlock.h"
class nsFixedContainingBlock : public nsAbsoluteContainingBlock {
public:
nsFixedContainingBlock() { } // useful for debugging
virtual ~nsFixedContainingBlock() { } // useful for debugging
virtual nsIAtom* GetChildListName() const { return nsGkAtoms::fixedList; }
};
/**
* ViewportFrame is the parent of a single child - the doc root frame or a scroll frame
* containing the doc root frame. ViewportFrame stores this child in its primary child
@ -68,7 +59,10 @@ class ViewportFrame : public nsContainerFrame {
public:
typedef nsContainerFrame Super;
ViewportFrame(nsStyleContext* aContext) : nsContainerFrame(aContext) {}
ViewportFrame(nsStyleContext* aContext)
: nsContainerFrame(aContext)
, mFixedContainer(nsGkAtoms::fixedList)
{}
virtual ~ViewportFrame() { } // useful for debugging
virtual void Destroy();
@ -126,7 +120,9 @@ protected:
nsPoint AdjustReflowStateForScrollbars(nsHTMLReflowState* aReflowState) const;
protected:
nsFixedContainingBlock mFixedContainer;
// position: fixed content is really content which is absolutely positioned with
// respect to the viewport.
nsAbsoluteContainingBlock mFixedContainer;
};