Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: ui/views/view.cc

Issue 2613343002: Allow a View to specify a non-default native theme (i.e. different from (Closed)
Patch Set: docs Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/views/view.h ('K') | « ui/views/view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view.cc
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 7345e71a3ec6e14d61efad8e537f6efe64b9b80e..2a5e74ea8c216cc18a82a0d7472c82734f191bd4 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -924,6 +924,12 @@ const ui::ThemeProvider* View::GetThemeProvider() const {
}
const ui::NativeTheme* View::GetNativeTheme() const {
+ if (native_theme_override_)
+ return native_theme_override_;
+
+ if (parent())
+ return parent()->GetNativeTheme();
+
const Widget* widget = GetWidget();
if (widget)
return widget->GetNativeTheme();
@@ -931,6 +937,13 @@ const ui::NativeTheme* View::GetNativeTheme() const {
return ui::NativeTheme::GetInstanceForNativeUi();
}
+void View::SetNativeThemeOverride(ui::NativeTheme* theme) {
+ ui::NativeTheme* original_native_theme = GetNativeTheme();
+ native_theme_override_ = theme;
+ if (native_theme_override_ != original_native_theme)
+ PropagateNativeThemeChanged(theme);
+}
+
// RTL painting ----------------------------------------------------------------
void View::EnableCanvasFlippingForRTLUI(bool enable) {
@@ -1975,6 +1988,9 @@ void View::ViewHierarchyChangedImpl(
}
void View::PropagateNativeThemeChanged(const ui::NativeTheme* theme) {
+ if (native_theme_override_ && native_theme_override_ != theme)
+ return;
+
{
internal::ScopedChildrenLock lock(this);
for (auto* child : children_)
« ui/views/view.h ('K') | « ui/views/view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698