Skip to content

Commit

Permalink
Bug 990907 - Add a flag on nsIScrollableFrame to indicate if it is ac…
Browse files Browse the repository at this point in the history
…tively being scrolled by APZ.
  • Loading branch information
rmottola committed Feb 15, 2019
1 parent 0f95f6f commit 3eb29e6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gfx/layers/apz/util/APZEventState.cpp
Expand Up @@ -249,6 +249,9 @@ APZEventState::ProcessAPZStateChange(const nsCOMPtr<nsIDocument>& aDocument,
case APZStateChange::TransformBegin:
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
if (sf) {
sf->SetTransformingByAPZ(true);
}
nsIScrollbarMediator* scrollbarMediator = do_QueryFrame(sf);
if (scrollbarMediator) {
scrollbarMediator->ScrollbarActivityStarted();
Expand All @@ -266,6 +269,9 @@ APZEventState::ProcessAPZStateChange(const nsCOMPtr<nsIDocument>& aDocument,
case APZStateChange::TransformEnd:
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
if (sf) {
sf->SetTransformingByAPZ(false);
}
nsIScrollbarMediator* scrollbarMediator = do_QueryFrame(sf);
if (scrollbarMediator) {
scrollbarMediator->ScrollbarActivityStopped();
Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsGfxScrollFrame.cpp
Expand Up @@ -1912,6 +1912,7 @@ ScrollFrameHelper::ScrollFrameHelper(nsContainerFrame* aOuter,
, mIsResolutionSet(false)
, mIgnoreMomentumScroll(false)
, mScaleToResolution(false)
, mTransformingByAPZ(false)
{
if (LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0) {
mScrollbarActivity = new ScrollbarActivity(do_QueryFrame(aOuter));
Expand Down
25 changes: 25 additions & 0 deletions layout/generic/nsGfxScrollFrame.h
Expand Up @@ -325,6 +325,13 @@ class ScrollFrameHelper : public nsIReflowCallback {
void MarkNotRecentlyScrolled();
nsExpirationState* GetExpirationState() { return &mActivityExpirationState; }

void SetTransformingByAPZ(bool aTransforming) {
mTransformingByAPZ = aTransforming;
}
bool IsTransformingByAPZ() const {
return mTransformingByAPZ;
}

void ScheduleSyntheticMouseMove();
static void ScrollActivityCallback(nsITimer *aTimer, void* anInstance);

Expand Down Expand Up @@ -471,6 +478,10 @@ class ScrollFrameHelper : public nsIReflowCallback {
// Only meaningful for root scroll frames.
bool mScaleToResolution:1;

// True if the APZ is in the process of async-transforming this scrollframe,
// (as best as we can tell on the main thread, anyway).
bool mTransformingByAPZ:1;

protected:
/**
* @note This method might destroy the frame, pres shell and other objects.
Expand Down Expand Up @@ -817,6 +828,13 @@ class nsHTMLScrollFrame : public nsContainerFrame,
}
virtual void ScrollbarActivityStarted() const override;
virtual void ScrollbarActivityStopped() const override;

virtual void SetTransformingByAPZ(bool aTransforming) MOZ_OVERRIDE {
mHelper.SetTransformingByAPZ(aTransforming);
}
bool IsTransformingByAPZ() const MOZ_OVERRIDE {
return mHelper.IsTransformingByAPZ();
}

#ifdef DEBUG_FRAME_DUMP
virtual nsresult GetFrameName(nsAString& aResult) const override;
Expand Down Expand Up @@ -1188,6 +1206,13 @@ class nsXULScrollFrame final : public nsBoxFrame,
virtual void ScrollbarActivityStarted() const override;
virtual void ScrollbarActivityStopped() const override;

virtual void SetTransformingByAPZ(bool aTransforming) MOZ_OVERRIDE {
mHelper.SetTransformingByAPZ(aTransforming);
}
bool IsTransformingByAPZ() const MOZ_OVERRIDE {
return mHelper.IsTransformingByAPZ();
}

#ifdef DEBUG_FRAME_DUMP
virtual nsresult GetFrameName(nsAString& aResult) const override;
#endif
Expand Down
3 changes: 3 additions & 0 deletions layout/generic/nsIScrollableFrame.h
Expand Up @@ -406,6 +406,9 @@ class nsIScrollableFrame : public nsIScrollbarMediator {
* Mark the scrollbar frames for reflow.
*/
virtual void MarkScrollbarsDirtyForReflow() const = 0;

virtual void SetTransformingByAPZ(bool aTransforming) = 0;
virtual bool IsTransformingByAPZ() const = 0;
};

#endif

0 comments on commit 3eb29e6

Please sign in to comment.