2005-08-20 11:11:56 +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:11:56 +04:00
|
|
|
|
2013-12-16 04:00:54 +04:00
|
|
|
#ifndef nsNativeThemeWin_h
|
|
|
|
#define nsNativeThemeWin_h
|
|
|
|
|
2005-08-20 11:11:56 +04:00
|
|
|
#include "nsITheme.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2017-10-03 01:05:19 +03:00
|
|
|
#include "nsAtom.h"
|
2005-08-20 11:14:03 +04:00
|
|
|
#include "nsNativeTheme.h"
|
2017-06-21 23:43:27 +03:00
|
|
|
#include "nsThemeConstants.h"
|
|
|
|
#include "nsUXThemeConstants.h"
|
|
|
|
#include "nsUXThemeData.h"
|
2013-02-25 04:27:22 +04:00
|
|
|
#include "gfxTypes.h"
|
2005-08-20 11:11:56 +04:00
|
|
|
#include <windows.h>
|
2017-06-21 23:43:27 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
2013-02-25 04:27:10 +04:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2015-03-29 17:59:08 +03:00
|
|
|
#include "nsSize.h"
|
2005-08-20 11:11:56 +04:00
|
|
|
|
2005-08-20 11:14:03 +04:00
|
|
|
class nsNativeThemeWin : private nsNativeTheme,
|
|
|
|
public nsITheme {
|
2014-07-16 00:37:58 +04:00
|
|
|
virtual ~nsNativeThemeWin();
|
|
|
|
|
2005-08-20 11:11:56 +04:00
|
|
|
public:
|
2013-02-25 04:27:10 +04:00
|
|
|
typedef mozilla::TimeStamp TimeStamp;
|
|
|
|
typedef mozilla::TimeDuration TimeDuration;
|
|
|
|
|
2010-11-13 11:19:38 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2005-08-20 11:11:56 +04:00
|
|
|
|
|
|
|
// The nsITheme interface.
|
2017-06-09 22:14:53 +03:00
|
|
|
NS_IMETHOD DrawWidgetBackground(gfxContext* aContext,
|
2005-08-20 11:11:56 +04:00
|
|
|
nsIFrame* aFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aWidgetType,
|
2005-08-20 11:11:56 +04:00
|
|
|
const nsRect& aRect,
|
2015-12-16 19:58:46 +03:00
|
|
|
const nsRect& aDirtyRect) override;
|
2005-08-20 11:11:56 +04:00
|
|
|
|
2018-05-14 04:05:28 +03:00
|
|
|
nscolor GetWidgetAutoColor(mozilla::ComputedStyle* aStyle,
|
|
|
|
uint8_t aWidgetType) override;
|
|
|
|
|
2018-06-02 20:10:48 +03:00
|
|
|
MOZ_MUST_USE LayoutDeviceIntMargin GetWidgetBorder(nsDeviceContext* aContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
uint8_t aWidgetType) override;
|
2005-08-20 11:11:56 +04:00
|
|
|
|
2018-05-17 18:30:35 +03:00
|
|
|
bool GetWidgetPadding(nsDeviceContext* aContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
uint8_t aWidgetType,
|
2018-06-02 20:10:48 +03:00
|
|
|
LayoutDeviceIntMargin* aResult) override;
|
2005-08-20 11:14:07 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool GetWidgetOverflow(nsDeviceContext* aContext,
|
2008-02-29 08:10:12 +03:00
|
|
|
nsIFrame* aFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aWidgetType,
|
2015-12-16 19:58:46 +03:00
|
|
|
nsRect* aOverflowRect) override;
|
2008-02-29 08:10:12 +03:00
|
|
|
|
2014-06-27 13:19:00 +04:00
|
|
|
NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aWidgetType,
|
2015-03-30 18:36:14 +03:00
|
|
|
mozilla::LayoutDeviceIntSize* aResult,
|
2015-12-16 19:58:46 +03:00
|
|
|
bool* aIsOverridable) override;
|
2005-08-20 11:11:56 +04:00
|
|
|
|
2015-12-16 19:58:46 +03:00
|
|
|
virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) override;
|
2008-12-11 17:37:38 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute, bool* aShouldRepaint,
|
2016-04-21 02:49:09 +03:00
|
|
|
const nsAttrValue* aOldValue) override;
|
2005-08-20 11:11:56 +04:00
|
|
|
|
2015-12-16 19:58:46 +03:00
|
|
|
NS_IMETHOD ThemeChanged() override;
|
2005-08-20 11:11:56 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool ThemeSupportsWidget(nsPresContext* aPresContext,
|
2005-08-20 11:12:55 +04:00
|
|
|
nsIFrame* aFrame,
|
2015-12-16 19:58:46 +03:00
|
|
|
uint8_t aWidgetType) override;
|
2005-08-20 11:11:56 +04:00
|
|
|
|
2015-12-16 19:58:46 +03:00
|
|
|
bool WidgetIsContainer(uint8_t aWidgetType) override;
|
2005-08-20 11:12:07 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
bool ThemeDrawsFocusForWidget(uint8_t aWidgetType) override;
|
2007-02-16 04:53:43 +03:00
|
|
|
|
2015-12-16 19:58:46 +03:00
|
|
|
bool ThemeNeedsComboboxDropmarker() override;
|
2007-05-18 07:04:04 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType) override;
|
2013-09-27 19:24:32 +04:00
|
|
|
|
2015-02-05 01:25:18 +03:00
|
|
|
enum {
|
|
|
|
eThemeGeometryTypeWindowButtons = eThemeGeometryTypeUnknown + 1
|
|
|
|
};
|
|
|
|
virtual ThemeGeometryType ThemeGeometryTypeForWidget(nsIFrame* aFrame,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint8_t aWidgetType) override;
|
2015-02-05 01:25:18 +03:00
|
|
|
|
2005-08-20 11:11:56 +04:00
|
|
|
nsNativeThemeWin();
|
|
|
|
|
|
|
|
protected:
|
2017-06-21 23:43:27 +03:00
|
|
|
mozilla::Maybe<nsUXThemeClass> GetThemeClass(uint8_t aWidgetType);
|
2012-08-22 19:56:38 +04:00
|
|
|
HANDLE GetTheme(uint8_t aWidgetType);
|
|
|
|
nsresult GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
|
|
|
|
int32_t& aPart, int32_t& aState);
|
|
|
|
nsresult ClassicGetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
|
2013-02-25 04:27:10 +04:00
|
|
|
int32_t& aPart, int32_t& aState, bool& aFocused);
|
2017-06-09 22:14:53 +03:00
|
|
|
nsresult ClassicDrawWidgetBackground(gfxContext* aContext,
|
2013-02-25 04:27:10 +04:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
uint8_t aWidgetType,
|
|
|
|
const nsRect& aRect,
|
|
|
|
const nsRect& aClipRect);
|
2018-06-02 20:10:48 +03:00
|
|
|
MOZ_MUST_USE LayoutDeviceIntMargin ClassicGetWidgetBorder(nsDeviceContext* aContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
uint8_t aWidgetType);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool ClassicGetWidgetPadding(nsDeviceContext* aContext,
|
2013-02-25 04:27:10 +04:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
uint8_t aWidgetType,
|
2018-06-02 20:10:48 +03:00
|
|
|
LayoutDeviceIntMargin* aResult);
|
2015-12-07 04:15:53 +03:00
|
|
|
nsresult ClassicGetMinimumWidgetSize(nsIFrame* aFrame, uint8_t aWidgetType,
|
2015-03-30 18:36:14 +03:00
|
|
|
mozilla::LayoutDeviceIntSize* aResult,
|
2013-02-25 04:27:10 +04:00
|
|
|
bool* aIsOverridable);
|
2015-12-07 04:15:53 +03:00
|
|
|
bool ClassicThemeSupportsWidget(nsIFrame* aFrame, uint8_t aWidgetType);
|
2012-08-22 19:56:38 +04:00
|
|
|
void DrawCheckedRect(HDC hdc, const RECT& rc, int32_t fore, int32_t back,
|
2006-05-30 17:50:48 +04:00
|
|
|
HBRUSH defaultBack);
|
2018-05-14 04:05:28 +03:00
|
|
|
nsresult DrawCustomScrollbarPart(gfxContext* aContext,
|
|
|
|
nsIFrame* aFrame,
|
2018-05-24 09:34:58 +03:00
|
|
|
mozilla::ComputedStyle* aStyle,
|
2018-05-14 04:05:28 +03:00
|
|
|
uint8_t aWidgetType,
|
|
|
|
const nsRect& aRect,
|
|
|
|
const nsRect& aClipRect);
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t GetWidgetNativeDrawingFlags(uint8_t aWidgetType);
|
|
|
|
int32_t StandardGetState(nsIFrame* aFrame, uint8_t aWidgetType, bool wantFocused);
|
|
|
|
bool IsMenuActive(nsIFrame* aFrame, uint8_t aWidgetType);
|
2013-02-25 04:27:10 +04:00
|
|
|
RECT CalculateProgressOverlayRect(nsIFrame* aFrame, RECT* aWidgetRect,
|
|
|
|
bool aIsVertical, bool aIsIndeterminate,
|
|
|
|
bool aIsClassic);
|
2013-02-25 04:27:22 +04:00
|
|
|
void DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType,
|
|
|
|
HANDLE aTheme, HDC aHdc,
|
|
|
|
int aPart, int aState,
|
2016-12-23 05:13:31 +03:00
|
|
|
RECT* aWidgetRect, RECT* aClipRect);
|
2013-02-25 04:27:10 +04:00
|
|
|
|
2018-06-02 20:10:48 +03:00
|
|
|
MOZ_MUST_USE LayoutDeviceIntMargin GetCachedWidgetBorder(HANDLE aTheme,
|
|
|
|
nsUXThemeClass aThemeClass,
|
|
|
|
uint8_t aWidgetType,
|
|
|
|
int32_t aPart,
|
|
|
|
int32_t aState);
|
2017-06-21 23:43:27 +03:00
|
|
|
|
2017-06-22 23:19:13 +03:00
|
|
|
nsresult GetCachedMinimumWidgetSize(nsIFrame* aFrame, HANDLE aTheme, nsUXThemeClass aThemeClass,
|
|
|
|
uint8_t aWidgetType, int32_t aPart, int32_t aState,
|
|
|
|
THEMESIZE aSizeReq, mozilla::LayoutDeviceIntSize* aResult);
|
|
|
|
|
2017-09-06 00:40:00 +03:00
|
|
|
SIZE GetCachedGutterSize(HANDLE theme);
|
|
|
|
|
2013-02-25 04:27:10 +04:00
|
|
|
private:
|
|
|
|
TimeStamp mProgressDeterminateTimeStamp;
|
|
|
|
TimeStamp mProgressIndeterminateTimeStamp;
|
2017-06-21 23:43:27 +03:00
|
|
|
|
|
|
|
// eUXNumClasses * THEME_PART_DISTINCT_VALUE_COUNT is about 800 at the time of writing
|
|
|
|
// this, and nsIntMargin is 16 bytes wide, which makes this cache (1/8 + 16) * 800
|
|
|
|
// bytes, or about ~12KB. We could probably reduce this cache to 3KB by caching on
|
|
|
|
// the aWidgetType value instead, but there would be some uncacheable values, since
|
|
|
|
// we derive some theme parts from other arguments.
|
|
|
|
uint8_t mBorderCacheValid[(eUXNumClasses * THEME_PART_DISTINCT_VALUE_COUNT + 7) / 8];
|
2018-06-02 20:10:48 +03:00
|
|
|
LayoutDeviceIntMargin mBorderCache[eUXNumClasses * THEME_PART_DISTINCT_VALUE_COUNT];
|
2017-06-22 23:19:13 +03:00
|
|
|
|
|
|
|
// See the above not for mBorderCache and friends. However mozilla::LayoutDeviceIntSize
|
|
|
|
// is half the size of nsIntMargin, making the cache roughly half as large. In total
|
|
|
|
// the caches should come to about 18KB.
|
|
|
|
uint8_t mMinimumWidgetSizeCacheValid[(eUXNumClasses * THEME_PART_DISTINCT_VALUE_COUNT + 7) / 8];
|
|
|
|
mozilla::LayoutDeviceIntSize mMinimumWidgetSizeCache[eUXNumClasses * THEME_PART_DISTINCT_VALUE_COUNT];
|
2017-09-06 00:40:00 +03:00
|
|
|
|
|
|
|
bool mGutterSizeCacheValid;
|
|
|
|
SIZE mGutterSizeCache;
|
2005-08-20 11:11:56 +04:00
|
|
|
};
|
2013-12-16 04:00:54 +04:00
|
|
|
|
|
|
|
#endif
|