nsIScrollbarMediator.h 3.4 KB

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