mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
parent
6a03b3bc1a
commit
1f90db3750
7 changed files with 126 additions and 5 deletions
|
|
@ -742,6 +742,8 @@ CSS_KEY(button-focus, button_focus)
|
||||||
CSS_KEY(-moz-win-media-toolbox, _moz_win_media_toolbox)
|
CSS_KEY(-moz-win-media-toolbox, _moz_win_media_toolbox)
|
||||||
CSS_KEY(-moz-win-communications-toolbox, _moz_win_communications_toolbox)
|
CSS_KEY(-moz-win-communications-toolbox, _moz_win_communications_toolbox)
|
||||||
CSS_KEY(-moz-win-browsertabbar-toolbox, _moz_win_browsertabbar_toolbox)
|
CSS_KEY(-moz-win-browsertabbar-toolbox, _moz_win_browsertabbar_toolbox)
|
||||||
|
CSS_KEY(-moz-win-accentcolor, _moz_win_accentcolor)
|
||||||
|
CSS_KEY(-moz-win-accentcolortext, _moz_win_accentcolortext)
|
||||||
CSS_KEY(-moz-win-mediatext, _moz_win_mediatext)
|
CSS_KEY(-moz-win-mediatext, _moz_win_mediatext)
|
||||||
CSS_KEY(-moz-win-communicationstext, _moz_win_communicationstext)
|
CSS_KEY(-moz-win-communicationstext, _moz_win_communicationstext)
|
||||||
CSS_KEY(-moz-win-glass, _moz_win_glass)
|
CSS_KEY(-moz-win-glass, _moz_win_glass)
|
||||||
|
|
|
||||||
|
|
@ -1174,6 +1174,8 @@ const KTableEntry nsCSSProps::kColorKTable[] = {
|
||||||
{ eCSSKeyword__moz_oddtreerow, LookAndFeel::eColorID__moz_oddtreerow },
|
{ eCSSKeyword__moz_oddtreerow, LookAndFeel::eColorID__moz_oddtreerow },
|
||||||
{ eCSSKeyword__moz_visitedhyperlinktext, NS_COLOR_MOZ_VISITEDHYPERLINKTEXT },
|
{ eCSSKeyword__moz_visitedhyperlinktext, NS_COLOR_MOZ_VISITEDHYPERLINKTEXT },
|
||||||
{ eCSSKeyword_currentcolor, NS_COLOR_CURRENTCOLOR },
|
{ eCSSKeyword_currentcolor, NS_COLOR_CURRENTCOLOR },
|
||||||
|
{ eCSSKeyword__moz_win_accentcolor, LookAndFeel::eColorID__moz_win_accentcolor },
|
||||||
|
{ eCSSKeyword__moz_win_accentcolortext, LookAndFeel::eColorID__moz_win_accentcolortext },
|
||||||
{ eCSSKeyword__moz_win_mediatext, LookAndFeel::eColorID__moz_win_mediatext },
|
{ eCSSKeyword__moz_win_mediatext, LookAndFeel::eColorID__moz_win_mediatext },
|
||||||
{ eCSSKeyword__moz_win_communicationstext, LookAndFeel::eColorID__moz_win_communicationstext },
|
{ eCSSKeyword__moz_win_communicationstext, LookAndFeel::eColorID__moz_win_communicationstext },
|
||||||
{ eCSSKeyword__moz_nativehyperlinktext, LookAndFeel::eColorID__moz_nativehyperlinktext },
|
{ eCSSKeyword__moz_nativehyperlinktext, LookAndFeel::eColorID__moz_nativehyperlinktext },
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,10 @@ public:
|
||||||
|
|
||||||
// vista rebars
|
// vista rebars
|
||||||
|
|
||||||
|
// accent color for title bar
|
||||||
|
eColorID__moz_win_accentcolor,
|
||||||
|
// color from drawing text over the accent color
|
||||||
|
eColorID__moz_win_accentcolortext,
|
||||||
// media rebar text
|
// media rebar text
|
||||||
eColorID__moz_win_mediatext,
|
eColorID__moz_win_mediatext,
|
||||||
// communications rebar text
|
// communications rebar text
|
||||||
|
|
|
||||||
|
|
@ -647,6 +647,11 @@ nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID)
|
||||||
result = NS_RGB(0x3F, 0x3F, 0x3F); break;
|
result = NS_RGB(0x3F, 0x3F, 0x3F); break;
|
||||||
case eColorID__moz_mac_secondaryhighlight:
|
case eColorID__moz_mac_secondaryhighlight:
|
||||||
result = NS_RGB(0xD4, 0xD4, 0xD4); break;
|
result = NS_RGB(0xD4, 0xD4, 0xD4); break;
|
||||||
|
case eColorID__moz_win_accentcolor:
|
||||||
|
// Seems to be the default color (hardcoded because of bug 1065998)
|
||||||
|
result = NS_RGB(0x9E, 0x9E, 0x9E); break;
|
||||||
|
case eColorID__moz_win_accentcolortext:
|
||||||
|
result = NS_RGB(0x00, 0x00, 0x00); break;
|
||||||
case eColorID__moz_win_mediatext:
|
case eColorID__moz_win_mediatext:
|
||||||
result = NS_RGB(0xFF, 0xFF, 0xFF); break;
|
result = NS_RGB(0xFF, 0xFF, 0xFF); break;
|
||||||
case eColorID__moz_win_communicationstext:
|
case eColorID__moz_win_communicationstext:
|
||||||
|
|
|
||||||
|
|
@ -267,6 +267,23 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
|
||||||
case eColorID__moz_cellhighlight:
|
case eColorID__moz_cellhighlight:
|
||||||
idx = COLOR_3DFACE;
|
idx = COLOR_3DFACE;
|
||||||
break;
|
break;
|
||||||
|
case eColorID__moz_win_accentcolor:
|
||||||
|
res = GetAccentColor(aColor);
|
||||||
|
if (NS_SUCCEEDED(res)) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
NS_WARNING("Using fallback for accent color - UI code failed to use the "
|
||||||
|
"-moz-windows-accent-color-applies media query properly");
|
||||||
|
// Seems to be the default color (hardcoded because of bug 1065998)
|
||||||
|
aColor = NS_RGB(158, 158, 158);
|
||||||
|
return NS_OK;
|
||||||
|
case eColorID__moz_win_accentcolortext:
|
||||||
|
res = GetAccentColorText(aColor);
|
||||||
|
if (NS_SUCCEEDED(res)) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
aColor = NS_RGB(0, 0, 0);
|
||||||
|
return NS_OK;
|
||||||
case eColorID__moz_win_mediatext:
|
case eColorID__moz_win_mediatext:
|
||||||
if (IsVistaOrLater() && IsAppThemed()) {
|
if (IsVistaOrLater() && IsAppThemed()) {
|
||||||
res = ::GetColorFromTheme(eUXMediaToolbar,
|
res = ::GetColorFromTheme(eUXMediaToolbar,
|
||||||
|
|
@ -705,3 +722,68 @@ nsLookAndFeel::SetIntCacheImpl(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ nsresult
|
||||||
|
nsLookAndFeel::GetAccentColor(nscolor& aColor)
|
||||||
|
{
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
|
if (!mDwmKey) {
|
||||||
|
mDwmKey = do_CreateInstance("@mozilla.org/windows-registry-key;1", &rv);
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = mDwmKey->Open(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
|
||||||
|
NS_LITERAL_STRING("SOFTWARE\\Microsoft\\Windows\\DWM"),
|
||||||
|
nsIWindowsRegKey::ACCESS_QUERY_VALUE);
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The ColorPrevalence value is set to 1 when the "Show color on title bar"
|
||||||
|
// setting in the Color section of Window's Personalization settings is
|
||||||
|
// turned on.
|
||||||
|
uint32_t accentColor, colorPrevalence;
|
||||||
|
if (NS_SUCCEEDED(mDwmKey->ReadIntValue(NS_LITERAL_STRING("AccentColor"), &accentColor)) &&
|
||||||
|
NS_SUCCEEDED(mDwmKey->ReadIntValue(NS_LITERAL_STRING("ColorPrevalence"), &colorPrevalence)) &&
|
||||||
|
colorPrevalence == 1) {
|
||||||
|
// The order of the color components in the DWORD stored in the registry
|
||||||
|
// happens to be the same order as we store the components in nscolor
|
||||||
|
// so we can just assign directly here.
|
||||||
|
aColor = accentColor;
|
||||||
|
rv = NS_OK;
|
||||||
|
} else {
|
||||||
|
rv = NS_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
mDwmKey->Close();
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* static */ nsresult
|
||||||
|
nsLookAndFeel::GetAccentColorText(nscolor& aColor)
|
||||||
|
{
|
||||||
|
nscolor accentColor;
|
||||||
|
nsresult rv = GetAccentColor(accentColor);
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We want the color that we return for text that will be drawn over
|
||||||
|
// a background that has the accent color to have good contrast with
|
||||||
|
// the accent color. Windows itself uses either white or black text
|
||||||
|
// depending on how light or dark the accent color is. We do the same
|
||||||
|
// here based on the luminance of the accent color with a threshhold
|
||||||
|
// value and formula that are specified in the UWP guidelines.
|
||||||
|
// See: https://docs.microsoft.com/en-us/windows/uwp/style/color
|
||||||
|
|
||||||
|
float luminance = (NS_GET_R(accentColor) * 2 +
|
||||||
|
NS_GET_G(accentColor) * 5 +
|
||||||
|
NS_GET_B(accentColor)) / 8;
|
||||||
|
|
||||||
|
aColor = (luminance <= 128) ? NS_RGB(255, 255, 255) : NS_RGB(0, 0, 0);
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#ifndef __nsLookAndFeel
|
#ifndef __nsLookAndFeel
|
||||||
#define __nsLookAndFeel
|
#define __nsLookAndFeel
|
||||||
#include "nsXPLookAndFeel.h"
|
#include "nsXPLookAndFeel.h"
|
||||||
|
#include "nsIWindowsRegKey.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gesture System Metrics
|
* Gesture System Metrics
|
||||||
|
|
@ -59,7 +60,25 @@ public:
|
||||||
virtual void SetIntCacheImpl(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache);
|
virtual void SetIntCacheImpl(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* Fetches the Windows accent color from the Windows settings if
|
||||||
|
* the accent color is set to apply to the title bar, otherwise
|
||||||
|
* returns an error code.
|
||||||
|
*/
|
||||||
|
nsresult GetAccentColor(nscolor& aColor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the Windows accent color from the Windows settings is set
|
||||||
|
* to apply to the title bar, this computes the color that should
|
||||||
|
* be used for text that is to be written over a background that has
|
||||||
|
* the accent color. Otherwise, (if the accent color should not
|
||||||
|
* apply to the title bar) this returns an error code.
|
||||||
|
*/
|
||||||
|
nsresult GetAccentColorText(nscolor& aColor);
|
||||||
|
|
||||||
int32_t mUseAccessibilityTheme;
|
int32_t mUseAccessibilityTheme;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIWindowsRegKey> mDwmKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -5084,12 +5084,19 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
|
||||||
|
|
||||||
case WM_SETTINGCHANGE:
|
case WM_SETTINGCHANGE:
|
||||||
{
|
{
|
||||||
if (IsWin10OrLater() && mWindowType == eWindowType_invisible && lParam) {
|
if (lParam) {
|
||||||
auto lParamString = reinterpret_cast<const wchar_t*>(lParam);
|
auto lParamString = reinterpret_cast<const wchar_t*>(lParam);
|
||||||
if (!wcscmp(lParamString, L"UserInteractionMode")) {
|
if (!wcscmp(lParamString, L"ImmersiveColorSet")) {
|
||||||
nsCOMPtr<nsIWindowsUIUtils> uiUtils(do_GetService("@mozilla.org/windows-ui-utils;1"));
|
// WM_SYSCOLORCHANGE is not dispatched for accent color changes
|
||||||
if (uiUtils) {
|
OnSysColorChanged();
|
||||||
uiUtils->UpdateTabletModeState();
|
break;
|
||||||
|
}
|
||||||
|
if (IsWin10OrLater() && mWindowType == eWindowType_invisible) {
|
||||||
|
if (!wcscmp(lParamString, L"UserInteractionMode")) {
|
||||||
|
nsCOMPtr<nsIWindowsUIUtils> uiUtils(do_GetService("@mozilla.org/windows-ui-utils;1"));
|
||||||
|
if (uiUtils) {
|
||||||
|
uiUtils->UpdateTabletModeState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue