| 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/touchui/touch_selection_controller_impl.h" | 5 #include "ui/views/touchui/touch_selection_controller_impl.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "ui/aura/client/cursor_client.h" | 9 #include "ui/aura/client/cursor_client.h" |
| 10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 // Temporary fix for selection handle going outside a window. On a webpage, | 497 // Temporary fix for selection handle going outside a window. On a webpage, |
| 498 // the page should scroll if the selection handle is dragged outside the | 498 // the page should scroll if the selection handle is dragged outside the |
| 499 // window. That does not happen currently. So we just hide the handle for | 499 // window. That does not happen currently. So we just hide the handle for |
| 500 // now. | 500 // now. |
| 501 // TODO(varunjain): Fix this: crbug.com/269003 | 501 // TODO(varunjain): Fix this: crbug.com/269003 |
| 502 dragging_handle_->SetDrawInvisible(!ShouldShowHandleFor(focus)); | 502 dragging_handle_->SetDrawInvisible(!ShouldShowHandleFor(focus)); |
| 503 | 503 |
| 504 if (dragging_handle_ != cursor_handle_.get()) { | 504 if (dragging_handle_ != cursor_handle_.get()) { |
| 505 // The non-dragging-handle might have recently become visible. | 505 // The non-dragging-handle might have recently become visible. |
| 506 EditingHandleView* non_dragging_handle = selection_handle_1_.get(); | 506 EditingHandleView* non_dragging_handle = selection_handle_1_.get(); |
| 507 if (dragging_handle_ == selection_handle_1_) { | 507 if (dragging_handle_ == selection_handle_1_.get()) { |
| 508 non_dragging_handle = selection_handle_2_.get(); | 508 non_dragging_handle = selection_handle_2_.get(); |
| 509 // if handle 1 is being dragged, it is corresponding to the end of | 509 // if handle 1 is being dragged, it is corresponding to the end of |
| 510 // selection and the other handle to the start of selection. | 510 // selection and the other handle to the start of selection. |
| 511 selection_bound_1_ = screen_bound_focus; | 511 selection_bound_1_ = screen_bound_focus; |
| 512 selection_bound_2_ = screen_bound_anchor; | 512 selection_bound_2_ = screen_bound_anchor; |
| 513 selection_bound_1_clipped_ = screen_bound_focus_clipped; | 513 selection_bound_1_clipped_ = screen_bound_focus_clipped; |
| 514 selection_bound_2_clipped_ = screen_bound_anchor_clipped; | 514 selection_bound_2_clipped_ = screen_bound_anchor_clipped; |
| 515 } | 515 } |
| 516 SetHandleBound(non_dragging_handle, anchor, screen_bound_anchor_clipped); | 516 SetHandleBound(non_dragging_handle, anchor, screen_bound_anchor_clipped); |
| 517 } | 517 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 gfx::Point drag_pos_in_client = drag_pos; | 560 gfx::Point drag_pos_in_client = drag_pos; |
| 561 ConvertPointToClientView(dragging_handle_, &drag_pos_in_client); | 561 ConvertPointToClientView(dragging_handle_, &drag_pos_in_client); |
| 562 | 562 |
| 563 if (dragging_handle_ == cursor_handle_.get()) { | 563 if (dragging_handle_ == cursor_handle_.get()) { |
| 564 client_view_->MoveCaretTo(drag_pos_in_client); | 564 client_view_->MoveCaretTo(drag_pos_in_client); |
| 565 return; | 565 return; |
| 566 } | 566 } |
| 567 | 567 |
| 568 // Find the stationary selection handle. | 568 // Find the stationary selection handle. |
| 569 ui::SelectionBound anchor_bound = | 569 ui::SelectionBound anchor_bound = |
| 570 selection_handle_1_ == dragging_handle_ ? selection_bound_2_ | 570 selection_handle_1_.get() == dragging_handle_ ? selection_bound_2_ |
| 571 : selection_bound_1_; | 571 : selection_bound_1_; |
| 572 | 572 |
| 573 // Find selection end points in client_view's coordinate system. | 573 // Find selection end points in client_view's coordinate system. |
| 574 gfx::Point p2 = anchor_bound.edge_top_rounded(); | 574 gfx::Point p2 = anchor_bound.edge_top_rounded(); |
| 575 p2.Offset(0, anchor_bound.GetHeight() / 2); | 575 p2.Offset(0, anchor_bound.GetHeight() / 2); |
| 576 client_view_->ConvertPointFromScreen(&p2); | 576 client_view_->ConvertPointFromScreen(&p2); |
| 577 | 577 |
| 578 // Instruct client_view to select the region between p1 and p2. The position | 578 // Instruct client_view to select the region between p1 and p2. The position |
| 579 // of |fixed_handle| is the start and that of |dragging_handle| is the end | 579 // of |fixed_handle| is the start and that of |dragging_handle| is the end |
| 580 // of selection. | 580 // of selection. |
| 581 client_view_->SelectRect(p2, drag_pos_in_client); | 581 client_view_->SelectRect(p2, drag_pos_in_client); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 | 770 |
| 771 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle1View() { | 771 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle1View() { |
| 772 return selection_handle_1_.get(); | 772 return selection_handle_1_.get(); |
| 773 } | 773 } |
| 774 | 774 |
| 775 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle2View() { | 775 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle2View() { |
| 776 return selection_handle_2_.get(); | 776 return selection_handle_2_.get(); |
| 777 } | 777 } |
| 778 | 778 |
| 779 } // namespace views | 779 } // namespace views |
| OLD | NEW |