Bug 855917 - Minor nsAbsoluteContainingBlock code cleanup. r=dholbert

This commit is contained in:
Mats Palmgren 2013-04-01 17:26:01 +02:00
parent 6bc5d009dc
commit c65839b418
2 changed files with 64 additions and 69 deletions

View File

@ -8,17 +8,32 @@
* object that is a containing block for them
*/
#include "nsCOMPtr.h"
#include "nsAbsoluteContainingBlock.h"
#include "nsContainerFrame.h"
#include "nsGkAtoms.h"
#include "nsIPresShell.h"
#include "nsHTMLParts.h"
#include "nsHTMLReflowState.h"
#include "nsPresContext.h"
#include "nsFrameManager.h"
#include "nsCSSFrameConstructor.h"
#ifdef DEBUG
#include "nsBlockFrame.h"
static void PrettyUC(nscoord aSize, char* aBuf)
{
if (NS_UNCONSTRAINEDSIZE == aSize) {
strcpy(aBuf, "UC");
} else {
if((int32_t)0xdeadbeef == aSize) {
strcpy(aBuf, "deadbeef");
} else {
sprintf(aBuf, "%d", aSize);
}
}
}
#endif
nsresult
@ -26,7 +41,7 @@ nsAbsoluteContainingBlock::SetInitialChildList(nsIFrame* aDelegatingFrame,
ChildListID aListID,
nsFrameList& aChildList)
{
NS_PRECONDITION(GetChildListID() == aListID, "unexpected child list name");
NS_PRECONDITION(mChildListID == aListID, "unexpected child list name");
#ifdef DEBUG
nsFrame::VerifyDirtyBitSet(aChildList);
#endif
@ -39,7 +54,7 @@ nsAbsoluteContainingBlock::AppendFrames(nsIFrame* aDelegatingFrame,
ChildListID aListID,
nsFrameList& aFrameList)
{
NS_ASSERTION(GetChildListID() == aListID, "unexpected child list");
NS_ASSERTION(mChildListID == aListID, "unexpected child list");
// Append the frames to our list of absolutely positioned frames
#ifdef DEBUG
@ -62,7 +77,7 @@ nsAbsoluteContainingBlock::InsertFrames(nsIFrame* aDelegatingFrame,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList)
{
NS_ASSERTION(GetChildListID() == aListID, "unexpected child list");
NS_ASSERTION(mChildListID == aListID, "unexpected child list");
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == aDelegatingFrame,
"inserting after sibling frame with different parent");
@ -85,7 +100,7 @@ nsAbsoluteContainingBlock::RemoveFrame(nsIFrame* aDelegatingFrame,
ChildListID aListID,
nsIFrame* aOldFrame)
{
NS_ASSERTION(GetChildListID() == aListID, "unexpected child list");
NS_ASSERTION(mChildListID == aListID, "unexpected child list");
nsIFrame* nif = aOldFrame->GetNextInFlow();
if (nif) {
static_cast<nsContainerFrame*>(nif->GetParent())
@ -328,7 +343,7 @@ nsAbsoluteContainingBlock::DoMarkFramesDirty(bool aMarkAllDirty)
// reflow...
// When bug 154892 is checked in, make sure that when
// GetChildListID() == kFixedList, the height is unconstrained.
// mChildListID == kFixedList, the height is unconstrained.
// since we don't allow replicated frames to split.
nsresult
@ -482,22 +497,3 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
return rv;
}
#ifdef DEBUG
void nsAbsoluteContainingBlock::PrettyUC(nscoord aSize,
char* aBuf)
{
if (NS_UNCONSTRAINEDSIZE == aSize) {
strcpy(aBuf, "UC");
}
else {
if((int32_t)0xdeadbeef == aSize)
{
strcpy(aBuf, "deadbeef");
}
else {
sprintf(aBuf, "%d", aSize);
}
}
}
#endif

View File

@ -12,12 +12,10 @@
#define nsAbsoluteContainingBlock_h___
#include "nsFrameList.h"
#include "nsHTMLReflowState.h"
#include "nsGkAtoms.h"
#include "nsContainerFrame.h"
#include "nsIFrame.h"
class nsIAtom;
class nsIFrame;
class nsContainerFrame;
class nsHTMLReflowState;
class nsPresContext;
/**
@ -32,7 +30,6 @@ class nsPresContext;
*
* All functions include as the first argument the frame that is delegating
* the request.
*
*/
class nsAbsoluteContainingBlock
{
@ -44,20 +41,16 @@ public:
: mChildListID(aChildListID)
#endif
{
NS_ASSERTION(mChildListID == nsIFrame::kAbsoluteList ||
mChildListID == nsIFrame::kFixedList,
"should either represent position:fixed or absolute content");
MOZ_ASSERT(mChildListID == nsIFrame::kAbsoluteList ||
mChildListID == nsIFrame::kFixedList,
"should either represent position:fixed or absolute content");
}
#ifdef DEBUG
ChildListID GetChildListID() const { return mChildListID; }
#endif
const nsFrameList& GetChildList() const { return mAbsoluteFrames; }
void AppendChildList(nsTArray<nsIFrame::ChildList>* aLists,
ChildListID aListID) const
{
NS_ASSERTION(aListID == GetChildListID(), "wrong list ID");
NS_ASSERTION(aListID == mChildListID, "wrong list ID");
GetChildList().AppendIfNonempty(aLists, aListID);
}
@ -75,18 +68,20 @@ public:
ChildListID aListID,
nsIFrame* aOldFrame);
// Called by the delegating frame after it has done its reflow first. This
// function will reflow any absolutely positioned child frames that need to
// be reflowed, e.g., because the absolutely positioned child frame has
// 'auto' for an offset, or a percentage based width or height.
//
// aOverflowAreas, if non-null, is unioned with (in the local
// coordinate space) the overflow areas of the absolutely positioned
// children.
//
// aReflowStatus is assumed to be already-initialized, e.g. with the status
// of the delegating frame's main reflow. This function merges in the
// statuses of the absolutely positioned children's reflows.
/**
* Called by the delegating frame after it has done its reflow first. This
* function will reflow any absolutely positioned child frames that need to
* be reflowed, e.g., because the absolutely positioned child frame has
* 'auto' for an offset, or a percentage based width or height.
*
* @param aOverflowAreas, if non-null, is unioned with (in the local
* coordinate space) the overflow areas of the absolutely positioned
* children.
*
* @param aReflowStatus is assumed to be already-initialized, e.g. with the
* status of the delegating frame's main reflow. This function merges in the
* statuses of the absolutely positioned children's reflows.
*/
nsresult Reflow(nsContainerFrame* aDelegatingFrame,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
@ -102,24 +97,30 @@ public:
void DestroyFrames(nsIFrame* aDelegatingFrame,
nsIFrame* aDestructRoot);
bool HasAbsoluteFrames() {return mAbsoluteFrames.NotEmpty();}
bool HasAbsoluteFrames() const { return mAbsoluteFrames.NotEmpty(); }
// Mark our size-dependent absolute frames with NS_FRAME_HAS_DIRTY_CHILDREN
// so that we'll make sure to reflow them.
/**
* Mark our size-dependent absolute frames with NS_FRAME_HAS_DIRTY_CHILDREN
* so that we'll make sure to reflow them.
*/
void MarkSizeDependentFramesDirty();
// Mark all our absolute frames with NS_FRAME_IS_DIRTY
/**
* Mark all our absolute frames with NS_FRAME_IS_DIRTY.
*/
void MarkAllFramesDirty();
protected:
// Returns true if the position of f depends on the position of
// its placeholder or if the position or size of f depends on a
// containing block dimension that changed.
bool FrameDependsOnContainer(nsIFrame* f, bool aCBWidthChanged,
bool aCBHeightChanged);
/**
* Returns true if the position of aFrame depends on the position of
* its placeholder or if the position or size of aFrame depends on a
* containing block dimension that changed.
*/
bool FrameDependsOnContainer(nsIFrame* aFrame, bool aCBWidthChanged,
bool aCBHeightChanged);
nsresult ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
nsPresContext* aPresContext,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nscoord aContainingBlockWidth,
nscoord aContainingBlockHeight,
@ -128,9 +129,12 @@ protected:
nsReflowStatus& aStatus,
nsOverflowAreas* aOverflowAreas);
// Mark our absolute frames dirty. If aMarkAllDirty is true, all will be
// marked with NS_FRAME_IS_DIRTY. Otherwise, the size-dependant ones will be
// marked with NS_FRAME_HAS_DIRTY_CHILDREN.
/**
* Mark our absolute frames dirty.
* @param aMarkAllDirty if true, all will be marked with NS_FRAME_IS_DIRTY.
* Otherwise, the size-dependant ones will be marked with
* NS_FRAME_HAS_DIRTY_CHILDREN.
*/
void DoMarkFramesDirty(bool aMarkAllDirty);
protected:
@ -138,12 +142,7 @@ protected:
#ifdef DEBUG
ChildListID const mChildListID; // kFixedList or kAbsoluteList
// helper routine for debug printout
void PrettyUC(nscoord aSize,
char* aBuf);
#endif
};
#endif /* nsnsAbsoluteContainingBlock_h___ */