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 : #ifndef nsIScrollbarMediator_h___
7 : #define nsIScrollbarMediator_h___
8 :
9 : #include "nsQueryFrame.h"
10 : #include "nsCoord.h"
11 :
12 : class nsScrollbarFrame;
13 : class nsIFrame;
14 :
15 43 : class nsIScrollbarMediator : public nsQueryFrame
16 : {
17 : public:
18 : NS_DECL_QUERYFRAME_TARGET(nsIScrollbarMediator)
19 :
20 : /**
21 : * The aScrollbar argument denotes the scrollbar that's firing the notification.
22 : * aScrollbar is never null.
23 : * aDirection is either -1, 0, or 1.
24 : */
25 :
26 : /**
27 : * When set to ENABLE_SNAP, additional scrolling will be performed after the
28 : * scroll operation to maintain the constraints set by CSS Scroll snapping.
29 : * The additional scrolling may include asynchronous smooth scrolls that
30 : * continue to animate after the initial scroll position has been set.
31 : */
32 : enum ScrollSnapMode { DISABLE_SNAP, ENABLE_SNAP };
33 :
34 : /**
35 : * One of the following three methods is called when the scrollbar's button is
36 : * clicked.
37 : * @note These methods might destroy the frame, pres shell, and other objects.
38 : */
39 : virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
40 : ScrollSnapMode aSnap = DISABLE_SNAP) = 0;
41 : virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
42 : ScrollSnapMode aSnap = DISABLE_SNAP) = 0;
43 : virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
44 : ScrollSnapMode aSnap = DISABLE_SNAP) = 0;
45 : /**
46 : * RepeatButtonScroll is called when the scrollbar's button is held down. When the
47 : * button is first clicked the increment is set; RepeatButtonScroll adds this
48 : * increment to the current position.
49 : * @note This method might destroy the frame, pres shell, and other objects.
50 : */
51 : virtual void RepeatButtonScroll(nsScrollbarFrame* aScrollbar) = 0;
52 : /**
53 : * aOldPos and aNewPos are scroll positions.
54 : * The scroll positions start with zero at the left edge; implementors that want
55 : * zero at the right edge for RTL content will need to adjust accordingly.
56 : * (See ScrollFrameHelper::ThumbMoved in nsGfxScrollFrame.cpp.)
57 : * @note This method might destroy the frame, pres shell, and other objects.
58 : */
59 : virtual void ThumbMoved(nsScrollbarFrame* aScrollbar,
60 : nscoord aOldPos,
61 : nscoord aNewPos) = 0;
62 : /**
63 : * Called when the scroll bar thumb, slider, or any other component is
64 : * released.
65 : */
66 : virtual void ScrollbarReleased(nsScrollbarFrame* aScrollbar) = 0;
67 : virtual void VisibilityChanged(bool aVisible) = 0;
68 :
69 : /**
70 : * Obtain the frame for the horizontal or vertical scrollbar, or null
71 : * if there is no such box.
72 : */
73 : virtual nsIFrame* GetScrollbarBox(bool aVertical) = 0;
74 : /**
75 : * Show or hide scrollbars on 2 fingers touch.
76 : * Subclasses should call their ScrollbarActivity's corresponding methods.
77 : */
78 : virtual void ScrollbarActivityStarted() const = 0;
79 : virtual void ScrollbarActivityStopped() const = 0;
80 :
81 : virtual bool IsScrollbarOnRight() const = 0;
82 :
83 : /**
84 : * Returns true if the mediator is asking the scrollbar to suppress
85 : * repainting itself on changes.
86 : */
87 : virtual bool ShouldSuppressScrollbarRepaints() const = 0;
88 : };
89 :
90 : #endif
91 :
|