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

Unified Diff: ui/gfx/render_text.cc

Issue 2345183002: Views: Draw Textfield selected text in gray when top-level Widget loses focus.
Patch Set: Refactor to use SelectionController(Delegate). Unfinished! Created 4 years, 1 month 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/gfx/render_text.h ('k') | ui/native_theme/common_theme.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text.cc
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
index eb2e8cf59efff1be9368ff7276313af02dd2b3d3..84306154723c31c23c6aef7b65b90530f8578e56 100644
--- a/ui/gfx/render_text.cc
+++ b/ui/gfx/render_text.cc
@@ -852,7 +852,7 @@ void RenderText::Draw(Canvas* canvas) {
canvas->ClipRect(clip_rect);
}
- if (!text().empty() && focused())
+ if (!selection().is_empty())
DrawSelection(canvas);
if (cursor_enabled() && cursor_visible() && focused())
@@ -1062,7 +1062,8 @@ RenderText::RenderText()
cursor_visible_(false),
cursor_color_(kDefaultColor),
selection_color_(kDefaultColor),
- selection_background_focused_color_(kDefaultSelectionBackgroundColor),
+ selection_background_color_(kDefaultSelectionBackgroundColor),
+ draw_text_selection_(false),
focused_(false),
composition_range_(Range::InvalidRange()),
colors_(kDefaultColor),
@@ -1636,8 +1637,10 @@ void RenderText::UpdateCachedBoundsAndOffset() {
}
void RenderText::DrawSelection(Canvas* canvas) {
+ if (!draw_text_selection_)
+ return;
for (const Rect& s : GetSubstringBounds(selection()))
- canvas->FillRect(s, selection_background_focused_color_);
+ canvas->FillRect(s, selection_background_color_);
}
size_t RenderText::GetNearestWordStartBoundary(size_t index) const {
« no previous file with comments | « ui/gfx/render_text.h ('k') | ui/native_theme/common_theme.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698