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, | |
1755 true); | |
tapted
2016/04/11 06:57:26
nit: git cl format puts this `true` on the previou
Elly Fong-Jones
2016/04/14 19:47:10
Done.
| |
1756 } else if (drags_to_end && last_drag_location_.y() > height()) { | |
1757 model_->MoveCursor(gfx::BreakType::LINE_BREAK, | |
1758 gfx::VisualCursorDirection::CURSOR_RIGHT, | |
1759 true); | |
1760 } else { | |
1761 model_->MoveCursorTo(last_drag_location_, true); | |
1762 } | |
1763 | |
1750 if (aggregated_clicks_ == 1) { | 1764 if (aggregated_clicks_ == 1) { |
1751 model_->SelectWord(); | 1765 model_->SelectWord(); |
1752 // Expand the selection so the initially selected word remains selected. | 1766 // Expand the selection so the initially selected word remains selected. |
1753 gfx::Range selection = GetRenderText()->selection(); | 1767 gfx::Range selection = GetRenderText()->selection(); |
1754 const size_t min = std::min(selection.GetMin(), | 1768 const size_t min = std::min(selection.GetMin(), |
1755 double_click_word_.GetMin()); | 1769 double_click_word_.GetMin()); |
1756 const size_t max = std::max(selection.GetMax(), | 1770 const size_t max = std::max(selection.GetMax(), |
1757 double_click_word_.GetMax()); | 1771 double_click_word_.GetMax()); |
1758 const bool reversed = selection.is_reversed(); | 1772 const bool reversed = selection.is_reversed(); |
1759 selection.set_start(reversed ? max : min); | 1773 selection.set_start(reversed ? max : min); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1901 RequestFocus(); | 1915 RequestFocus(); |
1902 model_->MoveCursorTo(mouse); | 1916 model_->MoveCursorTo(mouse); |
1903 if (!selection_clipboard_text.empty()) { | 1917 if (!selection_clipboard_text.empty()) { |
1904 model_->InsertText(selection_clipboard_text); | 1918 model_->InsertText(selection_clipboard_text); |
1905 UpdateAfterChange(true, true); | 1919 UpdateAfterChange(true, true); |
1906 } | 1920 } |
1907 OnAfterUserAction(); | 1921 OnAfterUserAction(); |
1908 } | 1922 } |
1909 | 1923 |
1910 } // namespace views | 1924 } // namespace views |
OLD | NEW |