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

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

Issue 2679313003: Implemented IA2::setSelection and related methods on text fields in Views. (Closed)
Patch Set: Created 3 years, 10 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
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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 } 890 }
891 node_data->AddStringAttribute(ui::AX_ATTR_PLACEHOLDER, 891 node_data->AddStringAttribute(ui::AX_ATTR_PLACEHOLDER,
892 base::UTF16ToUTF8(GetPlaceholderText())); 892 base::UTF16ToUTF8(GetPlaceholderText()));
893 893
894 const gfx::Range range = GetSelectedRange(); 894 const gfx::Range range = GetSelectedRange();
895 node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, range.start()); 895 node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, range.start());
896 node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, range.end()); 896 node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, range.end());
897 } 897 }
898 898
899 bool Textfield::HandleAccessibleAction(const ui::AXActionData& action_data) { 899 bool Textfield::HandleAccessibleAction(const ui::AXActionData& action_data) {
900 if (action_data.action == ui::AX_ACTION_SET_SELECTION) {
901 const gfx::Range range(action_data.anchor_offset, action_data.focus_offset);
902 SetSelectionRange(range);
903 }
904
905 // Remaining actions cannot be performed on readonly fields.
900 if (read_only()) 906 if (read_only())
901 return View::HandleAccessibleAction(action_data); 907 return View::HandleAccessibleAction(action_data);
902 908
903 if (action_data.action == ui::AX_ACTION_SET_VALUE) { 909 if (action_data.action == ui::AX_ACTION_SET_VALUE) {
904 SetText(action_data.value); 910 SetText(action_data.value);
905 ClearSelection(); 911 ClearSelection();
906 return true; 912 return true;
907 } else if (action_data.action == ui::AX_ACTION_REPLACE_SELECTED_TEXT) { 913 } else if (action_data.action == ui::AX_ACTION_REPLACE_SELECTED_TEXT) {
908 InsertOrReplaceText(action_data.value); 914 InsertOrReplaceText(action_data.value);
909 ClearSelection(); 915 ClearSelection();
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 } 2059 }
2054 2060
2055 void Textfield::OnCursorBlinkTimerFired() { 2061 void Textfield::OnCursorBlinkTimerFired() {
2056 DCHECK(ShouldBlinkCursor()); 2062 DCHECK(ShouldBlinkCursor());
2057 gfx::RenderText* render_text = GetRenderText(); 2063 gfx::RenderText* render_text = GetRenderText();
2058 render_text->set_cursor_visible(!render_text->cursor_visible()); 2064 render_text->set_cursor_visible(!render_text->cursor_visible());
2059 RepaintCursor(); 2065 RepaintCursor();
2060 } 2066 }
2061 2067
2062 } // namespace views 2068 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698