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
9 #include "nsAlgorithm.h"
14 #include "nsGkAtoms.h"
17 #include "nsIContent.h"
25 } // namespace mozilla
27 class nsNativeTheme
: public nsITimerCallback
30 virtual ~nsNativeTheme() {}
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
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
,
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
);
68 bool IsDefaultButton(nsIFrame
* aFrame
) {
69 return CheckBooleanAttr(aFrame
, nsGkAtoms::_default
);
72 bool IsButtonTypeMenu(nsIFrame
* aFrame
);
75 bool IsChecked(nsIFrame
* aFrame
) {
76 return GetCheckedOrSelected(aFrame
, false);
80 bool IsSelected(nsIFrame
* aFrame
) {
81 return GetCheckedOrSelected(aFrame
, true);
84 bool IsFocused(nsIFrame
* aFrame
) {
85 return CheckBooleanAttr(aFrame
, nsGkAtoms::focused
);
89 int32_t GetScrollbarButtonType(nsIFrame
* aFrame
);
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
);
131 TreeSortDirection
GetTreeSortDirection(nsIFrame
* aFrame
);
132 bool IsLastTreeHeaderCell(nsIFrame
* aFrame
);
135 bool IsBottomTab(nsIFrame
* aFrame
);
136 bool IsFirstTab(nsIFrame
* aFrame
);
138 bool IsHorizontal(nsIFrame
* aFrame
);
141 bool IsIndeterminateProgress(nsIFrame
* aFrame
,
142 mozilla::EventStates aEventStates
);
143 bool IsVerticalProgress(nsIFrame
* aFrame
);
146 bool IsVerticalMeter(nsIFrame
* aFrame
);
149 bool IsReadOnly(nsIFrame
* aFrame
) {
150 return CheckBooleanAttr(aFrame
, nsGkAtoms::readonly
);
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
,
178 bool IsRangeHorizontal(nsIFrame
* aFrame
);
181 bool IsDarkBackground(nsIFrame
* aFrame
);
184 uint32_t mAnimatedContentTimeout
;
185 nsCOMPtr
<nsITimer
> mAnimatedContentTimer
;
186 nsAutoTArray
<nsCOMPtr
<nsIContent
>, 20> mAnimatedContentList
;