OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/native_textfield_views.h" | 5 #include "ui/views/controls/textfield/native_textfield_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/i18n/case_conversion.h" | 12 #include "base/i18n/case_conversion.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "grit/ui_strings.h" | 16 #include "grit/ui_strings.h" |
17 #include "third_party/icu/source/common/unicode/uchar.h" | 17 #include "third_party/icu/source/common/unicode/uchar.h" |
18 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
19 #include "ui/base/clipboard/clipboard.h" | 19 #include "ui/base/clipboard/clipboard.h" |
20 #include "ui/base/dragdrop/drag_drop_types.h" | 20 #include "ui/base/dragdrop/drag_drop_types.h" |
21 #include "ui/base/dragdrop/drag_utils.h" | 21 #include "ui/base/dragdrop/drag_utils.h" |
22 #include "ui/base/events/event.h" | 22 #include "ui/base/events/event.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/base/range/range.h" | |
25 #include "ui/base/ui_base_switches_util.h" | 24 #include "ui/base/ui_base_switches_util.h" |
26 #include "ui/compositor/layer.h" | 25 #include "ui/compositor/layer.h" |
27 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
28 #include "ui/gfx/insets.h" | 27 #include "ui/gfx/insets.h" |
| 28 #include "ui/gfx/range/range.h" |
29 #include "ui/gfx/render_text.h" | 29 #include "ui/gfx/render_text.h" |
30 #include "ui/gfx/text_constants.h" | 30 #include "ui/gfx/text_constants.h" |
31 #include "ui/native_theme/native_theme.h" | 31 #include "ui/native_theme/native_theme.h" |
32 #include "ui/views/background.h" | 32 #include "ui/views/background.h" |
33 #include "ui/views/border.h" | 33 #include "ui/views/border.h" |
34 #include "ui/views/controls/focusable_border.h" | 34 #include "ui/views/controls/focusable_border.h" |
35 #include "ui/views/controls/menu/menu_item_view.h" | 35 #include "ui/views/controls/menu/menu_item_view.h" |
36 #include "ui/views/controls/menu/menu_model_adapter.h" | 36 #include "ui/views/controls/menu/menu_model_adapter.h" |
37 #include "ui/views/controls/menu/menu_runner.h" | 37 #include "ui/views/controls/menu/menu_runner.h" |
38 #include "ui/views/controls/textfield/textfield.h" | 38 #include "ui/views/controls/textfield/textfield.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 122 } |
123 | 123 |
124 OnBeforeUserAction(); | 124 OnBeforeUserAction(); |
125 // TODO: Remove once NativeTextfield implementations are consolidated to | 125 // TODO: Remove once NativeTextfield implementations are consolidated to |
126 // Textfield. | 126 // Textfield. |
127 if (!textfield_->OnMouseDragged(event)) { | 127 if (!textfield_->OnMouseDragged(event)) { |
128 MoveCursorTo(event.location(), true); | 128 MoveCursorTo(event.location(), true); |
129 if (aggregated_clicks_ == 1) { | 129 if (aggregated_clicks_ == 1) { |
130 model_->SelectWord(); | 130 model_->SelectWord(); |
131 // Expand the selection so the initially selected word remains selected. | 131 // Expand the selection so the initially selected word remains selected. |
132 ui::Range selection = GetRenderText()->selection(); | 132 gfx::Range selection = GetRenderText()->selection(); |
133 const size_t min = std::min(selection.GetMin(), | 133 const size_t min = std::min(selection.GetMin(), |
134 double_click_word_.GetMin()); | 134 double_click_word_.GetMin()); |
135 const size_t max = std::max(selection.GetMax(), | 135 const size_t max = std::max(selection.GetMax(), |
136 double_click_word_.GetMax()); | 136 double_click_word_.GetMax()); |
137 const bool reversed = selection.is_reversed(); | 137 const bool reversed = selection.is_reversed(); |
138 selection.set_start(reversed ? max : min); | 138 selection.set_start(reversed ? max : min); |
139 selection.set_end(reversed ? min : max); | 139 selection.set_end(reversed ? min : max); |
140 model_->SelectRange(selection); | 140 model_->SelectRange(selection); |
141 } | 141 } |
142 SchedulePaint(); | 142 SchedulePaint(); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 int formats; | 265 int formats; |
266 std::set<OSExchangeData::CustomFormat> custom_formats; | 266 std::set<OSExchangeData::CustomFormat> custom_formats; |
267 GetDropFormats(&formats, &custom_formats); | 267 GetDropFormats(&formats, &custom_formats); |
268 return textfield_->enabled() && !textfield_->read_only() && | 268 return textfield_->enabled() && !textfield_->read_only() && |
269 data.HasAnyFormat(formats, custom_formats); | 269 data.HasAnyFormat(formats, custom_formats); |
270 } | 270 } |
271 | 271 |
272 int NativeTextfieldViews::OnDragUpdated(const ui::DropTargetEvent& event) { | 272 int NativeTextfieldViews::OnDragUpdated(const ui::DropTargetEvent& event) { |
273 DCHECK(CanDrop(event.data())); | 273 DCHECK(CanDrop(event.data())); |
274 | 274 |
275 const ui::Range& selection = GetRenderText()->selection(); | 275 const gfx::Range& selection = GetRenderText()->selection(); |
276 drop_cursor_position_ = GetRenderText()->FindCursorPosition(event.location()); | 276 drop_cursor_position_ = GetRenderText()->FindCursorPosition(event.location()); |
277 bool in_selection = !selection.is_empty() && | 277 bool in_selection = !selection.is_empty() && |
278 selection.Contains(ui::Range(drop_cursor_position_.caret_pos())); | 278 selection.Contains(gfx::Range(drop_cursor_position_.caret_pos())); |
279 is_drop_cursor_visible_ = !in_selection; | 279 is_drop_cursor_visible_ = !in_selection; |
280 // TODO(msw): Pan over text when the user drags to the visible text edge. | 280 // TODO(msw): Pan over text when the user drags to the visible text edge. |
281 OnCaretBoundsChanged(); | 281 OnCaretBoundsChanged(); |
282 SchedulePaint(); | 282 SchedulePaint(); |
283 | 283 |
284 if (initiating_drag_) { | 284 if (initiating_drag_) { |
285 if (in_selection) | 285 if (in_selection) |
286 return ui::DragDropTypes::DRAG_NONE; | 286 return ui::DragDropTypes::DRAG_NONE; |
287 return event.IsControlDown() ? ui::DragDropTypes::DRAG_COPY : | 287 return event.IsControlDown() ? ui::DragDropTypes::DRAG_COPY : |
288 ui::DragDropTypes::DRAG_MOVE; | 288 ui::DragDropTypes::DRAG_MOVE; |
(...skipping 28 matching lines...) Expand all Loading... |
317 string16 text; | 317 string16 text; |
318 event.data().GetString(&text); | 318 event.data().GetString(&text); |
319 text = GetTextForDisplay(text); | 319 text = GetTextForDisplay(text); |
320 | 320 |
321 // Delete the current selection for a drag and drop within this view. | 321 // Delete the current selection for a drag and drop within this view. |
322 const bool move = initiating_drag_ && !event.IsControlDown() && | 322 const bool move = initiating_drag_ && !event.IsControlDown() && |
323 event.source_operations() & ui::DragDropTypes::DRAG_MOVE; | 323 event.source_operations() & ui::DragDropTypes::DRAG_MOVE; |
324 if (move) { | 324 if (move) { |
325 // Adjust the drop destination if it is on or after the current selection. | 325 // Adjust the drop destination if it is on or after the current selection. |
326 size_t drop = drop_destination_model.caret_pos(); | 326 size_t drop = drop_destination_model.caret_pos(); |
327 drop -= GetSelectedRange().Intersect(ui::Range(0, drop)).length(); | 327 drop -= GetSelectedRange().Intersect(gfx::Range(0, drop)).length(); |
328 model_->DeleteSelectionAndInsertTextAt(text, drop); | 328 model_->DeleteSelectionAndInsertTextAt(text, drop); |
329 } else { | 329 } else { |
330 model_->MoveCursorTo(drop_destination_model); | 330 model_->MoveCursorTo(drop_destination_model); |
331 // Drop always inserts text even if the textfield is not in insert mode. | 331 // Drop always inserts text even if the textfield is not in insert mode. |
332 model_->InsertText(text); | 332 model_->InsertText(text); |
333 } | 333 } |
334 skip_input_method_cancel_composition_ = false; | 334 skip_input_method_cancel_composition_ = false; |
335 UpdateAfterChange(true, true); | 335 UpdateAfterChange(true, true); |
336 OnAfterUserAction(); | 336 OnAfterUserAction(); |
337 return move ? ui::DragDropTypes::DRAG_MOVE : ui::DragDropTypes::DRAG_COPY; | 337 return move ? ui::DragDropTypes::DRAG_MOVE : ui::DragDropTypes::DRAG_COPY; |
(...skipping 25 matching lines...) Expand all Loading... |
363 } | 363 } |
364 | 364 |
365 void NativeTextfieldViews::SelectRect(const gfx::Point& start, | 365 void NativeTextfieldViews::SelectRect(const gfx::Point& start, |
366 const gfx::Point& end) { | 366 const gfx::Point& end) { |
367 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) | 367 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) |
368 return; | 368 return; |
369 | 369 |
370 gfx::SelectionModel start_caret = GetRenderText()->FindCursorPosition(start); | 370 gfx::SelectionModel start_caret = GetRenderText()->FindCursorPosition(start); |
371 gfx::SelectionModel end_caret = GetRenderText()->FindCursorPosition(end); | 371 gfx::SelectionModel end_caret = GetRenderText()->FindCursorPosition(end); |
372 gfx::SelectionModel selection( | 372 gfx::SelectionModel selection( |
373 ui::Range(start_caret.caret_pos(), end_caret.caret_pos()), | 373 gfx::Range(start_caret.caret_pos(), end_caret.caret_pos()), |
374 end_caret.caret_affinity()); | 374 end_caret.caret_affinity()); |
375 | 375 |
376 OnBeforeUserAction(); | 376 OnBeforeUserAction(); |
377 model_->SelectSelectionModel(selection); | 377 model_->SelectSelectionModel(selection); |
378 OnCaretBoundsChanged(); | 378 OnCaretBoundsChanged(); |
379 SchedulePaint(); | 379 SchedulePaint(); |
380 OnAfterUserAction(); | 380 OnAfterUserAction(); |
381 } | 381 } |
382 | 382 |
383 void NativeTextfieldViews::MoveCaretTo(const gfx::Point& point) { | 383 void NativeTextfieldViews::MoveCaretTo(const gfx::Point& point) { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 | 621 |
622 gfx::NativeView NativeTextfieldViews::GetTestingHandle() const { | 622 gfx::NativeView NativeTextfieldViews::GetTestingHandle() const { |
623 NOTREACHED(); | 623 NOTREACHED(); |
624 return NULL; | 624 return NULL; |
625 } | 625 } |
626 | 626 |
627 bool NativeTextfieldViews::IsIMEComposing() const { | 627 bool NativeTextfieldViews::IsIMEComposing() const { |
628 return model_->HasCompositionText(); | 628 return model_->HasCompositionText(); |
629 } | 629 } |
630 | 630 |
631 ui::Range NativeTextfieldViews::GetSelectedRange() const { | 631 gfx::Range NativeTextfieldViews::GetSelectedRange() const { |
632 return GetRenderText()->selection(); | 632 return GetRenderText()->selection(); |
633 } | 633 } |
634 | 634 |
635 void NativeTextfieldViews::SelectRange(const ui::Range& range) { | 635 void NativeTextfieldViews::SelectRange(const gfx::Range& range) { |
636 model_->SelectRange(range); | 636 model_->SelectRange(range); |
637 OnCaretBoundsChanged(); | 637 OnCaretBoundsChanged(); |
638 SchedulePaint(); | 638 SchedulePaint(); |
639 textfield_->NotifyAccessibilityEvent( | 639 textfield_->NotifyAccessibilityEvent( |
640 ui::AccessibilityTypes::EVENT_SELECTION_CHANGED, true); | 640 ui::AccessibilityTypes::EVENT_SELECTION_CHANGED, true); |
641 } | 641 } |
642 | 642 |
643 gfx::SelectionModel NativeTextfieldViews::GetSelectionModel() const { | 643 gfx::SelectionModel NativeTextfieldViews::GetSelectionModel() const { |
644 return GetRenderText()->selection_model(); | 644 return GetRenderText()->selection_model(); |
645 } | 645 } |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 break; | 829 break; |
830 } | 830 } |
831 } | 831 } |
832 } | 832 } |
833 | 833 |
834 void NativeTextfieldViews::SetColor(SkColor value) { | 834 void NativeTextfieldViews::SetColor(SkColor value) { |
835 GetRenderText()->SetColor(value); | 835 GetRenderText()->SetColor(value); |
836 SchedulePaint(); | 836 SchedulePaint(); |
837 } | 837 } |
838 | 838 |
839 void NativeTextfieldViews::ApplyColor(SkColor value, const ui::Range& range) { | 839 void NativeTextfieldViews::ApplyColor(SkColor value, const gfx::Range& range) { |
840 GetRenderText()->ApplyColor(value, range); | 840 GetRenderText()->ApplyColor(value, range); |
841 SchedulePaint(); | 841 SchedulePaint(); |
842 } | 842 } |
843 | 843 |
844 void NativeTextfieldViews::SetStyle(gfx::TextStyle style, bool value) { | 844 void NativeTextfieldViews::SetStyle(gfx::TextStyle style, bool value) { |
845 GetRenderText()->SetStyle(style, value); | 845 GetRenderText()->SetStyle(style, value); |
846 SchedulePaint(); | 846 SchedulePaint(); |
847 } | 847 } |
848 | 848 |
849 void NativeTextfieldViews::ApplyStyle(gfx::TextStyle style, | 849 void NativeTextfieldViews::ApplyStyle(gfx::TextStyle style, |
850 bool value, | 850 bool value, |
851 const ui::Range& range) { | 851 const gfx::Range& range) { |
852 GetRenderText()->ApplyStyle(style, value, range); | 852 GetRenderText()->ApplyStyle(style, value, range); |
853 SchedulePaint(); | 853 SchedulePaint(); |
854 } | 854 } |
855 | 855 |
856 void NativeTextfieldViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 856 void NativeTextfieldViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
857 // Set the RenderText display area. | 857 // Set the RenderText display area. |
858 gfx::Insets insets = GetInsets(); | 858 gfx::Insets insets = GetInsets(); |
859 gfx::Rect display_rect(insets.left(), | 859 gfx::Rect display_rect(insets.left(), |
860 insets.top(), | 860 insets.top(), |
861 width() - insets.width(), | 861 width() - insets.width(), |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 gfx::Rect rect = GetRenderText()->GetUpdatedCursorBounds(); | 983 gfx::Rect rect = GetRenderText()->GetUpdatedCursorBounds(); |
984 ConvertRectToScreen(this, &rect); | 984 ConvertRectToScreen(this, &rect); |
985 return rect; | 985 return rect; |
986 } | 986 } |
987 | 987 |
988 bool NativeTextfieldViews::GetCompositionCharacterBounds(uint32 index, | 988 bool NativeTextfieldViews::GetCompositionCharacterBounds(uint32 index, |
989 gfx::Rect* rect) { | 989 gfx::Rect* rect) { |
990 DCHECK(rect); | 990 DCHECK(rect); |
991 if (!HasCompositionText()) | 991 if (!HasCompositionText()) |
992 return false; | 992 return false; |
993 const ui::Range& composition_range = GetRenderText()->GetCompositionRange(); | 993 const gfx::Range& composition_range = GetRenderText()->GetCompositionRange(); |
994 const uint32 left_cursor_pos = composition_range.start() + index; | 994 const uint32 left_cursor_pos = composition_range.start() + index; |
995 const uint32 right_cursor_pos = composition_range.start() + index + 1; | 995 const uint32 right_cursor_pos = composition_range.start() + index + 1; |
996 DCHECK(!composition_range.is_empty()); | 996 DCHECK(!composition_range.is_empty()); |
997 if (composition_range.end() < right_cursor_pos) | 997 if (composition_range.end() < right_cursor_pos) |
998 return false; | 998 return false; |
999 const gfx::SelectionModel start_position(left_cursor_pos, | 999 const gfx::SelectionModel start_position(left_cursor_pos, |
1000 gfx::CURSOR_BACKWARD); | 1000 gfx::CURSOR_BACKWARD); |
1001 const gfx::SelectionModel end_position(right_cursor_pos, | 1001 const gfx::SelectionModel end_position(right_cursor_pos, |
1002 gfx::CURSOR_BACKWARD); | 1002 gfx::CURSOR_BACKWARD); |
1003 gfx::Rect start_cursor = GetRenderText()->GetCursorBounds(start_position, | 1003 gfx::Rect start_cursor = GetRenderText()->GetCursorBounds(start_position, |
1004 false); | 1004 false); |
1005 gfx::Rect end_cursor = GetRenderText()->GetCursorBounds(end_position, false); | 1005 gfx::Rect end_cursor = GetRenderText()->GetCursorBounds(end_position, false); |
1006 | 1006 |
1007 // TextInputClient::GetCompositionCharacterBounds is expected to fill |rect| | 1007 // TextInputClient::GetCompositionCharacterBounds is expected to fill |rect| |
1008 // in screen coordinates and GetCaretBounds returns screen coordinates. | 1008 // in screen coordinates and GetCaretBounds returns screen coordinates. |
1009 *rect = gfx::Rect(start_cursor.x(), | 1009 *rect = gfx::Rect(start_cursor.x(), |
1010 start_cursor.y(), | 1010 start_cursor.y(), |
1011 end_cursor.x() - start_cursor.x(), | 1011 end_cursor.x() - start_cursor.x(), |
1012 start_cursor.height()); | 1012 start_cursor.height()); |
1013 ConvertRectToScreen(this, rect); | 1013 ConvertRectToScreen(this, rect); |
1014 | 1014 |
1015 return true; | 1015 return true; |
1016 } | 1016 } |
1017 | 1017 |
1018 bool NativeTextfieldViews::HasCompositionText() { | 1018 bool NativeTextfieldViews::HasCompositionText() { |
1019 return model_->HasCompositionText(); | 1019 return model_->HasCompositionText(); |
1020 } | 1020 } |
1021 | 1021 |
1022 bool NativeTextfieldViews::GetTextRange(ui::Range* range) { | 1022 bool NativeTextfieldViews::GetTextRange(gfx::Range* range) { |
1023 if (!ImeEditingAllowed()) | 1023 if (!ImeEditingAllowed()) |
1024 return false; | 1024 return false; |
1025 | 1025 |
1026 model_->GetTextRange(range); | 1026 model_->GetTextRange(range); |
1027 return true; | 1027 return true; |
1028 } | 1028 } |
1029 | 1029 |
1030 bool NativeTextfieldViews::GetCompositionTextRange(ui::Range* range) { | 1030 bool NativeTextfieldViews::GetCompositionTextRange(gfx::Range* range) { |
1031 if (!ImeEditingAllowed()) | 1031 if (!ImeEditingAllowed()) |
1032 return false; | 1032 return false; |
1033 | 1033 |
1034 model_->GetCompositionTextRange(range); | 1034 model_->GetCompositionTextRange(range); |
1035 return true; | 1035 return true; |
1036 } | 1036 } |
1037 | 1037 |
1038 bool NativeTextfieldViews::GetSelectionRange(ui::Range* range) { | 1038 bool NativeTextfieldViews::GetSelectionRange(gfx::Range* range) { |
1039 if (!ImeEditingAllowed()) | 1039 if (!ImeEditingAllowed()) |
1040 return false; | 1040 return false; |
1041 *range = GetSelectedRange(); | 1041 *range = GetSelectedRange(); |
1042 return true; | 1042 return true; |
1043 } | 1043 } |
1044 | 1044 |
1045 bool NativeTextfieldViews::SetSelectionRange(const ui::Range& range) { | 1045 bool NativeTextfieldViews::SetSelectionRange(const gfx::Range& range) { |
1046 if (!ImeEditingAllowed() || !range.IsValid()) | 1046 if (!ImeEditingAllowed() || !range.IsValid()) |
1047 return false; | 1047 return false; |
1048 | 1048 |
1049 OnBeforeUserAction(); | 1049 OnBeforeUserAction(); |
1050 SelectRange(range); | 1050 SelectRange(range); |
1051 OnAfterUserAction(); | 1051 OnAfterUserAction(); |
1052 return true; | 1052 return true; |
1053 } | 1053 } |
1054 | 1054 |
1055 bool NativeTextfieldViews::DeleteRange(const ui::Range& range) { | 1055 bool NativeTextfieldViews::DeleteRange(const gfx::Range& range) { |
1056 if (!ImeEditingAllowed() || range.is_empty()) | 1056 if (!ImeEditingAllowed() || range.is_empty()) |
1057 return false; | 1057 return false; |
1058 | 1058 |
1059 OnBeforeUserAction(); | 1059 OnBeforeUserAction(); |
1060 model_->SelectRange(range); | 1060 model_->SelectRange(range); |
1061 if (model_->HasSelection()) { | 1061 if (model_->HasSelection()) { |
1062 model_->DeleteSelection(); | 1062 model_->DeleteSelection(); |
1063 UpdateAfterChange(true, true); | 1063 UpdateAfterChange(true, true); |
1064 } | 1064 } |
1065 OnAfterUserAction(); | 1065 OnAfterUserAction(); |
1066 return true; | 1066 return true; |
1067 } | 1067 } |
1068 | 1068 |
1069 bool NativeTextfieldViews::GetTextFromRange( | 1069 bool NativeTextfieldViews::GetTextFromRange( |
1070 const ui::Range& range, | 1070 const gfx::Range& range, |
1071 string16* text) { | 1071 string16* text) { |
1072 if (!ImeEditingAllowed() || !range.IsValid()) | 1072 if (!ImeEditingAllowed() || !range.IsValid()) |
1073 return false; | 1073 return false; |
1074 | 1074 |
1075 ui::Range text_range; | 1075 gfx::Range text_range; |
1076 if (!GetTextRange(&text_range) || !text_range.Contains(range)) | 1076 if (!GetTextRange(&text_range) || !text_range.Contains(range)) |
1077 return false; | 1077 return false; |
1078 | 1078 |
1079 *text = model_->GetTextFromRange(range); | 1079 *text = model_->GetTextFromRange(range); |
1080 return true; | 1080 return true; |
1081 } | 1081 } |
1082 | 1082 |
1083 void NativeTextfieldViews::OnInputMethodChanged() { | 1083 void NativeTextfieldViews::OnInputMethodChanged() { |
1084 // TODO(msw): NOTIMPLEMENTED(); see http://crbug.com/140402 | 1084 // TODO(msw): NOTIMPLEMENTED(); see http://crbug.com/140402 |
1085 } | 1085 } |
1086 | 1086 |
1087 bool NativeTextfieldViews::ChangeTextDirectionAndLayoutAlignment( | 1087 bool NativeTextfieldViews::ChangeTextDirectionAndLayoutAlignment( |
1088 base::i18n::TextDirection direction) { | 1088 base::i18n::TextDirection direction) { |
1089 NOTIMPLEMENTED(); | 1089 NOTIMPLEMENTED(); |
1090 return false; | 1090 return false; |
1091 } | 1091 } |
1092 | 1092 |
1093 void NativeTextfieldViews::ExtendSelectionAndDelete( | 1093 void NativeTextfieldViews::ExtendSelectionAndDelete( |
1094 size_t before, | 1094 size_t before, |
1095 size_t after) { | 1095 size_t after) { |
1096 ui::Range range = GetSelectedRange(); | 1096 gfx::Range range = GetSelectedRange(); |
1097 DCHECK_GE(range.start(), before); | 1097 DCHECK_GE(range.start(), before); |
1098 | 1098 |
1099 range.set_start(range.start() - before); | 1099 range.set_start(range.start() - before); |
1100 range.set_end(range.end() + after); | 1100 range.set_end(range.end() + after); |
1101 ui::Range text_range; | 1101 gfx::Range text_range; |
1102 if (GetTextRange(&text_range) && text_range.Contains(range)) | 1102 if (GetTextRange(&text_range) && text_range.Contains(range)) |
1103 DeleteRange(range); | 1103 DeleteRange(range); |
1104 } | 1104 } |
1105 | 1105 |
1106 void NativeTextfieldViews::EnsureCaretInRect(const gfx::Rect& rect) { | 1106 void NativeTextfieldViews::EnsureCaretInRect(const gfx::Rect& rect) { |
1107 } | 1107 } |
1108 | 1108 |
1109 void NativeTextfieldViews::OnCompositionTextConfirmedOrCleared() { | 1109 void NativeTextfieldViews::OnCompositionTextConfirmedOrCleared() { |
1110 if (skip_input_method_cancel_composition_) | 1110 if (skip_input_method_cancel_composition_) |
1111 return; | 1111 return; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 if (control && !alt && editable) | 1217 if (control && !alt && editable) |
1218 cursor_changed = text_changed = Paste(); | 1218 cursor_changed = text_changed = Paste(); |
1219 break; | 1219 break; |
1220 case ui::VKEY_RIGHT: | 1220 case ui::VKEY_RIGHT: |
1221 case ui::VKEY_LEFT: { | 1221 case ui::VKEY_LEFT: { |
1222 // We should ignore the alt-left/right keys because alt key doesn't make | 1222 // We should ignore the alt-left/right keys because alt key doesn't make |
1223 // any special effects for them and they can be shortcut keys such like | 1223 // any special effects for them and they can be shortcut keys such like |
1224 // forward/back of the browser history. | 1224 // forward/back of the browser history. |
1225 if (alt) | 1225 if (alt) |
1226 break; | 1226 break; |
1227 const ui::Range selection_range = GetSelectedRange(); | 1227 const gfx::Range selection_range = GetSelectedRange(); |
1228 model_->MoveCursor( | 1228 model_->MoveCursor( |
1229 control ? gfx::WORD_BREAK : gfx::CHARACTER_BREAK, | 1229 control ? gfx::WORD_BREAK : gfx::CHARACTER_BREAK, |
1230 (key_code == ui::VKEY_RIGHT) ? gfx::CURSOR_RIGHT : gfx::CURSOR_LEFT, | 1230 (key_code == ui::VKEY_RIGHT) ? gfx::CURSOR_RIGHT : gfx::CURSOR_LEFT, |
1231 shift); | 1231 shift); |
1232 cursor_changed = GetSelectedRange() != selection_range; | 1232 cursor_changed = GetSelectedRange() != selection_range; |
1233 break; | 1233 break; |
1234 } | 1234 } |
1235 case ui::VKEY_END: | 1235 case ui::VKEY_END: |
1236 case ui::VKEY_HOME: | 1236 case ui::VKEY_HOME: |
1237 if ((key_code == ui::VKEY_HOME) == | 1237 if ((key_code == ui::VKEY_HOME) == |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 if (index != -1) { | 1513 if (index != -1) { |
1514 obscured_reveal_timer_.Start( | 1514 obscured_reveal_timer_.Start( |
1515 FROM_HERE, | 1515 FROM_HERE, |
1516 duration, | 1516 duration, |
1517 base::Bind(&NativeTextfieldViews::RevealObscuredChar, | 1517 base::Bind(&NativeTextfieldViews::RevealObscuredChar, |
1518 base::Unretained(this), -1, base::TimeDelta())); | 1518 base::Unretained(this), -1, base::TimeDelta())); |
1519 } | 1519 } |
1520 } | 1520 } |
1521 | 1521 |
1522 } // namespace views | 1522 } // namespace views |
OLD | NEW |