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

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

Issue 29943002: Limit display of the virtual keyboard to state changes triggered from a user gesture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ash_unittests Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/ime/input_method.h » ('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) 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/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "grit/ui_strings.h" 10 #include "grit/ui_strings.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 void Textfield::SetFontList(const gfx::FontList& font_list) { 223 void Textfield::SetFontList(const gfx::FontList& font_list) {
224 GetRenderText()->SetFontList(font_list); 224 GetRenderText()->SetFontList(font_list);
225 OnCaretBoundsChanged(); 225 OnCaretBoundsChanged();
226 PreferredSizeChanged(); 226 PreferredSizeChanged();
227 } 227 }
228 228
229 base::string16 Textfield::GetPlaceholderText() const { 229 base::string16 Textfield::GetPlaceholderText() const {
230 return placeholder_text_; 230 return placeholder_text_;
231 } 231 }
232 232
233 void Textfield::ShowImeIfNeeded() {
234 GetInputMethod()->ShowImeIfNeeded();
235 }
236
233 bool Textfield::IsIMEComposing() const { 237 bool Textfield::IsIMEComposing() const {
234 return model_->HasCompositionText(); 238 return model_->HasCompositionText();
235 } 239 }
236 240
237 const gfx::Range& Textfield::GetSelectedRange() const { 241 const gfx::Range& Textfield::GetSelectedRange() const {
238 return GetRenderText()->selection(); 242 return GetRenderText()->selection();
239 } 243 }
240 244
241 void Textfield::SelectRange(const gfx::Range& range) { 245 void Textfield::SelectRange(const gfx::Range& range) {
242 model_->SelectRange(range); 246 model_->SelectRange(range);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 return (text_changed || cursor_changed); 460 return (text_changed || cursor_changed);
457 } 461 }
458 return false; 462 return false;
459 } 463 }
460 464
461 bool Textfield::OnMousePressed(const ui::MouseEvent& event) { 465 bool Textfield::OnMousePressed(const ui::MouseEvent& event) {
462 OnBeforeUserAction(); 466 OnBeforeUserAction();
463 TrackMouseClicks(event); 467 TrackMouseClicks(event);
464 468
465 if (!controller_ || !controller_->HandleMouseEvent(this, event)) { 469 if (!controller_ || !controller_->HandleMouseEvent(this, event)) {
466 if (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) 470 if (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) {
467 RequestFocus(); 471 RequestFocus();
472 ShowImeIfNeeded();
473 }
468 474
469 if (event.IsOnlyLeftMouseButton()) { 475 if (event.IsOnlyLeftMouseButton()) {
470 initiating_drag_ = false; 476 initiating_drag_ = false;
471 bool can_drag = true; 477 bool can_drag = true;
472 478
473 switch (aggregated_clicks_) { 479 switch (aggregated_clicks_) {
474 case 0: 480 case 0:
475 if (can_drag && 481 if (can_drag &&
476 GetRenderText()->IsPointInSelection(event.location())) { 482 GetRenderText()->IsPointInSelection(event.location())) {
477 initiating_drag_ = true; 483 initiating_drag_ = true;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 static HCURSOR arrow = LoadCursor(NULL, IDC_ARROW); 633 static HCURSOR arrow = LoadCursor(NULL, IDC_ARROW);
628 return text_cursor ? ibeam : arrow; 634 return text_cursor ? ibeam : arrow;
629 #endif 635 #endif
630 } 636 }
631 637
632 void Textfield::OnGestureEvent(ui::GestureEvent* event) { 638 void Textfield::OnGestureEvent(ui::GestureEvent* event) {
633 switch (event->type()) { 639 switch (event->type()) {
634 case ui::ET_GESTURE_TAP_DOWN: 640 case ui::ET_GESTURE_TAP_DOWN:
635 OnBeforeUserAction(); 641 OnBeforeUserAction();
636 RequestFocus(); 642 RequestFocus();
643 ShowImeIfNeeded();
644
637 // We don't deselect if the point is in the selection 645 // We don't deselect if the point is in the selection
638 // because TAP_DOWN may turn into a LONG_PRESS. 646 // because TAP_DOWN may turn into a LONG_PRESS.
639 if (!GetRenderText()->IsPointInSelection(event->location()) && 647 if (!GetRenderText()->IsPointInSelection(event->location()) &&
640 MoveCursorTo(event->location(), false)) 648 MoveCursorTo(event->location(), false))
641 SchedulePaint(); 649 SchedulePaint();
642 OnAfterUserAction(); 650 OnAfterUserAction();
643 event->SetHandled(); 651 event->SetHandled();
644 break; 652 break;
645 case ui::ET_GESTURE_SCROLL_UPDATE: 653 case ui::ET_GESTURE_SCROLL_UPDATE:
646 OnBeforeUserAction(); 654 OnBeforeUserAction();
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 void Textfield::CreateTouchSelectionControllerAndNotifyIt() { 1471 void Textfield::CreateTouchSelectionControllerAndNotifyIt() {
1464 if (!touch_selection_controller_) { 1472 if (!touch_selection_controller_) {
1465 touch_selection_controller_.reset( 1473 touch_selection_controller_.reset(
1466 ui::TouchSelectionController::create(this)); 1474 ui::TouchSelectionController::create(this));
1467 } 1475 }
1468 if (touch_selection_controller_) 1476 if (touch_selection_controller_)
1469 touch_selection_controller_->SelectionChanged(); 1477 touch_selection_controller_->SelectionChanged();
1470 } 1478 }
1471 1479
1472 } // namespace views 1480 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/ime/input_method.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698