Bug 732091 - Part 2: Add {set,get}IsFirstPaint to nsIDOMWindowUtils and nsIPresShell. r=ehsan

This commit is contained in:
Ali Juma 2012-03-12 11:50:11 -04:00
parent def0c0bab3
commit 42a0e56158
4 changed files with 53 additions and 1 deletions

View File

@ -388,6 +388,36 @@ nsDOMWindowUtils::SetResolution(float aXResolution, float aYResolution)
: NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsDOMWindowUtils::SetIsFirstPaint(bool aIsFirstPaint)
{
if (!IsUniversalXPConnectCapable()) {
return NS_ERROR_DOM_SECURITY_ERR;
}
nsIPresShell* presShell = GetPresShell();
if (presShell) {
presShell->SetIsFirstPaint(aIsFirstPaint);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetIsFirstPaint(bool *aIsFirstPaint)
{
if (!IsUniversalXPConnectCapable()) {
return NS_ERROR_DOM_SECURITY_ERR;
}
nsIPresShell* presShell = GetPresShell();
if (presShell) {
*aIsFirstPaint = presShell->GetIsFirstPaint();
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsDOMWindowUtils::SendMouseEvent(const nsAString& aType,
float aX,

View File

@ -70,7 +70,7 @@ interface nsIDOMFile;
interface nsIFile;
interface nsIDOMTouch;
[scriptable, uuid(73b48170-55d5-11e1-b86c-0800200c9a66)]
[scriptable, uuid(5740d0fe-9f4e-431f-b8b3-b82f9b7ff4cf)]
interface nsIDOMWindowUtils : nsISupports {
/**
@ -189,6 +189,15 @@ interface nsIDOMWindowUtils : nsISupports {
*/
void setResolution(in float aXResolution, in float aYResolution);
/**
* Whether the next paint should be flagged as the first paint for a document.
* This gives a way to track the next paint that occurs after the flag is
* set. The flag gets cleared after the next paint.
*
* Can only be accessed with UniversalXPConnect privileges.
*/
attribute boolean isFirstPaint;
/** Synthesize a mouse event. The event types supported are:
* mousedown, mouseup, mousemove, mouseover, mouseout, contextmenu
*

View File

@ -1146,6 +1146,16 @@ public:
float GetXResolution() { return mXResolution; }
float GetYResolution() { return mYResolution; }
/**
* Set the isFirstPaint flag.
*/
void SetIsFirstPaint(bool aIsFirstPaint) { mIsFirstPaint = aIsFirstPaint; }
/**
* Get the isFirstPaint flag.
*/
bool GetIsFirstPaint() const { return mIsFirstPaint; }
/**
* Dispatch a mouse move event based on the most recent mouse position if
* this PresShell is visible. This is used when the contents of the page
@ -1261,6 +1271,8 @@ protected:
bool mIsActive;
bool mFrozen;
bool mIsFirstPaint;
bool mObservesMutationsForPrint;
bool mReflowScheduled; // If true, we have a reflow

View File

@ -823,6 +823,7 @@ PresShell::PresShell()
mSelectionFlags = nsISelectionDisplay::DISPLAY_TEXT | nsISelectionDisplay::DISPLAY_IMAGES;
mIsThemeSupportDisabled = false;
mIsActive = true;
mIsFirstPaint = false;
mFrozen = false;
#ifdef DEBUG
mPresArenaAllocCount = 0;