Bug 1449756 - Make DisplayPort suppression PresShell specific and not process global. r=kats

Originally, DisplayPort suppression was a process-global static. This change makes it possible
to control DisplayPort suppression on a per-PresShell basis.

Differential Revision: https://phabricator.services.mozilla.com/D1759
This commit is contained in:
Mike Conley
2018-06-25 21:42:25 +00:00
parent 2824a326f1
commit 1a33d3d8d9
11 changed files with 99 additions and 91 deletions

View File

@@ -809,6 +809,7 @@ PresShell::PresShell()
, mLastCallbackEventRequest(nullptr)
, mLastReflowStart(0.0)
, mLastAnchorScrollPositionY(0)
, mActiveSuppressDisplayport(0)
, mAPZFocusSequenceNumber(0)
, mDocumentLoading(false)
, mIgnoreFrameDestruction(false)
@@ -8555,6 +8556,47 @@ PresShell::IsVisible()
return frame->IsVisibleConsideringAncestors(nsIFrame::VISIBILITY_CROSS_CHROME_CONTENT_BOUNDARY);
}
void
PresShell::SuppressDisplayport(bool aEnabled)
{
if (aEnabled) {
mActiveSuppressDisplayport++;
} else {
bool isSuppressed = IsDisplayportSuppressed();
mActiveSuppressDisplayport--;
if (isSuppressed && !IsDisplayportSuppressed()) {
// We unsuppressed the displayport, trigger a paint
if (nsIFrame* rootFrame = mFrameConstructor->GetRootFrame()) {
rootFrame->SchedulePaint();
}
}
}
MOZ_ASSERT(mActiveSuppressDisplayport >= 0);
}
static bool sDisplayPortSuppressionRespected = true;
void
PresShell::RespectDisplayportSuppression(bool aEnabled)
{
bool isSuppressed = IsDisplayportSuppressed();
sDisplayPortSuppressionRespected = aEnabled;
if (isSuppressed && !IsDisplayportSuppressed()) {
// We unsuppressed the displayport, trigger a paint
if (nsIFrame* rootFrame = mFrameConstructor->GetRootFrame()) {
rootFrame->SchedulePaint();
}
}
}
bool
PresShell::IsDisplayportSuppressed()
{
return sDisplayPortSuppressionRespected &&
mActiveSuppressDisplayport > 0;
}
nsresult
PresShell::GetAgentStyleSheets(nsTArray<RefPtr<StyleSheet>>& aSheets)
{