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 : //
7 : // nsScrollbarFrame
8 : //
9 :
10 : #ifndef nsScrollbarFrame_h__
11 : #define nsScrollbarFrame_h__
12 :
13 : #include "mozilla/Attributes.h"
14 : #include "nsBoxFrame.h"
15 :
16 : class nsIScrollbarMediator;
17 :
18 : nsIFrame* NS_NewScrollbarFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
19 :
20 0 : class nsScrollbarFrame final : public nsBoxFrame
21 : {
22 : public:
23 4 : explicit nsScrollbarFrame(nsStyleContext* aContext)
24 4 : : nsBoxFrame(aContext, kClassID)
25 : , mIncrement(0)
26 : , mSmoothScroll(false)
27 4 : , mScrollbarMediator(nullptr)
28 4 : {}
29 :
30 : NS_DECL_QUERYFRAME
31 18 : NS_DECL_FRAMEARENA_HELPERS(nsScrollbarFrame)
32 :
33 : #ifdef DEBUG_FRAME_DUMP
34 0 : virtual nsresult GetFrameName(nsAString& aResult) const override {
35 0 : return MakeFrameName(NS_LITERAL_STRING("ScrollbarFrame"), aResult);
36 : }
37 : #endif
38 :
39 : // nsIFrame overrides
40 : virtual nsresult AttributeChanged(int32_t aNameSpaceID,
41 : nsIAtom* aAttribute,
42 : int32_t aModType) override;
43 :
44 : NS_IMETHOD HandlePress(nsPresContext* aPresContext,
45 : mozilla::WidgetGUIEvent* aEvent,
46 : nsEventStatus* aEventStatus) override;
47 :
48 : NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext,
49 : mozilla::WidgetGUIEvent* aEvent,
50 : nsEventStatus* aEventStatus,
51 : bool aControlHeld) override;
52 :
53 : NS_IMETHOD HandleDrag(nsPresContext* aPresContext,
54 : mozilla::WidgetGUIEvent* aEvent,
55 : nsEventStatus* aEventStatus) override;
56 :
57 : NS_IMETHOD HandleRelease(nsPresContext* aPresContext,
58 : mozilla::WidgetGUIEvent* aEvent,
59 : nsEventStatus* aEventStatus) override;
60 :
61 : virtual void Init(nsIContent* aContent,
62 : nsContainerFrame* aParent,
63 : nsIFrame* aPrevInFlow) override;
64 :
65 : virtual void Reflow(nsPresContext* aPresContext,
66 : ReflowOutput& aDesiredSize,
67 : const ReflowInput& aReflowInput,
68 : nsReflowStatus& aStatus) override;
69 :
70 : void SetScrollbarMediatorContent(nsIContent* aMediator);
71 : nsIScrollbarMediator* GetScrollbarMediator();
72 :
73 : // nsBox methods
74 :
75 : /**
76 : * Treat scrollbars as clipping their children; overflowing children
77 : * will not be allowed to set an overflow rect on this
78 : * frame. This means that when the scroll code decides to hide a
79 : * scrollframe by setting its height or width to zero, that will
80 : * hide the children too.
81 : */
82 10 : virtual bool DoesClipChildren() override { return true; }
83 :
84 : virtual nsresult GetXULMargin(nsMargin& aMargin) override;
85 :
86 : /**
87 : * The following three methods set the value of mIncrement when a
88 : * scrollbar button is pressed.
89 : */
90 : void SetIncrementToLine(int32_t aDirection);
91 : void SetIncrementToPage(int32_t aDirection);
92 : void SetIncrementToWhole(int32_t aDirection);
93 : /**
94 : * MoveToNewPosition() adds mIncrement to the current position and
95 : * updates the curpos attribute.
96 : * @returns The new position after clamping, in CSS Pixels
97 : * @note This method might destroy the frame, pres shell, and other objects.
98 : */
99 : int32_t MoveToNewPosition();
100 0 : int32_t GetIncrement() { return mIncrement; }
101 :
102 : protected:
103 : int32_t mIncrement; // Amount to scroll, in CSSPixels
104 : bool mSmoothScroll;
105 :
106 : private:
107 : nsCOMPtr<nsIContent> mScrollbarMediator;
108 : }; // class nsScrollbarFrame
109 :
110 : #endif
|