2005-08-20 11:13:18 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2005-08-20 11:13:18 +04:00
|
|
|
|
|
|
|
// This defines a common base class for nsITheme implementations, to reduce
|
|
|
|
// code duplication.
|
|
|
|
|
2017-09-21 00:46:03 +03:00
|
|
|
#ifndef _NSNATIVETHEME_H_
|
|
|
|
#define _NSNATIVETHEME_H_
|
|
|
|
|
2011-06-02 16:56:50 +04:00
|
|
|
#include "nsAlgorithm.h"
|
2017-10-03 01:05:19 +03:00
|
|
|
#include "nsAtom.h"
|
2005-08-20 11:13:18 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsMargin.h"
|
2011-10-14 22:11:22 +04:00
|
|
|
#include "nsGkAtoms.h"
|
2010-11-13 11:19:38 +03:00
|
|
|
#include "nsTArray.h"
|
2017-07-26 21:18:20 +03:00
|
|
|
#include "nsINamed.h"
|
2010-11-13 11:19:38 +03:00
|
|
|
#include "nsITimer.h"
|
2013-03-26 00:24:14 +04:00
|
|
|
#include "nsIContent.h"
|
2005-08-20 11:13:18 +04:00
|
|
|
|
|
|
|
class nsIFrame;
|
|
|
|
class nsIPresShell;
|
2005-08-20 11:14:04 +04:00
|
|
|
class nsPresContext;
|
2005-08-20 11:13:18 +04:00
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
namespace mozilla {
|
2018-06-21 09:32:17 +03:00
|
|
|
class ComputedStyle;
|
2018-07-25 16:03:45 +03:00
|
|
|
enum class StyleAppearance : uint8_t;
|
2014-04-03 08:18:36 +04:00
|
|
|
class EventStates;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2017-07-26 21:18:20 +03:00
|
|
|
class nsNativeTheme : public nsITimerCallback, public nsINamed
|
2005-08-20 11:13:18 +04:00
|
|
|
{
|
2012-03-07 19:29:42 +04:00
|
|
|
protected:
|
2014-06-24 20:36:44 +04:00
|
|
|
virtual ~nsNativeTheme() {}
|
2012-03-07 19:29:21 +04:00
|
|
|
|
2010-11-13 11:19:38 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSITIMERCALLBACK
|
2017-07-26 21:18:20 +03:00
|
|
|
NS_DECL_NSINAMED
|
2010-11-13 11:19:38 +03:00
|
|
|
|
2008-01-13 07:13:50 +03:00
|
|
|
enum ScrollbarButtonType {
|
|
|
|
eScrollbarButton_UpTop = 0,
|
|
|
|
eScrollbarButton_Down = 1 << 0,
|
|
|
|
eScrollbarButton_Bottom = 1 << 1
|
|
|
|
};
|
|
|
|
|
2005-08-20 11:14:25 +04:00
|
|
|
enum TreeSortDirection {
|
|
|
|
eTreeSortDirection_Descending,
|
|
|
|
eTreeSortDirection_Natural,
|
|
|
|
eTreeSortDirection_Ascending
|
|
|
|
};
|
|
|
|
|
2005-08-20 11:13:18 +04:00
|
|
|
nsNativeTheme();
|
|
|
|
|
2014-04-01 08:09:23 +04:00
|
|
|
// Returns the content state (hover, focus, etc), see EventStateManager.h
|
2018-07-25 16:03:45 +03:00
|
|
|
mozilla::EventStates GetContentState(nsIFrame* aFrame,
|
|
|
|
mozilla::StyleAppearance aWidgetType);
|
2005-08-20 11:13:18 +04:00
|
|
|
|
|
|
|
// Returns whether the widget is already styled by content
|
|
|
|
// Normally called from ThemeSupportsWidget to turn off native theming
|
|
|
|
// for elements that are already styled.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame,
|
2018-07-25 16:03:45 +03:00
|
|
|
mozilla::StyleAppearance aWidgetType);
|
2005-08-20 11:13:18 +04:00
|
|
|
|
|
|
|
// Accessors to widget-specific state information
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
bool IsDisabled(nsIFrame* aFrame, mozilla::EventStates aEventStates);
|
2010-09-28 05:25:18 +04:00
|
|
|
|
2008-11-28 01:14:54 +03:00
|
|
|
// RTL chrome direction
|
2016-10-20 07:57:55 +03:00
|
|
|
static bool IsFrameRTL(nsIFrame* aFrame);
|
2008-11-28 01:14:54 +03:00
|
|
|
|
2013-02-25 04:16:02 +04:00
|
|
|
bool IsHTMLContent(nsIFrame *aFrame);
|
|
|
|
|
2005-08-20 11:13:18 +04:00
|
|
|
// button:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsDefaultButton(nsIFrame* aFrame) {
|
2011-10-14 22:11:22 +04:00
|
|
|
return CheckBooleanAttr(aFrame, nsGkAtoms::_default);
|
2005-08-20 11:13:18 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsButtonTypeMenu(nsIFrame* aFrame);
|
2009-08-11 01:23:50 +04:00
|
|
|
|
2005-08-20 11:13:18 +04:00
|
|
|
// checkbox:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsChecked(nsIFrame* aFrame) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return GetCheckedOrSelected(aFrame, false);
|
2005-08-20 11:13:18 +04:00
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:19 +04:00
|
|
|
// radiobutton:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsSelected(nsIFrame* aFrame) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return GetCheckedOrSelected(aFrame, true);
|
2005-08-20 11:13:18 +04:00
|
|
|
}
|
2013-02-25 04:16:02 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsFocused(nsIFrame* aFrame) {
|
2011-10-14 22:11:22 +04:00
|
|
|
return CheckBooleanAttr(aFrame, nsGkAtoms::focused);
|
2005-08-20 11:13:20 +04:00
|
|
|
}
|
2013-02-25 04:16:02 +04:00
|
|
|
|
2008-01-13 07:13:50 +03:00
|
|
|
// scrollbar button:
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t GetScrollbarButtonType(nsIFrame* aFrame);
|
2005-08-20 11:13:18 +04:00
|
|
|
|
2005-08-20 11:13:19 +04:00
|
|
|
// tab:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsSelectedTab(nsIFrame* aFrame) {
|
2015-03-16 21:30:41 +03:00
|
|
|
return CheckBooleanAttr(aFrame, nsGkAtoms::visuallyselected);
|
2005-08-20 11:13:19 +04:00
|
|
|
}
|
2008-11-28 01:16:13 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
bool IsNextToSelectedTab(nsIFrame* aFrame, int32_t aOffset);
|
2011-08-08 19:38:57 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsBeforeSelectedTab(nsIFrame* aFrame) {
|
2011-08-08 19:38:57 +04:00
|
|
|
return IsNextToSelectedTab(aFrame, -1);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsAfterSelectedTab(nsIFrame* aFrame) {
|
2011-08-08 19:38:57 +04:00
|
|
|
return IsNextToSelectedTab(aFrame, 1);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsLeftToSelectedTab(nsIFrame* aFrame) {
|
2011-08-08 19:38:57 +04:00
|
|
|
return IsFrameRTL(aFrame) ? IsAfterSelectedTab(aFrame) : IsBeforeSelectedTab(aFrame);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsRightToSelectedTab(nsIFrame* aFrame) {
|
2011-08-08 19:38:57 +04:00
|
|
|
return IsFrameRTL(aFrame) ? IsBeforeSelectedTab(aFrame) : IsAfterSelectedTab(aFrame);
|
|
|
|
}
|
|
|
|
|
2009-03-13 15:23:26 +03:00
|
|
|
// button / toolbarbutton:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsCheckedButton(nsIFrame* aFrame) {
|
2011-10-14 22:11:22 +04:00
|
|
|
return CheckBooleanAttr(aFrame, nsGkAtoms::checked);
|
2005-08-20 11:14:26 +04:00
|
|
|
}
|
2008-01-13 07:13:50 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsSelectedButton(nsIFrame* aFrame) {
|
2011-10-14 22:11:22 +04:00
|
|
|
return CheckBooleanAttr(aFrame, nsGkAtoms::checked) ||
|
|
|
|
CheckBooleanAttr(aFrame, nsGkAtoms::selected);
|
2011-08-08 18:42:45 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsOpenButton(nsIFrame* aFrame) {
|
2011-10-14 22:11:22 +04:00
|
|
|
return CheckBooleanAttr(aFrame, nsGkAtoms::open);
|
2009-03-13 15:23:26 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsPressedButton(nsIFrame* aFrame);
|
2011-08-08 18:42:45 +04:00
|
|
|
|
2005-08-20 11:13:18 +04:00
|
|
|
// treeheadercell:
|
2006-06-09 10:02:30 +04:00
|
|
|
TreeSortDirection GetTreeSortDirection(nsIFrame* aFrame);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsLastTreeHeaderCell(nsIFrame* aFrame);
|
2005-08-20 11:13:18 +04:00
|
|
|
|
|
|
|
// tab:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsBottomTab(nsIFrame* aFrame);
|
|
|
|
bool IsFirstTab(nsIFrame* aFrame);
|
2007-12-21 14:17:01 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsHorizontal(nsIFrame* aFrame);
|
2005-08-20 11:13:18 +04:00
|
|
|
|
|
|
|
// progressbar:
|
2014-04-03 08:18:36 +04:00
|
|
|
bool IsIndeterminateProgress(nsIFrame* aFrame,
|
|
|
|
mozilla::EventStates aEventStates);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsVerticalProgress(nsIFrame* aFrame);
|
Back out bug 514437, bug 567872, bug 568825, bug 633209, bug 633913, bug 634086, bug 634088, bug 634549, bug 634551, bug 638176, bug 641517, bug 641905, bug 641942, bug 642127, and bug 642667 to undo the performance regression tracked by bug 655860.
2011-05-10 02:48:39 +04:00
|
|
|
|
2012-06-06 11:58:00 +04:00
|
|
|
// meter:
|
|
|
|
bool IsVerticalMeter(nsIFrame* aFrame);
|
|
|
|
|
2005-08-20 11:13:18 +04:00
|
|
|
// textfield:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsReadOnly(nsIFrame* aFrame) {
|
2011-10-14 22:11:22 +04:00
|
|
|
return CheckBooleanAttr(aFrame, nsGkAtoms::readonly);
|
2005-08-20 11:13:18 +04:00
|
|
|
}
|
2005-08-20 11:14:11 +04:00
|
|
|
|
2009-01-12 22:23:51 +03:00
|
|
|
// menupopup:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsSubmenu(nsIFrame* aFrame, bool* aLeftOfParent);
|
2009-01-12 22:23:51 +03:00
|
|
|
|
2011-06-25 01:00:46 +04:00
|
|
|
// True if it's not a menubar item or menulist item
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsRegularMenuItem(nsIFrame *aFrame);
|
2011-06-25 01:00:46 +04:00
|
|
|
|
2005-08-20 11:14:11 +04:00
|
|
|
nsIPresShell *GetPresShell(nsIFrame* aFrame);
|
2017-10-03 01:05:19 +03:00
|
|
|
static bool CheckBooleanAttr(nsIFrame* aFrame, nsAtom* aAtom);
|
|
|
|
static int32_t CheckIntAttr(nsIFrame* aFrame, nsAtom* aAtom, int32_t defaultValue);
|
2013-02-25 04:26:07 +04:00
|
|
|
|
|
|
|
// Helpers for progressbar.
|
|
|
|
static double GetProgressValue(nsIFrame* aFrame);
|
|
|
|
static double GetProgressMaxValue(nsIFrame* aFrame);
|
2005-08-20 11:14:11 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool GetCheckedOrSelected(nsIFrame* aFrame, bool aCheckSelected);
|
|
|
|
bool GetIndeterminate(nsIFrame* aFrame);
|
2010-11-13 11:19:38 +03:00
|
|
|
|
2012-03-07 19:29:21 +04:00
|
|
|
bool QueueAnimatedContentForRefresh(nsIContent* aContent,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aMinimumFrameRate);
|
2012-03-07 19:29:21 +04:00
|
|
|
|
2012-03-08 05:15:57 +04:00
|
|
|
nsIFrame* GetAdjacentSiblingFrameWithSameAppearance(nsIFrame* aFrame,
|
|
|
|
bool aNextSibling);
|
2012-03-07 19:29:21 +04:00
|
|
|
|
2013-03-16 09:40:15 +04:00
|
|
|
bool IsRangeHorizontal(nsIFrame* aFrame);
|
|
|
|
|
2013-05-19 19:01:28 +04:00
|
|
|
// scrollbar
|
|
|
|
bool IsDarkBackground(nsIFrame* aFrame);
|
2018-06-21 09:32:17 +03:00
|
|
|
// custom scrollbar
|
|
|
|
typedef nscolor (*AutoColorGetter)(mozilla::ComputedStyle*);
|
2018-07-25 16:03:45 +03:00
|
|
|
bool IsWidgetScrollbarPart(mozilla::StyleAppearance aWidgetType);
|
2018-06-21 09:32:17 +03:00
|
|
|
nscolor GetScrollbarFaceColor(mozilla::ComputedStyle* aStyle,
|
|
|
|
AutoColorGetter aAutoGetter);
|
|
|
|
nscolor GetScrollbarTrackColor(mozilla::ComputedStyle* aStyle,
|
|
|
|
AutoColorGetter aAutoGetter);
|
2013-05-19 19:01:28 +04:00
|
|
|
|
2010-11-13 11:19:38 +03:00
|
|
|
private:
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mAnimatedContentTimeout;
|
2010-11-13 11:19:38 +03:00
|
|
|
nsCOMPtr<nsITimer> mAnimatedContentTimer;
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<nsCOMPtr<nsIContent>, 20> mAnimatedContentList;
|
2005-08-20 11:13:18 +04:00
|
|
|
};
|
2017-09-21 00:46:03 +03:00
|
|
|
|
|
|
|
#endif // _NSNATIVETHEME_H_
|