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

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

Issue 108063004: Give up focus if the focused view becomes unfocusable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Extracted to common code into FocusManager class Created 7 years 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 | Annotate | Revision Log
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 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 draw_border_(true), 65 draw_border_(true),
66 text_color_(SK_ColorBLACK), 66 text_color_(SK_ColorBLACK),
67 use_default_text_color_(true), 67 use_default_text_color_(true),
68 background_color_(SK_ColorWHITE), 68 background_color_(SK_ColorWHITE),
69 use_default_background_color_(true), 69 use_default_background_color_(true),
70 horizontal_margins_were_set_(false), 70 horizontal_margins_were_set_(false),
71 vertical_margins_were_set_(false), 71 vertical_margins_were_set_(false),
72 placeholder_text_color_(kDefaultPlaceholderTextColor), 72 placeholder_text_color_(kDefaultPlaceholderTextColor),
73 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT), 73 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT),
74 weak_ptr_factory_(this) { 74 weak_ptr_factory_(this) {
75 set_focusable(true); 75 SetFocusable(true);
76 76
77 if (ViewsDelegate::views_delegate) { 77 if (ViewsDelegate::views_delegate) {
78 obscured_reveal_duration_ = ViewsDelegate::views_delegate-> 78 obscured_reveal_duration_ = ViewsDelegate::views_delegate->
79 GetDefaultTextfieldObscuredRevealDuration(); 79 GetDefaultTextfieldObscuredRevealDuration();
80 } 80 }
81 81
82 if (NativeViewHost::kRenderNativeControlFocus) 82 if (NativeViewHost::kRenderNativeControlFocus)
83 focus_painter_ = Painter::CreateDashedFocusPainter(); 83 focus_painter_ = Painter::CreateDashedFocusPainter();
84 } 84 }
85 85
86 Textfield::Textfield(StyleFlags style) 86 Textfield::Textfield(StyleFlags style)
87 : native_wrapper_(NULL), 87 : native_wrapper_(NULL),
88 controller_(NULL), 88 controller_(NULL),
89 style_(style), 89 style_(style),
90 font_list_(GetDefaultFontList()), 90 font_list_(GetDefaultFontList()),
91 read_only_(false), 91 read_only_(false),
92 default_width_in_chars_(0), 92 default_width_in_chars_(0),
93 draw_border_(true), 93 draw_border_(true),
94 text_color_(SK_ColorBLACK), 94 text_color_(SK_ColorBLACK),
95 use_default_text_color_(true), 95 use_default_text_color_(true),
96 background_color_(SK_ColorWHITE), 96 background_color_(SK_ColorWHITE),
97 use_default_background_color_(true), 97 use_default_background_color_(true),
98 horizontal_margins_were_set_(false), 98 horizontal_margins_were_set_(false),
99 vertical_margins_were_set_(false), 99 vertical_margins_were_set_(false),
100 placeholder_text_color_(kDefaultPlaceholderTextColor), 100 placeholder_text_color_(kDefaultPlaceholderTextColor),
101 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT), 101 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT),
102 weak_ptr_factory_(this) { 102 weak_ptr_factory_(this) {
103 set_focusable(true); 103 SetFocusable(true);
104 if (IsObscured()) 104 if (IsObscured())
105 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 105 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
106 106
107 if (ViewsDelegate::views_delegate) { 107 if (ViewsDelegate::views_delegate) {
108 obscured_reveal_duration_ = ViewsDelegate::views_delegate-> 108 obscured_reveal_duration_ = ViewsDelegate::views_delegate->
109 GetDefaultTextfieldObscuredRevealDuration(); 109 GetDefaultTextfieldObscuredRevealDuration();
110 } 110 }
111 111
112 if (NativeViewHost::kRenderNativeControlFocus) 112 if (NativeViewHost::kRenderNativeControlFocus)
113 focus_painter_ = Painter::CreateDashedFocusPainter(); 113 focus_painter_ = Painter::CreateDashedFocusPainter();
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 //////////////////////////////////////////////////////////////////////////////// 569 ////////////////////////////////////////////////////////////////////////////////
570 // NativeTextfieldWrapper, public: 570 // NativeTextfieldWrapper, public:
571 571
572 // static 572 // static
573 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( 573 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper(
574 Textfield* field) { 574 Textfield* field) {
575 return new NativeTextfieldViews(field); 575 return new NativeTextfieldViews(field);
576 } 576 }
577 577
578 } // namespace views 578 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698