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 
9   Eric D Vaughan
10   This class lays out its children either vertically or horizontally
11 
12 **/
13 
14 #ifndef nsScrollbarButtonFrame_h___
15 #define nsScrollbarButtonFrame_h___
16 
17 #include "mozilla/Attributes.h"
18 #include "nsButtonBoxFrame.h"
19 #include "nsRepeatService.h"
20 
21 namespace mozilla {
22 class PresShell;
23 }  // namespace mozilla
24 
25 class nsScrollbarButtonFrame final : public nsButtonBoxFrame {
26  public:
NS_DECL_FRAMEARENA_HELPERS(nsScrollbarButtonFrame)27   NS_DECL_FRAMEARENA_HELPERS(nsScrollbarButtonFrame)
28 
29   explicit nsScrollbarButtonFrame(ComputedStyle* aStyle,
30                                   nsPresContext* aPresContext)
31       : nsButtonBoxFrame(aStyle, aPresContext, kClassID),
32         mCursorOnThis(false) {}
33 
34   // Overrides
35   virtual void DestroyFrom(nsIFrame* aDestructRoot,
36                            PostDestroyData& aPostDestroyData) override;
37 
38   friend nsIFrame* NS_NewScrollbarButtonFrame(mozilla::PresShell* aPresShell,
39                                               ComputedStyle* aStyle);
40 
41   virtual nsresult HandleEvent(nsPresContext* aPresContext,
42                                mozilla::WidgetGUIEvent* aEvent,
43                                nsEventStatus* aEventStatus) override;
44 
45   static nsresult GetChildWithTag(nsAtom* atom, nsIFrame* start,
46                                   nsIFrame*& result);
47   static nsresult GetParentWithTag(nsAtom* atom, nsIFrame* start,
48                                    nsIFrame*& result);
49 
50   bool HandleButtonPress(nsPresContext* aPresContext,
51                          mozilla::WidgetGUIEvent* aEvent,
52                          nsEventStatus* aEventStatus);
53 
HandleMultiplePress(nsPresContext * aPresContext,mozilla::WidgetGUIEvent * aEvent,nsEventStatus * aEventStatus,bool aControlHeld)54   NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext,
55                                  mozilla::WidgetGUIEvent* aEvent,
56                                  nsEventStatus* aEventStatus,
57                                  bool aControlHeld) override {
58     return NS_OK;
59   }
60 
61   MOZ_CAN_RUN_SCRIPT
HandleDrag(nsPresContext * aPresContext,mozilla::WidgetGUIEvent * aEvent,nsEventStatus * aEventStatus)62   NS_IMETHOD HandleDrag(nsPresContext* aPresContext,
63                         mozilla::WidgetGUIEvent* aEvent,
64                         nsEventStatus* aEventStatus) override {
65     return NS_OK;
66   }
67 
68   NS_IMETHOD HandleRelease(nsPresContext* aPresContext,
69                            mozilla::WidgetGUIEvent* aEvent,
70                            nsEventStatus* aEventStatus) override;
71 
72  protected:
StartRepeat()73   void StartRepeat() {
74     nsRepeatService::GetInstance()->Start(Notify, this, mContent->OwnerDoc(),
75                                           "nsScrollbarButtonFrame"_ns);
76   }
StopRepeat()77   void StopRepeat() { nsRepeatService::GetInstance()->Stop(Notify, this); }
78   void Notify();
Notify(void * aData)79   static void Notify(void* aData) {
80     static_cast<nsScrollbarButtonFrame*>(aData)->Notify();
81   }
82 
83   bool mCursorOnThis;
84 };
85 
86 #endif
87