gecko-dev/widget/gtk/nsLookAndFeel.h
Hiroyuki Ikezoe e538eea4dc Bug 1606503 - Move prefers-reduced-motion bits for testing into LookAndFeel. r=emilio
Now both of GTK and MacOSX backends use the same machinery, LookAndFeelInt, for
prefers-reduced-motion. And we are going to use it on Android as well so it'd
make sense to move the code into there.

On Windows we can also use the same LookAndFeelInt machinery and probably
all we have to do is to call SendNotifyMessage with SPI_SETCLIENTAREAANIMATION
in SetPrefersReducedMotionOverrideForTest.

Differential Revision: https://phabricator.services.mozilla.com/D59022

--HG--
extra : moz-landing-system : lando
2020-01-14 05:50:53 +00:00

114 lines
3.5 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* 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/. */
#ifndef __nsLookAndFeel
#define __nsLookAndFeel
#include "X11UndefineNone.h"
#include "nsXPLookAndFeel.h"
#include "nsCOMPtr.h"
#include "gfxFont.h"
struct _GtkStyle;
class nsLookAndFeel final : public nsXPLookAndFeel {
public:
nsLookAndFeel();
virtual ~nsLookAndFeel();
void NativeInit() final;
void RefreshImpl() override;
nsresult NativeGetColor(ColorID aID, nscolor& aResult) override;
nsresult GetIntImpl(IntID aID, int32_t& aResult) override;
nsresult GetFloatImpl(FloatID aID, float& aResult) override;
bool GetFontImpl(FontID aID, nsString& aFontName,
gfxFontStyle& aFontStyle) override;
char16_t GetPasswordCharacterImpl() override;
bool GetEchoPasswordImpl() override;
nsTArray<LookAndFeelInt> GetIntCacheImpl() override;
void SetIntCacheImpl(
const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) override;
bool IsCSDAvailable() const { return mCSDAvailable; }
static const nscolor kBlack = NS_RGB(0, 0, 0);
static const nscolor kWhite = NS_RGB(255, 255, 255);
protected:
// Cached fonts
bool mDefaultFontCached = false;
bool mButtonFontCached = false;
bool mFieldFontCached = false;
bool mMenuFontCached = false;
nsString mDefaultFontName;
nsString mButtonFontName;
nsString mFieldFontName;
nsString mMenuFontName;
gfxFontStyle mDefaultFontStyle;
gfxFontStyle mButtonFontStyle;
gfxFontStyle mFieldFontStyle;
gfxFontStyle mMenuFontStyle;
// Cached colors
nscolor mInfoBackground = kWhite;
nscolor mInfoText = kBlack;
nscolor mMenuBackground = kWhite;
nscolor mMenuBarText = kBlack;
nscolor mMenuBarHoverText = kBlack;
nscolor mMenuText = kBlack;
nscolor mMenuTextInactive = kWhite;
nscolor mMenuHover = kWhite;
nscolor mMenuHoverText = kBlack;
nscolor mButtonDefault = kWhite;
nscolor mButtonText = kBlack;
nscolor mButtonHoverText = kBlack;
nscolor mButtonHoverFace = kWhite;
nscolor mButtonActiveText = kBlack;
nscolor mFrameOuterLightBorder = kBlack;
nscolor mFrameInnerDarkBorder = kBlack;
nscolor mOddCellBackground = kWhite;
nscolor mNativeHyperLinkText = kBlack;
nscolor mComboBoxText = kBlack;
nscolor mComboBoxBackground = kWhite;
nscolor mFieldText = kBlack;
nscolor mFieldBackground = kWhite;
nscolor mMozWindowText = kBlack;
nscolor mMozWindowBackground = kWhite;
nscolor mMozWindowActiveBorder = kBlack;
nscolor mMozWindowInactiveBorder = kBlack;
nscolor mMozWindowInactiveCaption = kWhite;
nscolor mMozCellHighlightBackground = kWhite;
nscolor mMozCellHighlightText = kBlack;
nscolor mTextSelectedText = kBlack;
nscolor mTextSelectedBackground = kWhite;
nscolor mMozScrollbar = kWhite;
nscolor mInfoBarText = kBlack;
char16_t mInvisibleCharacter = 0;
float mCaretRatio = 0.0f;
int32_t mCaretBlinkTime = 0;
bool mMenuSupportsDrag = false;
bool mCSDAvailable = false;
bool mCSDHideTitlebarByDefault = false;
bool mCSDMaximizeButton = false;
bool mCSDMinimizeButton = false;
bool mCSDCloseButton = false;
bool mCSDReversedPlacement = false;
bool mSystemUsesDarkTheme = false;
bool mHighContrast = false;
bool mInitialized = false;
void EnsureInit();
void ConfigureContentGtkTheme();
private:
nsresult InitCellHighlightColors();
};
#endif