Bug 1907405 - Add appearance: -moz-sidebar and hook macOS vibrancy. r=mac-reviewers,spohl

Unused for now, but pretty straight-forward.

Bug 1905257 has some code that actually uses it. This allows the
front-end folks to experiment with this effect for the sidebar.

Differential Revision: https://phabricator.services.mozilla.com/D216325
This commit is contained in:
Emilio Cobos Álvarez
2024-07-12 14:08:13 +00:00
parent e0352d76b7
commit a9a3348226
7 changed files with 25 additions and 1 deletions

View File

@@ -16668,6 +16668,11 @@
value: true value: true
mirror: always mirror: always
- name: widget.macos.sidebar-blend-mode.behind-window
type: RelaxedAtomicBool
value: true
mirror: always
- name: widget.macos.titlebar-blend-mode.behind-window - name: widget.macos.titlebar-blend-mode.behind-window
type: RelaxedAtomicBool type: RelaxedAtomicBool
value: false value: false

View File

@@ -1580,6 +1580,10 @@ pub enum Appearance {
#[parse(condition = "ParserContext::chrome_rules_enabled")] #[parse(condition = "ParserContext::chrome_rules_enabled")]
Tooltip, Tooltip,
/// Sidebar appearance.
#[parse(condition = "ParserContext::chrome_rules_enabled")]
MozSidebar,
/// Mac help button. /// Mac help button.
#[parse(condition = "ParserContext::chrome_rules_enabled")] #[parse(condition = "ParserContext::chrome_rules_enabled")]
MozMacHelpButton, MozMacHelpButton,

View File

@@ -7,6 +7,7 @@
enum MacThemeGeometryType { enum MacThemeGeometryType {
eThemeGeometryTypeTitlebar = 1, eThemeGeometryTypeTitlebar = 1,
eThemeGeometryTypeSidebar,
eThemeGeometryTypeWindowButtons, eThemeGeometryTypeWindowButtons,
}; };

View File

@@ -18,6 +18,7 @@ namespace mozilla {
class ViewRegion; class ViewRegion;
enum class VibrancyType { enum class VibrancyType {
Sidebar,
// Add new values here, or update MaxEnumValue below if you add them after. // Add new values here, or update MaxEnumValue below if you add them after.
Titlebar, Titlebar,
}; };

View File

@@ -27,6 +27,7 @@ static NSVisualEffectState VisualEffectStateForVibrancyType(
VibrancyType aType) { VibrancyType aType) {
switch (aType) { switch (aType) {
case VibrancyType::Titlebar: case VibrancyType::Titlebar:
case VibrancyType::Sidebar:
break; break;
} }
return NSVisualEffectStateFollowsWindowActiveState; return NSVisualEffectStateFollowsWindowActiveState;
@@ -35,6 +36,8 @@ static NSVisualEffectState VisualEffectStateForVibrancyType(
static NSVisualEffectMaterial VisualEffectMaterialForVibrancyType( static NSVisualEffectMaterial VisualEffectMaterialForVibrancyType(
VibrancyType aType) { VibrancyType aType) {
switch (aType) { switch (aType) {
case VibrancyType::Sidebar:
return NSVisualEffectMaterialSidebar;
case VibrancyType::Titlebar: case VibrancyType::Titlebar:
return NSVisualEffectMaterialTitlebar; return NSVisualEffectMaterialTitlebar;
} }
@@ -43,6 +46,10 @@ static NSVisualEffectMaterial VisualEffectMaterialForVibrancyType(
static NSVisualEffectBlendingMode VisualEffectBlendingModeForVibrancyType( static NSVisualEffectBlendingMode VisualEffectBlendingModeForVibrancyType(
VibrancyType aType) { VibrancyType aType) {
switch (aType) { switch (aType) {
case VibrancyType::Sidebar:
return StaticPrefs::widget_macos_sidebar_blend_mode_behind_window()
? NSVisualEffectBlendingModeBehindWindow
: NSVisualEffectBlendingModeWithinWindow;
case VibrancyType::Titlebar: case VibrancyType::Titlebar:
return StaticPrefs::widget_macos_titlebar_blend_mode_behind_window() return StaticPrefs::widget_macos_titlebar_blend_mode_behind_window()
? NSVisualEffectBlendingModeBehindWindow ? NSVisualEffectBlendingModeBehindWindow

View File

@@ -1735,6 +1735,8 @@ void nsChildView::UpdateThemeGeometries(
static Maybe<VibrancyType> ThemeGeometryTypeToVibrancyType( static Maybe<VibrancyType> ThemeGeometryTypeToVibrancyType(
nsITheme::ThemeGeometryType aThemeGeometryType) { nsITheme::ThemeGeometryType aThemeGeometryType) {
switch (aThemeGeometryType) { switch (aThemeGeometryType) {
case eThemeGeometryTypeSidebar:
return Some(VibrancyType::Sidebar);
case eThemeGeometryTypeTitlebar: case eThemeGeometryTypeTitlebar:
return Some(VibrancyType::Titlebar); return Some(VibrancyType::Titlebar);
default: default:

View File

@@ -2191,6 +2191,7 @@ Maybe<nsNativeThemeCocoa::WidgetInfo> nsNativeThemeCocoa::ComputeWidgetInfo(
case StyleAppearance::Separator: case StyleAppearance::Separator:
return Some(WidgetInfo::Separator()); return Some(WidgetInfo::Separator());
case StyleAppearance::MozSidebar:
case StyleAppearance::MozWindowTitlebar: { case StyleAppearance::MozWindowTitlebar: {
return Nothing(); return Nothing();
} }
@@ -2525,7 +2526,6 @@ bool nsNativeThemeCocoa::CreateWebRenderCommandsForWidget(
case StyleAppearance::SpinnerDownbutton: case StyleAppearance::SpinnerDownbutton:
case StyleAppearance::Toolbarbutton: case StyleAppearance::Toolbarbutton:
case StyleAppearance::Separator: case StyleAppearance::Separator:
case StyleAppearance::MozWindowTitlebar:
case StyleAppearance::Statusbar: case StyleAppearance::Statusbar:
case StyleAppearance::Menulist: case StyleAppearance::Menulist:
case StyleAppearance::MenulistButton: case StyleAppearance::MenulistButton:
@@ -2879,6 +2879,7 @@ nsNativeThemeCocoa::WidgetStateChanged(nsIFrame* aFrame,
// Some widget types just never change state. // Some widget types just never change state.
switch (aAppearance) { switch (aAppearance) {
case StyleAppearance::MozWindowTitlebar: case StyleAppearance::MozWindowTitlebar:
case StyleAppearance::MozSidebar:
case StyleAppearance::Statusbar: case StyleAppearance::Statusbar:
case StyleAppearance::Tooltip: case StyleAppearance::Tooltip:
case StyleAppearance::Tabpanels: case StyleAppearance::Tabpanels:
@@ -2950,6 +2951,7 @@ bool nsNativeThemeCocoa::ThemeSupportsWidget(nsPresContext* aPresContext,
case StyleAppearance::Listbox: case StyleAppearance::Listbox:
case StyleAppearance::MozWindowButtonBox: case StyleAppearance::MozWindowButtonBox:
case StyleAppearance::MozWindowTitlebar: case StyleAppearance::MozWindowTitlebar:
case StyleAppearance::MozSidebar:
case StyleAppearance::Menupopup: case StyleAppearance::Menupopup:
case StyleAppearance::Tooltip: case StyleAppearance::Tooltip:
@@ -3057,6 +3059,8 @@ bool nsNativeThemeCocoa::WidgetAppearanceDependsOnWindowFocus(
nsITheme::ThemeGeometryType nsNativeThemeCocoa::ThemeGeometryTypeForWidget( nsITheme::ThemeGeometryType nsNativeThemeCocoa::ThemeGeometryTypeForWidget(
nsIFrame* aFrame, StyleAppearance aAppearance) { nsIFrame* aFrame, StyleAppearance aAppearance) {
switch (aAppearance) { switch (aAppearance) {
case StyleAppearance::MozSidebar:
return eThemeGeometryTypeSidebar;
case StyleAppearance::MozWindowTitlebar: case StyleAppearance::MozWindowTitlebar:
return eThemeGeometryTypeTitlebar; return eThemeGeometryTypeTitlebar;
case StyleAppearance::MozWindowButtonBox: case StyleAppearance::MozWindowButtonBox: