bug 128804 - moved optimization of text controls to nsBlockReflowState and initialized it earlier. a=dbaron, sr=attinasi, r=alexsavulov.

This commit is contained in:
karnaze%netscape.com 2002-03-12 15:48:52 +00:00
Родитель 3c88a713e6
Коммит 2b094e1eca
8 изменённых файлов: 72 добавлений и 76 удалений

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

@ -781,7 +781,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
// Do nothing; the dirty lines will already have been marked.
break;
case eReflowReason_Incremental: // should call GetNext() ?
case eReflowReason_Incremental:
aReflowState.reflowCommand->GetTarget(target);
if (this == target) {
nsReflowType type;
@ -2112,33 +2112,6 @@ WrappedLinesAreDirty(nsLineList::iterator aLine,
return PR_FALSE;
}
PRBool nsBlockFrame::IsIncrementalDamageConstrained(const nsBlockReflowState& aState) const
{
// see if the reflow will go through a text control. if so, we can optimize
// because we know the text control won't change size.
if (aState.mReflowState.reflowCommand)
{
nsIFrame *target;
aState.mReflowState.reflowCommand->GetTarget(target);
while (target)
{ // starting with the target's parent, scan for a text control
nsIFrame *parent;
target->GetParent(&parent);
if ((nsIFrame*)this==parent || !parent) // the null check is paranoia, it should never happen
break; // we found ourself, so we know there's no text control between us and target
nsCOMPtr<nsIAtom> frameType;
parent->GetFrameType(getter_AddRefs(frameType));
if (frameType)
{
if (nsLayoutAtoms::textInputFrame == frameType.get())
return PR_TRUE; // damage is constrained to the text control innards
}
target = parent; // advance the loop up the frame tree
}
}
return PR_FALSE; // default case, damage is not constrained (or unknown)
}
static void PlaceFrameView(nsIPresContext* aPresContext, nsIFrame* aFrame);
/**
@ -2273,10 +2246,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)
// Reflow the dirty line. If it's an incremental reflow, then force
// it to invalidate the dirty area if necessary
PRBool forceInvalidate = PR_FALSE;
if (incrementalReflow) {
forceInvalidate = !IsIncrementalDamageConstrained(aState);
}
PRBool forceInvalidate = incrementalReflow && !aState.GetFlag(BRS_DAMAGECONSTRAINED);
rv = ReflowLine(aState, line, &keepGoing, forceInvalidate);
if (NS_FAILED(rv)) {
return rv;

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

@ -230,11 +230,6 @@ protected:
return 0 != (mState & NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET);
}
/** return PR_TRUE if the incremental reflow described by aState is 100% contained
* within the bounds of a ancestor frame, relative to this frame.
*/
PRBool IsIncrementalDamageConstrained(const nsBlockReflowState& aState) const;
/** move the frames contained by aLine by aDY
* if aLine is a block, it's child floaters are added to the state manager
*/

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

@ -176,6 +176,8 @@ nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState,
mMinLineHeight = nsHTMLReflowState::CalcLineHeight(mPresContext,
aReflowState.rendContext,
aReflowState.frame);
SetFlag(BRS_DAMAGECONSTRAINED, IsIncrementalDamageConstrained(aFrame));
}
nsBlockReflowState::~nsBlockReflowState()
@ -188,6 +190,32 @@ nsBlockReflowState::~nsBlockReflowState()
}
}
PRBool
nsBlockReflowState::IsIncrementalDamageConstrained(nsIFrame* aBlockFrame) const
{
// see if the reflow will go through a text control. if so, we can optimize
// because we know the text control won't change size.
if ((eReflowReason_Incremental == mReflowState.reason) && (mReflowState.reflowCommand)) {
nsIFrame* target;
mReflowState.reflowCommand->GetTarget(target);
while (target) {
// starting with the target's parent, scan for a text control
nsIFrame* parent;
target->GetParent(&parent);
if ((aBlockFrame == parent) || !parent) // the null check is paranoia, it should never happen
break; // we found the block, so we know there's no text control between the block and target
nsCOMPtr<nsIAtom> frameType;
parent->GetFrameType(getter_AddRefs(frameType));
if (frameType) {
if (nsLayoutAtoms::textInputFrame == frameType.get())
return PR_TRUE; // damage is constrained to the text control innards
}
target = parent; // advance the loop up the frame tree
}
}
return PR_FALSE; // default case, damage is not constrained (or unknown)
}
nsLineBox*
nsBlockReflowState::NewLineBox(nsIFrame* aFrame,
PRInt32 aCount,

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

@ -112,6 +112,10 @@ public:
protected:
void RecoverFloaters(nsLineList::iterator aLine, nscoord aDeltaY);
// return PR_TRUE if the incremental reflow is 100% contained
// within the bounds of an ancestor frame, relative to aBlockFrame
PRBool IsIncrementalDamageConstrained(nsIFrame* aBlockFrame) const;
public:
void RecoverStateFrom(nsLineList::iterator aLine, nscoord aDeltaY);
@ -251,7 +255,8 @@ public:
#define BRS_APPLYTOPMARGIN 0x00000100 // See ShouldApplyTopMargin
#define BRS_COMPUTEMAXELEMENTSIZE 0x00000200
#define BRS_COMPUTEMAXWIDTH 0x00000400
#define BRS_LASTFLAG BRS_COMPUTEMAXWIDTH
#define BRS_DAMAGECONSTRAINED 0x00000800 // is the target of an incremental reflow command inside a text control
#define BRS_LASTFLAG BRS_DAMAGECONSTRAINED
PRInt16 mFlags;

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

@ -781,7 +781,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
// Do nothing; the dirty lines will already have been marked.
break;
case eReflowReason_Incremental: // should call GetNext() ?
case eReflowReason_Incremental:
aReflowState.reflowCommand->GetTarget(target);
if (this == target) {
nsReflowType type;
@ -2112,33 +2112,6 @@ WrappedLinesAreDirty(nsLineList::iterator aLine,
return PR_FALSE;
}
PRBool nsBlockFrame::IsIncrementalDamageConstrained(const nsBlockReflowState& aState) const
{
// see if the reflow will go through a text control. if so, we can optimize
// because we know the text control won't change size.
if (aState.mReflowState.reflowCommand)
{
nsIFrame *target;
aState.mReflowState.reflowCommand->GetTarget(target);
while (target)
{ // starting with the target's parent, scan for a text control
nsIFrame *parent;
target->GetParent(&parent);
if ((nsIFrame*)this==parent || !parent) // the null check is paranoia, it should never happen
break; // we found ourself, so we know there's no text control between us and target
nsCOMPtr<nsIAtom> frameType;
parent->GetFrameType(getter_AddRefs(frameType));
if (frameType)
{
if (nsLayoutAtoms::textInputFrame == frameType.get())
return PR_TRUE; // damage is constrained to the text control innards
}
target = parent; // advance the loop up the frame tree
}
}
return PR_FALSE; // default case, damage is not constrained (or unknown)
}
static void PlaceFrameView(nsIPresContext* aPresContext, nsIFrame* aFrame);
/**
@ -2273,10 +2246,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)
// Reflow the dirty line. If it's an incremental reflow, then force
// it to invalidate the dirty area if necessary
PRBool forceInvalidate = PR_FALSE;
if (incrementalReflow) {
forceInvalidate = !IsIncrementalDamageConstrained(aState);
}
PRBool forceInvalidate = incrementalReflow && !aState.GetFlag(BRS_DAMAGECONSTRAINED);
rv = ReflowLine(aState, line, &keepGoing, forceInvalidate);
if (NS_FAILED(rv)) {
return rv;

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

@ -230,11 +230,6 @@ protected:
return 0 != (mState & NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET);
}
/** return PR_TRUE if the incremental reflow described by aState is 100% contained
* within the bounds of a ancestor frame, relative to this frame.
*/
PRBool IsIncrementalDamageConstrained(const nsBlockReflowState& aState) const;
/** move the frames contained by aLine by aDY
* if aLine is a block, it's child floaters are added to the state manager
*/

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

@ -176,6 +176,8 @@ nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState,
mMinLineHeight = nsHTMLReflowState::CalcLineHeight(mPresContext,
aReflowState.rendContext,
aReflowState.frame);
SetFlag(BRS_DAMAGECONSTRAINED, IsIncrementalDamageConstrained(aFrame));
}
nsBlockReflowState::~nsBlockReflowState()
@ -188,6 +190,32 @@ nsBlockReflowState::~nsBlockReflowState()
}
}
PRBool
nsBlockReflowState::IsIncrementalDamageConstrained(nsIFrame* aBlockFrame) const
{
// see if the reflow will go through a text control. if so, we can optimize
// because we know the text control won't change size.
if ((eReflowReason_Incremental == mReflowState.reason) && (mReflowState.reflowCommand)) {
nsIFrame* target;
mReflowState.reflowCommand->GetTarget(target);
while (target) {
// starting with the target's parent, scan for a text control
nsIFrame* parent;
target->GetParent(&parent);
if ((aBlockFrame == parent) || !parent) // the null check is paranoia, it should never happen
break; // we found the block, so we know there's no text control between the block and target
nsCOMPtr<nsIAtom> frameType;
parent->GetFrameType(getter_AddRefs(frameType));
if (frameType) {
if (nsLayoutAtoms::textInputFrame == frameType.get())
return PR_TRUE; // damage is constrained to the text control innards
}
target = parent; // advance the loop up the frame tree
}
}
return PR_FALSE; // default case, damage is not constrained (or unknown)
}
nsLineBox*
nsBlockReflowState::NewLineBox(nsIFrame* aFrame,
PRInt32 aCount,

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

@ -112,6 +112,10 @@ public:
protected:
void RecoverFloaters(nsLineList::iterator aLine, nscoord aDeltaY);
// return PR_TRUE if the incremental reflow is 100% contained
// within the bounds of an ancestor frame, relative to aBlockFrame
PRBool IsIncrementalDamageConstrained(nsIFrame* aBlockFrame) const;
public:
void RecoverStateFrom(nsLineList::iterator aLine, nscoord aDeltaY);
@ -251,7 +255,8 @@ public:
#define BRS_APPLYTOPMARGIN 0x00000100 // See ShouldApplyTopMargin
#define BRS_COMPUTEMAXELEMENTSIZE 0x00000200
#define BRS_COMPUTEMAXWIDTH 0x00000400
#define BRS_LASTFLAG BRS_COMPUTEMAXWIDTH
#define BRS_DAMAGECONSTRAINED 0x00000800 // is the target of an incremental reflow command inside a text control
#define BRS_LASTFLAG BRS_DAMAGECONSTRAINED
PRInt16 mFlags;