Move reflow command construction into nsPresShell::AppendReflowCommand, remove

some members, switch some callers to the non-COM-ish apis.  Bug 267085, r+sr=rbs
This commit is contained in:
bzbarsky%mit.edu 2005-02-08 00:59:52 +00:00
parent e855f5bf2f
commit e042c2f571
23 changed files with 126 additions and 374 deletions

View File

@ -10193,14 +10193,9 @@ nsCSSFrameConstructor::StyleChangeReflow(nsPresContext* aPresContext,
aFrame = GetIBContainingBlockFor(aFrame);
// Target a style-change reflow at the frame.
nsHTMLReflowCommand *reflowCmd;
nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame,
eReflowType_StyleChanged,
nsnull,
aAttribute);
if (NS_SUCCEEDED(rv))
aPresContext->PresShell()->AppendReflowCommand(reflowCmd);
aPresContext->PresShell()->AppendReflowCommand(aFrame,
eReflowType_StyleChanged,
nsnull);
}
return NS_OK;

View File

@ -84,7 +84,6 @@ class nsILayoutHistoryState;
class nsIReflowCallback;
class nsISupportsArray;
class nsIDOMNode;
class nsHTMLReflowCommand;
class nsIStyleFrameConstruction;
class nsIStyleSheet;
class nsCSSFrameConstructor;
@ -323,7 +322,10 @@ public:
/**
* Reflow commands
*/
NS_IMETHOD AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand) = 0;
NS_IMETHOD AppendReflowCommand(nsIFrame* aTargetFrame,
nsReflowType aReflowType,
nsIAtom* aChildListName) = 0;
// XXXbz don't we need a child list name on this too?
NS_IMETHOD CancelReflowCommand(nsIFrame* aTargetFrame, nsReflowType* aCmdType) = 0;
NS_IMETHOD CancelAllReflowCommands() = 0;

View File

@ -1032,7 +1032,7 @@ ReflowCommandHashHashKey(PLDHashTable *table, const void *key)
// same high-order bits as all the other child list names.
return
(NS_PTR_TO_INT32(command->GetTarget()) >> 2) ^
(command->GetType() << 17) ^
(command->Type() << 17) ^
(NS_PTR_TO_INT32(command->GetChildListName()) << 20);
}
@ -1048,7 +1048,7 @@ ReflowCommandHashMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *entry,
return
command->GetTarget() == command2->GetTarget() &&
command->GetType() == command2->GetType() &&
command->Type() == command2->Type() &&
command->GetChildListName() == command2->GetChildListName();
}
@ -1109,8 +1109,10 @@ public:
nsISupports** aResult) const;
NS_IMETHOD GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aPlaceholderFrame) const;
NS_IMETHOD AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand);
NS_IMETHOD CancelReflowCommand(nsIFrame* aTargetFrame,
NS_IMETHOD AppendReflowCommand(nsIFrame* aTargetFrame,
nsReflowType aReflowType,
nsIAtom* aChildListName);
NS_IMETHOD CancelReflowCommand(nsIFrame* aTargetFrame,
nsReflowType* aCmdType);
NS_IMETHOD CancelReflowCommandInternal(nsIFrame* aTargetFrame,
nsReflowType* aCmdType,
@ -3558,7 +3560,9 @@ PresShell::AlreadyInQueue(nsHTMLReflowCommand* aReflowCommand)
}
NS_IMETHODIMP
PresShell::AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand)
PresShell::AppendReflowCommand(nsIFrame* aTargetFrame,
nsReflowType aReflowType,
nsIAtom* aChildListName)
{
// If we've not yet done the initial reflow, then don't bother
// enqueuing a reflow command yet.
@ -3569,10 +3573,20 @@ PresShell::AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand)
//printf("gShellCounter: %d\n", gShellCounter++);
if (mInVerifyReflow) {
return NS_OK;
}
}
#endif
nsHTMLReflowCommand* command = new nsHTMLReflowCommand(aTargetFrame,
aReflowType,
aChildListName);
if (!command) {
return NS_ERROR_OUT_OF_MEMORY;
}
#ifdef DEBUG
if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
printf("\nPresShell@%p: adding reflow command\n", (void*)this);
aReflowCommand->List(stdout);
command->List(stdout);
if (VERIFY_REFLOW_REALLY_NOISY_RC & gVerifyReflowFlags) {
printf("Current content model:\n");
nsIContent *rootContent = mDocument->GetRootContent();
@ -3585,20 +3599,20 @@ PresShell::AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand)
// Add the reflow command to the queue
nsresult rv = NS_OK;
if (!AlreadyInQueue(aReflowCommand)) {
if (mReflowCommands.AppendElement(aReflowCommand)) {
ReflowCommandAdded(aReflowCommand);
if (!AlreadyInQueue(command)) {
if (mReflowCommands.AppendElement(command)) {
ReflowCommandAdded(command);
} else {
// Drop this command.... we're out of memory
PL_DHashTableOperate(&mReflowCommandTable, aReflowCommand,
PL_DHashTableOperate(&mReflowCommandTable, command,
PL_DHASH_REMOVE);
delete aReflowCommand;
delete command;
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
else {
// We're not going to process this reflow command.
delete aReflowCommand;
delete command;
}
// For async reflow during doc load, post a reflow event if we are not batching reflow commands.
@ -3687,7 +3701,7 @@ PresShell::CancelReflowCommandInternal(nsIFrame* aTargetFrame,
for (i = 0; i < n; i++) {
nsHTMLReflowCommand* rc = (nsHTMLReflowCommand*) mReflowCommands.ElementAt(i);
if (rc && rc->GetTarget() == aTargetFrame &&
(!aCmdType || rc->GetType() == *aCmdType)) {
(!aCmdType || rc->Type() == *aCmdType)) {
#ifdef DEBUG
if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
printf("PresShell: removing rc=%p for frame ", (void*)rc);
@ -6372,10 +6386,7 @@ PresShell::ReflowCommandAdded(nsHTMLReflowCommand* aRC)
if (gAsyncReflowDuringDocLoad) {
NS_PRECONDITION(mRCCreatedDuringLoad >= 0, "PresShell's reflow command queue is in a bad state.");
if (mDocumentLoading) {
PRInt32 flags;
aRC->GetFlags(&flags);
flags |= NS_RC_CREATED_DURING_DOCUMENT_LOAD;
aRC->SetFlags(flags);
aRC->AddFlagBits(NS_RC_CREATED_DURING_DOCUMENT_LOAD);
mRCCreatedDuringLoad++;
#ifdef PR_LOGGING
@ -6413,9 +6424,7 @@ PresShell::ReflowCommandRemoved(nsHTMLReflowCommand* aRC)
if (gAsyncReflowDuringDocLoad) {
NS_PRECONDITION(mRCCreatedDuringLoad >= 0, "PresShell's reflow command queue is in a bad state.");
PRInt32 flags;
aRC->GetFlags(&flags);
if (flags & NS_RC_CREATED_DURING_DOCUMENT_LOAD) {
if (aRC->GetFlagBits() & NS_RC_CREATED_DURING_DOCUMENT_LOAD) {
mRCCreatedDuringLoad--;
PR_LOG(gLog, PR_LOG_DEBUG,

View File

@ -381,12 +381,9 @@ void
nsFormControlHelper::StyleChangeReflow(nsPresContext* aPresContext,
nsIFrame* aFrame)
{
nsHTMLReflowCommand* reflowCmd;
nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame,
eReflowType_StyleChanged);
if (NS_SUCCEEDED(rv)) {
aPresContext->PresShell()->AppendReflowCommand(reflowCmd);
}
aPresContext->PresShell()->AppendReflowCommand(aFrame,
eReflowType_StyleChanged,
nsnull);
}

View File

@ -78,8 +78,6 @@ nsAbsoluteContainingBlock::AppendFrames(nsIFrame* aDelegatingFrame,
nsIAtom* aListName,
nsIFrame* aFrameList)
{
nsresult rv = NS_OK;
// Append the frames to our list of absolutely positioned frames
#ifdef NS_DEBUG
nsFrame::VerifyDirtyBitSet(aFrameList);
@ -87,15 +85,9 @@ nsAbsoluteContainingBlock::AppendFrames(nsIFrame* aDelegatingFrame,
mAbsoluteFrames.AppendFrames(nsnull, aFrameList);
// Generate a reflow command to reflow the dirty frames
nsHTMLReflowCommand* reflowCmd;
rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, eReflowType_ReflowDirty);
if (NS_SUCCEEDED(rv)) {
reflowCmd->SetChildListName(GetChildListName());
aDelegatingFrame->GetPresContext()->PresShell()->
AppendReflowCommand(reflowCmd);
}
return rv;
return aDelegatingFrame->GetPresContext()->PresShell()->
AppendReflowCommand(aDelegatingFrame, eReflowType_ReflowDirty,
GetChildListName());
}
nsresult
@ -104,8 +96,6 @@ nsAbsoluteContainingBlock::InsertFrames(nsIFrame* aDelegatingFrame,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
{
nsresult rv = NS_OK;
// Insert the new frames
#ifdef NS_DEBUG
nsFrame::VerifyDirtyBitSet(aFrameList);
@ -113,15 +103,9 @@ nsAbsoluteContainingBlock::InsertFrames(nsIFrame* aDelegatingFrame,
mAbsoluteFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
// Generate a reflow command to reflow the dirty frames
nsHTMLReflowCommand* reflowCmd;
rv = NS_NewHTMLReflowCommand(&reflowCmd, aDelegatingFrame, eReflowType_ReflowDirty);
if (NS_SUCCEEDED(rv)) {
reflowCmd->SetChildListName(GetChildListName());
aDelegatingFrame->GetPresContext()->PresShell()->
AppendReflowCommand(reflowCmd);
}
return rv;
return aDelegatingFrame->GetPresContext()->PresShell()->
AppendReflowCommand(aDelegatingFrame, eReflowType_ReflowDirty,
GetChildListName());
}
nsresult
@ -248,10 +232,7 @@ nsAbsoluteContainingBlock::ReflowingAbsolutesOnly(nsIFrame* aDelegatingFrame,
if (command) {
// It's targeted at us. See if it's for the positioned child frames
nsCOMPtr<nsIAtom> listName;
command->GetChildListName(*getter_AddRefs(listName));
if (GetChildListName() != listName) {
if (GetChildListName() != command->GetChildListName()) {
// A reflow command is targeted directly at this block.
// The block will have to do a proper reflow.
return PR_FALSE;
@ -403,18 +384,11 @@ nsAbsoluteContainingBlock::IncrementalReflow(nsIFrame* aDelegatin
if (command) {
// It's targeted at us. See if it's for the positioned child frames
nsCOMPtr<nsIAtom> listName;
command->GetChildListName(*getter_AddRefs(listName));
if (GetChildListName() == listName) {
nsReflowType type;
// Get the type of reflow command
command->GetType(type);
if (GetChildListName() == command->GetChildListName()) {
// The only type of reflow command we expect is that we have dirty
// child frames to reflow
NS_ASSERTION(type == eReflowType_ReflowDirty, "unexpected reflow type");
NS_ASSERTION(command->Type() == eReflowType_ReflowDirty,
"unexpected reflow type");
// Walk the positioned frames and reflow the dirty frames
for (nsIFrame* f = mAbsoluteFrames.FirstChild(); f; f = f->GetNextSibling()) {
@ -504,9 +478,7 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
if (command) {
// We're the target.
nsReflowType type;
command->GetType(type);
printf("(%d)", type);
printf("(%d)", command->Type());
}
}
char width[16];

View File

@ -593,9 +593,7 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
// We're the target.
reflow += " (";
nsReflowType type;
command->GetType(type);
reflow += kReflowCommandType[type];
reflow += kReflowCommandType[command->Type()];
reflow += ")";
}
@ -760,12 +758,10 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
nsReflowPath *path = aReflowState.path;
nsHTMLReflowCommand *command = path->mReflowCommand;
if (command) {
nsReflowType type;
command->GetType(type);
#ifdef NOISY_REFLOW_REASON
printf("type=%s ", kReflowCommandType[type]);
printf("type=%s ", kReflowCommandType[command->Type()]);
#endif
switch (type) {
switch (command->Type()) {
case eReflowType_StyleChanged:
rv = PrepareStyleChangedReflow(state);
break;
@ -2080,9 +2076,8 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)
nsHTMLReflowCommand *command = aState.mReflowState.path->mReflowCommand;
if (command) {
nsReflowType type;
command->GetType(type);
printf(": type=%s(%d)", kReflowCommandType[type], type);
printf(": type=%s(%d)", kReflowCommandType[command->Type()],
command->Type());
}
}
else {
@ -2991,13 +2986,8 @@ nsBlockFrame::AttributeChanged(nsIContent* aChild,
// XXX Not sure if this is necessary anymore
RenumberLists(presContext);
nsHTMLReflowCommand* reflowCmd;
rv = NS_NewHTMLReflowCommand(&reflowCmd, this,
eReflowType_ContentChanged,
nsnull,
aAttribute);
if (NS_SUCCEEDED(rv))
presContext->PresShell()->AppendReflowCommand(reflowCmd);
rv = presContext->PresShell()->
AppendReflowCommand(this, eReflowType_ContentChanged, nsnull);
}
else if (nsHTMLAtoms::value == aAttribute) {
const nsStyleDisplay* styleDisplay = GetStyleDisplay();
@ -3024,13 +3014,8 @@ nsBlockFrame::AttributeChanged(nsIContent* aChild,
// XXX Not sure if this is necessary anymore
blockParent->RenumberLists(presContext);
nsHTMLReflowCommand* reflowCmd;
rv = NS_NewHTMLReflowCommand(&reflowCmd, blockParent,
eReflowType_ContentChanged,
nsnull,
aAttribute);
if (NS_SUCCEEDED(rv))
presContext->PresShell()->AppendReflowCommand(reflowCmd);
rv = presContext->PresShell()->
AppendReflowCommand(blockParent, eReflowType_ContentChanged, nsnull);
}
}
}
@ -6549,13 +6534,9 @@ nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
// 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...
nsHTMLReflowCommand* reflowCmd;
nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, this,
eReflowType_ReflowDirty);
if (NS_SUCCEEDED(rv)) {
reflowCmd->SetChildListName(mAbsoluteContainer.GetChildListName());
aPresShell->AppendReflowCommand(reflowCmd);
}
nsresult rv = aPresShell->
AppendReflowCommand(this, eReflowType_ReflowDirty,
mAbsoluteContainer.GetChildListName());
#ifdef DEBUG
if (gNoisyReflow) {
@ -6599,8 +6580,7 @@ nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
// post a dirty children reflow command targeted at yourself
mState |= NS_FRAME_HAS_DIRTY_CHILDREN;
nsFrame::CreateAndPostReflowCommand(aPresShell, this,
eReflowType_ReflowDirty, nsnull, nsnull, nsnull);
aPresShell->AppendReflowCommand(this, eReflowType_ReflowDirty, nsnull);
#ifdef DEBUG
if (gNoisyReflow) {
@ -6970,9 +6950,7 @@ nsBlockFrame::ReflowBullet(nsBlockReflowState& aState,
// the block, in which case, we propagate that to its children.
nsHTMLReflowCommand *command = rs.path->mReflowCommand;
if (command) {
nsReflowType type;
command->GetType(type);
if (type == eReflowType_StyleChanged)
if (command->Type() == eReflowType_StyleChanged)
reason = eReflowReason_StyleChange;
}
}

View File

@ -685,10 +685,7 @@ nsColumnSetFrame::Reflow(nsPresContext* aPresContext,
// See if it's targeted at us
if (command) {
nsReflowType reflowType;
command->GetType(reflowType);
switch (reflowType) {
switch (command->Type()) {
case eReflowType_StyleChanged:
kidReason = eReflowReason_StyleChange;

View File

@ -48,7 +48,6 @@
#include "nsIView.h"
#include "nsIScrollableView.h"
#include "nsVoidArray.h"
#include "nsHTMLReflowCommand.h"
#include "nsHTMLContainerFrame.h"
#include "nsFrameManager.h"
#include "nsIPresShell.h"
@ -416,8 +415,7 @@ nsContainerFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
// child because the frame may have more than one child
mState |= NS_FRAME_HAS_DIRTY_CHILDREN;
nsFrame::CreateAndPostReflowCommand(aPresShell, aChild,
eReflowType_ReflowDirty, nsnull, nsnull, nsnull);
aPresShell->AppendReflowCommand(aChild, eReflowType_ReflowDirty, nsnull);
return NS_OK;
}

View File

@ -4504,34 +4504,6 @@ nsFrame::GetFirstLeaf(nsPresContext* aPresContext, nsIFrame **aFrame)
}
}
nsresult nsFrame::CreateAndPostReflowCommand(nsIPresShell* aPresShell,
nsIFrame* aTargetFrame,
nsReflowType aReflowType,
nsIFrame* aChildFrame,
nsIAtom* aAttribute,
nsIAtom* aListName)
{
nsresult rv;
if (!aPresShell || !aTargetFrame) {
rv = NS_ERROR_NULL_POINTER;
}
else {
nsHTMLReflowCommand* reflowCmd;
rv = NS_NewHTMLReflowCommand(&reflowCmd, aTargetFrame,
aReflowType, aChildFrame,
aAttribute);
if (NS_SUCCEEDED(rv)) {
if (nsnull != aListName) {
reflowCmd->SetChildListName(aListName);
}
aPresShell->AppendReflowCommand(reflowCmd);
}
}
return rv;
}
NS_IMETHODIMP
nsFrame::CaptureMouse(nsPresContext* aPresContext, PRBool aGrabMouseEvents)
{
@ -5298,14 +5270,12 @@ nsFrame::BoxReflow(nsBoxLayoutState& aState,
PRBool reflowChild = PR_TRUE;
if (path->mReflowCommand &&
path->FirstChild() == path->EndChildren()) {
path->FirstChild() == path->EndChildren() &&
path->mReflowCommand->Type() == eReflowType_StyleChanged) {
// There's an incremental reflow targeted directly at our
// frame, and our frame only (i.e., none of our descendants
// are targets).
nsReflowType type;
path->mReflowCommand->GetType(type);
if (type == eReflowType_StyleChanged)
reflowChild = PR_FALSE;
reflowChild = PR_FALSE;
}
if (reflowChild) {
@ -5607,14 +5577,11 @@ nsFrame::CanSetMaxElementWidth(nsBoxLayoutState& aState, nsReflowReason& aReason
// only incremental reflows can handle maxelementsize being set.
if (reflowState->reason == eReflowReason_Incremental) {
nsReflowPath *path = *aReflowPath;
if (path && path->mReflowCommand) {
if (path && path->mReflowCommand &&
path->mReflowCommand->Type() == eReflowType_StyleChanged) {
// MaxElement doesn't work on style change reflows.. :-(
// XXXwaterson why?
nsReflowType type;
path->mReflowCommand->GetType(type);
if (type == eReflowType_StyleChanged)
return PR_FALSE;
return PR_FALSE;
}
return PR_TRUE;
@ -5719,9 +5686,7 @@ nsAdaptorPrintReason(nsHTMLReflowState& aReflowState)
break;
case eReflowReason_Incremental:
{
nsReflowType type;
aReflowState.reflowCommand->GetType(type);
switch (type) {
switch (aReflowState.reflowCommand->Type()) {
case eReflowType_StyleChanged:
reflowReasonString = "incremental (StyleChanged)";
break;
@ -6413,10 +6378,8 @@ static void DisplayReflowEnterPrint(nsPresContext* aPresContext,
DR_state->PrettyUC(aReflowState.availableWidth, width);
DR_state->PrettyUC(aReflowState.availableHeight, height);
if (aReflowState.path && aReflowState.path->mReflowCommand) {
nsReflowType type;
aReflowState.path->mReflowCommand->GetType(type);
const char *incr_reason;
switch(type) {
switch(aReflowState.path->mReflowCommand->Type()) {
case eReflowType_ContentChanged:
incr_reason = "incr. (Content)";
break;

View File

@ -358,13 +358,6 @@ public:
PRBool IsFrameTreeTooDeep(const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aMetrics);
static nsresult CreateAndPostReflowCommand(nsIPresShell* aPresShell,
nsIFrame* aTargetFrame,
nsReflowType aReflowType,
nsIFrame* aChildFrame,
nsIAtom* aAttribute,
nsIAtom* aListName);
// Do the work for getting the parent style context frame so that
// other frame's |GetParentStyleContextFrame| methods can call this
// method on *another* frame. (This function handles out-of-flow

View File

@ -38,7 +38,7 @@
#include "nsCOMPtr.h"
#include "nsHTMLParts.h"
#include "nsPresContext.h"
#include "nsHTMLReflowCommand.h"
#include "nsReflowType.h"
#include "nsIDeviceContext.h"
#include "nsPageFrame.h"
#include "nsViewsCID.h"
@ -2010,9 +2010,9 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState)
// at least one fixed child
if (parentFrame->GetFirstChild(nsLayoutAtoms::fixedList)) {
// force a reflow of the fixed children
nsFrame::CreateAndPostReflowCommand(mOuter->GetPresContext()->PresShell(),
parentFrame,
eReflowType_UserDefined, nsnull, nsnull, nsLayoutAtoms::fixedList);
mOuter->GetPresContext()->PresShell()->
AppendReflowCommand(parentFrame, eReflowType_UserDefined,
nsLayoutAtoms::fixedList);
}
}
}

View File

@ -288,11 +288,8 @@ CanvasFrame::AppendFrames(nsIAtom* aListName,
mFrames.AppendFrame(nsnull, aFrameList);
// Generate a reflow command to reflow the newly inserted frame
nsHTMLReflowCommand* reflowCmd;
rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty);
if (NS_SUCCEEDED(rv)) {
GetPresContext()->PresShell()->AppendReflowCommand(reflowCmd);
}
rv = GetPresContext()->PresShell()->
AppendReflowCommand(this, eReflowType_ReflowDirty, nsnull);
}
return rv;
@ -339,12 +336,8 @@ CanvasFrame::RemoveFrame(nsIAtom* aListName,
mFrames.DestroyFrame(GetPresContext(), aOldFrame);
// Generate a reflow command so we get reflowed
nsHTMLReflowCommand* reflowCmd;
rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty);
if (NS_SUCCEEDED(rv)) {
GetPresContext()->PresShell()->AppendReflowCommand(reflowCmd);
}
rv = GetPresContext()->PresShell()->
AppendReflowCommand(this, eReflowType_ReflowDirty, nsnull);
} else {
rv = NS_ERROR_FAILURE;
}
@ -468,10 +461,7 @@ CanvasFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowCommand *command = aReflowState.path->mReflowCommand;
if (command) {
// Get the reflow type
nsReflowType reflowType;
command->GetType(reflowType);
switch (reflowType) {
switch (command->Type()) {
case eReflowType_ReflowDirty:
isDirtyChildReflow = PR_TRUE;
break;

View File

@ -259,12 +259,4 @@ NS_NewHTMLFragmentContentSink(nsIFragmentContentSink** aInstancePtrResult);
nsresult
NS_NewHTMLFragmentContentSink2(nsIFragmentContentSink** aInstancePtrResult);
/** Create a new HTML reflow command */
nsresult
NS_NewHTMLReflowCommand(nsHTMLReflowCommand** aInstancePtrResult,
nsIFrame* aTargetFrame,
nsReflowType aReflowType,
nsIFrame* aChildFrame = nsnull,
nsIAtom* aAttribute = nsnull);
#endif /* nsHTMLParts_h___ */

View File

@ -46,25 +46,6 @@
#include "nsContainerFrame.h"
#include "nsLayoutAtoms.h"
nsresult
NS_NewHTMLReflowCommand(nsHTMLReflowCommand** aInstancePtrResult,
nsIFrame* aTargetFrame,
nsReflowType aReflowType,
nsIFrame* aChildFrame,
nsIAtom* aAttribute)
{
NS_ASSERTION(aInstancePtrResult,
"null result passed to NS_NewHTMLReflowCommand");
*aInstancePtrResult = new nsHTMLReflowCommand(aTargetFrame, aReflowType,
aChildFrame, aAttribute);
if (!*aInstancePtrResult) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}
#ifdef DEBUG_jesup
PRInt32 gReflows;
PRInt32 gReflowsInUse;
@ -105,17 +86,12 @@ mPathStats gmPathStats;
// and optional child frame
nsHTMLReflowCommand::nsHTMLReflowCommand(nsIFrame* aTargetFrame,
nsReflowType aReflowType,
nsIFrame* aChildFrame,
nsIAtom* aAttribute)
: mType(aReflowType), mTargetFrame(aTargetFrame), mChildFrame(aChildFrame),
mAttribute(aAttribute),
mListName(nsnull),
nsIAtom* aChildListName)
: mType(aReflowType), mTargetFrame(aTargetFrame), mListName(aChildListName),
mFlags(0)
{
MOZ_COUNT_CTOR(nsHTMLReflowCommand);
NS_PRECONDITION(mTargetFrame != nsnull, "null target frame");
if (nsnull!=mAttribute)
NS_ADDREF(mAttribute);
#ifdef DEBUG_jesup
gReflows++;
gReflowsInUse++;
@ -136,9 +112,6 @@ nsHTMLReflowCommand::~nsHTMLReflowCommand()
gReflowsMaxLarger++;
gReflowsInUse--;
#endif
NS_IF_RELEASE(mAttribute);
NS_IF_RELEASE(mListName);
}
nsresult
@ -158,16 +131,6 @@ nsHTMLReflowCommand::List(FILE* out) const
fprintf(out, " target=");
nsFrame::ListTag(out, mTargetFrame);
}
if (mChildFrame) {
fprintf(out, " child=");
nsFrame::ListTag(out, mChildFrame);
}
if (mAttribute) {
fprintf(out, " attr=");
nsAutoString attr;
mAttribute->ToString(attr);
fputs(NS_LossyConvertUCS2toASCII(attr).get(), out);
}
if (mListName) {
fprintf(out, " list=");
nsAutoString attr;

View File

@ -82,8 +82,7 @@ public:
*/
nsHTMLReflowCommand(nsIFrame* aTargetFrame,
nsReflowType aReflowType,
nsIFrame* aChildFrame = nsnull,
nsIAtom* aAttribute = nsnull);
nsIAtom* aChildListName);
~nsHTMLReflowCommand();
@ -95,17 +94,7 @@ public:
/**
* Get the type of reflow command.
*/
nsReflowType GetType() const { return mType; }
/**
* Can return nsnull.
*/
nsIAtom* GetAttribute() const { return mAttribute; }
/**
* Get the child frame associated with the reflow command.
*/
nsIFrame* GetChildFrame() const { return mChildFrame; }
nsReflowType Type() const { return mType; }
/**
* Returns the name of the child list to which the child frame belongs.
@ -117,25 +106,14 @@ public:
*/
nsIAtom* GetChildListName() const { return mListName; }
/**
* Sets the name of the child list to which the child frame belongs.
* Only used for reflow command types FrameAppended, FrameInserted, and
* FrameRemoved
*/
void SetChildListName(nsIAtom* aListName) {
NS_ASSERTION(!mListName, "SetChildListName called twice");
mListName = aListName;
NS_IF_ADDREF(mListName);
}
/**
* Dump out the reflow-command to out
*/
nsresult List(FILE* out) const;
/**
* Get/set reflow command flags
*/
/**
* Get/set reflow command flags
*/
PRInt32 GetFlagBits() { return mFlags; }
void AddFlagBits(PRInt32 aBits) { mFlags |= aBits; }
void RemoveFlagBits(PRInt32 aBits) { mFlags &= ~aBits; }
@ -152,40 +130,18 @@ public:
aReflowType = mType;
return NS_OK;
}
nsresult GetAttribute(nsIAtom *& aAttribute) const {
aAttribute = mAttribute;
NS_IF_ADDREF(aAttribute);
return NS_OK;
}
nsresult GetChildFrame(nsIFrame*& aChildFrame) const {
aChildFrame = mChildFrame;
return NS_OK;
}
nsresult GetChildListName(nsIAtom*& aListName) const {
aListName = mListName;
NS_IF_ADDREF(aListName);
return NS_OK;
}
nsresult GetFlags(PRInt32* aFlags) {
*aFlags = mFlags;
return NS_OK;
}
nsresult SetFlags(PRInt32 aFlags) {
mFlags = aFlags;
return NS_OK;
}
private:
nsReflowType mType;
nsIFrame* mTargetFrame;
nsIFrame* mChildFrame;
nsIAtom* mAttribute;
nsIAtom* mListName;
nsReflowType mType;
nsIFrame* mTargetFrame;
nsCOMPtr<nsIAtom> mListName;
// XXXbz remove the flags? They're not being used for much...
PRInt32 mFlags;
};

View File

@ -885,15 +885,12 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
// subtree.
nsHTMLReflowCommand* rc = rs->path->mReflowCommand;
if (rc) {
nsReflowType type;
rc->GetType(type);
nsReflowType type = rc->Type();
if (type == eReflowType_StyleChanged) {
nsIFrame* parentFrame = psd->mFrame
? psd->mFrame->mFrame
: mBlockReflowState->frame;
nsIFrame* target;
rc->GetTarget(target);
if (target == parentFrame) {
if (rc->GetTarget() == parentFrame) {
reason = eReflowReason_StyleChange;
}
}

View File

@ -452,8 +452,9 @@ nsMathMLmactionFrame::MouseClick(nsIDOMEvent* aMouseEvent)
// targeted at our selected frame
nsIPresShell *presShell = mPresContext->PresShell();
presShell->CancelReflowCommand(this, nsnull);
nsFrame::CreateAndPostReflowCommand(presShell, mSelectedFrame,
eReflowType_StyleChanged, nsnull, nsnull, nsnull);
presShell->AppendReflowCommand(mSelectedFrame,
eReflowType_StyleChanged,
nsnull);
}
}
}

View File

@ -254,7 +254,6 @@ protected:
const nsHTMLReflowState& aReflowState);
// nsIView* mView;
nsIPresShell* mPresShell; // XXX is a non-owning ref ok?
PRUint32 mRedrawSuspendCount;
PRBool mNeedsReflow;
PRBool mViewportInitialized;
@ -289,9 +288,6 @@ NS_NewSVGOuterSVGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame*
*aNewFrame = it;
// XXX is this ok?
it->mPresShell = aPresShell;
return NS_OK;
}
@ -876,11 +872,9 @@ nsSVGOuterSVGFrame::InvalidateRegion(nsISVGRendererRegion* region, PRBool bRedra
if (!region && !bRedraw) return NS_OK;
NS_ENSURE_TRUE(mPresShell, NS_ERROR_FAILURE);
// just ignore invalidates if painting is suppressed by the shell
PRBool suppressed = PR_FALSE;
mPresShell->IsPaintingSuppressed(&suppressed);
GetPresContext()->PresShell()->IsPaintingSuppressed(&suppressed);
if (suppressed) return NS_OK;
nsIView* view = GetClosestView();
@ -975,8 +969,6 @@ nsSVGOuterSVGFrame::UnsuspendRedraw()
}
}
NS_ENSURE_TRUE(mPresShell, NS_ERROR_FAILURE);
vm->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);
return NS_OK;
}
@ -1076,18 +1068,12 @@ void nsSVGOuterSVGFrame::InitiateReflow()
mNeedsReflow = PR_FALSE;
// Generate a reflow command to reflow ourselves
nsHTMLReflowCommand *reflowCmd;
NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty);
if (!reflowCmd) {
NS_ERROR("error creating reflow command object");
return;
}
mPresShell->AppendReflowCommand(reflowCmd);
nsIPresShell* presShell = GetPresContext()->PresShell();
presShell->AppendReflowCommand(this, eReflowType_ReflowDirty, nsnull);
// XXXbz why is this synchronously flushing reflows, exactly? If it
// needs to, why is it not using the presshell's reflow batching
// instead of hacking its own?
mPresShell->FlushPendingNotifications(Flush_OnlyReflow);
presShell->FlushPendingNotifications(Flush_OnlyReflow);
}

View File

@ -419,11 +419,7 @@ NS_METHOD nsTableColGroupFrame::IR_TargetIsMe(nsHTMLReflowMetrics& aDesiredS
{
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
nsReflowType type;
aReflowState.path->mReflowCommand->GetType(type);
nsIFrame *objectFrame;
aReflowState.path->mReflowCommand->GetChildFrame(objectFrame);
switch (type)
switch (aReflowState.path->mReflowCommand->Type())
{
case eReflowType_StyleChanged :
rv = IR_StyleChanged(aDesiredSize, aReflowState, aStatus);

View File

@ -343,15 +343,8 @@ nsTableFrame::AppendDirtyReflowCommand(nsIFrame* aFrame)
{
aFrame->AddStateBits(NS_FRAME_IS_DIRTY); // mark the table frame as dirty
nsHTMLReflowCommand* reflowCmd;
nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame,
eReflowType_ReflowDirty);
if (NS_SUCCEEDED(rv)) {
// Add the reflow command
rv = aFrame->GetPresContext()->PresShell()->AppendReflowCommand(reflowCmd);
}
return rv;
return aFrame->GetPresContext()->PresShell()->
AppendReflowCommand(aFrame, eReflowType_ReflowDirty, nsnull);
}
// Make sure any views are positioned properly
@ -2667,10 +2660,7 @@ nsTableFrame::IR_TargetIsMe(nsTableReflowState& aReflowState,
nsresult rv = NS_OK;
aStatus = NS_FRAME_COMPLETE;
nsReflowType type;
aReflowState.reflowState.path->mReflowCommand->GetType(type);
switch (type) {
switch (aReflowState.reflowState.path->mReflowCommand->Type()) {
case eReflowType_StyleChanged :
rv = IR_StyleChanged(aReflowState, aStatus);
break;
@ -7419,9 +7409,7 @@ void nsTableFrame::DebugReflow(nsIFrame* aFrame,
timer->mCount = gRflCount++;
nsHTMLReflowCommand* reflowCommand = aState.reflowCommand;
if (reflowCommand) {
nsReflowType reflowType;
reflowCommand->GetType(reflowType);
timer->mReflowType = reflowType;
timer->mReflowType = reflowType->Type();
}
timer->Start();
aState.mDebugHook = timer;

View File

@ -236,11 +236,9 @@ nsTableOuterFrame::AppendFrames(nsIAtom* aListName,
// Reflow the new caption frame. It's already marked dirty, so generate a reflow
// command that tells us to reflow our dirty child frames
nsHTMLReflowCommand* reflowCmd;
rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty);
if (NS_SUCCEEDED(rv))
GetPresContext()->PresShell()->AppendReflowCommand(reflowCmd);
rv = GetPresContext()->
PresShell()->AppendReflowCommand(this, eReflowType_ReflowDirty,
nsnull);
}
}
else {
@ -264,8 +262,6 @@ NS_IMETHODIMP
nsTableOuterFrame::RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame)
{
nsresult rv;
// We only have two child frames: the inner table and one caption frame.
// The inner frame can't be removed so this should be the caption
NS_PRECONDITION(nsLayoutAtoms::captionList == aListName, "can't remove inner frame");
@ -290,11 +286,9 @@ nsTableOuterFrame::RemoveFrame(nsIAtom* aListName,
}
// Generate a reflow command so we get reflowed
nsHTMLReflowCommand* reflowCmd;
rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty);
if (NS_SUCCEEDED(rv))
GetPresContext()->PresShell()->AppendReflowCommand(reflowCmd);
GetPresContext()->PresShell()->AppendReflowCommand(this,
eReflowType_ReflowDirty,
nsnull);
return NS_OK;
}
@ -1305,9 +1299,7 @@ nsTableOuterFrame::OuterReflowChild(nsPresContext* aPresContext,
mInnerTableFrame == aChildFrame && childRS.reason == eReflowReason_Incremental) {
nsHTMLReflowCommand* command = childRS.path->mReflowCommand;
if (command) {
nsReflowType type;
command->GetType(type);
*aNeedToReflowCaption = eReflowType_StyleChanged == type;
*aNeedToReflowCaption = eReflowType_StyleChanged == command->Type();
}
}
@ -1454,9 +1446,7 @@ nsTableOuterFrame::IR_TargetIsCaptionFrame(nsPresContext* aPresContext
nsReflowReason reflowReason = eReflowReason_Incremental;
nsHTMLReflowCommand* command = aOuterRS.path->mReflowCommand;
if (command) {
nsReflowType reflowCommandType;
command->GetType(reflowCommandType);
switch(reflowCommandType) {
switch(command->Type()) {
case eReflowType_StyleChanged:
needInnerReflow = PR_TRUE;
break;
@ -1605,12 +1595,7 @@ nsresult nsTableOuterFrame::IR_TargetIsMe(nsPresContext* aPresContext,
nsReflowStatus& aStatus)
{
nsresult rv = NS_OK;
nsHTMLReflowCommand* command = aReflowState.path->mReflowCommand;
nsReflowType type;
command->GetType(type);
nsIFrame* objectFrame;
command->GetChildFrame(objectFrame);
switch (type) {
switch (aReflowState.path->mReflowCommand->Type()) {
case eReflowType_ReflowDirty:
rv = IR_ReflowDirty(aPresContext, aDesiredSize, aReflowState, aStatus);
break;
@ -1658,9 +1643,7 @@ nsTableOuterFrame::IR_InnerTableReflow(nsPresContext* aPresContext,
nsReflowReason reflowReason = eReflowReason_Incremental;
nsHTMLReflowCommand* command = aOuterRS.path->mReflowCommand;
if (command) {
nsReflowType type;
command->GetType(type);
if (eReflowType_StyleChanged == type) {
if (eReflowType_StyleChanged == command->Type()) {
reflowReason = eReflowReason_StyleChange;
reflowCaption = PR_TRUE;
}

View File

@ -331,8 +331,8 @@ nsBox::MarkStyleChange(nsBoxLayoutState& aState)
return parent->RelayoutDirtyChild(aState, this);
else {
/*
nsFrame::CreateAndPostReflowCommand(aState.PresShell(), this,
nsHTMLReflowCommand::StyleChange, nsnull, nsnull, nsnull);
aState.PresShell()->AppendReflowCommand(this, eReflowType_StyleChanged,
nsnull);
return NS_OK;
*/
return GetParent()->ReflowDirtyChild(aState.PresShell(), this);
@ -396,9 +396,8 @@ nsBox::RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild)
AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
if (GetStateBits() & NS_FRAME_REFLOW_ROOT) {
nsFrame::CreateAndPostReflowCommand(aState.PresShell(), this,
eReflowType_ReflowDirty,
nsnull, nsnull, nsnull);
aState.PresShell()->AppendReflowCommand(this, eReflowType_ReflowDirty,
nsnull);
return NS_OK;
}

View File

@ -623,11 +623,8 @@ nsSplitterFrameInner::MouseDrag(nsPresContext* aPresContext, nsGUIEvent* aEvent)
/*
nsIPresShell *shell = aPresContext->PresShell();
nsCOMPtr<nsHTMLReflowCommand> reflowCmd;
nsresult rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), mOuter->mParent,
eReflowType_StyleChanged);
if (NS_SUCCEEDED(rv))
shell->AppendReflowCommand(reflowCmd);
shell->AppendReflowCommand(mOuter->mParent, eReflowType_StyleChanged,
nsnull);
mOuter->mState |= NS_FRAME_IS_DIRTY;
mOuter->mParent->ReflowDirtyChild(shell, mOuter);