зеркало из https://github.com/mozilla/pjs.git
Display frame reflow counts (turned via config file define)
Bug 71514 r=kmclusk sr=attinasi
This commit is contained in:
Родитель
71d6e2e266
Коммит
fe6f8fcf66
|
@ -511,9 +511,14 @@ public:
|
|||
|
||||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
NS_IMETHOD ClearTotals() = 0;
|
||||
NS_IMETHOD DumpReflows() = 0;
|
||||
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
|
||||
NS_IMETHOD PaintCount(const char * aName,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
nsIPresContext * aPresContext,
|
||||
nsIFrame * aFrame,
|
||||
PRUint32 aColor) = 0;
|
||||
NS_IMETHOD SetPaintFrameCount(PRBool aOn) = 0;
|
||||
#endif
|
||||
|
||||
#ifdef IBMBIDI
|
||||
|
|
|
@ -1505,4 +1505,13 @@ nsPresContext::CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFram
|
|||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::PaintCount(const char * aName, nsIRenderingContext* aRenderingContext, nsIFrame * aFrame, PRUint32 aColor)
|
||||
{
|
||||
if (mShell) {
|
||||
mShell->PaintCount(aName, aRenderingContext, this, aFrame, aColor);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -67,6 +67,10 @@ class nsIURI;
|
|||
class nsILookAndFeel;
|
||||
class nsICSSPseudoComparator;
|
||||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
class nsIRenderingContext;
|
||||
#endif
|
||||
|
||||
#define NS_IPRESCONTEXT_IID \
|
||||
{ 0x0a5d12e0, 0x944e, 0x11d1, \
|
||||
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
@ -474,6 +478,7 @@ public:
|
|||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
|
||||
NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRendingContext, nsIFrame * aFrame, PRUint32 aColor) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -495,10 +500,25 @@ extern NS_LAYOUT nsresult
|
|||
|
||||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
|
||||
#define DO_GLOBAL_REFLOW_COUNT(_name, _type) \
|
||||
aPresContext->CountReflows((_name), (_type), (nsIFrame*)this);
|
||||
#else
|
||||
#define DO_GLOBAL_REFLOW_COUNT(_name, _type)
|
||||
#endif // MOZ_REFLOW_PERF
|
||||
|
||||
#if defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF)
|
||||
#define DO_GLOBAL_REFLOW_COUNT_DSP(_name, _rend) \
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) { \
|
||||
aPresContext->PaintCount((_name), (_rend), (nsIFrame*)this, 0); \
|
||||
}
|
||||
#define DO_GLOBAL_REFLOW_COUNT_DSP_J(_name, _rend, _just) \
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) { \
|
||||
aPresContext->PaintCount((_name), (_rend), (nsIFrame*)this, (_just)); \
|
||||
}
|
||||
#else
|
||||
#define DO_GLOBAL_REFLOW_COUNT_DSP(_name, _rend)
|
||||
#define DO_GLOBAL_REFLOW_COUNT_DSP_J(_name, _rend, _just)
|
||||
#endif // MOZ_REFLOW_PERF_DSP
|
||||
|
||||
#endif /* nsIPresContext_h___ */
|
||||
|
|
|
@ -107,6 +107,11 @@
|
|||
#include "nsIFrameDebug.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_REFLOW_PERF_DSP
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#endif
|
||||
|
||||
#include "nsIReflowCallback.h"
|
||||
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
@ -188,6 +193,8 @@ static NS_DEFINE_CID(kHTMLConverterCID, NS_HTMLFORMATCONVERTER_CID);
|
|||
|
||||
#undef NOISY
|
||||
|
||||
//========================================================================
|
||||
//========================================================================
|
||||
//========================================================================
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
class ReflowCountMgr;
|
||||
|
@ -223,34 +230,33 @@ protected:
|
|||
PRUint32 mTotals[NUM_REFLOW_TYPES];
|
||||
PRUint32 mCacheTotals[NUM_REFLOW_TYPES];
|
||||
|
||||
ReflowCountMgr * mMgr;
|
||||
ReflowCountMgr * mMgr; // weak reference (don't delete)
|
||||
};
|
||||
|
||||
// Counting Class
|
||||
class IndiReflowCounter {
|
||||
public:
|
||||
IndiReflowCounter(ReflowCountMgr * aMgr = nsnull):mMgr(aMgr),mCounter(aMgr),mFrame(nsnull),mParent(nsnull), mCount(0), mHasBeenOutput(PR_FALSE) {}
|
||||
IndiReflowCounter(ReflowCountMgr * aMgr = nsnull):mMgr(aMgr),mCounter(aMgr),mFrame(nsnull), mCount(0), mHasBeenOutput(PR_FALSE) {}
|
||||
virtual ~IndiReflowCounter() {}
|
||||
|
||||
nsAutoString mName;
|
||||
nsIFrame * mFrame;
|
||||
nsIFrame * mParent;
|
||||
nsIFrame * mFrame; // weak reference (don't delete)
|
||||
PRInt32 mCount;
|
||||
|
||||
ReflowCountMgr * mMgr;
|
||||
ReflowCountMgr * mMgr; // weak reference (don't delete)
|
||||
|
||||
ReflowCounter mCounter;
|
||||
PRBool mHasBeenOutput;
|
||||
|
||||
};
|
||||
|
||||
//--------------------
|
||||
// Manager Class
|
||||
//--------------------
|
||||
class ReflowCountMgr {
|
||||
public:
|
||||
ReflowCountMgr();
|
||||
//static ReflowCountMgr * GetInstance() { return &gReflowCountMgr; }
|
||||
|
||||
~ReflowCountMgr();
|
||||
virtual ~ReflowCountMgr();
|
||||
|
||||
void ClearTotals();
|
||||
void ClearGrandTotals();
|
||||
|
@ -261,12 +267,18 @@ public:
|
|||
void Add(const char * aName, nsReflowReason aType, nsIFrame * aFrame);
|
||||
ReflowCounter * LookUp(const char * aName);
|
||||
|
||||
void PaintCount(const char * aName, nsIRenderingContext* aRenderingContext, nsIPresContext* aPresContext, nsIFrame * aFrame, PRUint32 aColor);
|
||||
|
||||
FILE * GetOutFile() { return mFD; }
|
||||
|
||||
PLHashTable * GetIndiFrameHT() { return mIndiFrameCounts; }
|
||||
|
||||
void SetPresContext(nsIPresContext * aPresContext) { mPresContext = aPresContext; } // weak reference
|
||||
void SetPresShell(nsIPresShell* aPresShell) { mPresShell= aPresShell; } // weak reference
|
||||
void SetPresContext(nsIPresContext * aPresContext) { mPresContext = aPresContext; } // weak reference
|
||||
void SetPresShell(nsIPresShell* aPresShell) { mPresShell= aPresShell; } // weak reference
|
||||
|
||||
void SetDumpFrameCounts(PRBool aVal) { mDumpFrameCounts = aVal; }
|
||||
void SetDumpFrameByFrameCounts(PRBool aVal) { mDumpFrameByFrameCounts = aVal; }
|
||||
void SetPaintFrameCounts(PRBool aVal) { mPaintFrameByFrameCounts = aVal; }
|
||||
|
||||
protected:
|
||||
void DisplayTotals(PRUint32 * aArray, PRUint32 * aDupArray, char * aTitle);
|
||||
|
@ -297,6 +309,10 @@ protected:
|
|||
PLHashTable * mIndiFrameCounts;
|
||||
FILE * mFD;
|
||||
|
||||
PRBool mDumpFrameCounts;
|
||||
PRBool mDumpFrameByFrameCounts;
|
||||
PRBool mPaintFrameByFrameCounts;
|
||||
|
||||
PRBool mCycledOnce;
|
||||
|
||||
// Root Frame for Individual Tracking
|
||||
|
@ -994,9 +1010,12 @@ public:
|
|||
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument);
|
||||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
NS_IMETHOD ClearTotals();
|
||||
NS_IMETHOD DumpReflows();
|
||||
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame);
|
||||
NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRenderingContext, nsIPresContext* aPresContext, nsIFrame * aFrame, PRUint32 aColor);
|
||||
|
||||
NS_IMETHOD SetPaintFrameCount(PRBool aOn);
|
||||
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
@ -1502,6 +1521,25 @@ PresShell::Init(nsIDocument* aDocument,
|
|||
// setup the preference style rules up (no forced reflow)
|
||||
SetPreferenceStyleRules(PR_FALSE);
|
||||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
// Get the prefs service
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &result);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
if (mReflowCountMgr != nsnull) {
|
||||
PRBool paintFrameCounts;
|
||||
PRBool dumpFrameCounts;
|
||||
PRBool dumpFrameByFrameCounts;
|
||||
prefs->GetBoolPref("layout.reflow.showframecounts", &paintFrameCounts);
|
||||
prefs->GetBoolPref("layout.reflow.dumpframecounts", &dumpFrameCounts);
|
||||
prefs->GetBoolPref("layout.reflow.dumpframebyframecounts", &dumpFrameByFrameCounts);
|
||||
|
||||
mReflowCountMgr->SetDumpFrameCounts(dumpFrameCounts);
|
||||
mReflowCountMgr->SetDumpFrameByFrameCounts(dumpFrameByFrameCounts);
|
||||
mReflowCountMgr->SetPaintFrameCounts(paintFrameCounts);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -6076,17 +6114,12 @@ nsresult CtlStyleWatch(PRUint32 aCtlValue, nsIStyleSet *aStyleSet)
|
|||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
//-- Reflow counts
|
||||
//-------------------------------------------------------------
|
||||
//=============================================================
|
||||
//=============================================================
|
||||
//-- Debug Reflow Counts
|
||||
//=============================================================
|
||||
//=============================================================
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
//-------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
PresShell::ClearTotals()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
PresShell::DumpReflows()
|
||||
|
@ -6118,10 +6151,29 @@ PresShell::CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
PresShell::PaintCount(const char * aName, nsIRenderingContext* aRenderingContext, nsIPresContext* aPresContext, nsIFrame * aFrame, PRUint32 aColor)
|
||||
{
|
||||
if (mReflowCountMgr) {
|
||||
mReflowCountMgr->PaintCount(aName, aRenderingContext, aPresContext, aFrame, aColor);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
PresShell::SetPaintFrameCount(PRBool aPaintFrameCounts)
|
||||
{
|
||||
if (mReflowCountMgr) {
|
||||
mReflowCountMgr->SetPaintFrameCounts(aPaintFrameCounts);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//-- Reflow Counter Classes Impls
|
||||
//------------------------------------------------------------------
|
||||
//ReflowCountMgr ReflowCountMgr::gReflowCountMgr;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
ReflowCounter::ReflowCounter(ReflowCountMgr * aMgr) :
|
||||
|
@ -6134,7 +6186,7 @@ ReflowCounter::ReflowCounter(ReflowCountMgr * aMgr) :
|
|||
//------------------------------------------------------------------
|
||||
ReflowCounter::~ReflowCounter()
|
||||
{
|
||||
//DisplayTotals(mTotals, "Grand Totals");
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
@ -6240,6 +6292,8 @@ void ReflowCounter::DisplayHTMLTotals(PRUint32 * aArray, const char * aTitle)
|
|||
fprintf(fd, "<td><center>%d</center></td></tr>\n", total);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//-- ReflowCountMgr
|
||||
//------------------------------------------------------------------
|
||||
ReflowCountMgr::ReflowCountMgr()
|
||||
{
|
||||
|
@ -6247,15 +6301,15 @@ ReflowCountMgr::ReflowCountMgr()
|
|||
PL_CompareValues, nsnull, nsnull);
|
||||
mIndiFrameCounts = PL_NewHashTable(10, PL_HashString, PL_CompareStrings,
|
||||
PL_CompareValues, nsnull, nsnull);
|
||||
mCycledOnce = PR_FALSE;
|
||||
mCycledOnce = PR_FALSE;
|
||||
mDumpFrameCounts = PR_FALSE;
|
||||
mDumpFrameByFrameCounts = PR_FALSE;
|
||||
mPaintFrameByFrameCounts = PR_FALSE;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
ReflowCountMgr::~ReflowCountMgr()
|
||||
{
|
||||
//if (GetInstance() == this) {
|
||||
// DoGrandTotals();
|
||||
//}
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
|
@ -6275,7 +6329,7 @@ void ReflowCountMgr::Add(const char * aName, nsReflowReason aType, nsIFrame * aF
|
|||
{
|
||||
NS_ASSERTION(aName != nsnull, "Name shouldn't be null!");
|
||||
|
||||
if (nsnull != mCounts) {
|
||||
if (mDumpFrameCounts && nsnull != mCounts) {
|
||||
ReflowCounter * counter = (ReflowCounter *)PL_HashTableLookup(mCounts, aName);
|
||||
if (counter == nsnull) {
|
||||
counter = new ReflowCounter(this);
|
||||
|
@ -6287,7 +6341,9 @@ void ReflowCountMgr::Add(const char * aName, nsReflowReason aType, nsIFrame * aF
|
|||
counter->Add(aType);
|
||||
}
|
||||
|
||||
if (nsnull != mIndiFrameCounts && aFrame != nsnull) {
|
||||
if ((mDumpFrameByFrameCounts || mPaintFrameByFrameCounts) &&
|
||||
nsnull != mIndiFrameCounts &&
|
||||
aFrame != nsnull) {
|
||||
char * key = new char[16];
|
||||
sprintf(key, "%p", aFrame);
|
||||
IndiReflowCounter * counter = (IndiReflowCounter *)PL_HashTableLookup(mIndiFrameCounts, key);
|
||||
|
@ -6295,18 +6351,81 @@ void ReflowCountMgr::Add(const char * aName, nsReflowReason aType, nsIFrame * aF
|
|||
counter = new IndiReflowCounter(this);
|
||||
NS_ASSERTION(counter != nsnull, "null ptr");
|
||||
counter->mFrame = aFrame;
|
||||
aFrame->GetParent(&counter->mParent);
|
||||
counter->mName.AssignWithConversion(aName);
|
||||
PL_HashTableAdd(mIndiFrameCounts, key, counter);
|
||||
}
|
||||
// this eliminates extra counts from super classes
|
||||
if (counter->mName.EqualsWithConversion(aName)) {
|
||||
if (counter != nsnull && counter->mName.EqualsWithConversion(aName)) {
|
||||
counter->mCount++;
|
||||
counter->mCounter.Add(aType, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
void ReflowCountMgr::PaintCount(const char * aName,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIFrame* aFrame,
|
||||
PRUint32 aColor)
|
||||
{
|
||||
if (mPaintFrameByFrameCounts &&
|
||||
nsnull != mIndiFrameCounts &&
|
||||
aFrame != nsnull) {
|
||||
char * key = new char[16];
|
||||
sprintf(key, "%p", aFrame);
|
||||
IndiReflowCounter * counter = (IndiReflowCounter *)PL_HashTableLookup(mIndiFrameCounts, key);
|
||||
if (counter != nsnull && counter->mName.EqualsWithConversion(aName)) {
|
||||
aRenderingContext->PushState();
|
||||
nsFont font("Times", NS_FONT_STYLE_NORMAL,NS_FONT_VARIANT_NORMAL,
|
||||
NS_FONT_WEIGHT_NORMAL,0,NSIntPointsToTwips(8));
|
||||
|
||||
nsCOMPtr<nsIFontMetrics> fm;
|
||||
aPresContext->GetMetricsFor(font, getter_AddRefs(fm));
|
||||
aRenderingContext->SetFont(fm);
|
||||
char buf[16];
|
||||
sprintf(buf, "%d", counter->mCount);
|
||||
nscoord width, height;
|
||||
aRenderingContext->GetWidth((char*)buf, width);
|
||||
fm->GetHeight(height);
|
||||
|
||||
nsRect r;
|
||||
aFrame->GetRect(r);
|
||||
|
||||
nscoord x = 0;
|
||||
PRUint32 color;
|
||||
PRUint32 color2;
|
||||
if (aColor != 0) {
|
||||
color = aColor;
|
||||
color2 = NS_RGB(0,0,0);
|
||||
} else {
|
||||
PRUint8 rc,gc,bc = 0;
|
||||
if (counter->mCount < 5) {
|
||||
rc = 255;
|
||||
gc = 255;
|
||||
} else if ( counter->mCount < 11) {
|
||||
gc = 255;
|
||||
} else {
|
||||
rc = 255;
|
||||
}
|
||||
color = NS_RGB(rc,gc,bc);
|
||||
color2 = NS_RGB(rc/2,gc/2,bc/2);
|
||||
}
|
||||
|
||||
nsRect rect(0,0, width+15, height+15);
|
||||
aRenderingContext->SetColor(NS_RGB(0,0,0));
|
||||
aRenderingContext->FillRect(rect);
|
||||
aRenderingContext->SetColor(color2);
|
||||
aRenderingContext->DrawString(buf, strlen(buf), x+15,15);
|
||||
aRenderingContext->SetColor(color);
|
||||
aRenderingContext->DrawString(buf, strlen(buf), x,0);
|
||||
|
||||
PRBool clipEmpty;
|
||||
aRenderingContext->PopState(clipEmpty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
PRIntn ReflowCountMgr::RemoveItems(PLHashEntry *he, PRIntn i, void *arg)
|
||||
{
|
||||
|
@ -6334,11 +6453,14 @@ void ReflowCountMgr::CleanUp()
|
|||
{
|
||||
if (nsnull != mCounts) {
|
||||
PL_HashTableEnumerateEntries(mCounts, RemoveItems, nsnull);
|
||||
PL_HashTableEnumerateEntries(mIndiFrameCounts, RemoveIndiItems, nsnull);
|
||||
PL_HashTableDestroy(mCounts);
|
||||
PL_HashTableDestroy(mIndiFrameCounts);
|
||||
mCounts = nsnull;
|
||||
mCounts = mIndiFrameCounts;
|
||||
}
|
||||
|
||||
if (nsnull != mIndiFrameCounts) {
|
||||
PL_HashTableEnumerateEntries(mIndiFrameCounts, RemoveIndiItems, nsnull);
|
||||
PL_HashTableDestroy(mIndiFrameCounts);
|
||||
mIndiFrameCounts = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6490,8 +6612,12 @@ void ReflowCountMgr::DoGrandHTMLTotals()
|
|||
void ReflowCountMgr::DisplayTotals(const char * aStr)
|
||||
{
|
||||
printf("%s\n", aStr?aStr:"No name");
|
||||
DoGrandTotals();
|
||||
DoIndiTotalsTree();
|
||||
if (mDumpFrameCounts) {
|
||||
DoGrandTotals();
|
||||
}
|
||||
if (mDumpFrameByFrameCounts) {
|
||||
DoIndiTotalsTree();
|
||||
}
|
||||
|
||||
}
|
||||
//------------------------------------
|
||||
|
@ -6612,3 +6738,5 @@ void ColorToString(nscolor aColor, nsAutoString &aString)
|
|||
if (tmp.Length() < 2) tmp.AppendInt(0,16);
|
||||
aString.Append(tmp);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -67,6 +67,10 @@ class nsIURI;
|
|||
class nsILookAndFeel;
|
||||
class nsICSSPseudoComparator;
|
||||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
class nsIRenderingContext;
|
||||
#endif
|
||||
|
||||
#define NS_IPRESCONTEXT_IID \
|
||||
{ 0x0a5d12e0, 0x944e, 0x11d1, \
|
||||
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
@ -474,6 +478,7 @@ public:
|
|||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
|
||||
NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRendingContext, nsIFrame * aFrame, PRUint32 aColor) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -495,10 +500,25 @@ extern NS_LAYOUT nsresult
|
|||
|
||||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
|
||||
#define DO_GLOBAL_REFLOW_COUNT(_name, _type) \
|
||||
aPresContext->CountReflows((_name), (_type), (nsIFrame*)this);
|
||||
#else
|
||||
#define DO_GLOBAL_REFLOW_COUNT(_name, _type)
|
||||
#endif // MOZ_REFLOW_PERF
|
||||
|
||||
#if defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF)
|
||||
#define DO_GLOBAL_REFLOW_COUNT_DSP(_name, _rend) \
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) { \
|
||||
aPresContext->PaintCount((_name), (_rend), (nsIFrame*)this, 0); \
|
||||
}
|
||||
#define DO_GLOBAL_REFLOW_COUNT_DSP_J(_name, _rend, _just) \
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) { \
|
||||
aPresContext->PaintCount((_name), (_rend), (nsIFrame*)this, (_just)); \
|
||||
}
|
||||
#else
|
||||
#define DO_GLOBAL_REFLOW_COUNT_DSP(_name, _rend)
|
||||
#define DO_GLOBAL_REFLOW_COUNT_DSP_J(_name, _rend, _just)
|
||||
#endif // MOZ_REFLOW_PERF_DSP
|
||||
|
||||
#endif /* nsIPresContext_h___ */
|
||||
|
|
|
@ -511,9 +511,14 @@ public:
|
|||
|
||||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
NS_IMETHOD ClearTotals() = 0;
|
||||
NS_IMETHOD DumpReflows() = 0;
|
||||
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
|
||||
NS_IMETHOD PaintCount(const char * aName,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
nsIPresContext * aPresContext,
|
||||
nsIFrame * aFrame,
|
||||
PRUint32 aColor) = 0;
|
||||
NS_IMETHOD SetPaintFrameCount(PRBool aOn) = 0;
|
||||
#endif
|
||||
|
||||
#ifdef IBMBIDI
|
||||
|
|
|
@ -67,6 +67,10 @@ class nsIURI;
|
|||
class nsILookAndFeel;
|
||||
class nsICSSPseudoComparator;
|
||||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
class nsIRenderingContext;
|
||||
#endif
|
||||
|
||||
#define NS_IPRESCONTEXT_IID \
|
||||
{ 0x0a5d12e0, 0x944e, 0x11d1, \
|
||||
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
@ -474,6 +478,7 @@ public:
|
|||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
|
||||
NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRendingContext, nsIFrame * aFrame, PRUint32 aColor) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -495,10 +500,25 @@ extern NS_LAYOUT nsresult
|
|||
|
||||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
|
||||
#define DO_GLOBAL_REFLOW_COUNT(_name, _type) \
|
||||
aPresContext->CountReflows((_name), (_type), (nsIFrame*)this);
|
||||
#else
|
||||
#define DO_GLOBAL_REFLOW_COUNT(_name, _type)
|
||||
#endif // MOZ_REFLOW_PERF
|
||||
|
||||
#if defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF)
|
||||
#define DO_GLOBAL_REFLOW_COUNT_DSP(_name, _rend) \
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) { \
|
||||
aPresContext->PaintCount((_name), (_rend), (nsIFrame*)this, 0); \
|
||||
}
|
||||
#define DO_GLOBAL_REFLOW_COUNT_DSP_J(_name, _rend, _just) \
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) { \
|
||||
aPresContext->PaintCount((_name), (_rend), (nsIFrame*)this, (_just)); \
|
||||
}
|
||||
#else
|
||||
#define DO_GLOBAL_REFLOW_COUNT_DSP(_name, _rend)
|
||||
#define DO_GLOBAL_REFLOW_COUNT_DSP_J(_name, _rend, _just)
|
||||
#endif // MOZ_REFLOW_PERF_DSP
|
||||
|
||||
#endif /* nsIPresContext_h___ */
|
||||
|
|
|
@ -1505,4 +1505,13 @@ nsPresContext::CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFram
|
|||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::PaintCount(const char * aName, nsIRenderingContext* aRenderingContext, nsIFrame * aFrame, PRUint32 aColor)
|
||||
{
|
||||
if (mShell) {
|
||||
mShell->PaintCount(aName, aRenderingContext, this, aFrame, aColor);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -164,6 +164,7 @@ public:
|
|||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame);
|
||||
NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRenderingContext, nsIFrame * aFrame, PRUint32 aColor);
|
||||
#endif
|
||||
|
||||
// nsIObserver method
|
||||
|
|
|
@ -252,6 +252,7 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
|
|||
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
||||
}
|
||||
#endif
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsFieldSetFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -335,6 +335,7 @@ nsListControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
return nsScrollFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsListControlFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
|
|
@ -180,7 +180,6 @@ nsAbsoluteContainingBlock::Reflow(nsIFrame* aDelegatingFrame,
|
|||
nscoord aContainingBlockHeight,
|
||||
nsRect& aChildBounds)
|
||||
{
|
||||
DO_GLOBAL_REFLOW_COUNT("nsAbsoluteContainingBlock", aReflowState.reason);
|
||||
// Initialize OUT parameter
|
||||
aChildBounds.SetRect(0, 0, 0, 0);
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ nsBulletFrame::GetFrameType(nsIAtom** aType) const
|
|||
|
||||
#include "nsIDOMNode.h"
|
||||
NS_IMETHODIMP
|
||||
nsBulletFrame::Paint(nsIPresContext* aCX,
|
||||
nsBulletFrame::Paint(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
|
@ -122,7 +122,7 @@ nsBulletFrame::Paint(nsIPresContext* aCX,
|
|||
}
|
||||
|
||||
PRBool isVisible;
|
||||
if (NS_SUCCEEDED(IsVisibleForPainting(aCX, aRenderingContext, PR_TRUE, &isVisible)) && isVisible) {
|
||||
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && isVisible) {
|
||||
const nsStyleList* myList =
|
||||
(const nsStyleList*)mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
PRUint8 listStyleType = myList->mListStyleType;
|
||||
|
@ -256,8 +256,8 @@ nsBulletFrame::Paint(nsIPresContext* aCX,
|
|||
case NS_STYLE_LIST_STYLE_LAO:
|
||||
case NS_STYLE_LIST_STYLE_MYANMAR:
|
||||
case NS_STYLE_LIST_STYLE_KHMER:
|
||||
aCX->GetMetricsFor(myFont->mFont, getter_AddRefs(fm));
|
||||
GetListItemText(aCX, *myList, text);
|
||||
aPresContext->GetMetricsFor(myFont->mFont, getter_AddRefs(fm));
|
||||
GetListItemText(aPresContext, *myList, text);
|
||||
aRenderingContext.SetFont(fm);
|
||||
aRenderingContext.DrawString(text, mPadding.left, mPadding.top);
|
||||
break;
|
||||
|
@ -288,6 +288,7 @@ nsBulletFrame::Paint(nsIPresContext* aCX,
|
|||
}
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsBulletFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -665,6 +665,7 @@ nsHTMLFrameInnerFrame::Paint(nsIPresContext* aPresContext,
|
|||
aRenderingContext.SetColor(color->mBackgroundColor);
|
||||
aRenderingContext.FillRect(mRect);
|
||||
}
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsHTMLFrameInnerFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ nsLeafFrame::Paint(nsIPresContext* aPresContext,
|
|||
aDirtyRect, rect, *myBorder, *myOutline, mStyleContext, 0);
|
||||
}
|
||||
}
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsLeafFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1345,6 +1345,7 @@ nsObjectFrame::Paint(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
#endif /* !XP_MAC */
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsObjectFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ nsPlaceholderFrame::Paint(nsIPresContext* aPresContext,
|
|||
aRenderingContext.FillRect(0, y, NSIntPixelsToTwips(3, p2t),
|
||||
NSIntPixelsToTwips(10, p2t));
|
||||
}
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsPlaceholderFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1287,6 +1287,7 @@ nsTextFrame::Paint(nsIPresContext* aPresContext,
|
|||
|
||||
}
|
||||
}
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsTextFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -180,7 +180,6 @@ nsAbsoluteContainingBlock::Reflow(nsIFrame* aDelegatingFrame,
|
|||
nscoord aContainingBlockHeight,
|
||||
nsRect& aChildBounds)
|
||||
{
|
||||
DO_GLOBAL_REFLOW_COUNT("nsAbsoluteContainingBlock", aReflowState.reason);
|
||||
// Initialize OUT parameter
|
||||
aChildBounds.SetRect(0, 0, 0, 0);
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ nsBulletFrame::GetFrameType(nsIAtom** aType) const
|
|||
|
||||
#include "nsIDOMNode.h"
|
||||
NS_IMETHODIMP
|
||||
nsBulletFrame::Paint(nsIPresContext* aCX,
|
||||
nsBulletFrame::Paint(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
|
@ -122,7 +122,7 @@ nsBulletFrame::Paint(nsIPresContext* aCX,
|
|||
}
|
||||
|
||||
PRBool isVisible;
|
||||
if (NS_SUCCEEDED(IsVisibleForPainting(aCX, aRenderingContext, PR_TRUE, &isVisible)) && isVisible) {
|
||||
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && isVisible) {
|
||||
const nsStyleList* myList =
|
||||
(const nsStyleList*)mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
PRUint8 listStyleType = myList->mListStyleType;
|
||||
|
@ -256,8 +256,8 @@ nsBulletFrame::Paint(nsIPresContext* aCX,
|
|||
case NS_STYLE_LIST_STYLE_LAO:
|
||||
case NS_STYLE_LIST_STYLE_MYANMAR:
|
||||
case NS_STYLE_LIST_STYLE_KHMER:
|
||||
aCX->GetMetricsFor(myFont->mFont, getter_AddRefs(fm));
|
||||
GetListItemText(aCX, *myList, text);
|
||||
aPresContext->GetMetricsFor(myFont->mFont, getter_AddRefs(fm));
|
||||
GetListItemText(aPresContext, *myList, text);
|
||||
aRenderingContext.SetFont(fm);
|
||||
aRenderingContext.DrawString(text, mPadding.left, mPadding.top);
|
||||
break;
|
||||
|
@ -288,6 +288,7 @@ nsBulletFrame::Paint(nsIPresContext* aCX,
|
|||
}
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsBulletFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ nsLeafFrame::Paint(nsIPresContext* aPresContext,
|
|||
aDirtyRect, rect, *myBorder, *myOutline, mStyleContext, 0);
|
||||
}
|
||||
}
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsLeafFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1345,6 +1345,7 @@ nsObjectFrame::Paint(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
#endif /* !XP_MAC */
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsObjectFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ nsPlaceholderFrame::Paint(nsIPresContext* aPresContext,
|
|||
aRenderingContext.FillRect(0, y, NSIntPixelsToTwips(3, p2t),
|
||||
NSIntPixelsToTwips(10, p2t));
|
||||
}
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsPlaceholderFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,11 @@
|
|||
#include "nsIFrameDebug.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_REFLOW_PERF_DSP
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#endif
|
||||
|
||||
#include "nsIReflowCallback.h"
|
||||
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
@ -188,6 +193,8 @@ static NS_DEFINE_CID(kHTMLConverterCID, NS_HTMLFORMATCONVERTER_CID);
|
|||
|
||||
#undef NOISY
|
||||
|
||||
//========================================================================
|
||||
//========================================================================
|
||||
//========================================================================
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
class ReflowCountMgr;
|
||||
|
@ -223,34 +230,33 @@ protected:
|
|||
PRUint32 mTotals[NUM_REFLOW_TYPES];
|
||||
PRUint32 mCacheTotals[NUM_REFLOW_TYPES];
|
||||
|
||||
ReflowCountMgr * mMgr;
|
||||
ReflowCountMgr * mMgr; // weak reference (don't delete)
|
||||
};
|
||||
|
||||
// Counting Class
|
||||
class IndiReflowCounter {
|
||||
public:
|
||||
IndiReflowCounter(ReflowCountMgr * aMgr = nsnull):mMgr(aMgr),mCounter(aMgr),mFrame(nsnull),mParent(nsnull), mCount(0), mHasBeenOutput(PR_FALSE) {}
|
||||
IndiReflowCounter(ReflowCountMgr * aMgr = nsnull):mMgr(aMgr),mCounter(aMgr),mFrame(nsnull), mCount(0), mHasBeenOutput(PR_FALSE) {}
|
||||
virtual ~IndiReflowCounter() {}
|
||||
|
||||
nsAutoString mName;
|
||||
nsIFrame * mFrame;
|
||||
nsIFrame * mParent;
|
||||
nsIFrame * mFrame; // weak reference (don't delete)
|
||||
PRInt32 mCount;
|
||||
|
||||
ReflowCountMgr * mMgr;
|
||||
ReflowCountMgr * mMgr; // weak reference (don't delete)
|
||||
|
||||
ReflowCounter mCounter;
|
||||
PRBool mHasBeenOutput;
|
||||
|
||||
};
|
||||
|
||||
//--------------------
|
||||
// Manager Class
|
||||
//--------------------
|
||||
class ReflowCountMgr {
|
||||
public:
|
||||
ReflowCountMgr();
|
||||
//static ReflowCountMgr * GetInstance() { return &gReflowCountMgr; }
|
||||
|
||||
~ReflowCountMgr();
|
||||
virtual ~ReflowCountMgr();
|
||||
|
||||
void ClearTotals();
|
||||
void ClearGrandTotals();
|
||||
|
@ -261,12 +267,18 @@ public:
|
|||
void Add(const char * aName, nsReflowReason aType, nsIFrame * aFrame);
|
||||
ReflowCounter * LookUp(const char * aName);
|
||||
|
||||
void PaintCount(const char * aName, nsIRenderingContext* aRenderingContext, nsIPresContext* aPresContext, nsIFrame * aFrame, PRUint32 aColor);
|
||||
|
||||
FILE * GetOutFile() { return mFD; }
|
||||
|
||||
PLHashTable * GetIndiFrameHT() { return mIndiFrameCounts; }
|
||||
|
||||
void SetPresContext(nsIPresContext * aPresContext) { mPresContext = aPresContext; } // weak reference
|
||||
void SetPresShell(nsIPresShell* aPresShell) { mPresShell= aPresShell; } // weak reference
|
||||
void SetPresContext(nsIPresContext * aPresContext) { mPresContext = aPresContext; } // weak reference
|
||||
void SetPresShell(nsIPresShell* aPresShell) { mPresShell= aPresShell; } // weak reference
|
||||
|
||||
void SetDumpFrameCounts(PRBool aVal) { mDumpFrameCounts = aVal; }
|
||||
void SetDumpFrameByFrameCounts(PRBool aVal) { mDumpFrameByFrameCounts = aVal; }
|
||||
void SetPaintFrameCounts(PRBool aVal) { mPaintFrameByFrameCounts = aVal; }
|
||||
|
||||
protected:
|
||||
void DisplayTotals(PRUint32 * aArray, PRUint32 * aDupArray, char * aTitle);
|
||||
|
@ -297,6 +309,10 @@ protected:
|
|||
PLHashTable * mIndiFrameCounts;
|
||||
FILE * mFD;
|
||||
|
||||
PRBool mDumpFrameCounts;
|
||||
PRBool mDumpFrameByFrameCounts;
|
||||
PRBool mPaintFrameByFrameCounts;
|
||||
|
||||
PRBool mCycledOnce;
|
||||
|
||||
// Root Frame for Individual Tracking
|
||||
|
@ -994,9 +1010,12 @@ public:
|
|||
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument);
|
||||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
NS_IMETHOD ClearTotals();
|
||||
NS_IMETHOD DumpReflows();
|
||||
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame);
|
||||
NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRenderingContext, nsIPresContext* aPresContext, nsIFrame * aFrame, PRUint32 aColor);
|
||||
|
||||
NS_IMETHOD SetPaintFrameCount(PRBool aOn);
|
||||
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
@ -1502,6 +1521,25 @@ PresShell::Init(nsIDocument* aDocument,
|
|||
// setup the preference style rules up (no forced reflow)
|
||||
SetPreferenceStyleRules(PR_FALSE);
|
||||
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
// Get the prefs service
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &result);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
if (mReflowCountMgr != nsnull) {
|
||||
PRBool paintFrameCounts;
|
||||
PRBool dumpFrameCounts;
|
||||
PRBool dumpFrameByFrameCounts;
|
||||
prefs->GetBoolPref("layout.reflow.showframecounts", &paintFrameCounts);
|
||||
prefs->GetBoolPref("layout.reflow.dumpframecounts", &dumpFrameCounts);
|
||||
prefs->GetBoolPref("layout.reflow.dumpframebyframecounts", &dumpFrameByFrameCounts);
|
||||
|
||||
mReflowCountMgr->SetDumpFrameCounts(dumpFrameCounts);
|
||||
mReflowCountMgr->SetDumpFrameByFrameCounts(dumpFrameByFrameCounts);
|
||||
mReflowCountMgr->SetPaintFrameCounts(paintFrameCounts);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -6076,17 +6114,12 @@ nsresult CtlStyleWatch(PRUint32 aCtlValue, nsIStyleSet *aStyleSet)
|
|||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
//-- Reflow counts
|
||||
//-------------------------------------------------------------
|
||||
//=============================================================
|
||||
//=============================================================
|
||||
//-- Debug Reflow Counts
|
||||
//=============================================================
|
||||
//=============================================================
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
//-------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
PresShell::ClearTotals()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
PresShell::DumpReflows()
|
||||
|
@ -6118,10 +6151,29 @@ PresShell::CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
PresShell::PaintCount(const char * aName, nsIRenderingContext* aRenderingContext, nsIPresContext* aPresContext, nsIFrame * aFrame, PRUint32 aColor)
|
||||
{
|
||||
if (mReflowCountMgr) {
|
||||
mReflowCountMgr->PaintCount(aName, aRenderingContext, aPresContext, aFrame, aColor);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
PresShell::SetPaintFrameCount(PRBool aPaintFrameCounts)
|
||||
{
|
||||
if (mReflowCountMgr) {
|
||||
mReflowCountMgr->SetPaintFrameCounts(aPaintFrameCounts);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//-- Reflow Counter Classes Impls
|
||||
//------------------------------------------------------------------
|
||||
//ReflowCountMgr ReflowCountMgr::gReflowCountMgr;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
ReflowCounter::ReflowCounter(ReflowCountMgr * aMgr) :
|
||||
|
@ -6134,7 +6186,7 @@ ReflowCounter::ReflowCounter(ReflowCountMgr * aMgr) :
|
|||
//------------------------------------------------------------------
|
||||
ReflowCounter::~ReflowCounter()
|
||||
{
|
||||
//DisplayTotals(mTotals, "Grand Totals");
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
@ -6240,6 +6292,8 @@ void ReflowCounter::DisplayHTMLTotals(PRUint32 * aArray, const char * aTitle)
|
|||
fprintf(fd, "<td><center>%d</center></td></tr>\n", total);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//-- ReflowCountMgr
|
||||
//------------------------------------------------------------------
|
||||
ReflowCountMgr::ReflowCountMgr()
|
||||
{
|
||||
|
@ -6247,15 +6301,15 @@ ReflowCountMgr::ReflowCountMgr()
|
|||
PL_CompareValues, nsnull, nsnull);
|
||||
mIndiFrameCounts = PL_NewHashTable(10, PL_HashString, PL_CompareStrings,
|
||||
PL_CompareValues, nsnull, nsnull);
|
||||
mCycledOnce = PR_FALSE;
|
||||
mCycledOnce = PR_FALSE;
|
||||
mDumpFrameCounts = PR_FALSE;
|
||||
mDumpFrameByFrameCounts = PR_FALSE;
|
||||
mPaintFrameByFrameCounts = PR_FALSE;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
ReflowCountMgr::~ReflowCountMgr()
|
||||
{
|
||||
//if (GetInstance() == this) {
|
||||
// DoGrandTotals();
|
||||
//}
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
|
@ -6275,7 +6329,7 @@ void ReflowCountMgr::Add(const char * aName, nsReflowReason aType, nsIFrame * aF
|
|||
{
|
||||
NS_ASSERTION(aName != nsnull, "Name shouldn't be null!");
|
||||
|
||||
if (nsnull != mCounts) {
|
||||
if (mDumpFrameCounts && nsnull != mCounts) {
|
||||
ReflowCounter * counter = (ReflowCounter *)PL_HashTableLookup(mCounts, aName);
|
||||
if (counter == nsnull) {
|
||||
counter = new ReflowCounter(this);
|
||||
|
@ -6287,7 +6341,9 @@ void ReflowCountMgr::Add(const char * aName, nsReflowReason aType, nsIFrame * aF
|
|||
counter->Add(aType);
|
||||
}
|
||||
|
||||
if (nsnull != mIndiFrameCounts && aFrame != nsnull) {
|
||||
if ((mDumpFrameByFrameCounts || mPaintFrameByFrameCounts) &&
|
||||
nsnull != mIndiFrameCounts &&
|
||||
aFrame != nsnull) {
|
||||
char * key = new char[16];
|
||||
sprintf(key, "%p", aFrame);
|
||||
IndiReflowCounter * counter = (IndiReflowCounter *)PL_HashTableLookup(mIndiFrameCounts, key);
|
||||
|
@ -6295,18 +6351,81 @@ void ReflowCountMgr::Add(const char * aName, nsReflowReason aType, nsIFrame * aF
|
|||
counter = new IndiReflowCounter(this);
|
||||
NS_ASSERTION(counter != nsnull, "null ptr");
|
||||
counter->mFrame = aFrame;
|
||||
aFrame->GetParent(&counter->mParent);
|
||||
counter->mName.AssignWithConversion(aName);
|
||||
PL_HashTableAdd(mIndiFrameCounts, key, counter);
|
||||
}
|
||||
// this eliminates extra counts from super classes
|
||||
if (counter->mName.EqualsWithConversion(aName)) {
|
||||
if (counter != nsnull && counter->mName.EqualsWithConversion(aName)) {
|
||||
counter->mCount++;
|
||||
counter->mCounter.Add(aType, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
void ReflowCountMgr::PaintCount(const char * aName,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIFrame* aFrame,
|
||||
PRUint32 aColor)
|
||||
{
|
||||
if (mPaintFrameByFrameCounts &&
|
||||
nsnull != mIndiFrameCounts &&
|
||||
aFrame != nsnull) {
|
||||
char * key = new char[16];
|
||||
sprintf(key, "%p", aFrame);
|
||||
IndiReflowCounter * counter = (IndiReflowCounter *)PL_HashTableLookup(mIndiFrameCounts, key);
|
||||
if (counter != nsnull && counter->mName.EqualsWithConversion(aName)) {
|
||||
aRenderingContext->PushState();
|
||||
nsFont font("Times", NS_FONT_STYLE_NORMAL,NS_FONT_VARIANT_NORMAL,
|
||||
NS_FONT_WEIGHT_NORMAL,0,NSIntPointsToTwips(8));
|
||||
|
||||
nsCOMPtr<nsIFontMetrics> fm;
|
||||
aPresContext->GetMetricsFor(font, getter_AddRefs(fm));
|
||||
aRenderingContext->SetFont(fm);
|
||||
char buf[16];
|
||||
sprintf(buf, "%d", counter->mCount);
|
||||
nscoord width, height;
|
||||
aRenderingContext->GetWidth((char*)buf, width);
|
||||
fm->GetHeight(height);
|
||||
|
||||
nsRect r;
|
||||
aFrame->GetRect(r);
|
||||
|
||||
nscoord x = 0;
|
||||
PRUint32 color;
|
||||
PRUint32 color2;
|
||||
if (aColor != 0) {
|
||||
color = aColor;
|
||||
color2 = NS_RGB(0,0,0);
|
||||
} else {
|
||||
PRUint8 rc,gc,bc = 0;
|
||||
if (counter->mCount < 5) {
|
||||
rc = 255;
|
||||
gc = 255;
|
||||
} else if ( counter->mCount < 11) {
|
||||
gc = 255;
|
||||
} else {
|
||||
rc = 255;
|
||||
}
|
||||
color = NS_RGB(rc,gc,bc);
|
||||
color2 = NS_RGB(rc/2,gc/2,bc/2);
|
||||
}
|
||||
|
||||
nsRect rect(0,0, width+15, height+15);
|
||||
aRenderingContext->SetColor(NS_RGB(0,0,0));
|
||||
aRenderingContext->FillRect(rect);
|
||||
aRenderingContext->SetColor(color2);
|
||||
aRenderingContext->DrawString(buf, strlen(buf), x+15,15);
|
||||
aRenderingContext->SetColor(color);
|
||||
aRenderingContext->DrawString(buf, strlen(buf), x,0);
|
||||
|
||||
PRBool clipEmpty;
|
||||
aRenderingContext->PopState(clipEmpty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
PRIntn ReflowCountMgr::RemoveItems(PLHashEntry *he, PRIntn i, void *arg)
|
||||
{
|
||||
|
@ -6334,11 +6453,14 @@ void ReflowCountMgr::CleanUp()
|
|||
{
|
||||
if (nsnull != mCounts) {
|
||||
PL_HashTableEnumerateEntries(mCounts, RemoveItems, nsnull);
|
||||
PL_HashTableEnumerateEntries(mIndiFrameCounts, RemoveIndiItems, nsnull);
|
||||
PL_HashTableDestroy(mCounts);
|
||||
PL_HashTableDestroy(mIndiFrameCounts);
|
||||
mCounts = nsnull;
|
||||
mCounts = mIndiFrameCounts;
|
||||
}
|
||||
|
||||
if (nsnull != mIndiFrameCounts) {
|
||||
PL_HashTableEnumerateEntries(mIndiFrameCounts, RemoveIndiItems, nsnull);
|
||||
PL_HashTableDestroy(mIndiFrameCounts);
|
||||
mIndiFrameCounts = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6490,8 +6612,12 @@ void ReflowCountMgr::DoGrandHTMLTotals()
|
|||
void ReflowCountMgr::DisplayTotals(const char * aStr)
|
||||
{
|
||||
printf("%s\n", aStr?aStr:"No name");
|
||||
DoGrandTotals();
|
||||
DoIndiTotalsTree();
|
||||
if (mDumpFrameCounts) {
|
||||
DoGrandTotals();
|
||||
}
|
||||
if (mDumpFrameByFrameCounts) {
|
||||
DoIndiTotalsTree();
|
||||
}
|
||||
|
||||
}
|
||||
//------------------------------------
|
||||
|
@ -6612,3 +6738,5 @@ void ColorToString(nscolor aColor, nsAutoString &aString)
|
|||
if (tmp.Length() < 2) tmp.AppendInt(0,16);
|
||||
aString.Append(tmp);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1287,6 +1287,7 @@ nsTextFrame::Paint(nsIPresContext* aPresContext,
|
|||
|
||||
}
|
||||
}
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsTextFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -665,6 +665,7 @@ nsHTMLFrameInnerFrame::Paint(nsIPresContext* aPresContext,
|
|||
aRenderingContext.SetColor(color->mBackgroundColor);
|
||||
aRenderingContext.FillRect(mRect);
|
||||
}
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsHTMLFrameInnerFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -252,6 +252,7 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
|
|||
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
||||
}
|
||||
#endif
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsFieldSetFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -2026,7 +2026,9 @@ nsGfxTextControlFrame2::Paint(nsIPresContext* aPresContext,
|
|||
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible) {
|
||||
return NS_OK;
|
||||
}
|
||||
return nsStackFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
nsresult rv = nsStackFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsGfxTextControlFrame2", &aRenderingContext);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -335,6 +335,7 @@ nsListControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
return nsScrollFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsListControlFrame", &aRenderingContext);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
|
|
@ -392,6 +392,7 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP_J("nsTableCellFrame", &aRenderingContext, 0);
|
||||
return NS_OK;
|
||||
/*nsFrame::Paint(aPresContext,
|
||||
aRenderingContext,
|
||||
|
|
|
@ -1377,6 +1377,7 @@ NS_METHOD nsTableFrame::Paint(nsIPresContext* aPresContext,
|
|||
#endif
|
||||
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP_J("nsTableFrame", &aRenderingContext, NS_RGB(255,128,255));
|
||||
return NS_OK;
|
||||
/*nsFrame::Paint(aPresContext,
|
||||
aRenderingContext,
|
||||
|
|
|
@ -392,6 +392,7 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP_J("nsTableCellFrame", &aRenderingContext, 0);
|
||||
return NS_OK;
|
||||
/*nsFrame::Paint(aPresContext,
|
||||
aRenderingContext,
|
||||
|
|
|
@ -1377,6 +1377,7 @@ NS_METHOD nsTableFrame::Paint(nsIPresContext* aPresContext,
|
|||
#endif
|
||||
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP_J("nsTableFrame", &aRenderingContext, NS_RGB(255,128,255));
|
||||
return NS_OK;
|
||||
/*nsFrame::Paint(aPresContext,
|
||||
aRenderingContext,
|
||||
|
|
Загрузка…
Ссылка в новой задаче