Commit bab0ac30 authored by Allen Bauer's avatar Allen Bauer Committed by Commit Bot

Use gfx::PlaceholderColor instead of explicit SK_ColorRED.

Bug: 1056761
Change-Id: I0f477c21d315ae707825b43daf8a1cbfb11eb72c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078996
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Auto-Submit: Allen Bauer <kylixrd@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745258}
parent 5d9d06ce
...@@ -13,14 +13,12 @@ LabelButtonLabel::~LabelButtonLabel() = default; ...@@ -13,14 +13,12 @@ LabelButtonLabel::~LabelButtonLabel() = default;
void LabelButtonLabel::SetDisabledColor(SkColor color) { void LabelButtonLabel::SetDisabledColor(SkColor color) {
requested_disabled_color_ = color; requested_disabled_color_ = color;
disabled_color_set_ = true;
if (!GetEnabled()) if (!GetEnabled())
Label::SetEnabledColor(color); Label::SetEnabledColor(color);
} }
void LabelButtonLabel::SetEnabledColor(SkColor color) { void LabelButtonLabel::SetEnabledColor(SkColor color) {
requested_enabled_color_ = color; requested_enabled_color_ = color;
enabled_color_set_ = true;
if (GetEnabled()) if (GetEnabled())
Label::SetEnabledColor(color); Label::SetEnabledColor(color);
} }
...@@ -35,9 +33,9 @@ void LabelButtonLabel::OnEnabledChanged() { ...@@ -35,9 +33,9 @@ void LabelButtonLabel::OnEnabledChanged() {
} }
void LabelButtonLabel::SetColorForEnableState() { void LabelButtonLabel::SetColorForEnableState() {
if (GetEnabled() ? enabled_color_set_ : disabled_color_set_) { if (GetEnabled() ? requested_enabled_color_ : requested_disabled_color_) {
Label::SetEnabledColor(GetEnabled() ? requested_enabled_color_ Label::SetEnabledColor(GetEnabled() ? *requested_enabled_color_
: requested_disabled_color_); : *requested_disabled_color_);
} else { } else {
int style = GetEnabled() ? style::STYLE_PRIMARY : style::STYLE_DISABLED; int style = GetEnabled() ? style::STYLE_PRIMARY : style::STYLE_DISABLED;
Label::SetEnabledColor(style::GetColor(*this, GetTextContext(), style)); Label::SetEnabledColor(style::GetColor(*this, GetTextContext(), style));
......
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h"
#include "base/strings/string16.h" #include "base/strings/string16.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/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/views_export.h" #include "ui/views/views_export.h"
...@@ -36,10 +38,8 @@ class VIEWS_EXPORT LabelButtonLabel : public Label { ...@@ -36,10 +38,8 @@ class VIEWS_EXPORT LabelButtonLabel : public Label {
void OnEnabledChanged(); void OnEnabledChanged();
void SetColorForEnableState(); void SetColorForEnableState();
SkColor requested_disabled_color_ = SK_ColorRED; base::Optional<SkColor> requested_disabled_color_;
SkColor requested_enabled_color_ = SK_ColorRED; base::Optional<SkColor> requested_enabled_color_;
bool disabled_color_set_ = false;
bool enabled_color_set_ = false;
PropertyChangedSubscription enabled_changed_subscription_ = PropertyChangedSubscription enabled_changed_subscription_ =
AddEnabledChangedCallback( AddEnabledChangedCallback(
base::BindRepeating(&LabelButtonLabel::OnEnabledChanged, base::BindRepeating(&LabelButtonLabel::OnEnabledChanged,
......
...@@ -955,19 +955,7 @@ void Label::Init(const base::string16& text, ...@@ -955,19 +955,7 @@ void Label::Init(const base::string16& text,
full_text_->SetCursorEnabled(false); full_text_->SetCursorEnabled(false);
full_text_->SetWordWrapBehavior(gfx::TRUNCATE_LONG_WORDS); full_text_->SetWordWrapBehavior(gfx::TRUNCATE_LONG_WORDS);
elide_behavior_ = gfx::ELIDE_TAIL;
stored_selection_range_ = gfx::Range::InvalidRange();
enabled_color_set_ = background_color_set_ = false;
selection_text_color_set_ = selection_background_color_set_ = false;
subpixel_rendering_enabled_ = true;
auto_color_readability_enabled_ = true;
multi_line_ = false;
max_lines_ = 0;
UpdateColorsFromTheme(); UpdateColorsFromTheme();
handles_tooltips_ = true;
collapse_when_hidden_ = false;
fixed_width_ = 0;
max_width_ = 0;
SetText(text); SetText(text);
// Only selectable labels will get requests to show the context menu, due to // Only selectable labels will get requests to show the context menu, due to
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/macros.h" #include "base/macros.h"
#include "ui/base/models/simple_menu_model.h" #include "ui/base/models/simple_menu_model.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/render_text.h" #include "ui/gfx/render_text.h"
#include "ui/gfx/text_constants.h" #include "ui/gfx/text_constants.h"
#include "ui/views/context_menu_controller.h" #include "ui/views/context_menu_controller.h"
...@@ -384,34 +385,34 @@ class VIEWS_EXPORT Label : public View, ...@@ -384,34 +385,34 @@ class VIEWS_EXPORT Label : public View,
// Persists the current selection range between the calls to // Persists the current selection range between the calls to
// ClearDisplayText() and MaybeBuildDisplayText(). Holds an InvalidRange when // ClearDisplayText() and MaybeBuildDisplayText(). Holds an InvalidRange when
// not in use. // not in use.
mutable gfx::Range stored_selection_range_; mutable gfx::Range stored_selection_range_ = gfx::Range::InvalidRange();
SkColor requested_enabled_color_ = SK_ColorRED; SkColor requested_enabled_color_ = gfx::kPlaceholderColor;
SkColor actual_enabled_color_ = SK_ColorRED; SkColor actual_enabled_color_ = gfx::kPlaceholderColor;
SkColor background_color_ = SK_ColorRED; SkColor background_color_ = gfx::kPlaceholderColor;
SkColor requested_selection_text_color_ = SK_ColorRED; SkColor requested_selection_text_color_ = gfx::kPlaceholderColor;
SkColor actual_selection_text_color_ = SK_ColorRED; SkColor actual_selection_text_color_ = gfx::kPlaceholderColor;
SkColor selection_background_color_ = SK_ColorRED; SkColor selection_background_color_ = gfx::kPlaceholderColor;
// Set to true once the corresponding setter is invoked. // Set to true once the corresponding setter is invoked.
bool enabled_color_set_; bool enabled_color_set_ = false;
bool background_color_set_; bool background_color_set_ = false;
bool selection_text_color_set_; bool selection_text_color_set_ = false;
bool selection_background_color_set_; bool selection_background_color_set_ = false;
gfx::ElideBehavior elide_behavior_; gfx::ElideBehavior elide_behavior_ = gfx::ELIDE_TAIL;
bool subpixel_rendering_enabled_; bool subpixel_rendering_enabled_ = true;
bool auto_color_readability_enabled_; bool auto_color_readability_enabled_ = true;
// TODO(mukai): remove |multi_line_| when all RenderText can render multiline. // TODO(mukai): remove |multi_line_| when all RenderText can render multiline.
bool multi_line_; bool multi_line_ = false;
int max_lines_; int max_lines_ = 0;
base::string16 tooltip_text_; base::string16 tooltip_text_;
bool handles_tooltips_; bool handles_tooltips_ = true;
// Whether to collapse the label when it's not visible. // Whether to collapse the label when it's not visible.
bool collapse_when_hidden_; bool collapse_when_hidden_ = false;
int fixed_width_; int fixed_width_ = 0;
int max_width_; int max_width_ = 0;
std::unique_ptr<SelectionController> selection_controller_; std::unique_ptr<SelectionController> selection_controller_;
......
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