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

Unified Diff: ui/views/controls/label.cc

Issue 2065003002: Do not SchedulePaint() inside views::Label::OnPaint() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a test 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/label.h ('k') | ui/views/controls/label_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/label.cc
diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc
index 872470efe9b24d8b0269d59f174ed234b6912043..f03084ae6bdcba757b93cf35a79000464d2bcb90 100644
--- a/ui/views/controls/label.cc
+++ b/ui/views/controls/label.cc
@@ -345,7 +345,8 @@ bool Label::GetTooltipText(const gfx::Point& p, base::string16* tooltip) const {
}
void Label::OnEnabledChanged() {
- RecalculateColors();
+ ApplyTextColors();
+ View::OnEnabledChanged();
}
std::unique_ptr<gfx::RenderText> Label::CreateRenderText(
@@ -495,7 +496,7 @@ void Label::MaybeBuildRenderTextLines() {
for (size_t i = lines_.size(); i < lines.size(); ++i)
lines_.back()->SetText(lines_.back()->text() + lines[i]);
}
- RecalculateColors();
+ ApplyTextColors();
}
gfx::Rect Label::GetFocusBounds() {
@@ -574,6 +575,11 @@ void Label::RecalculateColors() {
background_color_) :
requested_disabled_color_;
+ ApplyTextColors();
+ SchedulePaint();
+}
+
+void Label::ApplyTextColors() {
SkColor color = enabled() ? actual_enabled_color_ : actual_disabled_color_;
bool subpixel_rendering_suppressed =
SkColorGetA(background_color_) != 0xFF || !subpixel_rendering_enabled_;
@@ -581,7 +587,6 @@ void Label::RecalculateColors() {
lines_[i]->SetColor(color);
lines_[i]->set_subpixel_rendering_suppressed(subpixel_rendering_suppressed);
}
- SchedulePaint();
}
void Label::UpdateColorsFromTheme(const ui::NativeTheme* theme) {
« no previous file with comments | « ui/views/controls/label.h ('k') | ui/views/controls/label_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698