Bug 1257641 - Allow enabling/disabling of displayport suppression for tests. r?botond
MozReview-Commit-ID: DOfZLOwTW2H
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -3870,16 +3870,24 @@ nsDOMWindowUtils::SetNextPaintSyncId(int
return NS_OK;
}
}
NS_WARNING("Paint sync id could not be set on the ClientLayerManager");
return NS_OK;
}
+NS_IMETHODIMP
+nsDOMWindowUtils::RespectDisplayPortSuppression(bool aEnabled)
+{
+ nsCOMPtr<nsIPresShell> shell(GetPresShell());
+ APZCCallbackHelper::RespectDisplayPortSuppression(aEnabled, shell);
+ return NS_OK;
+}
+
NS_INTERFACE_MAP_BEGIN(nsTranslationNodeList)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY(nsITranslationNodeList)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(nsTranslationNodeList)
NS_IMPL_RELEASE(nsTranslationNodeList)
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -1837,16 +1837,24 @@ interface nsIDOMWindowUtils : nsISupport
* document's counters. Normally, use counters are flushed to telemetry
* upon document destruction, but as document destruction is somewhat
* non-deterministic, we have this method here for more determinism when
* running tests.
*/
void forceUseCounterFlush(in nsIDOMNode aNode);
void setNextPaintSyncId(in long aSyncId);
+
+ /**
+ * Enable or disable displayport suppression. This is intended to be used by
+ * testing code, to provide more deterministic behaviour over the displayport
+ * suppression during tests. Note that this updates a flag, so whatever value
+ * was last provided is what will be used.
+ */
+ void respectDisplayPortSuppression(in boolean aEnabled);
};
[scriptable, uuid(c694e359-7227-4392-a138-33c0cc1f15a6)]
interface nsITranslationNodeList : nsISupports {
readonly attribute unsigned long length;
nsIDOMNode item(in unsigned long index);
// A translation root is a block element, or an inline element
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -877,37 +877,55 @@ APZCCallbackHelper::NotifyFlushComplete(
}
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
MOZ_ASSERT(observerService);
observerService->NotifyObservers(nullptr, "apz-repaints-flushed", nullptr);
}
static int32_t sActiveSuppressDisplayport = 0;
+static bool sDisplayPortSuppressionRespected = true;
void
APZCCallbackHelper::SuppressDisplayport(const bool& aEnabled,
const nsCOMPtr<nsIPresShell>& aShell)
{
if (aEnabled) {
sActiveSuppressDisplayport++;
} else {
+ bool isSuppressed = IsDisplayportSuppressed();
sActiveSuppressDisplayport--;
- if (sActiveSuppressDisplayport == 0 && aShell && aShell->GetRootFrame()) {
+ if (isSuppressed && !IsDisplayportSuppressed() &&
+ aShell && aShell->GetRootFrame()) {
+ // We unsuppressed the displayport, trigger a paint
aShell->GetRootFrame()->SchedulePaint();
}
}
MOZ_ASSERT(sActiveSuppressDisplayport >= 0);
}
+void
+APZCCallbackHelper::RespectDisplayPortSuppression(bool aEnabled,
+ const nsCOMPtr<nsIPresShell>& aShell)
+{
+ bool isSuppressed = IsDisplayportSuppressed();
+ sDisplayPortSuppressionRespected = aEnabled;
+ if (isSuppressed && !IsDisplayportSuppressed() &&
+ aShell && aShell->GetRootFrame()) {
+ // We unsuppressed the displayport, trigger a paint
+ aShell->GetRootFrame()->SchedulePaint();
+ }
+}
+
bool
APZCCallbackHelper::IsDisplayportSuppressed()
{
- return sActiveSuppressDisplayport > 0;
+ return sDisplayPortSuppressionRespected
+ && sActiveSuppressDisplayport > 0;
}
/* static */ bool
APZCCallbackHelper::IsScrollInProgress(nsIScrollableFrame* aFrame)
{
return aFrame->IsProcessingAsyncScroll()
|| nsLayoutUtils::CanScrollOriginClobberApz(aFrame->LastScrollOrigin())
|| aFrame->LastSmoothScrollOrigin();
--- a/gfx/layers/apz/util/APZCCallbackHelper.h
+++ b/gfx/layers/apz/util/APZCCallbackHelper.h
@@ -159,16 +159,27 @@ public:
/* Temporarily ignore the Displayport for better paint performance. If at
* all possible, pass in a presShell if you have one at the call site, we
* use it to trigger a repaint once suppression is disabled. Without that
* the displayport may get left at the suppressed size for an extended
* period of time and result in unnecessary checkerboarding (see bug
* 1255054). */
static void SuppressDisplayport(const bool& aEnabled,
const nsCOMPtr<nsIPresShell>& aShell);
+
+ /* Whether or not displayport suppression should be turned on. Note that
+ * this only affects the return value of |IsDisplayportSuppressed()|, and
+ * doesn't change the value of the internal counter. As with
+ * SuppressDisplayport, this function should be passed a presShell to trigger
+ * a repaint if suppression is being turned off.
+ */
+ static void RespectDisplayPortSuppression(bool aEnabled,
+ const nsCOMPtr<nsIPresShell>& aShell);
+
+ /* Whether or not the displayport is currently suppressed. */
static bool IsDisplayportSuppressed();
static void
AdjustDisplayPortForScrollDelta(mozilla::layers::FrameMetrics& aFrameMetrics,
const CSSPoint& aActualScrollOffset);
/*
* Check if the scrollable frame is currently in the middle of an async