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

Side by Side Diff: ui/views/controls/textfield/textfield.cc

Issue 2383243002: Refactor MdFocusRing to make it easier to reuse on other controls. (Closed)
Patch Set: install Created 4 years, 2 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 | « ui/views/controls/focusable_border.cc ('k') | no next file » | no next file with comments »
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 "ui/views/controls/textfield/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 15 matching lines...) Expand all
26 #include "ui/display/screen.h" 26 #include "ui/display/screen.h"
27 #include "ui/events/base_event_utils.h" 27 #include "ui/events/base_event_utils.h"
28 #include "ui/events/event.h" 28 #include "ui/events/event.h"
29 #include "ui/events/keycodes/keyboard_codes.h" 29 #include "ui/events/keycodes/keyboard_codes.h"
30 #include "ui/gfx/canvas.h" 30 #include "ui/gfx/canvas.h"
31 #include "ui/gfx/geometry/insets.h" 31 #include "ui/gfx/geometry/insets.h"
32 #include "ui/gfx/selection_bound.h" 32 #include "ui/gfx/selection_bound.h"
33 #include "ui/native_theme/native_theme.h" 33 #include "ui/native_theme/native_theme.h"
34 #include "ui/strings/grit/ui_strings.h" 34 #include "ui/strings/grit/ui_strings.h"
35 #include "ui/views/background.h" 35 #include "ui/views/background.h"
36 #include "ui/views/controls/focus_ring.h"
36 #include "ui/views/controls/focusable_border.h" 37 #include "ui/views/controls/focusable_border.h"
37 #include "ui/views/controls/label.h" 38 #include "ui/views/controls/label.h"
38 #include "ui/views/controls/menu/menu_runner.h" 39 #include "ui/views/controls/menu/menu_runner.h"
39 #include "ui/views/controls/native/native_view_host.h" 40 #include "ui/views/controls/native/native_view_host.h"
40 #include "ui/views/controls/textfield/textfield_controller.h" 41 #include "ui/views/controls/textfield/textfield_controller.h"
41 #include "ui/views/drag_utils.h" 42 #include "ui/views/drag_utils.h"
42 #include "ui/views/metrics.h" 43 #include "ui/views/metrics.h"
43 #include "ui/views/native_cursor.h" 44 #include "ui/views/native_cursor.h"
44 #include "ui/views/painter.h" 45 #include "ui/views/painter.h"
45 #include "ui/views/style/platform_style.h" 46 #include "ui/views/style/platform_style.h"
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 if (ShouldShowCursor()) 984 if (ShouldShowCursor())
984 GetRenderText()->set_cursor_visible(true); 985 GetRenderText()->set_cursor_visible(true);
985 SchedulePaint(); 986 SchedulePaint();
986 if (GetInputMethod()) 987 if (GetInputMethod())
987 GetInputMethod()->SetFocusedTextInputClient(this); 988 GetInputMethod()->SetFocusedTextInputClient(this);
988 OnCaretBoundsChanged(); 989 OnCaretBoundsChanged();
989 if (ShouldBlinkCursor()) 990 if (ShouldBlinkCursor())
990 StartBlinkingCursor(); 991 StartBlinkingCursor();
991 View::OnFocus(); 992 View::OnFocus();
992 SchedulePaint(); 993 SchedulePaint();
994 if (ui::MaterialDesignController::IsSecondaryUiMaterial())
995 FocusRing::Install(this);
993 } 996 }
994 997
995 void Textfield::OnBlur() { 998 void Textfield::OnBlur() {
996 gfx::RenderText* render_text = GetRenderText(); 999 gfx::RenderText* render_text = GetRenderText();
997 render_text->set_focused(false); 1000 render_text->set_focused(false);
998 if (GetInputMethod()) 1001 if (GetInputMethod())
999 GetInputMethod()->DetachTextInputClient(this); 1002 GetInputMethod()->DetachTextInputClient(this);
1000 StopBlinkingCursor(); 1003 StopBlinkingCursor();
1001 if (render_text->cursor_visible()) { 1004 if (render_text->cursor_visible()) {
1002 render_text->set_cursor_visible(false); 1005 render_text->set_cursor_visible(false);
1003 RepaintCursor(); 1006 RepaintCursor();
1004 } 1007 }
1005 1008
1006 DestroyTouchSelection(); 1009 DestroyTouchSelection();
1007 1010
1008 // Border typically draws focus indicator. 1011 // Border typically draws focus indicator.
1009 SchedulePaint(); 1012 SchedulePaint();
1013 if (ui::MaterialDesignController::IsSecondaryUiMaterial())
1014 FocusRing::Uninstall(this);
1010 } 1015 }
1011 1016
1012 gfx::Point Textfield::GetKeyboardContextMenuLocation() { 1017 gfx::Point Textfield::GetKeyboardContextMenuLocation() {
1013 return GetCaretBounds().bottom_right(); 1018 return GetCaretBounds().bottom_right();
1014 } 1019 }
1015 1020
1016 void Textfield::OnNativeThemeChanged(const ui::NativeTheme* theme) { 1021 void Textfield::OnNativeThemeChanged(const ui::NativeTheme* theme) {
1017 gfx::RenderText* render_text = GetRenderText(); 1022 gfx::RenderText* render_text = GetRenderText();
1018 render_text->SetColor(GetTextColor()); 1023 render_text->SetColor(GetTextColor());
1019 UpdateBackgroundColor(); 1024 UpdateBackgroundColor();
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
2059 } 2064 }
2060 2065
2061 void Textfield::OnCursorBlinkTimerFired() { 2066 void Textfield::OnCursorBlinkTimerFired() {
2062 DCHECK(ShouldBlinkCursor()); 2067 DCHECK(ShouldBlinkCursor());
2063 gfx::RenderText* render_text = GetRenderText(); 2068 gfx::RenderText* render_text = GetRenderText();
2064 render_text->set_cursor_visible(!render_text->cursor_visible()); 2069 render_text->set_cursor_visible(!render_text->cursor_visible());
2065 RepaintCursor(); 2070 RepaintCursor();
2066 } 2071 }
2067 2072
2068 } // namespace views 2073 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/focusable_border.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698