Commit c939527d authored by Thomas Lukaszewicz's avatar Thomas Lukaszewicz Committed by Commit Bot

Fixed Bubbles not tracking the NativeTheme of their anchoring Widget

Currently child windows do not track the themes of their anchoring
widget. This can lead to theme mismatches in spawned bubbles (in
particular icons relying on native theme colors in the profile menu
for linux themes).

This change follows on from a previous change that fixes the issue
for ThemeProviders in Bubbles. Follow up CLs should address the
issue for the more general case of widgets tracking the themes of
the Widgets that spawned them (see https://crbug.com/948859).

Bug: 1057962
Change-Id: Ie3a71208cb920e8bced6a8bb2f42968bad46f403
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2121075
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753398}
parent 57d80a05
......@@ -45,15 +45,28 @@ class BubbleWidget : public Widget {
BubbleWidget() = default;
// Widget:
// TODO(tluk) Fix child windows so that they inherit the theme properties of
// their parent. Currently this only fixes the problem for bubble dialogs
// anchored to another window. (https://crbug.com/948859)
const ui::ThemeProvider* GetThemeProvider() const override {
const Widget* anchor_widget = GetAnchorWidget();
return anchor_widget ? anchor_widget->GetThemeProvider()
: Widget::GetThemeProvider();
}
const ui::NativeTheme* GetNativeTheme() const override {
const Widget* anchor_widget = GetAnchorWidget();
return anchor_widget ? anchor_widget->GetNativeTheme()
: Widget::GetNativeTheme();
}
private:
const Widget* GetAnchorWidget() const {
BubbleDialogDelegateView* const bubble_delegate =
static_cast<BubbleDialogDelegateView*>(widget_delegate());
if (!bubble_delegate || !bubble_delegate->anchor_widget())
return Widget::GetThemeProvider();
return bubble_delegate->anchor_widget()->GetThemeProvider();
return bubble_delegate ? bubble_delegate->anchor_widget() : nullptr;
}
private:
DISALLOW_COPY_AND_ASSIGN(BubbleWidget);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment