Backout 3ad33d09825a (bug 1059014 part 3) because the removed code is less dead than it first appears.

This commit is contained in:
Nicholas Nethercote 2015-11-23 14:13:48 -08:00
parent 478a54a686
commit a97216ee59
5 changed files with 101 additions and 4 deletions

View File

@ -31,7 +31,7 @@ class nsDOMNavigationTiming;
[ptr] native nsDOMNavigationTimingPtr(nsDOMNavigationTiming);
[ref] native nsIContentViewerTArray(nsTArray<nsCOMPtr<nsIContentViewer> >);
[scriptable, builtinclass, uuid(91b6c1f3-fc5f-43a9-88f4-9286bd19387f)]
[scriptable, builtinclass, uuid(2da17016-7851-4a45-a7a8-00b360e01595)]
interface nsIContentViewer : nsISupports
{
[noscript] void init(in nsIWidgetPtr aParentWidget,
@ -229,6 +229,18 @@ interface nsIContentViewer : nsISupports
*/
[noscript] void appendSubtree(in nsIContentViewerTArray array);
/**
* Instruct the refresh driver to discontinue painting until further
* notice.
*/
void pausePainting();
/**
* Instruct the refresh driver to resume painting after a previous call to
* pausePainting().
*/
void resumePainting();
/*
* Render the document as if being viewed on a device with the specified
* media type. This will cause a reflow.

View File

@ -2774,6 +2774,17 @@ nsDocumentViewer::CallChildren(CallChildFunc aFunc, void* aClosure)
}
}
static void
ChangeChildPaintingEnabled(nsIContentViewer* aChild, void* aClosure)
{
bool* enablePainting = (bool*) aClosure;
if (*enablePainting) {
aChild->ResumePainting();
} else {
aChild->PausePainting();
}
}
struct ZoomInfo
{
float mZoom;
@ -3203,6 +3214,34 @@ NS_IMETHODIMP nsDocumentViewer::AppendSubtree(nsTArray<nsCOMPtr<nsIContentViewer
return NS_OK;
}
NS_IMETHODIMP
nsDocumentViewer::PausePainting()
{
bool enablePaint = false;
CallChildren(ChangeChildPaintingEnabled, &enablePaint);
nsIPresShell* presShell = GetPresShell();
if (presShell) {
presShell->PausePainting();
}
return NS_OK;
}
NS_IMETHODIMP
nsDocumentViewer::ResumePainting()
{
bool enablePaint = true;
CallChildren(ChangeChildPaintingEnabled, &enablePaint);
nsIPresShell* presShell = GetPresShell();
if (presShell) {
presShell->ResumePainting();
}
return NS_OK;
}
NS_IMETHODIMP
nsDocumentViewer::GetContentSize(int32_t* aWidth, int32_t* aHeight)
{

View File

@ -140,10 +140,10 @@ typedef struct CapturingContentInfo {
mozilla::StaticRefPtr<nsIContent> mContent;
} CapturingContentInfo;
// 327d78a0-0680-4709-b209-1cf9578720e6
// e3042b8d-0cc0-4ee6-baca-fec1ba89ee97
#define NS_IPRESSHELL_IID \
{ 0x327d78a0, 0x0680, 0x4709, \
{ 0xb2, 0x09, 0x1c, 0xf9, 0x57, 0x87, 0x20, 0xe6 } }
{ 0xe3042b8d, 0x0cc0, 0x4ee6, \
{ 0xba, 0xca, 0xfe, 0xc1, 0xba, 0x89, 0xee, 0x97 } }
// debug VerifyReflow flags
#define VERIFY_REFLOW_ON 0x01
@ -936,6 +936,20 @@ public:
*/
bool IsPaintingSuppressed() const { return mPaintingSuppressed; }
/**
* Pause painting by freezing the refresh driver of this and all parent
* presentations. This may not have the desired effect if this pres shell
* has its own refresh driver.
*/
virtual void PausePainting() = 0;
/**
* Resume painting by thawing the refresh driver of this and all parent
* presentations. This may not have the desired effect if this pres shell
* has its own refresh driver.
*/
virtual void ResumePainting() = 0;
/**
* Unsuppress painting.
*/
@ -1799,6 +1813,7 @@ protected:
bool mFontSizeInflationForceEnabled;
bool mFontSizeInflationDisabledInMasterProcess;
bool mFontSizeInflationEnabled;
bool mPaintingIsFrozen;
// Dirty bit indicating that mFontSizeInflationEnabled needs to be recomputed.
bool mFontSizeInflationEnabledIsDirty;

View File

@ -799,6 +799,7 @@ PresShell::PresShell()
addedPointerEventEnabled = true;
}
mPaintingIsFrozen = false;
mHasCSSBackgroundColor = true;
mIsLastChromeOnlyEscapeKeyConsumed = false;
mHasReceivedPaintMessage = false;
@ -822,6 +823,13 @@ PresShell::~PresShell()
mLastCallbackEventRequest == nullptr,
"post-reflow queues not empty. This means we're leaking");
// Verify that if painting was frozen, but we're being removed from the tree,
// that we now re-enable painting on our refresh driver, since it may need to
// be re-used by another presentation.
if (mPaintingIsFrozen) {
mPresContext->RefreshDriver()->Thaw();
}
#ifdef DEBUG
MOZ_ASSERT(mPresArenaAllocCount == 0,
"Some pres arena objects were not freed");
@ -10843,6 +10851,26 @@ nsIPresShell::FontSizeInflationEnabled()
return mFontSizeInflationEnabled;
}
void
PresShell::PausePainting()
{
if (GetPresContext()->RefreshDriver()->PresContext() != GetPresContext())
return;
mPaintingIsFrozen = true;
GetPresContext()->RefreshDriver()->Freeze();
}
void
PresShell::ResumePainting()
{
if (GetPresContext()->RefreshDriver()->PresContext() != GetPresContext())
return;
mPaintingIsFrozen = false;
GetPresContext()->RefreshDriver()->Thaw();
}
void
nsIPresShell::SyncWindowProperties(nsView* aView)
{

View File

@ -738,6 +738,9 @@ protected:
virtual void ThemeChanged() override { mPresContext->ThemeChanged(); }
virtual void BackingScaleFactorChanged() override { mPresContext->UIResolutionChanged(); }
virtual void PausePainting() override;
virtual void ResumePainting() override;
void UpdateImageVisibility();
void UpdateActivePointerState(mozilla::WidgetGUIEvent* aEvent);