Backed out changeset 68b233bf0519 (bug 1771792) for causing xpcshell failures on test_css-properties-db.js . CLOSED TREE

This commit is contained in:
criss 2022-05-31 02:06:55 +03:00
parent 22ec54e75f
commit 9933879ba5
10 changed files with 80 additions and 6 deletions

View File

@ -109,6 +109,8 @@ const NON_CONTENT_ACCESSIBLE_VALUES = {
"-moz-mac-disclosure-button-open",
"-moz-mac-source-list",
"-moz-mac-source-list-selection",
"-moz-mac-vibrant-titlebar-dark",
"-moz-mac-vibrant-titlebar-light",
"button-bevel",
"caret",

View File

@ -1915,6 +1915,10 @@ pub enum Appearance {
MozMacSourceList,
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
MozMacSourceListSelection,
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
MozMacVibrantTitlebarDark,
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
MozMacVibrantTitlebarLight,
/// A themed focus outline (for outline:auto).
///

View File

@ -371,6 +371,10 @@ pub enum SystemColor {
/// Inactive light hightlight
MozMacSecondaryhighlight,
/// Font smoothing background colors needed by the Mac OS X theme, based on
/// -moz-appearance names.
MozMacVibrantTitlebarLight,
MozMacVibrantTitlebarDark,
MozMacMenupopup,
MozMacMenuitem,
MozMacActiveMenuitem,

View File

@ -12,6 +12,8 @@ enum MacThemeGeometryType {
eThemeGeometryTypeWindowButtons,
eThemeGeometryTypeMenu,
eThemeGeometryTypeHighlightedMenuItem,
eThemeGeometryTypeVibrantTitlebarLight,
eThemeGeometryTypeVibrantTitlebarDark,
eThemeGeometryTypeTooltip,
eThemeGeometryTypeSourceList,
eThemeGeometryTypeSourceListSelection,

View File

@ -22,6 +22,8 @@ class nsChildView;
namespace mozilla {
enum class VibrancyType {
TITLEBAR_LIGHT,
TITLEBAR_DARK,
TOOLTIP,
MENU,
HIGHLIGHTED_MENUITEM,

View File

@ -25,14 +25,29 @@ using namespace mozilla;
static NSAppearance* AppearanceForVibrancyType(VibrancyType aType) {
if (@available(macOS 10.14, *)) {
// Inherit the appearance from the window. If the window is using Dark Mode, the vibrancy
// will automatically be dark, too. This is available starting with macOS 10.14.
return nil;
switch (aType) {
case VibrancyType::TITLEBAR_LIGHT:
// This must always be light (regular aqua), regardless of window appearance.
return [NSAppearance appearanceNamed:NSAppearanceNameAqua];
case VibrancyType::TITLEBAR_DARK:
// This must always be dark (dark aqua), regardless of window appearance.
return [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
case VibrancyType::TOOLTIP:
case VibrancyType::MENU:
case VibrancyType::HIGHLIGHTED_MENUITEM:
case VibrancyType::SOURCE_LIST:
case VibrancyType::SOURCE_LIST_SELECTION:
case VibrancyType::ACTIVE_SOURCE_LIST_SELECTION:
// Inherit the appearance from the window. If the window is using Dark Mode, the vibrancy
// will automatically be dark, too. This is available starting with macOS 10.14.
return nil;
}
}
// For 10.13 and below, a vibrant appearance name must be used. There is no system dark mode and
// no automatic adaptation to the window; all windows are light.
switch (aType) {
case VibrancyType::TITLEBAR_LIGHT:
case VibrancyType::TOOLTIP:
case VibrancyType::MENU:
case VibrancyType::HIGHLIGHTED_MENUITEM:
@ -40,6 +55,8 @@ static NSAppearance* AppearanceForVibrancyType(VibrancyType aType) {
case VibrancyType::SOURCE_LIST_SELECTION:
case VibrancyType::ACTIVE_SOURCE_LIST_SELECTION:
return [NSAppearance appearanceNamed:NSAppearanceNameVibrantLight];
case VibrancyType::TITLEBAR_DARK:
return [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark];
}
}
@ -59,6 +76,9 @@ static NSVisualEffectState VisualEffectStateForVibrancyType(VibrancyType aType)
static NSVisualEffectMaterial VisualEffectMaterialForVibrancyType(VibrancyType aType,
BOOL* aOutIsEmphasized) {
switch (aType) {
case VibrancyType::TITLEBAR_LIGHT:
case VibrancyType::TITLEBAR_DARK:
return NSVisualEffectMaterialTitlebar;
case VibrancyType::TOOLTIP:
if (@available(macOS 10.14, *)) {
return (NSVisualEffectMaterial)NSVisualEffectMaterialToolTip;

View File

@ -1636,8 +1636,10 @@ static int32_t FindTitlebarBottom(const nsTArray<nsIWidget::ThemeGeometry>& aThe
int32_t aWindowWidth) {
int32_t titlebarBottom = 0;
for (auto& g : aThemeGeometries) {
if (g.mType == eThemeGeometryTypeTitlebar && g.mRect.X() <= 0 &&
g.mRect.XMost() >= aWindowWidth && g.mRect.Y() <= 0) {
if ((g.mType == eThemeGeometryTypeTitlebar ||
g.mType == eThemeGeometryTypeVibrantTitlebarLight ||
g.mType == eThemeGeometryTypeVibrantTitlebarDark) &&
g.mRect.X() <= 0 && g.mRect.XMost() >= aWindowWidth && g.mRect.Y() <= 0) {
titlebarBottom = std::max(titlebarBottom, g.mRect.YMost());
}
}
@ -1703,6 +1705,10 @@ void nsChildView::UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeo
static Maybe<VibrancyType> ThemeGeometryTypeToVibrancyType(
nsITheme::ThemeGeometryType aThemeGeometryType) {
switch (aThemeGeometryType) {
case eThemeGeometryTypeVibrantTitlebarLight:
return Some(VibrancyType::TITLEBAR_LIGHT);
case eThemeGeometryTypeVibrantTitlebarDark:
return Some(VibrancyType::TITLEBAR_DARK);
case eThemeGeometryTypeTooltip:
return Some(VibrancyType::TOOLTIP);
case eThemeGeometryTypeMenu:
@ -1752,6 +1758,10 @@ static void MakeRegionsNonOverlapping(Region& aFirst, Regions&... aRest) {
}
void nsChildView::UpdateVibrancy(const nsTArray<ThemeGeometry>& aThemeGeometries) {
LayoutDeviceIntRegion vibrantTitlebarLightRegion =
GatherVibrantRegion(aThemeGeometries, VibrancyType::TITLEBAR_LIGHT);
LayoutDeviceIntRegion vibrantTitlebarDarkRegion =
GatherVibrantRegion(aThemeGeometries, VibrancyType::TITLEBAR_DARK);
LayoutDeviceIntRegion menuRegion = GatherVibrantRegion(aThemeGeometries, VibrancyType::MENU);
LayoutDeviceIntRegion tooltipRegion =
GatherVibrantRegion(aThemeGeometries, VibrancyType::TOOLTIP);
@ -1764,11 +1774,14 @@ void nsChildView::UpdateVibrancy(const nsTArray<ThemeGeometry>& aThemeGeometries
LayoutDeviceIntRegion activeSourceListSelectionRegion =
GatherVibrantRegion(aThemeGeometries, VibrancyType::ACTIVE_SOURCE_LIST_SELECTION);
MakeRegionsNonOverlapping(menuRegion, tooltipRegion, highlightedMenuItemRegion, sourceListRegion,
MakeRegionsNonOverlapping(vibrantTitlebarLightRegion, vibrantTitlebarDarkRegion, menuRegion,
tooltipRegion, highlightedMenuItemRegion, sourceListRegion,
sourceListSelectionRegion, activeSourceListSelectionRegion);
auto& vm = EnsureVibrancyManager();
bool changed = false;
changed |= vm.UpdateVibrantRegion(VibrancyType::TITLEBAR_LIGHT, vibrantTitlebarLightRegion);
changed |= vm.UpdateVibrantRegion(VibrancyType::TITLEBAR_DARK, vibrantTitlebarDarkRegion);
changed |= vm.UpdateVibrantRegion(VibrancyType::MENU, menuRegion);
changed |= vm.UpdateVibrantRegion(VibrancyType::TOOLTIP, tooltipRegion);
changed |= vm.UpdateVibrantRegion(VibrancyType::HIGHLIGHTED_MENUITEM, highlightedMenuItemRegion);

View File

@ -326,6 +326,20 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, nscolor
case ColorID::MozNativevisitedhyperlinktext:
color = GetColorFromNSColor(NSColor.systemPurpleColor);
break;
// The following colors are supposed to be used as font-smoothing background
// colors, in the chrome-only -moz-font-smoothing-background-color property.
// This property is used for text on "vibrant" -moz-appearances.
// The colors have been obtained from the system on 10.14 using the
// program at https://bugzilla.mozilla.org/attachment.cgi?id=9208594 .
// We could obtain them at runtime, but doing so may be expensive and
// requires the use of the private API
// -[NSVisualEffectView fontSmoothingBackgroundColor].
case ColorID::MozMacVibrantTitlebarLight:
color = NS_RGB(0xe6, 0xe6, 0xe6);
break;
case ColorID::MozMacVibrantTitlebarDark:
color = NS_RGB(0x28, 0x28, 0x28);
break;
case ColorID::MozMacTooltip:
case ColorID::MozMacMenupopup:
case ColorID::MozMacMenuitem:

View File

@ -3232,6 +3232,8 @@ nsNativeThemeCocoa::WidgetStateChanged(nsIFrame* aFrame, StyleAppearance aAppear
case StyleAppearance::ProgressBar:
case StyleAppearance::Meter:
case StyleAppearance::Meterchunk:
case StyleAppearance::MozMacVibrantTitlebarLight:
case StyleAppearance::MozMacVibrantTitlebarDark:
*aShouldRepaint = false;
return NS_OK;
default:
@ -3364,6 +3366,9 @@ bool nsNativeThemeCocoa::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFra
case StyleAppearance::FocusOutline:
return true;
case StyleAppearance::MozMacVibrantTitlebarLight:
case StyleAppearance::MozMacVibrantTitlebarDark:
return true;
default:
break;
}
@ -3455,6 +3460,10 @@ nsITheme::ThemeGeometryType nsNativeThemeCocoa::ThemeGeometryTypeForWidget(
return eThemeGeometryTypeToolbox;
case StyleAppearance::MozWindowButtonBox:
return eThemeGeometryTypeWindowButtons;
case StyleAppearance::MozMacVibrantTitlebarLight:
return eThemeGeometryTypeVibrantTitlebarLight;
case StyleAppearance::MozMacVibrantTitlebarDark:
return eThemeGeometryTypeVibrantTitlebarDark;
case StyleAppearance::Tooltip:
return eThemeGeometryTypeTooltip;
case StyleAppearance::Menupopup:

View File

@ -288,6 +288,8 @@ static const char sColorPrefs[][41] = {
"ui.-moz-mac-menutextselect",
"ui.-moz_mac_disabledtoolbartext",
"ui.-moz-mac-secondaryhighlight",
"ui.-moz-mac-vibrant-titlebar-light",
"ui.-moz-mac-vibrant-titlebar-dark",
"ui.-moz-mac-menupopup",
"ui.-moz-mac-menuitem",
"ui.-moz-mac-active-menuitem",
@ -621,6 +623,8 @@ nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID,
COLOR(MozMacMenutextselect, 0xFF, 0xFF, 0xFF)
COLOR(MozMacDisabledtoolbartext, 0x3F, 0x3F, 0x3F)
COLOR(MozMacSecondaryhighlight, 0xD4, 0xD4, 0xD4)
COLOR(MozMacVibrantTitlebarLight, 0xf7, 0xf7, 0xf7)
COLOR(MozMacVibrantTitlebarDark, 0x28, 0x28, 0x28)
COLOR(MozMacMenupopup, 0xe6, 0xe6, 0xe6)
COLOR(MozMacMenuitem, 0xe6, 0xe6, 0xe6)
COLOR(MozMacActiveMenuitem, 0x0a, 0x64, 0xdc)