OLD | NEW |
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/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "ui/views/background.h" | 33 #include "ui/views/background.h" |
34 #include "ui/views/controls/focusable_border.h" | 34 #include "ui/views/controls/focusable_border.h" |
35 #include "ui/views/controls/label.h" | 35 #include "ui/views/controls/label.h" |
36 #include "ui/views/controls/menu/menu_runner.h" | 36 #include "ui/views/controls/menu/menu_runner.h" |
37 #include "ui/views/controls/native/native_view_host.h" | 37 #include "ui/views/controls/native/native_view_host.h" |
38 #include "ui/views/controls/textfield/textfield_controller.h" | 38 #include "ui/views/controls/textfield/textfield_controller.h" |
39 #include "ui/views/drag_utils.h" | 39 #include "ui/views/drag_utils.h" |
40 #include "ui/views/metrics.h" | 40 #include "ui/views/metrics.h" |
41 #include "ui/views/native_cursor.h" | 41 #include "ui/views/native_cursor.h" |
42 #include "ui/views/painter.h" | 42 #include "ui/views/painter.h" |
| 43 #include "ui/views/style/platform_style.h" |
43 #include "ui/views/views_delegate.h" | 44 #include "ui/views/views_delegate.h" |
44 #include "ui/views/widget/widget.h" | 45 #include "ui/views/widget/widget.h" |
45 | 46 |
46 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
47 #include "base/win/win_util.h" | 48 #include "base/win/win_util.h" |
48 #endif | 49 #endif |
49 | 50 |
50 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 51 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
51 #include "base/strings/utf_string_conversions.h" | 52 #include "base/strings/utf_string_conversions.h" |
52 #include "ui/events/linux/text_edit_command_auralinux.h" | 53 #include "ui/events/linux/text_edit_command_auralinux.h" |
(...skipping 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1739 canvas->Restore(); | 1740 canvas->Restore(); |
1740 } | 1741 } |
1741 | 1742 |
1742 void Textfield::MoveCursorTo(const gfx::Point& point, bool select) { | 1743 void Textfield::MoveCursorTo(const gfx::Point& point, bool select) { |
1743 if (model_->MoveCursorTo(point, select)) | 1744 if (model_->MoveCursorTo(point, select)) |
1744 UpdateAfterChange(false, true); | 1745 UpdateAfterChange(false, true); |
1745 } | 1746 } |
1746 | 1747 |
1747 void Textfield::SelectThroughLastDragLocation() { | 1748 void Textfield::SelectThroughLastDragLocation() { |
1748 OnBeforeUserAction(); | 1749 OnBeforeUserAction(); |
1749 model_->MoveCursorTo(last_drag_location_, true); | 1750 |
| 1751 const bool drags_to_end = PlatformStyle::kTextfieldDragVerticallyDragsToEnd; |
| 1752 if (drags_to_end && last_drag_location_.y() < 0) { |
| 1753 model_->MoveCursor(gfx::BreakType::LINE_BREAK, |
| 1754 gfx::VisualCursorDirection::CURSOR_LEFT, true); |
| 1755 } else if (drags_to_end && last_drag_location_.y() > height()) { |
| 1756 model_->MoveCursor(gfx::BreakType::LINE_BREAK, |
| 1757 gfx::VisualCursorDirection::CURSOR_RIGHT, true); |
| 1758 } else { |
| 1759 model_->MoveCursorTo(last_drag_location_, true); |
| 1760 } |
| 1761 |
1750 if (aggregated_clicks_ == 1) { | 1762 if (aggregated_clicks_ == 1) { |
1751 model_->SelectWord(); | 1763 model_->SelectWord(); |
1752 // Expand the selection so the initially selected word remains selected. | 1764 // Expand the selection so the initially selected word remains selected. |
1753 gfx::Range selection = GetRenderText()->selection(); | 1765 gfx::Range selection = GetRenderText()->selection(); |
1754 const size_t min = std::min(selection.GetMin(), | 1766 const size_t min = std::min(selection.GetMin(), |
1755 double_click_word_.GetMin()); | 1767 double_click_word_.GetMin()); |
1756 const size_t max = std::max(selection.GetMax(), | 1768 const size_t max = std::max(selection.GetMax(), |
1757 double_click_word_.GetMax()); | 1769 double_click_word_.GetMax()); |
1758 const bool reversed = selection.is_reversed(); | 1770 const bool reversed = selection.is_reversed(); |
1759 selection.set_start(reversed ? max : min); | 1771 selection.set_start(reversed ? max : min); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 RequestFocus(); | 1913 RequestFocus(); |
1902 model_->MoveCursorTo(mouse); | 1914 model_->MoveCursorTo(mouse); |
1903 if (!selection_clipboard_text.empty()) { | 1915 if (!selection_clipboard_text.empty()) { |
1904 model_->InsertText(selection_clipboard_text); | 1916 model_->InsertText(selection_clipboard_text); |
1905 UpdateAfterChange(true, true); | 1917 UpdateAfterChange(true, true); |
1906 } | 1918 } |
1907 OnAfterUserAction(); | 1919 OnAfterUserAction(); |
1908 } | 1920 } |
1909 | 1921 |
1910 } // namespace views | 1922 } // namespace views |
OLD | NEW |