LCOV - code coverage report
Current view: top level - layout/generic - nsGfxScrollFrame.h (source / functions) Hit Total Coverage
Test: output.info Lines: 171 482 35.5 %
Date: 2017-07-14 16:53:18 Functions: 79 203 38.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : /* rendering object to wrap rendering objects that should be scrollable */
       7             : 
       8             : #ifndef nsGfxScrollFrame_h___
       9             : #define nsGfxScrollFrame_h___
      10             : 
      11             : #include "mozilla/Attributes.h"
      12             : #include "nsContainerFrame.h"
      13             : #include "nsIAnonymousContentCreator.h"
      14             : #include "nsBoxFrame.h"
      15             : #include "nsIScrollableFrame.h"
      16             : #include "nsIScrollbarMediator.h"
      17             : #include "nsIStatefulFrame.h"
      18             : #include "nsThreadUtils.h"
      19             : #include "nsIReflowCallback.h"
      20             : #include "nsBoxLayoutState.h"
      21             : #include "nsQueryFrame.h"
      22             : #include "nsRefreshDriver.h"
      23             : #include "nsExpirationTracker.h"
      24             : #include "TextOverflow.h"
      25             : #include "ScrollVelocityQueue.h"
      26             : 
      27             : class nsPresContext;
      28             : class nsIPresShell;
      29             : class nsIContent;
      30             : class nsIAtom;
      31             : class nsPresState;
      32             : class nsIScrollPositionListener;
      33             : 
      34             : namespace mozilla {
      35             : struct ScrollReflowInput;
      36             : namespace layers {
      37             : class Layer;
      38             : } // namespace layers
      39             : namespace layout {
      40             : class ScrollbarActivity;
      41             : } // namespace layout
      42             : 
      43             : class ScrollFrameHelper : public nsIReflowCallback {
      44             : public:
      45             :   typedef nsIFrame::Sides Sides;
      46             :   typedef mozilla::CSSIntPoint CSSIntPoint;
      47             :   typedef mozilla::layout::ScrollbarActivity ScrollbarActivity;
      48             :   typedef mozilla::layers::FrameMetrics FrameMetrics;
      49             :   typedef mozilla::layers::ScrollSnapInfo ScrollSnapInfo;
      50             :   typedef mozilla::layers::Layer Layer;
      51             : 
      52             :   class AsyncScroll;
      53             :   class AsyncSmoothMSDScroll;
      54             : 
      55             :   ScrollFrameHelper(nsContainerFrame* aOuter, bool aIsRoot);
      56             :   ~ScrollFrameHelper();
      57             : 
      58             :   mozilla::ScrollbarStyles GetScrollbarStylesFromFrame() const;
      59             : 
      60             :   // If a child frame was added or removed on the scrollframe,
      61             :   // reload our child frame list.
      62             :   // We need this if a scrollbar frame is recreated.
      63             :   void ReloadChildFrames();
      64             : 
      65             :   nsresult CreateAnonymousContent(
      66             :     nsTArray<nsIAnonymousContentCreator::ContentInfo>& aElements);
      67             :   void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements, uint32_t aFilter);
      68             :   nsresult FireScrollPortEvent();
      69             :   void PostOverflowEvent();
      70             :   void Destroy();
      71             : 
      72             :   void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
      73             :                         const nsRect&           aDirtyRect,
      74             :                         const nsDisplayListSet& aLists);
      75             : 
      76             :   void AppendScrollPartsTo(nsDisplayListBuilder*   aBuilder,
      77             :                            const nsRect&           aDirtyRect,
      78             :                            const nsDisplayListSet& aLists,
      79             :                            bool                    aCreateLayer,
      80             :                            bool                    aPositioned);
      81             : 
      82             :   bool GetBorderRadii(const nsSize& aFrameSize, const nsSize& aBorderArea,
      83             :                       Sides aSkipSides, nscoord aRadii[8]) const;
      84             : 
      85             :   // nsIReflowCallback
      86             :   virtual bool ReflowFinished() override;
      87             :   virtual void ReflowCallbackCanceled() override;
      88             : 
      89             :   /**
      90             :    * @note This method might destroy the frame, pres shell and other objects.
      91             :    * Called when the 'curpos' attribute on one of the scrollbars changes.
      92             :    */
      93             :   void CurPosAttributeChanged(nsIContent* aChild);
      94             : 
      95             :   void PostScrollEvent();
      96             :   void FireScrollEvent();
      97             :   void PostScrolledAreaEvent();
      98             :   void FireScrolledAreaEvent();
      99             : 
     100             :   bool IsSmoothScrollingEnabled();
     101             : 
     102             :   /**
     103             :    * This class handles the dispatching of scroll events to content.
     104             :    *
     105             :    * nsRefreshDriver maintains three lists of refresh observers, one for each
     106             :    * flush type: FlushType::Style, FlushType::Layout, and FlushType::Display.
     107             :    *
     108             :    * During a tick, it runs through each list of observers, in order, and runs
     109             :    * them. To iterate over each list, it uses an EndLimitedIterator, which is
     110             :    * designed to iterate only over elements present when the iterator was
     111             :    * created, not elements added afterwards. This means that, for a given flush
     112             :    * type, a refresh observer added during the execution of another refresh
     113             :    * observer of that flush type, will not run until the next tick.
     114             :    *
     115             :    * During main-thread animation-driven scrolling, ScrollEvents are *posted*
     116             :    * by AsyncScroll::WillRefresh(). AsyncScroll registers itself as a FlushType::Style
     117             :    * refresh observer.
     118             :    *
     119             :    * Posting a scroll event, as of bug 1250550, registers a FlushType::Layout
     120             :    * refresh observer, which *fires* the event when run. This allows the event
     121             :    * to be fired to content in the same refresh driver tick as it is posted.
     122             :    * This is an important invariant to maintain to reduce scroll event latency
     123             :    * for main-thread scrolling.
     124             :    */
     125             :   class ScrollEvent : public nsARefreshObserver {
     126             :   public:
     127           0 :     NS_INLINE_DECL_REFCOUNTING(ScrollEvent, override)
     128             :     explicit ScrollEvent(ScrollFrameHelper *helper);
     129             :     void WillRefresh(mozilla::TimeStamp aTime) override;
     130             :   protected:
     131             :     virtual ~ScrollEvent();
     132             :   private:
     133             :     ScrollFrameHelper *mHelper;
     134             :     RefPtr<nsRefreshDriver> mDriver;
     135             :   };
     136             : 
     137          33 :   class AsyncScrollPortEvent : public Runnable {
     138             :   public:
     139             :     NS_DECL_NSIRUNNABLE
     140          11 :     explicit AsyncScrollPortEvent(ScrollFrameHelper* helper)
     141          11 :       : Runnable("ScrollFrameHelper::AsyncScrollPortEvent")
     142          11 :       , mHelper(helper)
     143             :     {
     144          11 :     }
     145           0 :     void Revoke() { mHelper = nullptr; }
     146             :   private:
     147             :     ScrollFrameHelper *mHelper;
     148             :   };
     149             : 
     150          60 :   class ScrolledAreaEvent : public Runnable {
     151             :   public:
     152             :     NS_DECL_NSIRUNNABLE
     153          20 :     explicit ScrolledAreaEvent(ScrollFrameHelper* helper)
     154          20 :       : Runnable("ScrollFrameHelper::ScrolledAreaEvent")
     155          20 :       , mHelper(helper)
     156             :     {
     157          20 :     }
     158           0 :     void Revoke() { mHelper = nullptr; }
     159             :   private:
     160             :     ScrollFrameHelper *mHelper;
     161             :   };
     162             : 
     163             :   /**
     164             :    * @note This method might destroy the frame, pres shell and other objects.
     165             :    */
     166             :   void FinishReflowForScrollbar(nsIContent* aContent, nscoord aMinXY,
     167             :                                 nscoord aMaxXY, nscoord aCurPosXY,
     168             :                                 nscoord aPageIncrement,
     169             :                                 nscoord aIncrement);
     170             :   /**
     171             :    * @note This method might destroy the frame, pres shell and other objects.
     172             :    */
     173             :   void SetScrollbarEnabled(nsIContent* aContent, nscoord aMaxPos);
     174             :   /**
     175             :    * @note This method might destroy the frame, pres shell and other objects.
     176             :    */
     177             :   void SetCoordAttribute(nsIContent* aContent, nsIAtom* aAtom, nscoord aSize);
     178             : 
     179             :   nscoord GetCoordAttribute(nsIFrame* aFrame, nsIAtom* aAtom, nscoord aDefaultValue,
     180             :                             nscoord* aRangeStart, nscoord* aRangeLength);
     181             : 
     182             :   /**
     183             :    * @note This method might destroy the frame, pres shell and other objects.
     184             :    * Update scrollbar curpos attributes to reflect current scroll position
     185             :    */
     186             :   void UpdateScrollbarPosition();
     187             : 
     188         122 :   nsRect GetScrollPortRect() const { return mScrollPort; }
     189         856 :   nsPoint GetScrollPosition() const {
     190         856 :     return mScrollPort.TopLeft() - mScrolledFrame->GetPosition();
     191             :   }
     192             :   /**
     193             :    * For LTR frames, the logical scroll position is the offset of the top left
     194             :    * corner of the frame from the top left corner of the scroll port (same as
     195             :    * GetScrollPosition).
     196             :    * For RTL frames, it is the offset of the top right corner of the frame from
     197             :    * the top right corner of the scroll port
     198             :    */
     199          97 :   nsPoint GetLogicalScrollPosition() const {
     200          97 :     nsPoint pt;
     201         291 :     pt.x = IsPhysicalLTR() ?
     202         388 :       mScrollPort.x - mScrolledFrame->GetPosition().x :
     203          97 :       mScrollPort.XMost() - mScrolledFrame->GetRect().XMost();
     204          97 :     pt.y = mScrollPort.y - mScrolledFrame->GetPosition().y;
     205          97 :     return pt;
     206             :   }
     207             :   nsRect GetScrollRange() const;
     208             :   // Get the scroll range assuming the scrollport has size (aWidth, aHeight).
     209             :   nsRect GetScrollRange(nscoord aWidth, nscoord aHeight) const;
     210             :   nsSize GetScrollPositionClampingScrollPortSize() const;
     211             :   void ScrollSnap(nsIScrollableFrame::ScrollMode aMode = nsIScrollableFrame::SMOOTH_MSD);
     212             :   void ScrollSnap(const nsPoint &aDestination,
     213             :                   nsIScrollableFrame::ScrollMode aMode = nsIScrollableFrame::SMOOTH_MSD);
     214             : 
     215             : protected:
     216             :   nsRect GetScrollRangeForClamping() const;
     217             : 
     218             : public:
     219             :   static void AsyncScrollCallback(ScrollFrameHelper* aInstance,
     220             :                                   mozilla::TimeStamp aTime);
     221             :   static void AsyncSmoothMSDScrollCallback(ScrollFrameHelper* aInstance,
     222             :                                            mozilla::TimeDuration aDeltaTime);
     223             :   /**
     224             :    * @note This method might destroy the frame, pres shell and other objects.
     225             :    * aRange is the range of allowable scroll positions around the desired
     226             :    * aScrollPosition. Null means only aScrollPosition is allowed.
     227             :    * This is a closed-ended range --- aRange.XMost()/aRange.YMost() are allowed.
     228             :    */
     229           0 :   void ScrollTo(nsPoint aScrollPosition, nsIScrollableFrame::ScrollMode aMode,
     230             :                 const nsRect* aRange = nullptr,
     231             :                 nsIScrollbarMediator::ScrollSnapMode aSnap
     232             :                   = nsIScrollbarMediator::DISABLE_SNAP) {
     233           0 :     ScrollToWithOrigin(aScrollPosition, aMode, nsGkAtoms::other, aRange,
     234           0 :                        aSnap);
     235           0 :   }
     236             :   /**
     237             :    * @note This method might destroy the frame, pres shell and other objects.
     238             :    */
     239             :   void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition,
     240             :                          nsIScrollableFrame::ScrollMode aMode
     241             :                            = nsIScrollableFrame::INSTANT);
     242             :   /**
     243             :    * @note This method might destroy the frame, pres shell and other objects.
     244             :    */
     245             :   void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition,
     246             :                                     nsIAtom* aOrigin = nullptr);
     247             : 
     248             :   CSSIntPoint GetScrollPositionCSSPixels();
     249             :   /**
     250             :    * @note This method might destroy the frame, pres shell and other objects.
     251             :    */
     252             :   void ScrollToImpl(nsPoint aScrollPosition, const nsRect& aRange, nsIAtom* aOrigin = nullptr);
     253             :   void ScrollVisual();
     254             :   /**
     255             :    * @note This method might destroy the frame, pres shell and other objects.
     256             :    */
     257             :   void ScrollBy(nsIntPoint aDelta, nsIScrollableFrame::ScrollUnit aUnit,
     258             :                 nsIScrollableFrame::ScrollMode aMode, nsIntPoint* aOverflow,
     259             :                 nsIAtom* aOrigin = nullptr,
     260             :                 nsIScrollableFrame::ScrollMomentum aMomentum = nsIScrollableFrame::NOT_MOMENTUM,
     261             :                 nsIScrollbarMediator::ScrollSnapMode aSnap
     262             :                   = nsIScrollbarMediator::DISABLE_SNAP);
     263             :   /**
     264             :    * @note This method might destroy the frame, pres shell and other objects.
     265             :    */
     266             :   void ScrollToRestoredPosition();
     267             : 
     268             :   enum class LoadingState {
     269             :     Loading,
     270             :     Stopped,
     271             :     Loaded
     272             :   };
     273             : 
     274             :   LoadingState GetPageLoadingState();
     275             : 
     276             :   /**
     277             :    * GetSnapPointForDestination determines which point to snap to after
     278             :    * scrolling. aStartPos gives the position before scrolling and aDestination
     279             :    * gives the position after scrolling, with no snapping. Behaviour is
     280             :    * dependent on the value of aUnit.
     281             :    * Returns true if a suitable snap point could be found and aDestination has
     282             :    * been updated to a valid snapping position.
     283             :    */
     284             :   bool GetSnapPointForDestination(nsIScrollableFrame::ScrollUnit aUnit,
     285             :                                   nsPoint aStartPos,
     286             :                                   nsPoint &aDestination);
     287             : 
     288             :   nsSize GetLineScrollAmount() const;
     289             :   nsSize GetPageScrollAmount() const;
     290             : 
     291             :   nsPresState* SaveState() const;
     292             :   void RestoreState(nsPresState* aState);
     293             : 
     294        1185 :   nsIFrame* GetScrolledFrame() const { return mScrolledFrame; }
     295           0 :   nsIFrame* GetScrollbarBox(bool aVertical) const {
     296           0 :     return aVertical ? mVScrollbarBox : mHScrollbarBox;
     297             :   }
     298             : 
     299           0 :   void AddScrollPositionListener(nsIScrollPositionListener* aListener) {
     300           0 :     mListeners.AppendElement(aListener);
     301           0 :   }
     302           0 :   void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) {
     303           0 :     mListeners.RemoveElement(aListener);
     304           0 :   }
     305             : 
     306             :   static void SetScrollbarVisibility(nsIFrame* aScrollbar, bool aVisible);
     307             : 
     308             :   /**
     309             :    * GetScrolledRect is designed to encapsulate deciding which
     310             :    * directions of overflow should be reachable by scrolling and which
     311             :    * should not.  Callers should NOT depend on it having any particular
     312             :    * behavior (although nsXULScrollFrame currently does).
     313             :    *
     314             :    * This should only be called when the scrolled frame has been
     315             :    * reflowed with the scroll port size given in mScrollPort.
     316             :    *
     317             :    * Currently it allows scrolling down and to the right for
     318             :    * nsHTMLScrollFrames with LTR directionality and for all
     319             :    * nsXULScrollFrames, and allows scrolling down and to the left for
     320             :    * nsHTMLScrollFrames with RTL directionality.
     321             :    */
     322             :   nsRect GetScrolledRect() const;
     323             : 
     324             :   /**
     325             :    * GetUnsnappedScrolledRectInternal is designed to encapsulate deciding which
     326             :    * directions of overflow should be reachable by scrolling and which
     327             :    * should not.  Callers should NOT depend on it having any particular
     328             :    * behavior (although nsXULScrollFrame currently does).
     329             :    *
     330             :    * Currently it allows scrolling down and to the right for
     331             :    * nsHTMLScrollFrames with LTR directionality and for all
     332             :    * nsXULScrollFrames, and allows scrolling down and to the left for
     333             :    * nsHTMLScrollFrames with RTL directionality.
     334             :    */
     335             :   nsRect GetUnsnappedScrolledRectInternal(const nsRect& aScrolledOverflowArea,
     336             :                                           const nsSize& aScrollPortSize) const;
     337             : 
     338           1 :   uint32_t GetScrollbarVisibility() const {
     339           2 :     return (mHasVerticalScrollbar ? nsIScrollableFrame::VERTICAL : 0) |
     340           2 :            (mHasHorizontalScrollbar ? nsIScrollableFrame::HORIZONTAL : 0);
     341             :   }
     342             :   nsMargin GetActualScrollbarSizes() const;
     343             :   nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState);
     344             :   nscoord GetNondisappearingScrollbarWidth(nsBoxLayoutState* aState,
     345             :                                            mozilla::WritingMode aVerticalWM);
     346         337 :   bool IsPhysicalLTR() const {
     347         337 :     WritingMode wm = GetFrameForDir()->GetWritingMode();
     348         337 :     return wm.IsVertical() ? wm.IsVerticalLR() : wm.IsBidiLTR();
     349             :   }
     350        2032 :   bool IsBidiLTR() const {
     351        2032 :     nsIFrame* frame = GetFrameForDir();
     352        2032 :     return frame->StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR;
     353             :   }
     354             : private:
     355             :   nsIFrame* GetFrameForDir() const; // helper for Is{Physical,Bidi}LTR to find
     356             :                                     // the frame whose directionality we use
     357             : 
     358             : public:
     359             :   bool IsScrollbarOnRight() const;
     360             :   bool IsScrollingActive(nsDisplayListBuilder* aBuilder) const;
     361             :   bool IsMaybeScrollingActive() const;
     362          11 :   bool IsProcessingAsyncScroll() const {
     363          11 :     return mAsyncScroll != nullptr || mAsyncSmoothMSDScroll != nullptr;
     364             :   }
     365           1 :   void ResetScrollPositionForLayerPixelAlignment()
     366             :   {
     367           1 :     mScrollPosForLayerPixelAlignment = GetScrollPosition();
     368           1 :   }
     369             : 
     370             :   bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas);
     371             : 
     372             :   void UpdateSticky();
     373             : 
     374             :   void UpdatePrevScrolledRect();
     375             : 
     376             :   bool IsRectNearlyVisible(const nsRect& aRect) const;
     377             :   nsRect ExpandRectToNearlyVisible(const nsRect& aRect) const;
     378             : 
     379             :   // adjust the scrollbar rectangle aRect to account for any visible resizer.
     380             :   // aHasResizer specifies if there is a content resizer, however this method
     381             :   // will also check if a widget resizer is present as well.
     382             :   void AdjustScrollbarRectForResizer(nsIFrame* aFrame, nsPresContext* aPresContext,
     383             :                                      nsRect& aRect, bool aHasResizer, bool aVertical);
     384             :   // returns true if a resizer should be visible
     385         124 :   bool HasResizer() { return mResizerBox && !mCollapsedResizer; }
     386             :   void LayoutScrollbars(nsBoxLayoutState& aState,
     387             :                         const nsRect& aContentArea,
     388             :                         const nsRect& aOldScrollArea);
     389             : 
     390             :   bool IsIgnoringViewportClipping() const;
     391             : 
     392             :   void MarkScrollbarsDirtyForReflow() const;
     393             : 
     394             :   bool ShouldClampScrollPosition() const;
     395             : 
     396             :   bool IsAlwaysActive() const;
     397             :   void MarkRecentlyScrolled();
     398             :   void MarkNotRecentlyScrolled();
     399           0 :   nsExpirationState* GetExpirationState() { return &mActivityExpirationState; }
     400             : 
     401           0 :   void SetTransformingByAPZ(bool aTransforming) {
     402           0 :     mTransformingByAPZ = aTransforming;
     403           0 :     if (!mozilla::css::TextOverflow::HasClippedOverflow(mOuter)) {
     404             :       // If the block has some text-overflow stuff we should kick off a paint
     405             :       // because we have special behaviour for it when APZ scrolling is active.
     406           0 :       mOuter->SchedulePaint();
     407             :     }
     408           0 :   }
     409           0 :   bool IsTransformingByAPZ() const {
     410           0 :     return mTransformingByAPZ;
     411             :   }
     412             :   void SetScrollableByAPZ(bool aScrollable);
     413             :   void SetZoomableByAPZ(bool aZoomable);
     414             : 
     415             :   bool UsesContainerScrolling() const;
     416             : 
     417             :   ScrollSnapInfo GetScrollSnapInfo() const;
     418             : 
     419             :   bool DecideScrollableLayer(nsDisplayListBuilder* aBuilder,
     420             :                              nsRect* aDirtyRect,
     421             :                              bool aAllowCreateDisplayPort);
     422             :   void NotifyApproximateFrameVisibilityUpdate(bool aIgnoreDisplayPort);
     423             :   bool GetDisplayPortAtLastApproximateFrameVisibilityUpdate(nsRect* aDisplayPort);
     424             : 
     425             :   bool AllowDisplayPortExpiration();
     426             :   void TriggerDisplayPortExpiration();
     427             :   void ResetDisplayPortExpiryTimer();
     428             : 
     429             :   void ScheduleSyntheticMouseMove();
     430             :   static void ScrollActivityCallback(nsITimer *aTimer, void* anInstance);
     431             : 
     432             :   void HandleScrollbarStyleSwitching();
     433             : 
     434           6 :   nsIAtom* LastScrollOrigin() const { return mLastScrollOrigin; }
     435           3 :   void AllowScrollOriginDowngrade() { mAllowScrollOriginDowngrade = true; }
     436           3 :   nsIAtom* LastSmoothScrollOrigin() const { return mLastSmoothScrollOrigin; }
     437           3 :   uint32_t CurrentScrollGeneration() const { return mScrollGeneration; }
     438           4 :   nsPoint LastScrollDestination() const { return mDestination; }
     439           0 :   void ResetScrollInfoIfGeneration(uint32_t aGeneration) {
     440           0 :     if (aGeneration == mScrollGeneration) {
     441           0 :       mLastScrollOrigin = nullptr;
     442           0 :       mLastSmoothScrollOrigin = nullptr;
     443             :     }
     444           0 :   }
     445             :   bool WantAsyncScroll() const;
     446             :   Maybe<mozilla::layers::ScrollMetadata> ComputeScrollMetadata(
     447             :     Layer* aLayer, nsIFrame* aContainerReferenceFrame,
     448             :     const ContainerLayerParameters& aParameters,
     449             :     const mozilla::DisplayItemClip* aClip) const;
     450             : 
     451             :   // nsIScrollbarMediator
     452             :   void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
     453             :                     nsIScrollbarMediator::ScrollSnapMode aSnap
     454             :                       = nsIScrollbarMediator::DISABLE_SNAP);
     455             :   void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
     456             :                      nsIScrollbarMediator::ScrollSnapMode aSnap
     457             :                        = nsIScrollbarMediator::DISABLE_SNAP);
     458             :   void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
     459             :                     nsIScrollbarMediator::ScrollSnapMode aSnap
     460             :                       = nsIScrollbarMediator::DISABLE_SNAP);
     461             :   void RepeatButtonScroll(nsScrollbarFrame* aScrollbar);
     462             :   void ThumbMoved(nsScrollbarFrame* aScrollbar,
     463             :                   nscoord aOldPos,
     464             :                   nscoord aNewPos);
     465             :   void ScrollbarReleased(nsScrollbarFrame* aScrollbar);
     466             :   void ScrollByUnit(nsScrollbarFrame* aScrollbar,
     467             :                     nsIScrollableFrame::ScrollMode aMode,
     468             :                     int32_t aDirection,
     469             :                     nsIScrollableFrame::ScrollUnit aUnit,
     470             :                     nsIScrollbarMediator::ScrollSnapMode aSnap
     471             :                       = nsIScrollbarMediator::DISABLE_SNAP);
     472           0 :   bool ShouldSuppressScrollbarRepaints() const {
     473           0 :     return mSuppressScrollbarRepaints;
     474             :   }
     475             : 
     476             :   bool DragScroll(WidgetEvent* aEvent);
     477             : 
     478             :   void AsyncScrollbarDragRejected();
     479             : 
     480           0 :   bool IsRootScrollFrameOfDocument() const { return mIsRoot; }
     481             : 
     482             :   // owning references to the nsIAnonymousContentCreator-built content
     483             :   nsCOMPtr<nsIContent> mHScrollbarContent;
     484             :   nsCOMPtr<nsIContent> mVScrollbarContent;
     485             :   nsCOMPtr<nsIContent> mScrollCornerContent;
     486             :   nsCOMPtr<nsIContent> mResizerContent;
     487             : 
     488             :   RefPtr<ScrollEvent> mScrollEvent;
     489             :   nsRevocableEventPtr<AsyncScrollPortEvent> mAsyncScrollPortEvent;
     490             :   nsRevocableEventPtr<ScrolledAreaEvent> mScrolledAreaEvent;
     491             :   nsIFrame* mHScrollbarBox;
     492             :   nsIFrame* mVScrollbarBox;
     493             :   nsIFrame* mScrolledFrame;
     494             :   nsIFrame* mScrollCornerBox;
     495             :   nsIFrame* mResizerBox;
     496             :   nsContainerFrame* mOuter;
     497             :   RefPtr<AsyncScroll> mAsyncScroll;
     498             :   RefPtr<AsyncSmoothMSDScroll> mAsyncSmoothMSDScroll;
     499             :   RefPtr<ScrollbarActivity> mScrollbarActivity;
     500             :   nsTArray<nsIScrollPositionListener*> mListeners;
     501             :   nsIAtom* mLastScrollOrigin;
     502             :   bool mAllowScrollOriginDowngrade;
     503             :   nsIAtom* mLastSmoothScrollOrigin;
     504             :   Maybe<nsPoint> mApzSmoothScrollDestination;
     505             :   uint32_t mScrollGeneration;
     506             :   nsRect mScrollPort;
     507             :   // Where we're currently scrolling to, if we're scrolling asynchronously.
     508             :   // If we're not in the middle of an asynchronous scroll then this is
     509             :   // just the current scroll position. ScrollBy will choose its
     510             :   // destination based on this value.
     511             :   nsPoint mDestination;
     512             :   nsPoint mScrollPosAtLastPaint;
     513             : 
     514             :   // A goal position to try to scroll to as content loads. As long as mLastPos
     515             :   // matches the current logical scroll position, we try to scroll to mRestorePos
     516             :   // after every reflow --- because after each time content is loaded/added to the
     517             :   // scrollable element, there will be a reflow.
     518             :   nsPoint mRestorePos;
     519             :   // The last logical position we scrolled to while trying to restore mRestorePos, or
     520             :   // 0,0 when this is a new frame. Set to -1,-1 once we've scrolled for any reason
     521             :   // other than trying to restore mRestorePos.
     522             :   nsPoint mLastPos;
     523             : 
     524             :   nsExpirationState mActivityExpirationState;
     525             : 
     526             :   nsCOMPtr<nsITimer> mScrollActivityTimer;
     527             :   nsPoint mScrollPosForLayerPixelAlignment;
     528             : 
     529             :   // The scroll position where we last updated frame visibility.
     530             :   nsPoint mLastUpdateFramesPos;
     531             :   bool mHadDisplayPortAtLastFrameUpdate;
     532             :   nsRect mDisplayPortAtLastFrameUpdate;
     533             : 
     534             :   nsRect mPrevScrolledRect;
     535             : 
     536             :   FrameMetrics::ViewID mScrollParentID;
     537             : 
     538             :   // Timer to remove the displayport some time after scrolling has stopped
     539             :   nsCOMPtr<nsITimer> mDisplayPortExpiryTimer;
     540             : 
     541             :   bool mNeverHasVerticalScrollbar:1;
     542             :   bool mNeverHasHorizontalScrollbar:1;
     543             :   bool mHasVerticalScrollbar:1;
     544             :   bool mHasHorizontalScrollbar:1;
     545             :   bool mFrameIsUpdatingScrollbar:1;
     546             :   bool mDidHistoryRestore:1;
     547             :   // Is this the scrollframe for the document's viewport?
     548             :   bool mIsRoot:1;
     549             :   // True if we should clip all descendants, false if we should only clip
     550             :   // descendants for which we are the containing block.
     551             :   bool mClipAllDescendants:1;
     552             :   // If true, don't try to layout the scrollbars in Reflow().  This can be
     553             :   // useful if multiple passes are involved, because we don't want to place the
     554             :   // scrollbars at the wrong size.
     555             :   bool mSuppressScrollbarUpdate:1;
     556             :   // If true, we skipped a scrollbar layout due to mSuppressScrollbarUpdate
     557             :   // being set at some point.  That means we should lay out scrollbars even if
     558             :   // it might not strictly be needed next time mSuppressScrollbarUpdate is
     559             :   // false.
     560             :   bool mSkippedScrollbarLayout:1;
     561             : 
     562             :   bool mHadNonInitialReflow:1;
     563             :   // State used only by PostScrollEvents so we know
     564             :   // which overflow states have changed.
     565             :   bool mHorizontalOverflow:1;
     566             :   bool mVerticalOverflow:1;
     567             :   bool mPostedReflowCallback:1;
     568             :   bool mMayHaveDirtyFixedChildren:1;
     569             :   // If true, need to actually update our scrollbar attributes in the
     570             :   // reflow callback.
     571             :   bool mUpdateScrollbarAttributes:1;
     572             :   // If true, we should be prepared to scroll using this scrollframe
     573             :   // by placing descendant content into its own layer(s)
     574             :   bool mHasBeenScrolledRecently:1;
     575             :   // If true, the resizer is collapsed and not displayed
     576             :   bool mCollapsedResizer:1;
     577             : 
     578             :   // If true, the scroll frame should always be active because we always build
     579             :   // a scrollable layer. Used for asynchronous scrolling.
     580             :   bool mWillBuildScrollableLayer:1;
     581             : 
     582             :   // If true, the scroll frame is an ancestor of other scrolling frames, so
     583             :   // we shouldn't expire the displayport on this scrollframe unless those
     584             :   // descendant scrollframes also have their displayports removed.
     585             :   bool mIsScrollParent:1;
     586             : 
     587             :   // Whether we are the root scroll frame that is used for containerful
     588             :   // scrolling with a display port. If true, the scrollable frame
     589             :   // shouldn't attach frame metrics to its layers because the container
     590             :   // will already have the necessary frame metrics.
     591             :   bool mIsScrollableLayerInRootContainer:1;
     592             : 
     593             :   // If true, add clipping in ScrollFrameHelper::ComputeFrameMetrics.
     594             :   bool mAddClipRectToLayer:1;
     595             : 
     596             :   // True if this frame has been scrolled at least once
     597             :   bool mHasBeenScrolled:1;
     598             : 
     599             :   // True if the events synthesized by OSX to produce momentum scrolling should
     600             :   // be ignored.  Reset when the next real, non-synthesized scroll event occurs.
     601             :   bool mIgnoreMomentumScroll:1;
     602             : 
     603             :   // True if the APZ is in the process of async-transforming this scrollframe,
     604             :   // (as best as we can tell on the main thread, anyway).
     605             :   bool mTransformingByAPZ:1;
     606             : 
     607             :   // True if APZ can scroll this frame asynchronously (i.e. it has an APZC
     608             :   // set up for this frame and it's not a scrollinfo layer).
     609             :   bool mScrollableByAPZ:1;
     610             : 
     611             :   // True if the APZ is allowed to zoom this scrollframe.
     612             :   bool mZoomableByAPZ:1;
     613             : 
     614             :   // True if we don't want the scrollbar to repaint itself right now.
     615             :   bool mSuppressScrollbarRepaints:1;
     616             : 
     617             :   mozilla::layout::ScrollVelocityQueue mVelocityQueue;
     618             : 
     619             : protected:
     620             :   class AutoScrollbarRepaintSuppression;
     621             :   friend class AutoScrollbarRepaintSuppression;
     622             :   class AutoScrollbarRepaintSuppression {
     623             :   public:
     624           0 :     AutoScrollbarRepaintSuppression(ScrollFrameHelper* aHelper, bool aSuppress)
     625           0 :       : mHelper(aHelper)
     626           0 :       , mOldSuppressValue(aHelper->mSuppressScrollbarRepaints)
     627             :     {
     628           0 :       mHelper->mSuppressScrollbarRepaints = aSuppress;
     629           0 :     }
     630             : 
     631           0 :     ~AutoScrollbarRepaintSuppression()
     632           0 :     {
     633           0 :       mHelper->mSuppressScrollbarRepaints = mOldSuppressValue;
     634           0 :     }
     635             : 
     636             :   private:
     637             :     ScrollFrameHelper* mHelper;
     638             :     bool mOldSuppressValue;
     639             :   };
     640             : 
     641             :   /**
     642             :    * @note This method might destroy the frame, pres shell and other objects.
     643             :    */
     644             :   void ScrollToWithOrigin(nsPoint aScrollPosition,
     645             :                           nsIScrollableFrame::ScrollMode aMode,
     646             :                           nsIAtom *aOrigin, // nullptr indicates "other" origin
     647             :                           const nsRect* aRange,
     648             :                           nsIScrollbarMediator::ScrollSnapMode aSnap
     649             :                             = nsIScrollbarMediator::DISABLE_SNAP);
     650             : 
     651             :   void CompleteAsyncScroll(const nsRect &aRange, nsIAtom* aOrigin = nullptr);
     652             : 
     653             :   bool HasPluginFrames();
     654             :   bool HasPerspective() const;
     655             :   bool HasBgAttachmentLocal() const;
     656             :   uint8_t GetScrolledFrameDir() const;
     657             : 
     658             :   static void EnsureFrameVisPrefsCached();
     659             :   static bool sFrameVisPrefsCached;
     660             :   // The number of scrollports wide/high to expand when tracking frame visibility.
     661             :   static uint32_t sHorzExpandScrollPort;
     662             :   static uint32_t sVertExpandScrollPort;
     663             :   // The fraction of the scrollport we allow to scroll by before we schedule
     664             :   // an update of frame visibility.
     665             :   static int32_t sHorzScrollFraction;
     666             :   static int32_t sVertScrollFraction;
     667             : };
     668             : 
     669             : } // namespace mozilla
     670             : 
     671             : /**
     672             :  * The scroll frame creates and manages the scrolling view
     673             :  *
     674             :  * It only supports having a single child frame that typically is an area
     675             :  * frame, but doesn't have to be. The child frame must have a view, though
     676             :  *
     677             :  * Scroll frames don't support incremental changes, i.e. you can't replace
     678             :  * or remove the scrolled frame
     679             :  */
     680           6 : class nsHTMLScrollFrame : public nsContainerFrame,
     681             :                           public nsIScrollableFrame,
     682             :                           public nsIAnonymousContentCreator,
     683             :                           public nsIStatefulFrame {
     684             : public:
     685             :   typedef mozilla::ScrollFrameHelper ScrollFrameHelper;
     686             :   typedef mozilla::CSSIntPoint CSSIntPoint;
     687             :   typedef mozilla::ScrollReflowInput ScrollReflowInput;
     688             :   friend nsHTMLScrollFrame* NS_NewHTMLScrollFrame(nsIPresShell* aPresShell,
     689             :                                                   nsStyleContext* aContext,
     690             :                                                   bool aIsRoot);
     691             : 
     692             :   NS_DECL_QUERYFRAME
     693         518 :   NS_DECL_FRAMEARENA_HELPERS(nsHTMLScrollFrame)
     694             : 
     695         153 :   virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
     696             :                                 const nsRect&           aDirtyRect,
     697             :                                 const nsDisplayListSet& aLists) override {
     698         153 :     mHelper.BuildDisplayList(aBuilder, aDirtyRect, aLists);
     699         153 :   }
     700             : 
     701             :   bool TryLayout(ScrollReflowInput* aState,
     702             :                    ReflowOutput* aKidMetrics,
     703             :                    bool aAssumeVScroll, bool aAssumeHScroll,
     704             :                    bool aForce);
     705             :   bool ScrolledContentDependsOnHeight(ScrollReflowInput* aState);
     706             :   void ReflowScrolledFrame(ScrollReflowInput* aState,
     707             :                            bool aAssumeHScroll,
     708             :                            bool aAssumeVScroll,
     709             :                            ReflowOutput* aMetrics,
     710             :                            bool aFirstPass);
     711             :   void ReflowContents(ScrollReflowInput* aState,
     712             :                       const ReflowOutput& aDesiredSize);
     713             :   void PlaceScrollArea(ScrollReflowInput& aState,
     714             :                        const nsPoint& aScrollPosition);
     715             :   nscoord GetIntrinsicVScrollbarWidth(gfxContext *aRenderingContext);
     716             : 
     717         135 :   virtual bool GetBorderRadii(const nsSize& aFrameSize, const nsSize& aBorderArea,
     718             :                               Sides aSkipSides, nscoord aRadii[8]) const override {
     719         135 :     return mHelper.GetBorderRadii(aFrameSize, aBorderArea, aSkipSides, aRadii);
     720             :   }
     721             : 
     722             :   virtual nscoord GetMinISize(gfxContext *aRenderingContext) override;
     723             :   virtual nscoord GetPrefISize(gfxContext *aRenderingContext) override;
     724             :   virtual nsresult GetXULPadding(nsMargin& aPadding) override;
     725             :   virtual bool IsXULCollapsed() override;
     726             : 
     727             :   virtual void Reflow(nsPresContext*           aPresContext,
     728             :                       ReflowOutput&     aDesiredSize,
     729             :                       const ReflowInput& aReflowInput,
     730             :                       nsReflowStatus&          aStatus) override;
     731             : 
     732           0 :   virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
     733           0 :     return mHelper.ComputeCustomOverflow(aOverflowAreas);
     734             :   }
     735             : 
     736           0 :   bool GetVerticalAlignBaseline(mozilla::WritingMode aWM,
     737             :                                 nscoord* aBaseline) const override {
     738           0 :     *aBaseline = GetLogicalBaseline(aWM);
     739           0 :     return true;
     740             :   }
     741             : 
     742             :   // Recomputes the scrollable overflow area we store in the helper to take children
     743             :   // that are affected by perpsective set on the outer frame and scroll at different
     744             :   // rates.
     745             :   void AdjustForPerspective(nsRect& aScrollableOverflow);
     746             : 
     747             :   // Called to set the child frames. We typically have three: the scroll area,
     748             :   // the vertical scrollbar, and the horizontal scrollbar.
     749             :   virtual void SetInitialChildList(ChildListID     aListID,
     750             :                                    nsFrameList&    aChildList) override;
     751             :   virtual void AppendFrames(ChildListID     aListID,
     752             :                             nsFrameList&    aFrameList) override;
     753             :   virtual void InsertFrames(ChildListID     aListID,
     754             :                             nsIFrame*       aPrevFrame,
     755             :                             nsFrameList&    aFrameList) override;
     756             :   virtual void RemoveFrame(ChildListID     aListID,
     757             :                            nsIFrame*       aOldFrame) override;
     758             : 
     759             :   virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
     760             : 
     761          80 :   virtual nsIScrollableFrame* GetScrollTargetFrame() override {
     762          80 :     return this;
     763             :   }
     764             : 
     765          73 :   virtual nsContainerFrame* GetContentInsertionFrame() override {
     766          73 :     return mHelper.GetScrolledFrame()->GetContentInsertionFrame();
     767             :   }
     768             : 
     769           0 :   virtual bool DoesClipChildren() override { return true; }
     770             :   virtual nsSplittableType GetSplittableType() const override;
     771             : 
     772           0 :   virtual nsPoint GetPositionOfChildIgnoringScrolling(nsIFrame* aChild) override
     773           0 :   { nsPoint pt = aChild->GetPosition();
     774           0 :     if (aChild == mHelper.GetScrolledFrame()) pt += GetScrollPosition();
     775           0 :     return pt;
     776             :   }
     777             : 
     778             :   // nsIAnonymousContentCreator
     779             :   virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
     780             :   virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
     781             :                                         uint32_t aFilter) override;
     782             : 
     783             :   // nsIScrollableFrame
     784         322 :   virtual nsIFrame* GetScrolledFrame() const override {
     785         322 :     return mHelper.GetScrolledFrame();
     786             :   }
     787         316 :   virtual mozilla::ScrollbarStyles GetScrollbarStyles() const override {
     788         316 :     return mHelper.GetScrollbarStylesFromFrame();
     789             :   }
     790           1 :   virtual uint32_t GetScrollbarVisibility() const override {
     791           1 :     return mHelper.GetScrollbarVisibility();
     792             :   }
     793          18 :   virtual nsMargin GetActualScrollbarSizes() const override {
     794          18 :     return mHelper.GetActualScrollbarSizes();
     795             :   }
     796           0 :   virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState) override {
     797           0 :     return mHelper.GetDesiredScrollbarSizes(aState);
     798             :   }
     799           0 :   virtual nsMargin GetDesiredScrollbarSizes(nsPresContext* aPresContext,
     800             :           gfxContext* aRC) override {
     801           0 :     nsBoxLayoutState bls(aPresContext, aRC, 0);
     802           0 :     return GetDesiredScrollbarSizes(&bls);
     803             :   }
     804           0 :   virtual nscoord GetNondisappearingScrollbarWidth(nsPresContext* aPresContext,
     805             :           gfxContext* aRC, mozilla::WritingMode aWM) override {
     806           0 :     nsBoxLayoutState bls(aPresContext, aRC, 0);
     807           0 :     return mHelper.GetNondisappearingScrollbarWidth(&bls, aWM);
     808             :   }
     809           0 :   virtual nsRect GetScrolledRect() const override {
     810           0 :     return mHelper.GetScrolledRect();
     811             :   }
     812         122 :   virtual nsRect GetScrollPortRect() const override {
     813         122 :     return mHelper.GetScrollPortRect();
     814             :   }
     815          29 :   virtual nsPoint GetScrollPosition() const override {
     816          29 :     return mHelper.GetScrollPosition();
     817             :   }
     818           0 :   virtual nsPoint GetLogicalScrollPosition() const override {
     819           0 :     return mHelper.GetLogicalScrollPosition();
     820             :   }
     821          14 :   virtual nsRect GetScrollRange() const override {
     822          14 :     return mHelper.GetScrollRange();
     823             :   }
     824           1 :   virtual nsSize GetScrollPositionClampingScrollPortSize() const override {
     825           1 :     return mHelper.GetScrollPositionClampingScrollPortSize();
     826             :   }
     827           3 :   virtual nsSize GetLineScrollAmount() const override {
     828           3 :     return mHelper.GetLineScrollAmount();
     829             :   }
     830           3 :   virtual nsSize GetPageScrollAmount() const override {
     831           3 :     return mHelper.GetPageScrollAmount();
     832             :   }
     833             :   /**
     834             :    * @note This method might destroy the frame, pres shell and other objects.
     835             :    */
     836           0 :   virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
     837             :                         const nsRect* aRange = nullptr,
     838             :                         nsIScrollbarMediator::ScrollSnapMode aSnap
     839             :                           = nsIScrollbarMediator::DISABLE_SNAP)
     840             :                         override {
     841           0 :     mHelper.ScrollTo(aScrollPosition, aMode, aRange, aSnap);
     842           0 :   }
     843             :   /**
     844             :    * @note This method might destroy the frame, pres shell and other objects.
     845             :    */
     846           0 :   virtual void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition,
     847             :                                  nsIScrollableFrame::ScrollMode aMode
     848             :                                    = nsIScrollableFrame::INSTANT) override {
     849           0 :     mHelper.ScrollToCSSPixels(aScrollPosition, aMode);
     850           0 :   }
     851           0 :   virtual void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition,
     852             :                                             nsIAtom* aOrigin = nullptr) override {
     853           0 :     mHelper.ScrollToCSSPixelsApproximate(aScrollPosition, aOrigin);
     854           0 :   }
     855             :   /**
     856             :    * @note This method might destroy the frame, pres shell and other objects.
     857             :    */
     858           0 :   virtual CSSIntPoint GetScrollPositionCSSPixels() override {
     859           0 :     return mHelper.GetScrollPositionCSSPixels();
     860             :   }
     861             :   /**
     862             :    * @note This method might destroy the frame, pres shell and other objects.
     863             :    */
     864           0 :   virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
     865             :                         nsIntPoint* aOverflow, nsIAtom* aOrigin = nullptr,
     866             :                         nsIScrollableFrame::ScrollMomentum aMomentum = nsIScrollableFrame::NOT_MOMENTUM,
     867             :                         nsIScrollbarMediator::ScrollSnapMode aSnap
     868             :                           = nsIScrollbarMediator::DISABLE_SNAP)
     869             :                         override {
     870           0 :     mHelper.ScrollBy(aDelta, aUnit, aMode, aOverflow, aOrigin, aMomentum, aSnap);
     871           0 :   }
     872           0 :   virtual void ScrollSnap() override {
     873           0 :     mHelper.ScrollSnap();
     874           0 :   }
     875             :   /**
     876             :    * @note This method might destroy the frame, pres shell and other objects.
     877             :    */
     878          23 :   virtual void ScrollToRestoredPosition() override {
     879          23 :     mHelper.ScrollToRestoredPosition();
     880          23 :   }
     881           0 :   virtual void AddScrollPositionListener(nsIScrollPositionListener* aListener) override {
     882           0 :     mHelper.AddScrollPositionListener(aListener);
     883           0 :   }
     884           0 :   virtual void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) override {
     885           0 :     mHelper.RemoveScrollPositionListener(aListener);
     886           0 :   }
     887             :   /**
     888             :    * @note This method might destroy the frame, pres shell and other objects.
     889             :    */
     890           4 :   virtual void CurPosAttributeChanged(nsIContent* aChild) override {
     891           4 :     mHelper.CurPosAttributeChanged(aChild);
     892           4 :   }
     893           0 :   NS_IMETHOD PostScrolledAreaEventForCurrentArea() override {
     894           0 :     mHelper.PostScrolledAreaEvent();
     895           0 :     return NS_OK;
     896             :   }
     897         137 :   virtual bool IsScrollingActive(nsDisplayListBuilder* aBuilder) override {
     898         137 :     return mHelper.IsScrollingActive(aBuilder);
     899             :   }
     900           0 :   virtual bool IsProcessingAsyncScroll() override {
     901           0 :     return mHelper.IsProcessingAsyncScroll();
     902             :   }
     903           1 :   virtual void ResetScrollPositionForLayerPixelAlignment() override {
     904           1 :     mHelper.ResetScrollPositionForLayerPixelAlignment();
     905           1 :   }
     906           2 :   virtual bool DidHistoryRestore() const override {
     907           2 :     return mHelper.mDidHistoryRestore;
     908             :   }
     909           0 :   virtual void ClearDidHistoryRestore() override {
     910           0 :     mHelper.mDidHistoryRestore = false;
     911           0 :   }
     912           0 :   virtual bool IsRectNearlyVisible(const nsRect& aRect) override {
     913           0 :     return mHelper.IsRectNearlyVisible(aRect);
     914             :   }
     915           1 :   virtual nsRect ExpandRectToNearlyVisible(const nsRect& aRect) const override {
     916           1 :     return mHelper.ExpandRectToNearlyVisible(aRect);
     917             :   }
     918           6 :   virtual nsIAtom* LastScrollOrigin() override {
     919           6 :     return mHelper.LastScrollOrigin();
     920             :   }
     921           3 :   virtual void AllowScrollOriginDowngrade() override {
     922           3 :     mHelper.AllowScrollOriginDowngrade();
     923           3 :   }
     924           3 :   virtual nsIAtom* LastSmoothScrollOrigin() override {
     925           3 :     return mHelper.LastSmoothScrollOrigin();
     926             :   }
     927           3 :   virtual uint32_t CurrentScrollGeneration() override {
     928           3 :     return mHelper.CurrentScrollGeneration();
     929             :   }
     930           4 :   virtual nsPoint LastScrollDestination() override {
     931           4 :     return mHelper.LastScrollDestination();
     932             :   }
     933           0 :   virtual void ResetScrollInfoIfGeneration(uint32_t aGeneration) override {
     934           0 :     mHelper.ResetScrollInfoIfGeneration(aGeneration);
     935           0 :   }
     936         137 :   virtual bool WantAsyncScroll() const override {
     937         137 :     return mHelper.WantAsyncScroll();
     938             :   }
     939           3 :   virtual mozilla::Maybe<mozilla::layers::ScrollMetadata> ComputeScrollMetadata(
     940             :     Layer* aLayer, nsIFrame* aContainerReferenceFrame,
     941             :     const ContainerLayerParameters& aParameters,
     942             :     const mozilla::DisplayItemClip* aClip) const override
     943             :   {
     944           3 :     return mHelper.ComputeScrollMetadata(aLayer, aContainerReferenceFrame, aParameters, aClip);
     945             :   }
     946           0 :   virtual bool IsIgnoringViewportClipping() const override {
     947           0 :     return mHelper.IsIgnoringViewportClipping();
     948             :   }
     949           0 :   virtual void MarkScrollbarsDirtyForReflow() const override {
     950           0 :     mHelper.MarkScrollbarsDirtyForReflow();
     951           0 :   }
     952           3 :   virtual bool UsesContainerScrolling() const override {
     953           3 :     return mHelper.UsesContainerScrolling();
     954             :   }
     955          20 :   virtual bool DecideScrollableLayer(nsDisplayListBuilder* aBuilder,
     956             :                                      nsRect* aDirtyRect,
     957             :                                      bool aAllowCreateDisplayPort) override {
     958          20 :     return mHelper.DecideScrollableLayer(aBuilder, aDirtyRect, aAllowCreateDisplayPort);
     959             :   }
     960           1 :   virtual void NotifyApproximateFrameVisibilityUpdate(bool aIgnoreDisplayPort) override {
     961           1 :     mHelper.NotifyApproximateFrameVisibilityUpdate(aIgnoreDisplayPort);
     962           1 :   }
     963           1 :   virtual bool GetDisplayPortAtLastApproximateFrameVisibilityUpdate(nsRect* aDisplayPort) override {
     964           1 :     return mHelper.GetDisplayPortAtLastApproximateFrameVisibilityUpdate(aDisplayPort);
     965             :   }
     966           1 :   void TriggerDisplayPortExpiration() override {
     967           1 :     mHelper.TriggerDisplayPortExpiration();
     968           1 :   }
     969             : 
     970             :   // nsIStatefulFrame
     971          10 :   NS_IMETHOD SaveState(nsPresState** aState) override {
     972          10 :     NS_ENSURE_ARG_POINTER(aState);
     973          10 :     *aState = mHelper.SaveState();
     974          10 :     return NS_OK;
     975             :   }
     976           0 :   NS_IMETHOD RestoreState(nsPresState* aState) override {
     977           0 :     NS_ENSURE_ARG_POINTER(aState);
     978           0 :     mHelper.RestoreState(aState);
     979           0 :     return NS_OK;
     980             :   }
     981             : 
     982             :   // nsIScrollbarMediator
     983           0 :   virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
     984             :                             nsIScrollbarMediator::ScrollSnapMode aSnap
     985             :                               = nsIScrollbarMediator::DISABLE_SNAP) override {
     986           0 :     mHelper.ScrollByPage(aScrollbar, aDirection, aSnap);
     987           0 :   }
     988           0 :   virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
     989             :                              nsIScrollbarMediator::ScrollSnapMode aSnap
     990             :                                = nsIScrollbarMediator::DISABLE_SNAP) override {
     991           0 :     mHelper.ScrollByWhole(aScrollbar, aDirection, aSnap);
     992           0 :   }
     993           0 :   virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
     994             :                             nsIScrollbarMediator::ScrollSnapMode aSnap
     995             :                               = nsIScrollbarMediator::DISABLE_SNAP) override {
     996           0 :     mHelper.ScrollByLine(aScrollbar, aDirection, aSnap);
     997           0 :   }
     998           0 :   virtual void RepeatButtonScroll(nsScrollbarFrame* aScrollbar) override {
     999           0 :     mHelper.RepeatButtonScroll(aScrollbar);
    1000           0 :   }
    1001           0 :   virtual void ThumbMoved(nsScrollbarFrame* aScrollbar,
    1002             :                           nscoord aOldPos,
    1003             :                           nscoord aNewPos) override {
    1004           0 :     mHelper.ThumbMoved(aScrollbar, aOldPos, aNewPos);
    1005           0 :   }
    1006           0 :   virtual void ScrollbarReleased(nsScrollbarFrame* aScrollbar) override {
    1007           0 :     mHelper.ScrollbarReleased(aScrollbar);
    1008           0 :   }
    1009           6 :   virtual void VisibilityChanged(bool aVisible) override {}
    1010           0 :   virtual nsIFrame* GetScrollbarBox(bool aVertical) override {
    1011           0 :     return mHelper.GetScrollbarBox(aVertical);
    1012             :   }
    1013             :   virtual void ScrollbarActivityStarted() const override;
    1014             :   virtual void ScrollbarActivityStopped() const override;
    1015             : 
    1016         127 :   virtual bool IsScrollbarOnRight() const override {
    1017         127 :     return mHelper.IsScrollbarOnRight();
    1018             :   }
    1019             : 
    1020           0 :   virtual bool ShouldSuppressScrollbarRepaints() const override {
    1021           0 :     return mHelper.ShouldSuppressScrollbarRepaints();
    1022             :   }
    1023             : 
    1024           0 :   virtual void SetTransformingByAPZ(bool aTransforming) override {
    1025           0 :     mHelper.SetTransformingByAPZ(aTransforming);
    1026           0 :   }
    1027           0 :   bool IsTransformingByAPZ() const override {
    1028           0 :     return mHelper.IsTransformingByAPZ();
    1029             :   }
    1030           0 :   void SetScrollableByAPZ(bool aScrollable) override {
    1031           0 :     mHelper.SetScrollableByAPZ(aScrollable);
    1032           0 :   }
    1033           1 :   void SetZoomableByAPZ(bool aZoomable) override {
    1034           1 :     mHelper.SetZoomableByAPZ(aZoomable);
    1035           1 :   }
    1036             : 
    1037           3 :   ScrollSnapInfo GetScrollSnapInfo() const override {
    1038           3 :     return mHelper.GetScrollSnapInfo();
    1039             :   }
    1040             : 
    1041           0 :   virtual bool DragScroll(mozilla::WidgetEvent* aEvent) override {
    1042           0 :     return mHelper.DragScroll(aEvent);
    1043             :   }
    1044             : 
    1045           0 :   virtual void AsyncScrollbarDragRejected() override {
    1046           0 :     return mHelper.AsyncScrollbarDragRejected();
    1047             :   }
    1048             : 
    1049           0 :   virtual bool IsRootScrollFrameOfDocument() const override {
    1050           0 :     return mHelper.IsRootScrollFrameOfDocument();
    1051             :   }
    1052             : 
    1053             :   // Return the scrolled frame.
    1054           0 :   void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override {
    1055           0 :     aResult.AppendElement(OwnedAnonBox(mHelper.GetScrolledFrame()));
    1056           0 :   }
    1057             : 
    1058             : #ifdef DEBUG_FRAME_DUMP
    1059             :   virtual nsresult GetFrameName(nsAString& aResult) const override;
    1060             : #endif
    1061             : 
    1062             : #ifdef ACCESSIBILITY
    1063             :   virtual mozilla::a11y::AccType AccessibleType() override;
    1064             : #endif
    1065             : 
    1066             : protected:
    1067          35 :   nsHTMLScrollFrame(nsStyleContext* aContext, bool aIsRoot)
    1068          35 :     : nsHTMLScrollFrame(aContext, kClassID, aIsRoot)
    1069          35 :   {}
    1070             : 
    1071             :   nsHTMLScrollFrame(nsStyleContext* aContext,
    1072             :                     nsIFrame::ClassID aID,
    1073             :                     bool aIsRoot);
    1074           0 :   void SetSuppressScrollbarUpdate(bool aSuppress) {
    1075           0 :     mHelper.mSuppressScrollbarUpdate = aSuppress;
    1076           0 :   }
    1077             :   bool GuessHScrollbarNeeded(const ScrollReflowInput& aState);
    1078             :   bool GuessVScrollbarNeeded(const ScrollReflowInput& aState);
    1079             : 
    1080           0 :   bool IsScrollbarUpdateSuppressed() const {
    1081           0 :     return mHelper.mSuppressScrollbarUpdate;
    1082             :   }
    1083             : 
    1084             :   // Return whether we're in an "initial" reflow.  Some reflows with
    1085             :   // NS_FRAME_FIRST_REFLOW set are NOT "initial" as far as we're concerned.
    1086             :   bool InInitialReflow() const;
    1087             : 
    1088             :   /**
    1089             :    * Override this to return false if computed bsize/min-bsize/max-bsize
    1090             :    * should NOT be propagated to child content.
    1091             :    * nsListControlFrame uses this.
    1092             :    */
    1093         127 :   virtual bool ShouldPropagateComputedBSizeToScrolledContent() const { return true; }
    1094             : 
    1095             : private:
    1096             :   friend class mozilla::ScrollFrameHelper;
    1097             :   ScrollFrameHelper mHelper;
    1098             : };
    1099             : 
    1100             : /**
    1101             :  * The scroll frame creates and manages the scrolling view
    1102             :  *
    1103             :  * It only supports having a single child frame that typically is an area
    1104             :  * frame, but doesn't have to be. The child frame must have a view, though
    1105             :  *
    1106             :  * Scroll frames don't support incremental changes, i.e. you can't replace
    1107             :  * or remove the scrolled frame
    1108             :  */
    1109           1 : class nsXULScrollFrame final : public nsBoxFrame,
    1110             :                                public nsIScrollableFrame,
    1111             :                                public nsIAnonymousContentCreator,
    1112             :                                public nsIStatefulFrame
    1113             : {
    1114             : public:
    1115             :   typedef mozilla::ScrollFrameHelper ScrollFrameHelper;
    1116             :   typedef mozilla::CSSIntPoint CSSIntPoint;
    1117             : 
    1118             :   NS_DECL_QUERYFRAME
    1119          73 :   NS_DECL_FRAMEARENA_HELPERS(nsXULScrollFrame)
    1120             : 
    1121             :   friend nsXULScrollFrame* NS_NewXULScrollFrame(nsIPresShell* aPresShell,
    1122             :                                                 nsStyleContext* aContext,
    1123             :                                                 bool aIsRoot,
    1124             :                                                 bool aClipAllDescendants);
    1125             : 
    1126          96 :   virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
    1127             :                                 const nsRect&           aDirtyRect,
    1128             :                                 const nsDisplayListSet& aLists) override {
    1129          96 :     mHelper.BuildDisplayList(aBuilder, aDirtyRect, aLists);
    1130          96 :   }
    1131             : 
    1132             :   // XXXldb Is this actually used?
    1133             : #if 0
    1134             :   virtual nscoord GetMinISize(gfxContext *aRenderingContext) override;
    1135             : #endif
    1136             : 
    1137           0 :   virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
    1138           0 :     return mHelper.ComputeCustomOverflow(aOverflowAreas);
    1139             :   }
    1140             : 
    1141           0 :   bool GetVerticalAlignBaseline(mozilla::WritingMode aWM,
    1142             :                                 nscoord* aBaseline) const override {
    1143           0 :     *aBaseline = GetLogicalBaseline(aWM);
    1144           0 :     return true;
    1145             :   }
    1146             : 
    1147             :   // Called to set the child frames. We typically have three: the scroll area,
    1148             :   // the vertical scrollbar, and the horizontal scrollbar.
    1149             :   virtual void SetInitialChildList(ChildListID     aListID,
    1150             :                                    nsFrameList&    aChildList) override;
    1151             :   virtual void AppendFrames(ChildListID     aListID,
    1152             :                             nsFrameList&    aFrameList) override;
    1153             :   virtual void InsertFrames(ChildListID     aListID,
    1154             :                             nsIFrame*       aPrevFrame,
    1155             :                             nsFrameList&    aFrameList) override;
    1156             :   virtual void RemoveFrame(ChildListID     aListID,
    1157             :                            nsIFrame*       aOldFrame) override;
    1158             : 
    1159             :   virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
    1160             : 
    1161             : 
    1162           2 :   virtual nsIScrollableFrame* GetScrollTargetFrame() override {
    1163           2 :     return this;
    1164             :   }
    1165             : 
    1166          44 :   virtual nsContainerFrame* GetContentInsertionFrame() override {
    1167          44 :     return mHelper.GetScrolledFrame()->GetContentInsertionFrame();
    1168             :   }
    1169             : 
    1170          38 :   virtual bool DoesClipChildren() override { return true; }
    1171             :   virtual nsSplittableType GetSplittableType() const override;
    1172             : 
    1173          59 :   virtual nsPoint GetPositionOfChildIgnoringScrolling(nsIFrame* aChild) override
    1174          59 :   { nsPoint pt = aChild->GetPosition();
    1175          59 :     if (aChild == mHelper.GetScrolledFrame())
    1176          59 :       pt += mHelper.GetLogicalScrollPosition();
    1177          59 :     return pt;
    1178             :   }
    1179             : 
    1180             :   // nsIAnonymousContentCreator
    1181             :   virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
    1182             :   virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
    1183             :                                         uint32_t aFilter) override;
    1184             : 
    1185             :   virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
    1186             :   virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
    1187             :   virtual nsSize GetXULMaxSize(nsBoxLayoutState& aBoxLayoutState) override;
    1188             :   virtual nscoord GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) override;
    1189             : 
    1190             :   NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState) override;
    1191             :   virtual nsresult GetXULPadding(nsMargin& aPadding) override;
    1192             : 
    1193         102 :   virtual bool GetBorderRadii(const nsSize& aFrameSize, const nsSize& aBorderArea,
    1194             :                               Sides aSkipSides, nscoord aRadii[8]) const override {
    1195         102 :     return mHelper.GetBorderRadii(aFrameSize, aBorderArea, aSkipSides, aRadii);
    1196             :   }
    1197             : 
    1198             :   nsresult XULLayout(nsBoxLayoutState& aState);
    1199             :   void LayoutScrollArea(nsBoxLayoutState& aState, const nsPoint& aScrollPosition);
    1200             : 
    1201             :   static bool AddRemoveScrollbar(bool& aHasScrollbar,
    1202             :                                    nscoord& aXY,
    1203             :                                    nscoord& aSize,
    1204             :                                    nscoord aSbSize,
    1205             :                                    bool aOnRightOrBottom,
    1206             :                                    bool aAdd);
    1207             : 
    1208             :   bool AddRemoveScrollbar(nsBoxLayoutState& aState,
    1209             :                             bool aOnRightOrBottom,
    1210             :                             bool aHorizontal,
    1211             :                             bool aAdd);
    1212             : 
    1213             :   bool AddHorizontalScrollbar (nsBoxLayoutState& aState, bool aOnBottom);
    1214             :   bool AddVerticalScrollbar   (nsBoxLayoutState& aState, bool aOnRight);
    1215             :   void RemoveHorizontalScrollbar(nsBoxLayoutState& aState, bool aOnBottom);
    1216             :   void RemoveVerticalScrollbar  (nsBoxLayoutState& aState, bool aOnRight);
    1217             : 
    1218             :   static void AdjustReflowInputForPrintPreview(nsBoxLayoutState& aState, bool& aSetBack);
    1219             :   static void AdjustReflowInputBack(nsBoxLayoutState& aState, bool aSetBack);
    1220             : 
    1221             :   // nsIScrollableFrame
    1222         214 :   virtual nsIFrame* GetScrolledFrame() const override {
    1223         214 :     return mHelper.GetScrolledFrame();
    1224             :   }
    1225         485 :   virtual mozilla::ScrollbarStyles GetScrollbarStyles() const override {
    1226         485 :     return mHelper.GetScrollbarStylesFromFrame();
    1227             :   }
    1228           0 :   virtual uint32_t GetScrollbarVisibility() const override {
    1229           0 :     return mHelper.GetScrollbarVisibility();
    1230             :   }
    1231           0 :   virtual nsMargin GetActualScrollbarSizes() const override {
    1232           0 :     return mHelper.GetActualScrollbarSizes();
    1233             :   }
    1234           0 :   virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState) override {
    1235           0 :     return mHelper.GetDesiredScrollbarSizes(aState);
    1236             :   }
    1237           0 :   virtual nsMargin GetDesiredScrollbarSizes(nsPresContext* aPresContext,
    1238             :           gfxContext* aRC) override {
    1239           0 :     nsBoxLayoutState bls(aPresContext, aRC, 0);
    1240           0 :     return GetDesiredScrollbarSizes(&bls);
    1241             :   }
    1242           0 :   virtual nscoord GetNondisappearingScrollbarWidth(nsPresContext* aPresContext,
    1243             :           gfxContext* aRC, mozilla::WritingMode aWM) override {
    1244           0 :     nsBoxLayoutState bls(aPresContext, aRC, 0);
    1245           0 :     return mHelper.GetNondisappearingScrollbarWidth(&bls, aWM);
    1246             :   }
    1247           0 :   virtual nsRect GetScrolledRect() const override {
    1248           0 :     return mHelper.GetScrolledRect();
    1249             :   }
    1250           0 :   virtual nsRect GetScrollPortRect() const override {
    1251           0 :     return mHelper.GetScrollPortRect();
    1252             :   }
    1253           0 :   virtual nsPoint GetScrollPosition() const override {
    1254           0 :     return mHelper.GetScrollPosition();
    1255             :   }
    1256           0 :   virtual nsPoint GetLogicalScrollPosition() const override {
    1257           0 :     return mHelper.GetLogicalScrollPosition();
    1258             :   }
    1259           2 :   virtual nsRect GetScrollRange() const override {
    1260           2 :     return mHelper.GetScrollRange();
    1261             :   }
    1262           0 :   virtual nsSize GetScrollPositionClampingScrollPortSize() const override {
    1263           0 :     return mHelper.GetScrollPositionClampingScrollPortSize();
    1264             :   }
    1265           0 :   virtual nsSize GetLineScrollAmount() const override {
    1266           0 :     return mHelper.GetLineScrollAmount();
    1267             :   }
    1268           0 :   virtual nsSize GetPageScrollAmount() const override {
    1269           0 :     return mHelper.GetPageScrollAmount();
    1270             :   }
    1271             :   /**
    1272             :    * @note This method might destroy the frame, pres shell and other objects.
    1273             :    */
    1274           0 :   virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
    1275             :                         const nsRect* aRange = nullptr,
    1276             :                         ScrollSnapMode aSnap = nsIScrollbarMediator::DISABLE_SNAP)
    1277             :                         override {
    1278           0 :     mHelper.ScrollTo(aScrollPosition, aMode, aRange, aSnap);
    1279           0 :   }
    1280             :   /**
    1281             :    * @note This method might destroy the frame, pres shell and other objects.
    1282             :    */
    1283           0 :   virtual void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition,
    1284             :                                  nsIScrollableFrame::ScrollMode aMode
    1285             :                                    = nsIScrollableFrame::INSTANT) override {
    1286           0 :     mHelper.ScrollToCSSPixels(aScrollPosition, aMode);
    1287           0 :   }
    1288           0 :   virtual void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition,
    1289             :                                             nsIAtom* aOrigin = nullptr) override {
    1290           0 :     mHelper.ScrollToCSSPixelsApproximate(aScrollPosition, aOrigin);
    1291           0 :   }
    1292           0 :   virtual CSSIntPoint GetScrollPositionCSSPixels() override {
    1293           0 :     return mHelper.GetScrollPositionCSSPixels();
    1294             :   }
    1295             :   /**
    1296             :    * @note This method might destroy the frame, pres shell and other objects.
    1297             :    */
    1298           0 :   virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
    1299             :                         nsIntPoint* aOverflow, nsIAtom* aOrigin = nullptr,
    1300             :                         nsIScrollableFrame::ScrollMomentum aMomentum = nsIScrollableFrame::NOT_MOMENTUM,
    1301             :                         nsIScrollbarMediator::ScrollSnapMode aSnap
    1302             :                           = nsIScrollbarMediator::DISABLE_SNAP)
    1303             :                         override {
    1304           0 :     mHelper.ScrollBy(aDelta, aUnit, aMode, aOverflow, aOrigin, aMomentum, aSnap);
    1305           0 :   }
    1306           0 :   virtual void ScrollSnap() override {
    1307           0 :     mHelper.ScrollSnap();
    1308           0 :   }
    1309             :   /**
    1310             :    * @note This method might destroy the frame, pres shell and other objects.
    1311             :    */
    1312           0 :   virtual void ScrollToRestoredPosition() override {
    1313           0 :     mHelper.ScrollToRestoredPosition();
    1314           0 :   }
    1315           0 :   virtual void AddScrollPositionListener(nsIScrollPositionListener* aListener) override {
    1316           0 :     mHelper.AddScrollPositionListener(aListener);
    1317           0 :   }
    1318           0 :   virtual void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) override {
    1319           0 :     mHelper.RemoveScrollPositionListener(aListener);
    1320           0 :   }
    1321             :   /**
    1322             :    * @note This method might destroy the frame, pres shell and other objects.
    1323             :    */
    1324           0 :   virtual void CurPosAttributeChanged(nsIContent* aChild) override {
    1325           0 :     mHelper.CurPosAttributeChanged(aChild);
    1326           0 :   }
    1327           0 :   NS_IMETHOD PostScrolledAreaEventForCurrentArea() override {
    1328           0 :     mHelper.PostScrolledAreaEvent();
    1329           0 :     return NS_OK;
    1330             :   }
    1331          96 :   virtual bool IsScrollingActive(nsDisplayListBuilder* aBuilder) override {
    1332          96 :     return mHelper.IsScrollingActive(aBuilder);
    1333             :   }
    1334           0 :   virtual bool IsProcessingAsyncScroll() override {
    1335           0 :     return mHelper.IsProcessingAsyncScroll();
    1336             :   }
    1337           0 :   virtual void ResetScrollPositionForLayerPixelAlignment() override {
    1338           0 :     mHelper.ResetScrollPositionForLayerPixelAlignment();
    1339           0 :   }
    1340           0 :   virtual bool DidHistoryRestore() const override {
    1341           0 :     return mHelper.mDidHistoryRestore;
    1342             :   }
    1343           0 :   virtual void ClearDidHistoryRestore() override {
    1344           0 :     mHelper.mDidHistoryRestore = false;
    1345           0 :   }
    1346           0 :   virtual bool IsRectNearlyVisible(const nsRect& aRect) override {
    1347           0 :     return mHelper.IsRectNearlyVisible(aRect);
    1348             :   }
    1349           0 :   virtual nsRect ExpandRectToNearlyVisible(const nsRect& aRect) const override {
    1350           0 :     return mHelper.ExpandRectToNearlyVisible(aRect);
    1351             :   }
    1352           0 :   virtual nsIAtom* LastScrollOrigin() override {
    1353           0 :     return mHelper.LastScrollOrigin();
    1354             :   }
    1355           0 :   virtual void AllowScrollOriginDowngrade() override {
    1356           0 :     mHelper.AllowScrollOriginDowngrade();
    1357           0 :   }
    1358           0 :   virtual nsIAtom* LastSmoothScrollOrigin() override {
    1359           0 :     return mHelper.LastSmoothScrollOrigin();
    1360             :   }
    1361           0 :   virtual uint32_t CurrentScrollGeneration() override {
    1362           0 :     return mHelper.CurrentScrollGeneration();
    1363             :   }
    1364           0 :   virtual nsPoint LastScrollDestination() override {
    1365           0 :     return mHelper.LastScrollDestination();
    1366             :   }
    1367           0 :   virtual void ResetScrollInfoIfGeneration(uint32_t aGeneration) override {
    1368           0 :     mHelper.ResetScrollInfoIfGeneration(aGeneration);
    1369           0 :   }
    1370          96 :   virtual bool WantAsyncScroll() const override {
    1371          96 :     return mHelper.WantAsyncScroll();
    1372             :   }
    1373           0 :   virtual mozilla::Maybe<mozilla::layers::ScrollMetadata> ComputeScrollMetadata(
    1374             :     Layer* aLayer, nsIFrame* aContainerReferenceFrame,
    1375             :     const ContainerLayerParameters& aParameters,
    1376             :     const mozilla::DisplayItemClip* aClip) const override
    1377             :   {
    1378           0 :     return mHelper.ComputeScrollMetadata(aLayer, aContainerReferenceFrame, aParameters, aClip);
    1379             :   }
    1380           0 :   virtual bool IsIgnoringViewportClipping() const override {
    1381           0 :     return mHelper.IsIgnoringViewportClipping();
    1382             :   }
    1383           0 :   virtual void MarkScrollbarsDirtyForReflow() const override {
    1384           0 :     mHelper.MarkScrollbarsDirtyForReflow();
    1385           0 :   }
    1386             : 
    1387             :   // nsIStatefulFrame
    1388           1 :   NS_IMETHOD SaveState(nsPresState** aState) override {
    1389           1 :     NS_ENSURE_ARG_POINTER(aState);
    1390           1 :     *aState = mHelper.SaveState();
    1391           1 :     return NS_OK;
    1392             :   }
    1393           0 :   NS_IMETHOD RestoreState(nsPresState* aState) override {
    1394           0 :     NS_ENSURE_ARG_POINTER(aState);
    1395           0 :     mHelper.RestoreState(aState);
    1396           0 :     return NS_OK;
    1397             :   }
    1398             : 
    1399         480 :   virtual bool IsFrameOfType(uint32_t aFlags) const override
    1400             :   {
    1401             :     // Override bogus IsFrameOfType in nsBoxFrame.
    1402         480 :     if (aFlags & (nsIFrame::eReplacedContainsBlock | nsIFrame::eReplaced))
    1403         139 :       return false;
    1404         341 :     return nsBoxFrame::IsFrameOfType(aFlags);
    1405             :   }
    1406             : 
    1407           0 :   virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
    1408             :                             nsIScrollbarMediator::ScrollSnapMode aSnap
    1409             :                               = nsIScrollbarMediator::DISABLE_SNAP) override {
    1410           0 :     mHelper.ScrollByPage(aScrollbar, aDirection, aSnap);
    1411           0 :   }
    1412           0 :   virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
    1413             :                              nsIScrollbarMediator::ScrollSnapMode aSnap
    1414             :                                = nsIScrollbarMediator::DISABLE_SNAP) override {
    1415           0 :     mHelper.ScrollByWhole(aScrollbar, aDirection, aSnap);
    1416           0 :   }
    1417           0 :   virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
    1418             :                             nsIScrollbarMediator::ScrollSnapMode aSnap
    1419             :                               = nsIScrollbarMediator::DISABLE_SNAP) override {
    1420           0 :     mHelper.ScrollByLine(aScrollbar, aDirection, aSnap);
    1421           0 :   }
    1422           0 :   virtual void RepeatButtonScroll(nsScrollbarFrame* aScrollbar) override {
    1423           0 :     mHelper.RepeatButtonScroll(aScrollbar);
    1424           0 :   }
    1425           0 :   virtual void ThumbMoved(nsScrollbarFrame* aScrollbar,
    1426             :                           nscoord aOldPos,
    1427             :                           nscoord aNewPos) override {
    1428           0 :     mHelper.ThumbMoved(aScrollbar, aOldPos, aNewPos);
    1429           0 :   }
    1430           0 :   virtual void ScrollbarReleased(nsScrollbarFrame* aScrollbar) override {
    1431           0 :     mHelper.ScrollbarReleased(aScrollbar);
    1432           0 :   }
    1433           0 :   virtual void VisibilityChanged(bool aVisible) override {}
    1434           0 :   virtual nsIFrame* GetScrollbarBox(bool aVertical) override {
    1435           0 :     return mHelper.GetScrollbarBox(aVertical);
    1436             :   }
    1437             : 
    1438             :   virtual void ScrollbarActivityStarted() const override;
    1439             :   virtual void ScrollbarActivityStopped() const override;
    1440             : 
    1441          38 :   virtual bool IsScrollbarOnRight() const override {
    1442          38 :     return mHelper.IsScrollbarOnRight();
    1443             :   }
    1444             : 
    1445           0 :   virtual bool ShouldSuppressScrollbarRepaints() const override {
    1446           0 :     return mHelper.ShouldSuppressScrollbarRepaints();
    1447             :   }
    1448             : 
    1449           0 :   virtual void SetTransformingByAPZ(bool aTransforming) override {
    1450           0 :     mHelper.SetTransformingByAPZ(aTransforming);
    1451           0 :   }
    1452           0 :   virtual bool UsesContainerScrolling() const override {
    1453           0 :     return mHelper.UsesContainerScrolling();
    1454             :   }
    1455           0 :   bool IsTransformingByAPZ() const override {
    1456           0 :     return mHelper.IsTransformingByAPZ();
    1457             :   }
    1458           0 :   void SetScrollableByAPZ(bool aScrollable) override {
    1459           0 :     mHelper.SetScrollableByAPZ(aScrollable);
    1460           0 :   }
    1461           0 :   void SetZoomableByAPZ(bool aZoomable) override {
    1462           0 :     mHelper.SetZoomableByAPZ(aZoomable);
    1463           0 :   }
    1464           0 :   virtual bool DecideScrollableLayer(nsDisplayListBuilder* aBuilder,
    1465             :                                      nsRect* aDirtyRect,
    1466             :                                      bool aAllowCreateDisplayPort) override {
    1467           0 :     return mHelper.DecideScrollableLayer(aBuilder, aDirtyRect, aAllowCreateDisplayPort);
    1468             :   }
    1469           0 :   virtual void NotifyApproximateFrameVisibilityUpdate(bool aIgnoreDisplayPort) override {
    1470           0 :     mHelper.NotifyApproximateFrameVisibilityUpdate(aIgnoreDisplayPort);
    1471           0 :   }
    1472           0 :   virtual bool GetDisplayPortAtLastApproximateFrameVisibilityUpdate(nsRect* aDisplayPort) override {
    1473           0 :     return mHelper.GetDisplayPortAtLastApproximateFrameVisibilityUpdate(aDisplayPort);
    1474             :   }
    1475           0 :   void TriggerDisplayPortExpiration() override {
    1476           0 :     mHelper.TriggerDisplayPortExpiration();
    1477           0 :   }
    1478             : 
    1479           0 :   ScrollSnapInfo GetScrollSnapInfo() const override {
    1480           0 :     return mHelper.GetScrollSnapInfo();
    1481             :   }
    1482             : 
    1483           0 :   virtual bool DragScroll(mozilla::WidgetEvent* aEvent) override {
    1484           0 :     return mHelper.DragScroll(aEvent);
    1485             :   }
    1486             : 
    1487           0 :   virtual void AsyncScrollbarDragRejected() override {
    1488           0 :     return mHelper.AsyncScrollbarDragRejected();
    1489             :   }
    1490             : 
    1491           0 :   virtual bool IsRootScrollFrameOfDocument() const override {
    1492           0 :     return mHelper.IsRootScrollFrameOfDocument();
    1493             :   }
    1494             : 
    1495             :   // Return the scrolled frame.
    1496           0 :   void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override {
    1497           0 :     aResult.AppendElement(OwnedAnonBox(mHelper.GetScrolledFrame()));
    1498           0 :   }
    1499             : 
    1500             : #ifdef DEBUG_FRAME_DUMP
    1501             :   virtual nsresult GetFrameName(nsAString& aResult) const override;
    1502             : #endif
    1503             : 
    1504             : protected:
    1505             :   nsXULScrollFrame(nsStyleContext* aContext, bool aIsRoot,
    1506             :                    bool aClipAllDescendants);
    1507             : 
    1508          38 :   void ClampAndSetBounds(nsBoxLayoutState& aState,
    1509             :                          nsRect& aRect,
    1510             :                          nsPoint aScrollPosition,
    1511             :                          bool aRemoveOverflowAreas = false) {
    1512             :     /*
    1513             :      * For RTL frames, restore the original scrolled position of the right
    1514             :      * edge, then subtract the current width to find the physical position.
    1515             :      */
    1516          38 :     if (!mHelper.IsPhysicalLTR()) {
    1517           0 :       aRect.x = mHelper.mScrollPort.XMost() - aScrollPosition.x - aRect.width;
    1518             :     }
    1519          38 :     mHelper.mScrolledFrame->SetXULBounds(aState, aRect, aRemoveOverflowAreas);
    1520          38 :   }
    1521             : 
    1522             : private:
    1523             :   friend class mozilla::ScrollFrameHelper;
    1524             :   ScrollFrameHelper mHelper;
    1525             : };
    1526             : 
    1527             : #endif /* nsGfxScrollFrame_h___ */

Generated by: LCOV version 1.13