| 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 | 8 |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "ui/accessibility/ax_view_state.h" | 10 #include "ui/accessibility/ax_view_state.h" |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 last_drag_location_ = event.location(); | 640 last_drag_location_ = event.location(); |
| 641 | 641 |
| 642 // Don't adjust the cursor on a potential drag and drop, or if the mouse | 642 // Don't adjust the cursor on a potential drag and drop, or if the mouse |
| 643 // movement from the last mouse click does not exceed the drag threshold. | 643 // movement from the last mouse click does not exceed the drag threshold. |
| 644 if (initiating_drag_ || !event.IsOnlyLeftMouseButton() || | 644 if (initiating_drag_ || !event.IsOnlyLeftMouseButton() || |
| 645 !ExceededDragThreshold(last_drag_location_ - last_click_location_)) { | 645 !ExceededDragThreshold(last_drag_location_ - last_click_location_)) { |
| 646 return true; | 646 return true; |
| 647 } | 647 } |
| 648 | 648 |
| 649 // A timer is used to continuously scroll while selecting beyond side edges. | 649 // A timer is used to continuously scroll while selecting beyond side edges. |
| 650 if ((event.location().x() > 0 && event.location().x() < size().width()) || | 650 const int x = event.location().x(); |
| 651 GetDragSelectionDelay() == 0) { | 651 if ((x >= 0 && x <= width()) || GetDragSelectionDelay() == 0) { |
| 652 drag_selection_timer_.Stop(); | 652 drag_selection_timer_.Stop(); |
| 653 SelectThroughLastDragLocation(); | 653 SelectThroughLastDragLocation(); |
| 654 } else if (!drag_selection_timer_.IsRunning()) { | 654 } else if (!drag_selection_timer_.IsRunning()) { |
| 655 // Select through the edge of the visible text, then start the scroll timer. |
| 656 last_drag_location_.set_x(std::min(std::max(0, x), width())); |
| 657 SelectThroughLastDragLocation(); |
| 655 drag_selection_timer_.Start( | 658 drag_selection_timer_.Start( |
| 656 FROM_HERE, base::TimeDelta::FromMilliseconds(GetDragSelectionDelay()), | 659 FROM_HERE, base::TimeDelta::FromMilliseconds(GetDragSelectionDelay()), |
| 657 this, &Textfield::SelectThroughLastDragLocation); | 660 this, &Textfield::SelectThroughLastDragLocation); |
| 658 } | 661 } |
| 659 | 662 |
| 660 return true; | 663 return true; |
| 661 } | 664 } |
| 662 | 665 |
| 663 void Textfield::OnMouseReleased(const ui::MouseEvent& event) { | 666 void Textfield::OnMouseReleased(const ui::MouseEvent& event) { |
| 664 OnBeforeUserAction(); | 667 OnBeforeUserAction(); |
| (...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1887 RequestFocus(); | 1890 RequestFocus(); |
| 1888 model_->MoveCursorTo(mouse); | 1891 model_->MoveCursorTo(mouse); |
| 1889 if (!selection_clipboard_text.empty()) { | 1892 if (!selection_clipboard_text.empty()) { |
| 1890 model_->InsertText(selection_clipboard_text); | 1893 model_->InsertText(selection_clipboard_text); |
| 1891 UpdateAfterChange(true, true); | 1894 UpdateAfterChange(true, true); |
| 1892 } | 1895 } |
| 1893 OnAfterUserAction(); | 1896 OnAfterUserAction(); |
| 1894 } | 1897 } |
| 1895 | 1898 |
| 1896 } // namespace views | 1899 } // namespace views |
| OLD | NEW |