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

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

Issue 8368016: Rebase BookmarkBubble on the new views bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Anchor by View instead of Point, tweak select_on_focus, add TextfieldTest. Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/controls/textfield/textfield.h ('k') | views/controls/textfield/textfield_unittest.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/controls/textfield/textfield.h" 5 #include "views/controls/textfield/textfield.h"
6 6
7 #if defined(TOOLKIT_USES_GTK) 7 #if defined(TOOLKIT_USES_GTK)
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 #endif 9 #endif
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 read_only_(false), 48 read_only_(false),
49 default_width_in_chars_(0), 49 default_width_in_chars_(0),
50 draw_border_(true), 50 draw_border_(true),
51 text_color_(SK_ColorBLACK), 51 text_color_(SK_ColorBLACK),
52 use_default_text_color_(true), 52 use_default_text_color_(true),
53 background_color_(SK_ColorWHITE), 53 background_color_(SK_ColorWHITE),
54 use_default_background_color_(true), 54 use_default_background_color_(true),
55 initialized_(false), 55 initialized_(false),
56 horizontal_margins_were_set_(false), 56 horizontal_margins_were_set_(false),
57 vertical_margins_were_set_(false), 57 vertical_margins_were_set_(false),
58 select_all_on_focus_(false),
58 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) { 59 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) {
59 set_focusable(true); 60 set_focusable(true);
60 } 61 }
61 62
62 Textfield::Textfield(StyleFlags style) 63 Textfield::Textfield(StyleFlags style)
63 : native_wrapper_(NULL), 64 : native_wrapper_(NULL),
64 controller_(NULL), 65 controller_(NULL),
65 style_(style), 66 style_(style),
66 read_only_(false), 67 read_only_(false),
67 default_width_in_chars_(0), 68 default_width_in_chars_(0),
68 draw_border_(true), 69 draw_border_(true),
69 text_color_(SK_ColorBLACK), 70 text_color_(SK_ColorBLACK),
70 use_default_text_color_(true), 71 use_default_text_color_(true),
71 background_color_(SK_ColorWHITE), 72 background_color_(SK_ColorWHITE),
72 use_default_background_color_(true), 73 use_default_background_color_(true),
73 initialized_(false), 74 initialized_(false),
74 horizontal_margins_were_set_(false), 75 horizontal_margins_were_set_(false),
75 vertical_margins_were_set_(false), 76 vertical_margins_were_set_(false),
77 select_all_on_focus_(false),
76 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) { 78 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) {
77 set_focusable(true); 79 set_focusable(true);
78 if (IsPassword()) 80 if (IsPassword())
79 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 81 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
80 } 82 }
81 83
82 Textfield::~Textfield() { 84 Textfield::~Textfield() {
83 } 85 }
84 86
85 void Textfield::SetController(TextfieldController* controller) { 87 void Textfield::SetController(TextfieldController* controller) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 if (native_wrapper_) 382 if (native_wrapper_)
381 native_wrapper_->HandleFocus(); 383 native_wrapper_->HandleFocus();
382 384
383 // Forward the focus to the wrapper if it exists. 385 // Forward the focus to the wrapper if it exists.
384 if (!native_wrapper_ || !native_wrapper_->SetFocus()) { 386 if (!native_wrapper_ || !native_wrapper_->SetFocus()) {
385 // If there is no wrapper or the wrapper didn't take focus, call 387 // If there is no wrapper or the wrapper didn't take focus, call
386 // View::Focus to clear the native focus so that we still get 388 // View::Focus to clear the native focus so that we still get
387 // keyboard messages. 389 // keyboard messages.
388 View::OnFocus(); 390 View::OnFocus();
389 } 391 }
392
393 if (select_all_on_focus())
394 SelectAll();
395 else
396 ClearSelection();
jennyz 2011/11/10 18:08:33 I still concern this may affect the NativeTextfiel
jennyz 2011/11/10 18:27:06 Sorry I missed some detail in previous comment. I
390 } 397 }
391 398
392 void Textfield::OnBlur() { 399 void Textfield::OnBlur() {
393 if (native_wrapper_) 400 if (native_wrapper_)
394 native_wrapper_->HandleBlur(); 401 native_wrapper_->HandleBlur();
395 } 402 }
396 403
397 void Textfield::GetAccessibleState(ui::AccessibleViewState* state) { 404 void Textfield::GetAccessibleState(ui::AccessibleViewState* state) {
398 state->role = ui::AccessibilityTypes::ROLE_TEXT; 405 state->role = ui::AccessibilityTypes::ROLE_TEXT;
399 state->name = accessible_name_; 406 state->name = accessible_name_;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 } 451 }
445 #endif 452 #endif
446 } 453 }
447 } 454 }
448 455
449 std::string Textfield::GetClassName() const { 456 std::string Textfield::GetClassName() const {
450 return kViewClassName; 457 return kViewClassName;
451 } 458 }
452 459
453 } // namespace views 460 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/textfield/textfield.h ('k') | views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698