Commit 04b23e51 authored by Wei Li's avatar Wei Li Committed by Commit Bot

[Color] Remove SkColor constants from Background class

In Background class, the default value for |color_| is not used in any
of the subclasses: either a subclass will override the color with
SetNativeControlColor(), or a subclass will not use |color_| at all. So
change the initial value to a placeholder color.

Also replace CreateStandardPanelBackground() with directly calling
CreateThemedSolidBackground() to make shell window to use themed colors
and to remove unnecessary wrapping function.

BUG=1059867

Change-Id: I97c6cf8943046453516ba93dc3b779eb6740d658
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2102785
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753734}
parent 14354817
...@@ -406,6 +406,7 @@ jumbo_static_library("content_shell_lib") { ...@@ -406,6 +406,7 @@ jumbo_static_library("content_shell_lib") {
"browser/shell_web_contents_view_delegate_views.cc", "browser/shell_web_contents_view_delegate_views.cc",
] ]
deps += [ deps += [
"//ui/native_theme",
"//ui/resources", "//ui/resources",
"//ui/views:test_support", "//ui/views:test_support",
"//ui/views/controls/webview", "//ui/views/controls/webview",
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/clipboard.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/native_theme/native_theme_color_id.h"
#include "ui/views/background.h" #include "ui/views/background.h"
#include "ui/views/controls/button/md_text_button.h" #include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
...@@ -117,7 +118,8 @@ class ShellWindowDelegateView : public views::WidgetDelegateView, ...@@ -117,7 +118,8 @@ class ShellWindowDelegateView : public views::WidgetDelegateView,
private: private:
// Initialize the UI control contained in shell window // Initialize the UI control contained in shell window
void InitShellWindow() { void InitShellWindow() {
SetBackground(views::CreateStandardPanelBackground()); SetBackground(CreateThemedSolidBackground(
this, ui::NativeTheme::kColorId_WindowBackground));
auto contents_view = std::make_unique<views::View>(); auto contents_view = std::make_unique<views::View>();
auto toolbar_view = std::make_unique<views::View>(); auto toolbar_view = std::make_unique<views::View>();
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "cc/paint/paint_flags.h" #include "cc/paint/paint_flags.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
#include "ui/native_theme/native_theme_color_id.h"
#include "ui/views/painter.h" #include "ui/views/painter.h"
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/view_observer.h" #include "ui/views/view_observer.h"
...@@ -108,7 +108,7 @@ class BackgroundPainter : public Background { ...@@ -108,7 +108,7 @@ class BackgroundPainter : public Background {
DISALLOW_COPY_AND_ASSIGN(BackgroundPainter); DISALLOW_COPY_AND_ASSIGN(BackgroundPainter);
}; };
Background::Background() : color_(SK_ColorWHITE) {} Background::Background() = default;
Background::~Background() = default; Background::~Background() = default;
...@@ -131,11 +131,6 @@ std::unique_ptr<Background> CreateThemedSolidBackground( ...@@ -131,11 +131,6 @@ std::unique_ptr<Background> CreateThemedSolidBackground(
return std::make_unique<ThemedSolidBackground>(view, color_id); return std::make_unique<ThemedSolidBackground>(view, color_id);
} }
std::unique_ptr<Background> CreateStandardPanelBackground() {
// TODO(beng): Should be in NativeTheme.
return CreateSolidBackground(SK_ColorWHITE);
}
std::unique_ptr<Background> CreateBackgroundFromPainter( std::unique_ptr<Background> CreateBackgroundFromPainter(
std::unique_ptr<Painter> painter) { std::unique_ptr<Painter> painter) {
return std::make_unique<BackgroundPainter>(std::move(painter)); return std::make_unique<BackgroundPainter>(std::move(painter));
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/color_palette.h"
#include "ui/native_theme/native_theme.h" #include "ui/native_theme/native_theme.h"
#include "ui/views/views_export.h" #include "ui/views/views_export.h"
...@@ -59,7 +60,7 @@ class VIEWS_EXPORT Background { ...@@ -59,7 +60,7 @@ class VIEWS_EXPORT Background {
SkColor get_color() const { return color_; } SkColor get_color() const { return color_; }
private: private:
SkColor color_; SkColor color_ = gfx::kPlaceholderColor;
DISALLOW_COPY_AND_ASSIGN(Background); DISALLOW_COPY_AND_ASSIGN(Background);
}; };
...@@ -78,9 +79,6 @@ VIEWS_EXPORT std::unique_ptr<Background> CreateThemedSolidBackground( ...@@ -78,9 +79,6 @@ VIEWS_EXPORT std::unique_ptr<Background> CreateThemedSolidBackground(
View* view, View* view,
ui::NativeTheme::ColorId color_id); ui::NativeTheme::ColorId color_id);
// Creates Chrome's standard panel background
VIEWS_EXPORT std::unique_ptr<Background> CreateStandardPanelBackground();
// Creates a Background from the specified Painter. // Creates a Background from the specified Painter.
VIEWS_EXPORT std::unique_ptr<Background> CreateBackgroundFromPainter( VIEWS_EXPORT std::unique_ptr<Background> CreateBackgroundFromPainter(
std::unique_ptr<Painter> painter); std::unique_ptr<Painter> painter);
......
...@@ -94,6 +94,7 @@ static_library("weblayer_shell_lib") { ...@@ -94,6 +94,7 @@ static_library("weblayer_shell_lib") {
if (toolkit_views) { if (toolkit_views) {
sources += [ "browser/shell_views.cc" ] sources += [ "browser/shell_views.cc" ]
deps += [ deps += [
"//ui/native_theme",
"//ui/resources", "//ui/resources",
"//ui/views:test_support", "//ui/views:test_support",
"//ui/views/controls/webview", "//ui/views/controls/webview",
......
...@@ -4,6 +4,7 @@ include_rules = [ ...@@ -4,6 +4,7 @@ include_rules = [
"+ui/base", "+ui/base",
"+ui/events", "+ui/events",
"+ui/gfx", "+ui/gfx",
"+ui/native_theme",
"+ui/views", "+ui/views",
"+ui/wm", "+ui/wm",
] ]
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/clipboard.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/native_theme/native_theme_color_id.h"
#include "ui/views/background.h" #include "ui/views/background.h"
#include "ui/views/controls/button/md_text_button.h" #include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
...@@ -107,7 +108,8 @@ class ShellWindowDelegateView : public views::WidgetDelegateView, ...@@ -107,7 +108,8 @@ class ShellWindowDelegateView : public views::WidgetDelegateView,
private: private:
// Initialize the UI control contained in shell window // Initialize the UI control contained in shell window
void InitShellWindow() { void InitShellWindow() {
SetBackground(views::CreateStandardPanelBackground()); SetBackground(CreateThemedSolidBackground(
this, ui::NativeTheme::kColorId_WindowBackground));
auto contents_view = std::make_unique<views::View>(); auto contents_view = std::make_unique<views::View>();
auto toolbar_view = std::make_unique<views::View>(); auto toolbar_view = std::make_unique<views::View>();
......
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