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

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

Issue 759433002: Reland: Move TouchSelectionController from content to ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Excluded ui/touch_selection from Windows GN build Created 6 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
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 "ui/accessibility/ax_view_state.h" 10 #include "ui/accessibility/ax_view_state.h"
11 #include "ui/base/clipboard/scoped_clipboard_writer.h" 11 #include "ui/base/clipboard/scoped_clipboard_writer.h"
12 #include "ui/base/cursor/cursor.h" 12 #include "ui/base/cursor/cursor.h"
13 #include "ui/base/dragdrop/drag_drop_types.h" 13 #include "ui/base/dragdrop/drag_drop_types.h"
14 #include "ui/base/dragdrop/drag_utils.h" 14 #include "ui/base/dragdrop/drag_utils.h"
15 #include "ui/base/touch/selection_bound.h"
15 #include "ui/base/ui_base_switches_util.h" 16 #include "ui/base/ui_base_switches_util.h"
16 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 17 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
17 #include "ui/events/event.h" 18 #include "ui/events/event.h"
18 #include "ui/events/keycodes/keyboard_codes.h" 19 #include "ui/events/keycodes/keyboard_codes.h"
19 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/display.h" 21 #include "ui/gfx/display.h"
21 #include "ui/gfx/insets.h" 22 #include "ui/gfx/insets.h"
22 #include "ui/gfx/screen.h" 23 #include "ui/gfx/screen.h"
23 #include "ui/native_theme/native_theme.h" 24 #include "ui/native_theme/native_theme.h"
24 #include "ui/strings/grit/ui_strings.h" 25 #include "ui/strings/grit/ui_strings.h"
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 1104
1104 void Textfield::GetSelectionEndPoints(ui::SelectionBound* anchor, 1105 void Textfield::GetSelectionEndPoints(ui::SelectionBound* anchor,
1105 ui::SelectionBound* focus) { 1106 ui::SelectionBound* focus) {
1106 gfx::RenderText* render_text = GetRenderText(); 1107 gfx::RenderText* render_text = GetRenderText();
1107 const gfx::SelectionModel& sel = render_text->selection_model(); 1108 const gfx::SelectionModel& sel = render_text->selection_model();
1108 gfx::SelectionModel start_sel = 1109 gfx::SelectionModel start_sel =
1109 render_text->GetSelectionModelForSelectionStart(); 1110 render_text->GetSelectionModelForSelectionStart();
1110 gfx::Rect r1 = render_text->GetCursorBounds(start_sel, true); 1111 gfx::Rect r1 = render_text->GetCursorBounds(start_sel, true);
1111 gfx::Rect r2 = render_text->GetCursorBounds(sel, true); 1112 gfx::Rect r2 = render_text->GetCursorBounds(sel, true);
1112 1113
1113 anchor->edge_top = r1.origin(); 1114 anchor->SetEdge(r1.origin(), r1.bottom_left());
1114 anchor->edge_bottom = r1.bottom_left(); 1115 focus->SetEdge(r2.origin(), r2.bottom_left());
1115 focus->edge_top = r2.origin();
1116 focus->edge_bottom = r2.bottom_left();
1117 1116
1118 // Determine the SelectionBound's type for focus and anchor. 1117 // Determine the SelectionBound's type for focus and anchor.
1119 // TODO(mfomitchev): Ideally we should have different logical directions for 1118 // TODO(mfomitchev): Ideally we should have different logical directions for
1120 // start and end to support proper handle direction for mixed LTR/RTL text. 1119 // start and end to support proper handle direction for mixed LTR/RTL text.
1121 const bool ltr = GetTextDirection() != base::i18n::RIGHT_TO_LEFT; 1120 const bool ltr = GetTextDirection() != base::i18n::RIGHT_TO_LEFT;
1122 size_t anchor_position_index = sel.selection().start(); 1121 size_t anchor_position_index = sel.selection().start();
1123 size_t focus_position_index = sel.selection().end(); 1122 size_t focus_position_index = sel.selection().end();
1124 1123
1125 if (anchor_position_index == focus_position_index) { 1124 if (anchor_position_index == focus_position_index) {
1126 anchor->type = focus->type = ui::SelectionBound::CENTER; 1125 anchor->set_type(ui::SelectionBound::CENTER);
1126 focus->set_type(ui::SelectionBound::CENTER);
1127 } else if ((ltr && anchor_position_index < focus_position_index) || 1127 } else if ((ltr && anchor_position_index < focus_position_index) ||
1128 (!ltr && anchor_position_index > focus_position_index)) { 1128 (!ltr && anchor_position_index > focus_position_index)) {
1129 anchor->type = ui::SelectionBound::LEFT; 1129 anchor->set_type(ui::SelectionBound::LEFT);
1130 focus->type = ui::SelectionBound::RIGHT; 1130 focus->set_type(ui::SelectionBound::RIGHT);
1131 } else { 1131 } else {
1132 anchor->type = ui::SelectionBound::RIGHT; 1132 anchor->set_type(ui::SelectionBound::RIGHT);
1133 focus->type = ui::SelectionBound::LEFT; 1133 focus->set_type(ui::SelectionBound::LEFT);
1134 } 1134 }
1135 } 1135 }
1136 1136
1137 gfx::Rect Textfield::GetBounds() { 1137 gfx::Rect Textfield::GetBounds() {
1138 return GetLocalBounds(); 1138 return GetLocalBounds();
1139 } 1139 }
1140 1140
1141 gfx::NativeView Textfield::GetNativeView() const { 1141 gfx::NativeView Textfield::GetNativeView() const {
1142 return GetWidget()->GetNativeView(); 1142 return GetWidget()->GetNativeView();
1143 } 1143 }
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 const size_t length = selection_clipboard_text.length(); 1865 const size_t length = selection_clipboard_text.length();
1866 range = gfx::Range(range.start() + length, range.end() + length); 1866 range = gfx::Range(range.start() + length, range.end() + length);
1867 } 1867 }
1868 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); 1868 model_->MoveCursorTo(gfx::SelectionModel(range, affinity));
1869 UpdateAfterChange(true, true); 1869 UpdateAfterChange(true, true);
1870 OnAfterUserAction(); 1870 OnAfterUserAction();
1871 } 1871 }
1872 } 1872 }
1873 1873
1874 } // namespace views 1874 } // namespace views
OLDNEW
« no previous file with comments | « ui/touch_selection/ui_touch_selection_export.h ('k') | ui/views/touchui/touch_selection_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698