diff --git a/layout/xul/nsSliderFrame.cpp b/layout/xul/nsSliderFrame.cpp index b730efdfdbc5..6a561711066f 100644 --- a/layout/xul/nsSliderFrame.cpp +++ b/layout/xul/nsSliderFrame.cpp @@ -22,11 +22,13 @@ #include "nsHTMLParts.h" #include "nsIPresShell.h" #include "nsCSSRendering.h" +#include "nsIDOMEvent.h" #include "nsIDOMMouseEvent.h" #include "nsScrollbarButtonFrame.h" #include "nsISliderListener.h" #include "nsIScrollableFrame.h" #include "nsIScrollbarMediator.h" +#include "nsISupportsImpl.h" #include "nsScrollbarFrame.h" #include "nsRepeatService.h" #include "nsBoxLayoutState.h" @@ -35,16 +37,19 @@ #include "nsContentUtils.h" #include "nsLayoutUtils.h" #include "nsDisplayList.h" +#include "mozilla/Assertions.h" // for MOZ_ASSERT #include "mozilla/Preferences.h" #include "mozilla/LookAndFeel.h" #include "mozilla/MouseEvents.h" #include "mozilla/Telemetry.h" +#include "mozilla/layers/APZCCallbackHelper.h" #include "mozilla/layers/AsyncDragMetrics.h" #include "mozilla/layers/InputAPZContext.h" #include "mozilla/layers/ScrollInputMethods.h" #include using namespace mozilla; +using mozilla::layers::APZCCallbackHelper; using mozilla::layers::AsyncDragMetrics; using mozilla::layers::InputAPZContext; using mozilla::layers::ScrollInputMethod; @@ -80,13 +85,20 @@ nsSliderFrame::nsSliderFrame(nsStyleContext* aContext): mChange(0), mDragFinished(true), mUserChanged(false), - mScrollingWithAPZ(false) + mScrollingWithAPZ(false), + mSuppressionActive(false) { } // stop timer nsSliderFrame::~nsSliderFrame() { + MOZ_ASSERT(!mSuppressionActive, "Should have un-suppress via StopDrag() first."); + if (mSuppressionActive) { + APZCCallbackHelper::SuppressDisplayport(false, PresContext() ? + PresContext()->PresShell() : + nullptr); + } } void @@ -1042,6 +1054,12 @@ nsSliderFrame::StartDrag(nsIDOMEvent* aEvent) printf("Pressed mDragStart=%d\n",mDragStart); #endif + if (!mScrollingWithAPZ && !mSuppressionActive) { + MOZ_ASSERT(PresContext()->PresShell()); + APZCCallbackHelper::SuppressDisplayport(true, PresContext()->PresShell()); + mSuppressionActive = true; + } + return NS_OK; } @@ -1053,6 +1071,12 @@ nsSliderFrame::StopDrag() mScrollingWithAPZ = false; + if (mSuppressionActive) { + MOZ_ASSERT(PresContext()->PresShell()); + APZCCallbackHelper::SuppressDisplayport(false, PresContext()->PresShell()); + mSuppressionActive = false; + } + #ifdef MOZ_WIDGET_GTK nsIFrame* thumbFrame = mFrames.FirstChild(); if (thumbFrame) { diff --git a/layout/xul/nsSliderFrame.h b/layout/xul/nsSliderFrame.h index 2b55a949cc0a..f31a20119a38 100644 --- a/layout/xul/nsSliderFrame.h +++ b/layout/xul/nsSliderFrame.h @@ -195,6 +195,10 @@ private: // causing the scroll position to jump. bool mScrollingWithAPZ; + // true if displayport suppression is active, for more performant + // scrollbar-dragging behaviour. + bool mSuppressionActive; + static bool gMiddlePref; static int32_t gSnapMultiplier; }; // class nsSliderFrame