| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "ui/base/touch/touch_editing_controller.h" | 7 #include "ui/base/touch/touch_editing_controller.h" |
| 8 #include "ui/base/ui_base_switches.h" | 8 #include "ui/base/ui_base_switches.h" |
| 9 #include "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
| 10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 | 72 |
| 73 void SimulateSelectionHandleDrag(gfx::Point p, int selection_handle) { | 73 void SimulateSelectionHandleDrag(gfx::Point p, int selection_handle) { |
| 74 TouchSelectionControllerImpl* controller = GetSelectionController(); | 74 TouchSelectionControllerImpl* controller = GetSelectionController(); |
| 75 // Do the work of OnMousePressed(). | 75 // Do the work of OnMousePressed(). |
| 76 if (selection_handle == 1) | 76 if (selection_handle == 1) |
| 77 controller->SetDraggingHandle(controller->selection_handle_1_.get()); | 77 controller->SetDraggingHandle(controller->selection_handle_1_.get()); |
| 78 else | 78 else |
| 79 controller->SetDraggingHandle(controller->selection_handle_2_.get()); | 79 controller->SetDraggingHandle(controller->selection_handle_2_.get()); |
| 80 | 80 |
| 81 // Offset the drag position by the selection handle radius since it is |
| 82 // supposed to be in the coordinate system of the handle. |
| 83 p.Offset(10, 0); |
| 81 controller->SelectionHandleDragged(p); | 84 controller->SelectionHandleDragged(p); |
| 82 | 85 |
| 83 // Do the work of OnMouseReleased(). | 86 // Do the work of OnMouseReleased(). |
| 84 controller->dragging_handle_ = NULL; | 87 controller->dragging_handle_ = NULL; |
| 85 } | 88 } |
| 86 | 89 |
| 87 gfx::Point GetSelectionHandle1Position() { | 90 gfx::Point GetSelectionHandle1Position() { |
| 88 return GetSelectionController()->GetSelectionHandle1Position(); | 91 return GetSelectionController()->GetSelectionHandle1Position(); |
| 89 } | 92 } |
| 90 | 93 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 VERIFY_HANDLE_POSITIONS(true); | 397 VERIFY_HANDLE_POSITIONS(true); |
| 395 | 398 |
| 396 // Drag selection handle 2 to right by 1 char. | 399 // Drag selection handle 2 to right by 1 char. |
| 397 x = textfield_->font().GetStringWidth(WideToUTF16(L"\x05e2")); | 400 x = textfield_->font().GetStringWidth(WideToUTF16(L"\x05e2")); |
| 398 SimulateSelectionHandleDrag(gfx::Point(x, 0), 2); | 401 SimulateSelectionHandleDrag(gfx::Point(x, 0), 2); |
| 399 EXPECT_EQ(WideToUTF16(L"c\x05e1"), textfield_->GetSelectedText()); | 402 EXPECT_EQ(WideToUTF16(L"c\x05e1"), textfield_->GetSelectedText()); |
| 400 VERIFY_HANDLE_POSITIONS(false); | 403 VERIFY_HANDLE_POSITIONS(false); |
| 401 } | 404 } |
| 402 | 405 |
| 403 } // namespace views | 406 } // namespace views |
| OLD | NEW |