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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 2345183002: Views: Draw Textfield selected text in gray when top-level Widget loses focus.
Patch Set: Fix up diff & add colors to Windows/Mac. Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/gfx/render_text.h » ('j') | ui/gfx/render_text.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 void OmniboxViewViews::OnNativeThemeChanged(const ui::NativeTheme* theme) { 301 void OmniboxViewViews::OnNativeThemeChanged(const ui::NativeTheme* theme) {
302 views::Textfield::OnNativeThemeChanged(theme); 302 views::Textfield::OnNativeThemeChanged(theme);
303 if (location_bar_view_) { 303 if (location_bar_view_) {
304 SetBackgroundColor( 304 SetBackgroundColor(
305 location_bar_view_->GetColor(LocationBarView::BACKGROUND)); 305 location_bar_view_->GetColor(LocationBarView::BACKGROUND));
306 } 306 }
307 EmphasizeURLComponents(); 307 EmphasizeURLComponents();
308 } 308 }
309 309
310 void OmniboxViewViews::OnPaint(gfx::Canvas* canvas) { 310 void OmniboxViewViews::OnPaint(gfx::Canvas* canvas) {
311 bool draw_unfocused_selection_ =
312 !HasFocus() &&
313 GetWidget()->GetFocusManager()->GetStoredFocusView() == this;
314 gfx::Range range = GetSelectedRange();
315 if (draw_unfocused_selection_)
316 GetRenderText()->SelectRange(saved_selection_for_focus_change_);
317
311 Textfield::OnPaint(canvas); 318 Textfield::OnPaint(canvas);
319
320 if (draw_unfocused_selection_)
321 GetRenderText()->SelectRange(range);
322
312 if (!insert_char_time_.is_null()) { 323 if (!insert_char_time_.is_null()) {
313 UMA_HISTOGRAM_TIMES("Omnibox.CharTypedToRepaintLatency", 324 UMA_HISTOGRAM_TIMES("Omnibox.CharTypedToRepaintLatency",
314 base::TimeTicks::Now() - insert_char_time_); 325 base::TimeTicks::Now() - insert_char_time_);
315 insert_char_time_ = base::TimeTicks(); 326 insert_char_time_ = base::TimeTicks();
316 } 327 }
317 } 328 }
318 329
319 void OmniboxViewViews::ExecuteCommand(int command_id, int event_flags) { 330 void OmniboxViewViews::ExecuteCommand(int command_id, int event_flags) {
320 // In the base class, touch text selection is deactivated when a command is 331 // In the base class, touch text selection is deactivated when a command is
321 // executed. Since we are not always calling the base class implementation 332 // executed. Since we are not always calling the base class implementation
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); 1087 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO);
1077 1088
1078 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); 1089 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR);
1079 1090
1080 // Minor note: We use IDC_ for command id here while the underlying textfield 1091 // Minor note: We use IDC_ for command id here while the underlying textfield
1081 // is using IDS_ for all its command ids. This is because views cannot depend 1092 // is using IDS_ for all its command ids. This is because views cannot depend
1082 // on IDC_ for now. 1093 // on IDC_ for now.
1083 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, 1094 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
1084 IDS_EDIT_SEARCH_ENGINES); 1095 IDS_EDIT_SEARCH_ENGINES);
1085 } 1096 }
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/render_text.h » ('j') | ui/gfx/render_text.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698