Bug 1073336 part 12 - Add AnimationPlayer::GetCollection(); r=dbaron
[gecko.git] / widget / nsNativeTheme.h
blob3fb0ee5bcd0d2d7baaac248a01eedfac7ad79791
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/. */
6 // This defines a common base class for nsITheme implementations, to reduce
7 // code duplication.
9 #include "nsAlgorithm.h"
10 #include "nsIAtom.h"
11 #include "nsCOMPtr.h"
12 #include "nsString.h"
13 #include "nsMargin.h"
14 #include "nsGkAtoms.h"
15 #include "nsTArray.h"
16 #include "nsITimer.h"
17 #include "nsIContent.h"
19 class nsIFrame;
20 class nsIPresShell;
21 class nsPresContext;
23 namespace mozilla {
24 class EventStates;
25 } // namespace mozilla
27 class nsNativeTheme : public nsITimerCallback
29 protected:
30 virtual ~nsNativeTheme() {}
32 NS_DECL_ISUPPORTS
33 NS_DECL_NSITIMERCALLBACK
35 enum ScrollbarButtonType {
36 eScrollbarButton_UpTop = 0,
37 eScrollbarButton_Down = 1 << 0,
38 eScrollbarButton_Bottom = 1 << 1
41 enum TreeSortDirection {
42 eTreeSortDirection_Descending,
43 eTreeSortDirection_Natural,
44 eTreeSortDirection_Ascending
47 nsNativeTheme();
49 // Returns the content state (hover, focus, etc), see EventStateManager.h
50 mozilla::EventStates GetContentState(nsIFrame* aFrame, uint8_t aWidgetType);
52 // Returns whether the widget is already styled by content
53 // Normally called from ThemeSupportsWidget to turn off native theming
54 // for elements that are already styled.
55 bool IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame,
56 uint8_t aWidgetType);
58 // Accessors to widget-specific state information
60 bool IsDisabled(nsIFrame* aFrame, mozilla::EventStates aEventStates);
62 // RTL chrome direction
63 bool IsFrameRTL(nsIFrame* aFrame);
65 bool IsHTMLContent(nsIFrame *aFrame);
67 // button:
68 bool IsDefaultButton(nsIFrame* aFrame) {
69 return CheckBooleanAttr(aFrame, nsGkAtoms::_default);
72 bool IsButtonTypeMenu(nsIFrame* aFrame);
74 // checkbox:
75 bool IsChecked(nsIFrame* aFrame) {
76 return GetCheckedOrSelected(aFrame, false);
79 // radiobutton:
80 bool IsSelected(nsIFrame* aFrame) {
81 return GetCheckedOrSelected(aFrame, true);
84 bool IsFocused(nsIFrame* aFrame) {
85 return CheckBooleanAttr(aFrame, nsGkAtoms::focused);
88 // scrollbar button:
89 int32_t GetScrollbarButtonType(nsIFrame* aFrame);
91 // tab:
92 bool IsSelectedTab(nsIFrame* aFrame) {
93 return CheckBooleanAttr(aFrame, nsGkAtoms::selected);
96 bool IsNextToSelectedTab(nsIFrame* aFrame, int32_t aOffset);
98 bool IsBeforeSelectedTab(nsIFrame* aFrame) {
99 return IsNextToSelectedTab(aFrame, -1);
102 bool IsAfterSelectedTab(nsIFrame* aFrame) {
103 return IsNextToSelectedTab(aFrame, 1);
106 bool IsLeftToSelectedTab(nsIFrame* aFrame) {
107 return IsFrameRTL(aFrame) ? IsAfterSelectedTab(aFrame) : IsBeforeSelectedTab(aFrame);
110 bool IsRightToSelectedTab(nsIFrame* aFrame) {
111 return IsFrameRTL(aFrame) ? IsBeforeSelectedTab(aFrame) : IsAfterSelectedTab(aFrame);
114 // button / toolbarbutton:
115 bool IsCheckedButton(nsIFrame* aFrame) {
116 return CheckBooleanAttr(aFrame, nsGkAtoms::checked);
119 bool IsSelectedButton(nsIFrame* aFrame) {
120 return CheckBooleanAttr(aFrame, nsGkAtoms::checked) ||
121 CheckBooleanAttr(aFrame, nsGkAtoms::selected);
124 bool IsOpenButton(nsIFrame* aFrame) {
125 return CheckBooleanAttr(aFrame, nsGkAtoms::open);
128 bool IsPressedButton(nsIFrame* aFrame);
130 // treeheadercell:
131 TreeSortDirection GetTreeSortDirection(nsIFrame* aFrame);
132 bool IsLastTreeHeaderCell(nsIFrame* aFrame);
134 // tab:
135 bool IsBottomTab(nsIFrame* aFrame);
136 bool IsFirstTab(nsIFrame* aFrame);
138 bool IsHorizontal(nsIFrame* aFrame);
140 // progressbar:
141 bool IsIndeterminateProgress(nsIFrame* aFrame,
142 mozilla::EventStates aEventStates);
143 bool IsVerticalProgress(nsIFrame* aFrame);
145 // meter:
146 bool IsVerticalMeter(nsIFrame* aFrame);
148 // textfield:
149 bool IsReadOnly(nsIFrame* aFrame) {
150 return CheckBooleanAttr(aFrame, nsGkAtoms::readonly);
153 // menupopup:
154 bool IsSubmenu(nsIFrame* aFrame, bool* aLeftOfParent);
156 // True if it's not a menubar item or menulist item
157 bool IsRegularMenuItem(nsIFrame *aFrame);
159 bool IsMenuListEditable(nsIFrame *aFrame);
161 nsIPresShell *GetPresShell(nsIFrame* aFrame);
162 static bool CheckBooleanAttr(nsIFrame* aFrame, nsIAtom* aAtom);
163 static int32_t CheckIntAttr(nsIFrame* aFrame, nsIAtom* aAtom, int32_t defaultValue);
165 // Helpers for progressbar.
166 static double GetProgressValue(nsIFrame* aFrame);
167 static double GetProgressMaxValue(nsIFrame* aFrame);
169 bool GetCheckedOrSelected(nsIFrame* aFrame, bool aCheckSelected);
170 bool GetIndeterminate(nsIFrame* aFrame);
172 bool QueueAnimatedContentForRefresh(nsIContent* aContent,
173 uint32_t aMinimumFrameRate);
175 nsIFrame* GetAdjacentSiblingFrameWithSameAppearance(nsIFrame* aFrame,
176 bool aNextSibling);
178 bool IsRangeHorizontal(nsIFrame* aFrame);
180 // scrollbar
181 bool IsDarkBackground(nsIFrame* aFrame);
183 private:
184 uint32_t mAnimatedContentTimeout;
185 nsCOMPtr<nsITimer> mAnimatedContentTimer;
186 nsAutoTArray<nsCOMPtr<nsIContent>, 20> mAnimatedContentList;