Chromium Code Reviews| 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 { |