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
Родитель 8ecb2b3e4c
Коммит f1a4df024d
7 изменённых файлов: 25 добавлений и 1 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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