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

Side by Side Diff: chrome/browser/ui/libgtk2ui/gtk2_ui.cc

Issue 2089263002: [top-chrome-md] Allows UpdateMaterialDesignColors to be called before MDC::Initialize() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [top-chrome-md] Allows UpdateMaterialDesignColors to be called before MDC::Initialize() (back to Pa… Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" 5 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <pango/pango.h> 8 #include <pango/pango.h>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 989
990 colors_[ThemeProperties::COLOR_TAB_THROBBER_SPINNING] = 990 colors_[ThemeProperties::COLOR_TAB_THROBBER_SPINNING] =
991 theme->GetSystemColor(ui::NativeTheme::kColorId_ThrobberSpinningColor); 991 theme->GetSystemColor(ui::NativeTheme::kColorId_ThrobberSpinningColor);
992 colors_[ThemeProperties::COLOR_TAB_THROBBER_WAITING] = 992 colors_[ThemeProperties::COLOR_TAB_THROBBER_WAITING] =
993 theme->GetSystemColor(ui::NativeTheme::kColorId_ThrobberWaitingColor); 993 theme->GetSystemColor(ui::NativeTheme::kColorId_ThrobberWaitingColor);
994 } 994 }
995 995
996 void Gtk2UI::UpdateMaterialDesignColors() { 996 void Gtk2UI::UpdateMaterialDesignColors() {
997 // TODO(varkha): This should be merged back into LoadGtkValues() once Material 997 // TODO(varkha): This should be merged back into LoadGtkValues() once Material
998 // Design is on unconditionally. 998 // Design is on unconditionally.
999 if (ui::MaterialDesignController::IsModeMaterial()) { 999 // Early return when Material Design Controller is not initialized yet. This
1000 NativeThemeGtk2* theme = NativeThemeGtk2::instance(); 1000 // is harmless and the colors will get updated when this method is called
1001 SkColor label_color = 1001 // again after the initialization. See http://crbug.com/622234.
1002 theme->GetSystemColor(ui::NativeTheme::kColorId_LabelEnabledColor); 1002 if (!ui::MaterialDesignController::is_mode_initialized() ||
1003 colors_[ThemeProperties::COLOR_BACKGROUND_TAB_TEXT] = 1003 !ui::MaterialDesignController::IsModeMaterial()) {
1004 color_utils::BlendTowardOppositeLuma(label_color, 50); 1004 return;
1005 } 1005 }
1006 NativeThemeGtk2* theme = NativeThemeGtk2::instance();
1007 SkColor label_color =
1008 theme->GetSystemColor(ui::NativeTheme::kColorId_LabelEnabledColor);
1009 colors_[ThemeProperties::COLOR_BACKGROUND_TAB_TEXT] =
1010 color_utils::BlendTowardOppositeLuma(label_color, 50);
1006 } 1011 }
1007 1012
1008 SkColor Gtk2UI::BuildFrameColors() { 1013 SkColor Gtk2UI::BuildFrameColors() {
1009 NativeThemeGtk2* theme = NativeThemeGtk2::instance(); 1014 NativeThemeGtk2* theme = NativeThemeGtk2::instance();
1010 SkColor frame_color = 1015 SkColor frame_color =
1011 theme->GetSystemColor(ui::NativeTheme::kColorId_WindowBackground); 1016 theme->GetSystemColor(ui::NativeTheme::kColorId_WindowBackground);
1012 SkColor temp_color; 1017 SkColor temp_color;
1013 1018
1014 #if GTK_MAJOR_VERSION == 2 1019 #if GTK_MAJOR_VERSION == 2
1015 color_utils::HSL kDefaultFrameShift = { -1, -1, 0.4 }; 1020 color_utils::HSL kDefaultFrameShift = { -1, -1, 0.4 };
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 // Blacklist scaling factors <130% (crbug.com/484400) and round 1408 // Blacklist scaling factors <130% (crbug.com/484400) and round
1404 // to 1 decimal to prevent rendering problems (crbug.com/485183). 1409 // to 1 decimal to prevent rendering problems (crbug.com/485183).
1405 return scale < 1.3f ? 1.0f : roundf(scale * 10) / 10; 1410 return scale < 1.3f ? 1.0f : roundf(scale * 10) / 10;
1406 } 1411 }
1407 1412
1408 } // namespace libgtk2ui 1413 } // namespace libgtk2ui
1409 1414
1410 views::LinuxUI* BuildGtk2UI() { 1415 views::LinuxUI* BuildGtk2UI() {
1411 return new libgtk2ui::Gtk2UI; 1416 return new libgtk2ui::Gtk2UI;
1412 } 1417 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698