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

Unified Diff: ui/gfx/render_text.cc

Issue 2345183002: Views: Draw Textfield selected text in gray when top-level Widget loses focus.
Patch Set: Fix lifetime issues with BorderView's widget_ and address review comments. 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
Index: ui/gfx/render_text.cc
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
index eb2e8cf59efff1be9368ff7276313af02dd2b3d3..34b51206580b242c10cfb12e4fe7e6522a3251e9 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_(true),
msw 2016/11/09 02:14:54 I don't know if this should be true by default, no
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 {

Powered by Google App Engine
This is Rietveld 408576698