1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 /*
8  * interface that provides scroll APIs implemented by scrollable frames
9  */
10 
11 #ifndef nsIScrollFrame_h___
12 #define nsIScrollFrame_h___
13 
14 #include "nsCoord.h"
15 #include "mozilla/dom/WindowBinding.h"  // for mozilla::dom::ScrollBehavior
16 #include "mozilla/Maybe.h"
17 #include "mozilla/ScrollOrigin.h"
18 #include "mozilla/ScrollPositionUpdate.h"
19 #include "mozilla/ScrollStyles.h"
20 #include "mozilla/ScrollTypes.h"
21 #include "mozilla/gfx/Point.h"
22 #include "nsIScrollbarMediator.h"
23 #include "Units.h"
24 #include "FrameMetrics.h"
25 
26 #define NS_DEFAULT_VERTICAL_SCROLL_DISTANCE 3
27 #define NS_DEFAULT_HORIZONTAL_SCROLL_DISTANCE 5
28 
29 class gfxContext;
30 class nsBoxLayoutState;
31 class nsIScrollPositionListener;
32 class nsIFrame;
33 class nsPresContext;
34 class nsIContent;
35 class nsDisplayListBuilder;
36 
37 namespace mozilla {
38 struct ContainerLayerParameters;
39 class DisplayItemClip;
40 namespace layers {
41 struct ScrollMetadata;
42 class Layer;
43 class LayerManager;
44 }  // namespace layers
45 namespace layout {
46 class ScrollAnchorContainer;
47 }  // namespace layout
48 }  // namespace mozilla
49 
50 /**
51  * Interface for frames that are scrollable. This interface exposes
52  * APIs for examining scroll state, observing changes to scroll state,
53  * and triggering scrolling.
54  */
55 class nsIScrollableFrame : public nsIScrollbarMediator {
56  public:
57   typedef mozilla::CSSIntPoint CSSIntPoint;
58   typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
59   typedef mozilla::layers::ScrollSnapInfo ScrollSnapInfo;
60   typedef mozilla::layout::ScrollAnchorContainer ScrollAnchorContainer;
61   typedef mozilla::ScrollMode ScrollMode;
62   typedef mozilla::ScrollOrigin ScrollOrigin;
63 
64   NS_DECL_QUERYFRAME_TARGET(nsIScrollableFrame)
65 
66   /**
67    * Get the frame for the content that we are scrolling within
68    * this scrollable frame.
69    */
70   virtual nsIFrame* GetScrolledFrame() const = 0;
71 
72   /**
73    * Get the overflow styles (StyleOverflow::Scroll, StyleOverflow::Hidden, or
74    * StyleOverflow::Auto) governing the horizontal and vertical scrollbars for
75    * this frame.
76    *
77    * This is special because they can be propagated from the <body> element,
78    * unlike other styles.
79    */
80   virtual mozilla::ScrollStyles GetScrollStyles() const = 0;
81 
82   /**
83    * Returns whether this scroll frame is for a text control element with no
84    * scrollbars (for <input>, basically).
85    */
86   virtual bool IsForTextControlWithNoScrollbars() const = 0;
87 
88   /**
89    * Get the overscroll-behavior styles.
90    */
91   virtual mozilla::layers::OverscrollBehaviorInfo GetOverscrollBehaviorInfo()
92       const = 0;
93 
94   /**
95    * Return the scrollbars which are visible. It's OK to call this during reflow
96    * of the scrolled contents, in which case it will reflect the current
97    * assumptions about scrollbar visibility.
98    */
99   virtual mozilla::layers::ScrollDirections GetScrollbarVisibility() const = 0;
100   /**
101    * Returns the directions in which scrolling is allowed (if the scroll range
102    * is at least one device pixel in that direction).
103    */
104   mozilla::layers::ScrollDirections GetAvailableScrollingDirections() const;
105   /**
106    * Returns the directions in which scrolling is allowed when taking into
107    * account the visual viewport size and overflow hidden. (An (apz) zoomed in
108    * overflow hidden scrollframe is actually user scrollable.)
109    */
110   virtual mozilla::layers::ScrollDirections
111   GetAvailableScrollingDirectionsForUserInputEvents() const = 0;
112   /**
113    * Return the actual sizes of all possible scrollbars. Returns 0 for scrollbar
114    * positions that don't have a scrollbar or where the scrollbar is not
115    * visible. Do not call this while this frame's descendants are being
116    * reflowed, it won't be accurate.
117    * INCLUDE_VISUAL_VIEWPORT_SCROLLBARS means we include the size of layout
118    * scrollbars that are only visible to scroll the visual viewport inside the
119    * layout viewport (ie the layout viewport cannot be scrolled) even though
120    * there is no layout space set aside for these scrollbars.
121    */
122   enum class ScrollbarSizesOptions { NONE, INCLUDE_VISUAL_VIEWPORT_SCROLLBARS };
123   virtual nsMargin GetActualScrollbarSizes(
124       ScrollbarSizesOptions aOptions = ScrollbarSizesOptions::NONE) const = 0;
125   /**
126    * Return the sizes of all scrollbars assuming that any scrollbars that could
127    * be visible due to overflowing content, are. This can be called during
128    * reflow of the scrolled contents.
129    */
130   virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState) = 0;
131   /**
132    * Return the sizes of all scrollbars assuming that any scrollbars that could
133    * be visible due to overflowing content, are. This can be called during
134    * reflow of the scrolled contents.
135    */
136   virtual nsMargin GetDesiredScrollbarSizes(nsPresContext* aPresContext,
137                                             gfxContext* aRC) = 0;
138   /**
139    * Return the width for non-disappearing scrollbars.
140    */
141   virtual nscoord GetNondisappearingScrollbarWidth(
142       nsPresContext* aPresContext, gfxContext* aRC,
143       mozilla::WritingMode aWM) = 0;
144   /**
145    * Get the layout size of this frame.
146    * Note that this is a value which is not expanded by the minimum scale size.
147    * For scroll frames other than the root content document's scroll frame, this
148    * value will be the same as GetScrollPortRect().Size().
149    *
150    * This value is used for Element.clientWidth and clientHeight.
151    */
152   virtual nsSize GetLayoutSize() const = 0;
153   /**
154    * GetScrolledRect is designed to encapsulate deciding which
155    * directions of overflow should be reachable by scrolling and which
156    * should not.  Callers should NOT depend on it having any particular
157    * behavior (although nsXULScrollFrame currently does).
158    *
159    * This should only be called when the scrolled frame has been
160    * reflowed with the scroll port size given in mScrollPort.
161    *
162    * Currently it allows scrolling down and to the right for
163    * nsHTMLScrollFrames with LTR directionality and for all
164    * nsXULScrollFrames, and allows scrolling down and to the left for
165    * nsHTMLScrollFrames with RTL directionality.
166    */
167   virtual nsRect GetScrolledRect() const = 0;
168   /**
169    * Get the area of the scrollport relative to the origin of this frame's
170    * border-box.
171    * This is the area of this frame minus border and scrollbars.
172    */
173   virtual nsRect GetScrollPortRect() const = 0;
174   /**
175    * Get the offset of the scrollport origin relative to the scrolled
176    * frame origin. Typically the position will be non-negative.
177    * This will always be a multiple of device pixels.
178    */
179   virtual nsPoint GetScrollPosition() const = 0;
180   /**
181    * As GetScrollPosition(), but uses the top-right as origin for RTL frames.
182    */
183   virtual nsPoint GetLogicalScrollPosition() const = 0;
184 
185   /**
186    * Get the area that must contain the scroll position. Typically
187    * (but not always, e.g. for RTL content) x and y will be 0, and
188    * width or height will be nonzero if the content can be scrolled in
189    * that direction. Since scroll positions must be a multiple of
190    * device pixels, the range extrema will also be a multiple of
191    * device pixels.
192    */
193   virtual nsRect GetScrollRange() const = 0;
194   /**
195    * Get the size of the view port to use when clamping the scroll
196    * position.
197    */
198   virtual nsSize GetVisualViewportSize() const = 0;
199   /**
200    * Returns the offset of the visual viewport relative to
201    * the origin of the scrolled content. Note that only the RCD-RSF
202    * has a distinct visual viewport; for other scroll frames, the
203    * visual viewport always coincides with the layout viewport, and
204    * consequently the offset this function returns is equal to
205    * GetScrollPosition().
206    */
207   virtual nsPoint GetVisualViewportOffset() const = 0;
208   /**
209    * Set the visual viewport offset associated with a root scroll frame. This is
210    * only valid when called on a root scroll frame and will assert otherwise.
211    * aRepaint indicates if we need to ask for a main thread paint if this
212    * changes scrollbar positions or not. For example, if the compositor has
213    * already put the scrollbars at this position then they don't need to move so
214    * we can skip the repaint. Returns true if the offset changed and the scroll
215    * frame is still alive after this call.
216    */
217   virtual bool SetVisualViewportOffset(const nsPoint& aOffset,
218                                        bool aRepaint) = 0;
219   /**
220    * Get the area that must contain the visual viewport offset.
221    */
222   virtual nsRect GetVisualScrollRange() const = 0;
223   /**
224    * Like GetVisualScrollRange but also takes into account overflow: hidden.
225    */
226   virtual nsRect GetScrollRangeForUserInputEvents() const = 0;
227   /**
228    * Return how much we would try to scroll by in each direction if
229    * asked to scroll by one "line" vertically and horizontally.
230    */
231   virtual nsSize GetLineScrollAmount() const = 0;
232   /**
233    * Return how much we would try to scroll by in each direction if
234    * asked to scroll by one "page" vertically and horizontally.
235    */
236   virtual nsSize GetPageScrollAmount() const = 0;
237 
238   /**
239    * Return scroll-padding value of this frame.
240    */
241   virtual nsMargin GetScrollPadding() const = 0;
242   /**
243    * Some platforms (OSX) may generate additional scrolling events even
244    * after the user has stopped scrolling, simulating a momentum scrolling
245    * effect resulting from fling gestures.
246    * SYNTHESIZED_MOMENTUM_EVENT indicates that the scrolling is being requested
247    * by such a synthesized event and may be ignored if another scroll has
248    * been started since the last actual user input.
249    */
250   enum ScrollMomentum { NOT_MOMENTUM, SYNTHESIZED_MOMENTUM_EVENT };
251   /**
252    * @note This method might destroy the frame, pres shell and other objects.
253    * Clamps aScrollPosition to GetScrollRange and sets the scroll position
254    * to that value.
255    * @param aRange If non-null, specifies area which contains aScrollPosition
256    * and can be used for choosing a performance-optimized scroll position.
257    * Any point within this area can be chosen.
258    * The choosen point will be as close as possible to aScrollPosition.
259    */
260   virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
261                         const nsRect* aRange = nullptr,
262                         nsIScrollbarMediator::ScrollSnapMode aSnap =
263                             nsIScrollbarMediator::DISABLE_SNAP) = 0;
264   /**
265    * @note This method might destroy the frame, pres shell and other objects.
266    * Scrolls to a particular position in integer CSS pixels.
267    * Keeps the exact current horizontal or vertical position if the current
268    * position, rounded to CSS pixels, matches aScrollPosition. If
269    * aScrollPosition.x/y is different from the current CSS pixel position,
270    * makes sure we only move in the direction given by the difference.
271    *
272    * When aMode is SMOOTH, INSTANT, or NORMAL, GetScrollPositionCSSPixels (the
273    * scroll position after rounding to CSS pixels) will be exactly
274    * aScrollPosition at the end of the scroll animation.
275    *
276    * When aMode is SMOOTH_MSD, intermediate animation frames may be outside the
277    * range and / or moving in any direction; GetScrollPositionCSSPixels will be
278    * exactly aScrollPosition at the end of the scroll animation unless the
279    * SMOOTH_MSD animation is interrupted.
280    *
281    * FIXME: Drop |aSnap| argument once after we finished the migration to the
282    * Scroll Snap Module v1. We should alway use ENABLE_SNAP.
283    */
284   virtual void ScrollToCSSPixels(
285       const CSSIntPoint& aScrollPosition,
286       ScrollMode aMode = ScrollMode::Instant,
287       nsIScrollbarMediator::ScrollSnapMode aSnap =
288           nsIScrollbarMediator::DEFAULT,
289       ScrollOrigin aOrigin = ScrollOrigin::NotSpecified) = 0;
290   /**
291    * @note This method might destroy the frame, pres shell and other objects.
292    * Scrolls to a particular position in float CSS pixels.
293    * This does not guarantee that GetScrollPositionCSSPixels equals
294    * aScrollPosition afterward. It tries to scroll as close to
295    * aScrollPosition as possible while scrolling by an integer
296    * number of layer pixels (so the operation is fast and looks clean).
297    */
298   virtual void ScrollToCSSPixelsApproximate(
299       const mozilla::CSSPoint& aScrollPosition,
300       ScrollOrigin aOrigin = ScrollOrigin::NotSpecified) = 0;
301 
302   /**
303    * Returns the scroll position in integer CSS pixels, rounded to the nearest
304    * pixel.
305    */
306   virtual CSSIntPoint GetScrollPositionCSSPixels() = 0;
307   /**
308    * @note This method might destroy the frame, pres shell and other objects.
309    * Modifies the current scroll position by aDelta units given by aUnit,
310    * clamping it to GetScrollRange. If WHOLE is specified as the unit,
311    * content is scrolled all the way in the direction(s) given by aDelta.
312    * @param aOverflow if non-null, returns the amount that scrolling
313    * was clamped by in each direction (how far we moved the scroll position
314    * to bring it back into the legal range). This is never negative. The
315    * values are in device pixels.
316    */
317   virtual void ScrollBy(nsIntPoint aDelta, mozilla::ScrollUnit aUnit,
318                         ScrollMode aMode, nsIntPoint* aOverflow = nullptr,
319                         ScrollOrigin aOrigin = ScrollOrigin::NotSpecified,
320                         ScrollMomentum aMomentum = NOT_MOMENTUM,
321                         nsIScrollbarMediator::ScrollSnapMode aSnap =
322                             nsIScrollbarMediator::DISABLE_SNAP) = 0;
323 
324   /**
325    * FIXME: Drop |aSnap| argument once after we finished the migration to the
326    * Scroll Snap Module v1. We should alway use ENABLE_SNAP.
327    */
328   virtual void ScrollByCSSPixels(
329       const CSSIntPoint& aDelta, ScrollMode aMode = ScrollMode::Instant,
330       ScrollOrigin aOrigin = ScrollOrigin::NotSpecified,
331       nsIScrollbarMediator::ScrollSnapMode aSnap =
332           nsIScrollbarMediator::DEFAULT) = 0;
333 
334   /**
335    * Perform scroll snapping, possibly resulting in a smooth scroll to
336    * maintain the scroll snap position constraints.  Velocity sampled from
337    * main thread scrolling is used to determine best matching snap point
338    * when called after a fling gesture on a trackpad or mouse wheel.
339    */
340   virtual void ScrollSnap() = 0;
341 
342   /**
343    * @note This method might destroy the frame, pres shell and other objects.
344    * This tells the scroll frame to try scrolling to the scroll
345    * position that was restored from the history. This must be called
346    * at least once after state has been restored. It is called by the
347    * scrolled frame itself during reflow, but sometimes state can be
348    * restored after reflows are done...
349    * XXX should we take an aMode parameter here? Currently it's instant.
350    */
351   virtual void ScrollToRestoredPosition() = 0;
352 
353   /**
354    * Add a scroll position listener. This listener must be removed
355    * before it is destroyed.
356    */
357   virtual void AddScrollPositionListener(
358       nsIScrollPositionListener* aListener) = 0;
359   /**
360    * Remove a scroll position listener.
361    */
362   virtual void RemoveScrollPositionListener(
363       nsIScrollPositionListener* aListener) = 0;
364 
365   /**
366    * Internal method used by scrollbars to notify their scrolling
367    * container of changes.
368    */
369   virtual void CurPosAttributeChanged(nsIContent* aChild) = 0;
370 
371   /**
372    * Allows the docshell to request that the scroll frame post an event
373    * after being restored from history.
374    */
375   NS_IMETHOD PostScrolledAreaEventForCurrentArea() = 0;
376 
377   /**
378    * Returns true if this scrollframe is being "actively scrolled".
379    * This basically means that we should allocate resources in the
380    * expectation that scrolling is going to happen.
381    */
382   virtual bool IsScrollingActive() = 0;
383 
384   /**
385    * The same as IsScrollingActive but minimal display ports are not considered
386    * active.
387    */
388   virtual bool IsScrollingActiveNotMinimalDisplayPort() = 0;
389 
390   /**
391    * Returns true if this scroll frame might be scrolled
392    * asynchronously by the compositor.
393    */
394   virtual bool IsMaybeAsynchronouslyScrolled() = 0;
395 
396   /**
397    * Call this when the layer(s) induced by active scrolling are being
398    * completely redrawn.
399    */
400   virtual void ResetScrollPositionForLayerPixelAlignment() = 0;
401   /**
402    * Was the current presentation state for this frame restored from history?
403    */
404   virtual bool DidHistoryRestore() const = 0;
405   /**
406    * Clear the flag so that DidHistoryRestore() returns false until the next
407    * RestoreState call.
408    * @see nsIStatefulFrame::RestoreState
409    */
410   virtual void ClearDidHistoryRestore() = 0;
411   /**
412    * Mark the frame as having been scrolled at least once, so that it remains
413    * active and we can also start storing its scroll position when saving state.
414    */
415   virtual void MarkEverScrolled() = 0;
416   /**
417    * Determine if the passed in rect is nearly visible according to the frame
418    * visibility heuristics for how close it is to the visible scrollport.
419    */
420   virtual bool IsRectNearlyVisible(const nsRect& aRect) = 0;
421   /**
422    * Expand the given rect taking into account which directions we can scroll
423    * and how far we want to expand for frame visibility purposes.
424    */
425   virtual nsRect ExpandRectToNearlyVisible(const nsRect& aRect) const = 0;
426   /**
427    * Returns the origin that triggered the last instant scroll. Will equal
428    * ScrollOrigin::Apz when the compositor's replica frame metrics includes the
429    * latest instant scroll.
430    */
431   virtual ScrollOrigin LastScrollOrigin() = 0;
432 
433   /**
434    * Returns whether there's an async scroll going on.
435    *
436    * The argument allows a subtle distinction that's needed for APZ. When
437    * `IncludeApzAnimation::No` is given, ongoing APZ animations that have
438    * already been synced to the main thread are not included, which is needed so
439    * that APZ can keep syncing the scroll offset properly.
440    */
441   enum class IncludeApzAnimation : bool { No, Yes };
442   virtual bool IsScrollAnimating(
443       IncludeApzAnimation = IncludeApzAnimation::Yes) = 0;
444 
445   /**
446    * Returns the current generation counter for the scrollframe. This counter
447    * increments every time the scroll position is set.
448    */
449   virtual mozilla::ScrollGeneration CurrentScrollGeneration() const = 0;
450   /**
451    * LastScrollDestination returns the destination of the most recently
452    * requested smooth scroll animation.
453    */
454   virtual nsPoint LastScrollDestination() = 0;
455   /**
456    * Returns the list of scroll position updates since the last call to
457    * NotifyApzTransaction().
458    */
459   virtual nsTArray<mozilla::ScrollPositionUpdate> GetScrollUpdates() const = 0;
460   /**
461    * Returns true if the scroll frame has any scroll position updates since
462    * the last call to NotifyApzTransaction().
463    */
464   virtual bool HasScrollUpdates() const = 0;
465   /**
466    * Clears the "origin of last scroll" property stored in this frame, if
467    * the generation counter passed in matches the current scroll generation
468    * counter, and clears the "origin of last smooth scroll" property if the
469    * generation counter matches. It also resets whether there's an ongoing apz
470    * animation.
471    */
472   virtual void ResetScrollInfoIfNeeded(
473       const mozilla::ScrollGeneration& aGeneration,
474       bool aApzAnimationInProgress) = 0;
475   /**
476    * Determine whether it is desirable to be able to asynchronously scroll this
477    * scroll frame.
478    */
479   virtual bool WantAsyncScroll() const = 0;
480   /**
481    * Returns the ScrollMetadata contributed by this frame, if there is one.
482    */
483   virtual mozilla::Maybe<mozilla::layers::ScrollMetadata> ComputeScrollMetadata(
484       mozilla::layers::LayerManager* aLayerManager,
485       const nsIFrame* aContainerReferenceFrame,
486       const mozilla::Maybe<ContainerLayerParameters>& aParameters,
487       const mozilla::DisplayItemClip* aClip) const = 0;
488   /**
489    * Ensure's aLayer is clipped to the display port.
490    */
491   virtual void ClipLayerToDisplayPort(
492       mozilla::layers::Layer* aLayer, const mozilla::DisplayItemClip* aClip,
493       const ContainerLayerParameters& aParameters) const = 0;
494 
495   /**
496    * Mark the scrollbar frames for reflow.
497    */
498   virtual void MarkScrollbarsDirtyForReflow() const = 0;
499 
500   /**
501    * Invalidate the scrollbar after the marks have been changed.
502    */
503   virtual void InvalidateVerticalScrollbar() const = 0;
504 
505   virtual void UpdateScrollbarPosition() = 0;
506 
507   virtual void SetTransformingByAPZ(bool aTransforming) = 0;
508   virtual bool IsTransformingByAPZ() const = 0;
509 
510   /**
511    * Notify this scroll frame that it can be scrolled by APZ. In particular,
512    * this is called *after* the APZ code has created an APZC for this scroll
513    * frame and verified that it is not a scrollinfo layer. Therefore, setting an
514    * async transform on it is actually user visible.
515    */
516   virtual void SetScrollableByAPZ(bool aScrollable) = 0;
517 
518   /**
519    * Notify this scroll frame that it can be zoomed by APZ.
520    */
521   virtual void SetZoomableByAPZ(bool aZoomable) = 0;
522 
523   /**
524    * Mark this scroll frame as having out-of-flow content inside a CSS filter.
525    * Such content will move incorrectly during async-scrolling; to mitigate
526    * this, paint skipping is disabled for such scroll frames.
527    */
528   virtual void SetHasOutOfFlowContentInsideFilter() = 0;
529 
530   /**
531    * Determine if we should build a scrollable layer for this scroll frame and
532    * return the result. It will also record this result on the scroll frame.
533    * Pass the visible rect in aVisibleRect. On return it will be set to the
534    * displayport if there is one.
535    * Pass the dirty rect in aDirtyRect. On return it will be set to the
536    * dirty rect inside the displayport (ie the dirty rect that should be used).
537    * This function will set the display port base rect if aSetBase is true.
538    * aSetBase is only allowed to be false if there has been a call with it
539    * set to true before on the same paint.
540    */
541   virtual bool DecideScrollableLayer(nsDisplayListBuilder* aBuilder,
542                                      nsRect* aVisibleRect, nsRect* aDirtyRect,
543                                      bool aSetBase) = 0;
544 
545   /**
546    * Notify the scrollframe that the current scroll offset and origin have been
547    * sent over in a layers transaction.
548    *
549    * This sets a flag on the scrollframe that indicates subsequent changes
550    * to the scroll position by "weaker" origins are permitted to overwrite the
551    * the scroll origin. Scroll origins that
552    * nsLayoutUtils::CanScrollOriginClobberApz returns false for are considered
553    * "weaker" than scroll origins for which that function returns true.
554    *
555    * This function must be called for a scrollframe after all calls to
556    * ComputeScrollMetadata in a layers transaction have been completed.
557    *
558    */
559   virtual void NotifyApzTransaction() = 0;
560 
561   /**
562    * Notification that this scroll frame is getting its frame visibility
563    * updated. aIgnoreDisplayPort indicates that the display port was ignored
564    * (because there was no suitable base rect)
565    */
566   virtual void NotifyApproximateFrameVisibilityUpdate(
567       bool aIgnoreDisplayPort) = 0;
568 
569   /**
570    * Returns true if this scroll frame had a display port at the last frame
571    * visibility update and fills in aDisplayPort with that displayport. Returns
572    * false otherwise, and doesn't touch aDisplayPort.
573    */
574   virtual bool GetDisplayPortAtLastApproximateFrameVisibilityUpdate(
575       nsRect* aDisplayPort) = 0;
576 
577   /**
578    * This is called when a descendant scrollframe's has its displayport expired.
579    * This function will check to see if this scrollframe may safely expire its
580    * own displayport and schedule a timer to do that if it is safe.
581    */
582   virtual void TriggerDisplayPortExpiration() = 0;
583 
584   /**
585    * Returns information required to determine where to snap to after a scroll.
586    */
587   virtual ScrollSnapInfo GetScrollSnapInfo() const = 0;
588 
589   /**
590    * Given the drag event aEvent, determine whether the mouse is near the edge
591    * of the scrollable area, and scroll the view in the direction of that edge
592    * if so. If scrolling occurred, true is returned. When false is returned, the
593    * caller should look for an ancestor to scroll.
594    */
595   virtual bool DragScroll(mozilla::WidgetEvent* aEvent) = 0;
596 
597   virtual void AsyncScrollbarDragInitiated(
598       uint64_t aDragBlockId, mozilla::layers::ScrollDirection aDirection) = 0;
599   virtual void AsyncScrollbarDragRejected() = 0;
600 
601   /**
602    * Returns whether this scroll frame is the root scroll frame of the document
603    * that it is in. Note that some documents don't have root scroll frames at
604    * all (ie XUL documents) even though they may contain other scroll frames.
605    */
606   virtual bool IsRootScrollFrameOfDocument() const = 0;
607 
608   /**
609    * Returns the scroll anchor associated with this scrollable frame. This is
610    * never null.
611    */
612   virtual const ScrollAnchorContainer* Anchor() const = 0;
613   virtual ScrollAnchorContainer* Anchor() = 0;
614 
615   virtual bool SmoothScrollVisual(
616       const nsPoint& aVisualViewportOffset,
617       mozilla::layers::FrameMetrics::ScrollOffsetUpdateType aUpdateType) = 0;
618 
619   /**
620    * Returns true if this scroll frame should perform smooth scroll with the
621    * given |aBehavior|.
622    */
623   virtual bool IsSmoothScroll(mozilla::dom::ScrollBehavior aBehavior =
624                                   mozilla::dom::ScrollBehavior::Auto) const = 0;
625 };
626 
627 #endif
628