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