Skip to content

Commit 0d3971b

Browse files
naeioiChromium LUCI CQ
authored andcommitted
Revert "mac: Fix macOS 26 traffic light contrast for dark frames in light mode"
This reverts commit f3c6fcb. Reason for revert: causes problem in window background blending on Win10 + ANGLE D3D11 for translucent windows. crbug.com/445485657 Original change's description: > mac: Fix macOS 26 traffic light contrast for dark frames in light mode > > In macOS 26, the window traffic light buttons can lose contrast and > become invisible on inactive windows. This occurs when the operating > system is in light mode while the window frame uses a dark background > color. > > It appears that this is because macOS is using a window's NSAppearance > to determine the traffic lights' color. Bad colors are chosen by the > system when a light appearance (NSAppearanceNameAqua) uses dark colors. > > To fix this, the window's NSAppearance is now set based on the luminance > of its frame color rather than the browser-wide theme. If the frame > color is dark, the window's appearance is now set to dark. > > Fixed: 442612600 > Change-Id: I65ac33324d2db2bec12a9a856fd0126fe265207e > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6914855 > Commit-Queue: Keren Zhu <[email protected]> > Reviewed-by: Tom Lukaszewicz <[email protected]> > Cr-Commit-Position: refs/heads/main@{#1512214} Bug: 445485657 Change-Id: Iede19df3ebf832c71b8c6ca5a547361ff1308e00 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7062815 Commit-Queue: Keren Zhu <[email protected]> Reviewed-by: Tom Lukaszewicz <[email protected]> Cr-Commit-Position: refs/heads/main@{#1532391}
1 parent 5d24194 commit 0d3971b

16 files changed

+55
-54
lines changed

chrome/browser/ui/views/frame/browser_view.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6009,11 +6009,6 @@ void BrowserView::FrameColorsChanged() {
60096009
web_app_window_title_->SetBackgroundColor(frame_color);
60106010
web_app_window_title_->SetEnabledColor(caption_color);
60116011
}
6012-
6013-
ui::ColorId frame_color_id = browser_widget_->ShouldPaintAsActive()
6014-
? ui::kColorFrameActive
6015-
: ui::kColorFrameInactive;
6016-
GetWidget()->SetBackgroundColor(frame_color_id);
60176012
}
60186013

60196014
void BrowserView::UpdateAccessibleNameForRootView() {

ui/views/test/mock_native_widget.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ class MockNativeWidget : public internal::NativeWidgetPrivate {
7272
InitModalType,
7373
(ui::mojom::ModalType modal_type),
7474
(override));
75-
MOCK_METHOD(void, SetBackgroundColor, (SkColor background_color), (override));
75+
MOCK_METHOD(void,
76+
OnWidgetThemeChanged,
77+
(ui::ColorProviderKey::ColorMode, std::optional<SkColor>),
78+
(override));
7679
MOCK_METHOD(gfx::Rect, GetWindowBoundsInScreen, (), (const override));
7780
MOCK_METHOD(gfx::Rect, GetClientAreaBoundsInScreen, (), (const override));
7881
MOCK_METHOD(gfx::Rect, GetRestoredBounds, (), (const override));

ui/views/widget/desktop_aura/desktop_native_widget_aura.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,8 +869,10 @@ void DesktopNativeWidgetAura::InitModalType(ui::mojom::ModalType modal_type) {
869869
desktop_window_tree_host_->InitModalType(modal_type);
870870
}
871871

872-
void DesktopNativeWidgetAura::SetBackgroundColor(SkColor background_color) {
873-
desktop_window_tree_host_->SetBackgroundColor(background_color);
872+
void DesktopNativeWidgetAura::OnWidgetThemeChanged(
873+
ui::ColorProviderKey::ColorMode color_mode,
874+
std::optional<SkColor> background_color) {
875+
desktop_window_tree_host_->OnWidgetThemeChanged(color_mode, background_color);
874876
}
875877

876878
gfx::Rect DesktopNativeWidgetAura::GetWindowBoundsInScreen() const {

ui/views/widget/desktop_aura/desktop_native_widget_aura.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
155155
void SetWindowIcons(const gfx::ImageSkia& window_icon,
156156
const gfx::ImageSkia& app_icon) override;
157157
void InitModalType(ui::mojom::ModalType modal_type) override;
158-
void SetBackgroundColor(SkColor background_color) override;
158+
void OnWidgetThemeChanged(ui::ColorProviderKey::ColorMode color_mode,
159+
std::optional<SkColor> background_color) override;
159160
gfx::Rect GetWindowBoundsInScreen() const override;
160161
gfx::Rect GetClientAreaBoundsInScreen() const override;
161162
gfx::Rect GetRestoredBounds() const override;

ui/views/widget/desktop_aura/desktop_window_tree_host.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ class VIEWS_EXPORT DesktopWindowTreeHost {
6868
// Called from DesktopNativeWidgetAura::OnWidgetInitDone().
6969
virtual void OnWidgetInitDone() = 0;
7070

71+
virtual void OnWidgetThemeChanged(
72+
ui::ColorProviderKey::ColorMode color_mode,
73+
std::optional<SkColor> background_color) = 0;
74+
7175
// Called from DesktopNativeWidgetAura::OnWindowActivated().
7276
// `active`: if `DesktopNativeWidgetAura::content_window()` contains the
7377
// `aura::Window` that gains active.
@@ -190,8 +194,6 @@ class VIEWS_EXPORT DesktopWindowTreeHost {
190194

191195
virtual void SetOpacity(float opacity) = 0;
192196

193-
virtual void SetBackgroundColor(SkColor background_color) = 0;
194-
195197
// See NativeWidgetPrivate::SetAspectRatio for more information about what
196198
// `excluded_margin` does.
197199
virtual void SetAspectRatio(const gfx::SizeF& aspect_ratio,

ui/views/widget/desktop_aura/desktop_window_tree_host_platform.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,9 @@ void DesktopWindowTreeHostPlatform::OnWidgetInitDone() {
329329
GetWindowMaskForClipping().isEmpty());
330330
}
331331

332-
void DesktopWindowTreeHostPlatform::SetBackgroundColor(
333-
SkColor background_color) {}
332+
void DesktopWindowTreeHostPlatform::OnWidgetThemeChanged(
333+
ui::ColorProviderKey::ColorMode color_mode,
334+
std::optional<SkColor> background_color) {}
334335

335336
void DesktopWindowTreeHostPlatform::OnActiveWindowChanged(bool active) {
336337
#if BUILDFLAG(IS_OZONE)

ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class VIEWS_EXPORT DesktopWindowTreeHostPlatform
7070
void Init(const Widget::InitParams& params) override;
7171
void OnNativeWidgetCreated(const Widget::InitParams& params) override;
7272
void OnWidgetInitDone() override;
73+
void OnWidgetThemeChanged(ui::ColorProviderKey::ColorMode color_mode,
74+
std::optional<SkColor> background_color) override;
7375
void OnActiveWindowChanged(bool active) override;
7476
std::unique_ptr<corewm::Tooltip> CreateTooltip() override;
7577
std::unique_ptr<aura::client::DragDropClient> CreateDragDropClient() override;
@@ -124,7 +126,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostPlatform
124126
void SetFullscreen(bool fullscreen, int64_t display_id) override;
125127
bool IsFullscreen() const override;
126128
void SetOpacity(float opacity) override;
127-
void SetBackgroundColor(SkColor background_color) override;
128129
void SetAspectRatio(const gfx::SizeF& aspect_ratio,
129130
const gfx::Size& excluded_margin) override;
130131
void SetWindowIcons(const gfx::ImageSkia& window_icon,

ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,15 @@ void DesktopWindowTreeHostWin::OnActiveWindowChanged(bool active) {}
247247

248248
void DesktopWindowTreeHostWin::OnWidgetInitDone() {}
249249

250-
void DesktopWindowTreeHostWin::SetBackgroundColor(SkColor background_color) {
250+
void DesktopWindowTreeHostWin::OnWidgetThemeChanged(
251+
ui::ColorProviderKey::ColorMode color_mode,
252+
std::optional<SkColor> background_color) {
251253
UpdateBackdropColorMode();
252-
ClearBackgroundPaintBrush();
253-
background_paint_brush_ =
254-
CreateSolidBrush(skia::SkColorToCOLORREF(background_color));
254+
if (background_color) {
255+
ClearBackgroundPaintBrush();
256+
background_paint_brush_ =
257+
CreateSolidBrush(skia::SkColorToCOLORREF(*background_color));
258+
}
255259
}
256260

257261
std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostWin::CreateTooltip() {

ui/views/widget/desktop_aura/desktop_window_tree_host_win.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin
9999
void OnNativeWidgetCreated(const Widget::InitParams& params) override;
100100
void OnActiveWindowChanged(bool active) override;
101101
void OnWidgetInitDone() override;
102+
void OnWidgetThemeChanged(ui::ColorProviderKey::ColorMode color_mode,
103+
std::optional<SkColor> background_color) override;
102104
std::unique_ptr<corewm::Tooltip> CreateTooltip() override;
103105
std::unique_ptr<aura::client::DragDropClient> CreateDragDropClient() override;
104106
void Close() override;
@@ -152,7 +154,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin
152154
void SetFullscreen(bool fullscreen, int64_t target_display_id) override;
153155
bool IsFullscreen() const override;
154156
void SetOpacity(float opacity) override;
155-
void SetBackgroundColor(SkColor background_color) override;
156157
void SetAspectRatio(const gfx::SizeF& aspect_ratio,
157158
const gfx::Size& excluded_margin) override;
158159
void SetWindowIcons(const gfx::ImageSkia& window_icon,

ui/views/widget/native_widget_aura.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,12 @@ void NativeWidgetAura::InitModalType(ui::mojom::ModalType modal_type) {
570570
}
571571
}
572572

573-
void NativeWidgetAura::SetBackgroundColor(SkColor background_color) {
573+
void NativeWidgetAura::OnWidgetThemeChanged(
574+
ui::ColorProviderKey::ColorMode color_mode,
575+
std::optional<SkColor> background_color) {
574576
// Intentional no-op.
575-
// The window is drawn by views. The OS does not need to know about what
576-
// background color the window is using.
577+
// The window frame is drawn by views. The OS does not need to know about
578+
// which color mode the window is using.
577579
}
578580

579581
gfx::Rect NativeWidgetAura::GetWindowBoundsInScreen() const {

0 commit comments

Comments
 (0)