Bug 1178354 - Ensure we fire a before-first-paint event for printing as well. r=tn

This commit is contained in:
Kartikaya Gupta 2015-07-23 17:53:32 -04:00
parent 6bc3f407c4
commit d005fffd01
2 changed files with 19 additions and 6 deletions

View File

@ -1736,6 +1736,12 @@ PresShell::Initialize(nscoord aWidth, nscoord aHeight)
}
}
// If we get here and painting is not suppressed, then we can paint anytime
// and we should fire the before-first-paint notification
if (!mPaintingSuppressed) {
ScheduleBeforeFirstPaint();
}
if (root && root->IsXULElement()) {
mozilla::Telemetry::AccumulateTimeDelta(Telemetry::XUL_INITIAL_FRAME_CONSTRUCTION,
timerStart);
@ -3773,6 +3779,17 @@ PresShell::CaptureHistoryState(nsILayoutHistoryState** aState)
return NS_OK;
}
void
PresShell::ScheduleBeforeFirstPaint()
{
if (!mDocument->IsResourceDoc()) {
// Notify observers that a new page is about to be drawn. Execute this
// as soon as it is safe to run JS, which is guaranteed to be before we
// go back to the event loop and actually draw the page.
nsContentUtils::AddScriptRunner(new nsBeforeFirstPaintDispatcher(mDocument));
}
}
void
PresShell::UnsuppressAndInvalidate()
{
@ -3784,12 +3801,7 @@ PresShell::UnsuppressAndInvalidate()
return;
}
if (!mDocument->IsResourceDoc()) {
// Notify observers that a new page is about to be drawn. Execute this
// as soon as it is safe to run JS, which is guaranteed to be before we
// go back to the event loop and actually draw the page.
nsContentUtils::AddScriptRunner(new nsBeforeFirstPaintDispatcher(mDocument));
}
ScheduleBeforeFirstPaint();
mPaintingSuppressed = false;
nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();

View File

@ -413,6 +413,7 @@ protected:
void HandlePostedReflowCallbacks(bool aInterruptible);
void CancelPostedReflowCallbacks();
void ScheduleBeforeFirstPaint();
void UnsuppressAndInvalidate();
void WillCauseReflow() {