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

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: no "override" 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
« no previous file with comments | « 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..48f3fbbe8f5bd85201cfcfdd559426442cc25ef9 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_)
+ return native_theme_;
+
+ 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::SetNativeTheme(ui::NativeTheme* theme) {
+ ui::NativeTheme* original_native_theme = GetNativeTheme();
+ native_theme_ = theme;
+ if (native_theme_ != 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_ && native_theme_ != theme)
+ return;
+
{
internal::ScopedChildrenLock lock(this);
for (auto* child : children_)
« no previous file with comments | « ui/views/view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698