bug 563864. Add mozPaintCount API. r=smaug,sr=vlad

This commit is contained in:
Robert O'Callahan 2010-05-13 12:56:08 +12:00
Родитель 784bd59b11
Коммит 8874172bf5
8 изменённых файлов: 99 добавлений и 4 удалений

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

@ -3565,6 +3565,25 @@ nsGlobalWindow::GetMozInnerScreenY(float* aScreenY)
return NS_OK;
}
NS_IMETHODIMP
nsGlobalWindow::GetMozPaintCount(PRUint64* aResult)
{
FORWARD_TO_OUTER(GetMozPaintCount, (aResult), NS_ERROR_NOT_INITIALIZED);
*aResult = 0;
if (!mDocShell)
return NS_OK;
nsCOMPtr<nsIPresShell> presShell;
mDocShell->GetPresShell(getter_AddRefs(presShell));
if (!presShell)
return NS_OK;
*aResult = presShell->GetPaintCount();
return NS_OK;
}
NS_IMETHODIMP
nsGlobalWindow::SetScreenX(PRInt32 aScreenX)
{

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

@ -44,7 +44,7 @@ interface nsIControllers;
interface nsIDOMLocation;
interface nsIVariant;
[scriptable, uuid(c2f4433a-8b4c-4676-ab30-3bffd26fb29e)]
[scriptable, uuid(f18e491b-0c1a-4a9d-9281-32f39fa2d637)]
interface nsIDOMWindowInternal : nsIDOMWindow2
{
readonly attribute nsIDOMWindowInternal window;
@ -218,4 +218,10 @@ interface nsIDOMWindowInternal : nsIDOMWindow2
*/
[binaryname(PostMessageMoz)] void postMessage(in DOMString message,
in DOMString targetOrigin);
/**
* Returns the number of times this document for this window has
* been painted to the screen.
*/
readonly attribute unsigned long long mozPaintCount;
};

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

@ -77,7 +77,8 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
mPaintAllFrames(PR_FALSE),
mAccurateVisibleRegions(PR_FALSE),
mInTransform(PR_FALSE),
mSyncDecodeImages(PR_FALSE) {
mSyncDecodeImages(PR_FALSE),
mIsPaintingToWindow(PR_FALSE) {
PL_InitArenaPool(&mPool, "displayListArena", 1024, sizeof(void*)-1);
nsPresContext* pc = aReferenceFrame->PresContext();
@ -196,6 +197,10 @@ nsDisplayListBuilder::EnterPresShell(nsIFrame* aReferenceFrame,
state->mPresShell->UpdateCanvasBackground();
if (mIsPaintingToWindow) {
state->mPresShell->IncrementPaintCount();
}
if (!mBuildCaret)
return;

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

@ -249,6 +249,10 @@ public:
* so that methods like GetFrameForPoint work when painting is suppressed.
*/
void IgnorePaintSuppression() { mIsBackgroundOnly = PR_FALSE; }
/**
* Call this if we're doing normal painting to the window.
*/
void SetPaintingToWindow(PRBool aToWindow) { mIsPaintingToWindow = aToWindow; }
/**
* Display the caret if needed.
*/
@ -424,6 +428,7 @@ private:
// under an nsDisplayTransform
PRPackedBool mInTransform;
PRPackedBool mSyncDecodeImages;
PRPackedBool mIsPaintingToWindow;
};
class nsDisplayItem;

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

@ -119,8 +119,8 @@ typedef struct CapturingContentInfo {
} CapturingContentInfo;
#define NS_IPRESSHELL_IID \
{ 0x84f1a428, 0x6bbe, 0x4958, \
{ 0xa1, 0x08, 0x8a, 0xe0, 0x78, 0xb8, 0x63, 0xf4 } }
{ 0x47c5b7c4, 0x8d35, 0x4d36, \
{ 0xa1, 0xf9, 0x19, 0x44, 0xf8, 0xb9, 0x46, 0xb5 } }
// Constants for ScrollContentIntoView() function
#define NS_PRESSHELL_SCROLL_TOP 0
@ -984,6 +984,13 @@ public:
return gCaptureInfo.mPreventDrag && gCaptureInfo.mContent;
}
/**
* Keep track of how many times this presshell has been rendered to
* a window.
*/
PRUint64 GetPaintCount() { return mPaintCount; }
void IncrementPaintCount() { ++mPaintCount; }
protected:
// IMPORTANT: The ownership implicit in the following member variables
// has been explicitly checked. If you add any members to this class,
@ -1004,6 +1011,10 @@ protected:
nsIFrame* mDrawEventTargetFrame;
#endif
// Count of the number of times this presshell has been painted to
// a window
PRUint64 mPaintCount;
PRInt16 mSelectionFlags;
PRPackedBool mStylesHaveChanged;

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

@ -1178,6 +1178,9 @@ nsLayoutUtils::PaintFrame(nsIRenderingContext* aRenderingContext, nsIFrame* aFra
if (aFlags & PAINT_SYNC_DECODE_IMAGES) {
builder.SetSyncDecodeImages(PR_TRUE);
}
if (aFlags & PAINT_WIDGET_LAYERS) {
builder.SetPaintingToWindow(PR_TRUE);
}
nsresult rv;
builder.EnterPresShell(aFrame, dirtyRect);

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

@ -105,6 +105,7 @@ _TEST_FILES = \
test_bug518777.html \
test_bug548545.xhtml \
test_flush_on_paint.html \
test_mozPaintCount.html \
test_scroll_selection_into_view.html \
test_scrolling.html \
$(NULL)

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

@ -0,0 +1,45 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Tests for mozPaintCount</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="doFlicker()">
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
var startPaintCount = window.mozPaintCount;
var color = 0;
function doFlicker() {
if (window.mozPaintCount - startPaintCount > 20) {
ok(true, "Got enough paints");
SimpleTest.finish();
return;
}
color = (color + 1) % 256;
document.body.style.backgroundColor = "rgb(" + color + "," + color + "," + color + ")";
setTimeout(doFlicker, 0);
}
</script>
</pre>
<div style="height:4000px"></div>
<a id="first" href="http://www.mozilla.org/">first<br>link</a>
<a id="second" href="http://www.mozilla.org/">second link</a>
<a id="third" href="http://www.mozilla.org/">third<br>link</a>
<div style="height:4000px"></div>
</body>
</html>