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

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

Issue 2729133005: Fix: Cursor missing in omnibox after entering a alphabet in NTP 'Search box' (Closed)
Patch Set: Created 3 years, 9 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/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) 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/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 // Adjust the drop destination if it is on or after the current selection. 876 // Adjust the drop destination if it is on or after the current selection.
877 size_t pos = drop_destination_model.caret_pos(); 877 size_t pos = drop_destination_model.caret_pos();
878 pos -= render_text->selection().Intersect(gfx::Range(0, pos)).length(); 878 pos -= render_text->selection().Intersect(gfx::Range(0, pos)).length();
879 model_->DeleteSelectionAndInsertTextAt(new_text, pos); 879 model_->DeleteSelectionAndInsertTextAt(new_text, pos);
880 } else { 880 } else {
881 model_->MoveCursorTo(drop_destination_model); 881 model_->MoveCursorTo(drop_destination_model);
882 // Drop always inserts text even if the textfield is not in insert mode. 882 // Drop always inserts text even if the textfield is not in insert mode.
883 model_->InsertText(new_text); 883 model_->InsertText(new_text);
884 } 884 }
885 skip_input_method_cancel_composition_ = false; 885 skip_input_method_cancel_composition_ = false;
886 OnAfterUserAction();
886 UpdateAfterChange(true, true); 887 UpdateAfterChange(true, true);
887 OnAfterUserAction();
888 return move ? ui::DragDropTypes::DRAG_MOVE : ui::DragDropTypes::DRAG_COPY; 888 return move ? ui::DragDropTypes::DRAG_MOVE : ui::DragDropTypes::DRAG_COPY;
889 } 889 }
890 890
891 void Textfield::OnDragDone() { 891 void Textfield::OnDragDone() {
892 initiating_drag_ = false; 892 initiating_drag_ = false;
893 drop_cursor_visible_ = false; 893 drop_cursor_visible_ = false;
894 } 894 }
895 895
896 void Textfield::GetAccessibleNodeData(ui::AXNodeData* node_data) { 896 void Textfield::GetAccessibleNodeData(ui::AXNodeData* node_data) {
897 node_data->role = ui::AX_ROLE_TEXT_FIELD; 897 node_data->role = ui::AX_ROLE_TEXT_FIELD;
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 1257
1258 void Textfield::SetCompositionText(const ui::CompositionText& composition) { 1258 void Textfield::SetCompositionText(const ui::CompositionText& composition) {
1259 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) 1259 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE)
1260 return; 1260 return;
1261 1261
1262 OnBeforeUserAction(); 1262 OnBeforeUserAction();
1263 skip_input_method_cancel_composition_ = true; 1263 skip_input_method_cancel_composition_ = true;
1264 model_->SetCompositionText(composition); 1264 model_->SetCompositionText(composition);
1265 skip_input_method_cancel_composition_ = false; 1265 skip_input_method_cancel_composition_ = false;
1266 UpdateAfterChange(true, true); 1266 UpdateAfterChange(true, true);
1267 OnAfterUserAction(); 1267 OnAfterUserAction();
sadrul 2017/03/04 04:05:17 There are a few other places where OnAfterUserActi
1268 } 1268 }
1269 1269
1270 void Textfield::ConfirmCompositionText() { 1270 void Textfield::ConfirmCompositionText() {
1271 if (!model_->HasCompositionText()) 1271 if (!model_->HasCompositionText())
1272 return; 1272 return;
1273 1273
1274 OnBeforeUserAction(); 1274 OnBeforeUserAction();
1275 skip_input_method_cancel_composition_ = true; 1275 skip_input_method_cancel_composition_ = true;
1276 model_->ConfirmCompositionText(); 1276 model_->ConfirmCompositionText();
1277 skip_input_method_cancel_composition_ = false; 1277 skip_input_method_cancel_composition_ = false;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 1576
1577 //////////////////////////////////////////////////////////////////////////////// 1577 ////////////////////////////////////////////////////////////////////////////////
1578 // Textfield, protected: 1578 // Textfield, protected:
1579 1579
1580 void Textfield::DoInsertChar(base::char16 ch) { 1580 void Textfield::DoInsertChar(base::char16 ch) {
1581 OnBeforeUserAction(); 1581 OnBeforeUserAction();
1582 skip_input_method_cancel_composition_ = true; 1582 skip_input_method_cancel_composition_ = true;
1583 model_->InsertChar(ch); 1583 model_->InsertChar(ch);
1584 skip_input_method_cancel_composition_ = false; 1584 skip_input_method_cancel_composition_ = false;
1585 1585
1586 OnAfterUserAction();
1586 UpdateAfterChange(true, true); 1587 UpdateAfterChange(true, true);
1587 OnAfterUserAction();
1588 } 1588 }
1589 1589
1590 gfx::RenderText* Textfield::GetRenderText() const { 1590 gfx::RenderText* Textfield::GetRenderText() const {
1591 return model_->render_text(); 1591 return model_->render_text();
1592 } 1592 }
1593 1593
1594 gfx::Point Textfield::GetLastClickLocation() const { 1594 gfx::Point Textfield::GetLastClickLocation() const {
1595 return selection_controller_.last_click_location(); 1595 return selection_controller_.last_click_location();
1596 } 1596 }
1597 1597
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 cursor_blink_timer_.Stop(); 2086 cursor_blink_timer_.Stop();
2087 } 2087 }
2088 2088
2089 void Textfield::OnCursorBlinkTimerFired() { 2089 void Textfield::OnCursorBlinkTimerFired() {
2090 DCHECK(ShouldBlinkCursor()); 2090 DCHECK(ShouldBlinkCursor());
2091 cursor_view_.SetVisible(!cursor_view_.visible()); 2091 cursor_view_.SetVisible(!cursor_view_.visible());
2092 UpdateCursorView(); 2092 UpdateCursorView();
2093 } 2093 }
2094 2094
2095 } // namespace views 2095 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698