| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // Note that this is not quite correct because it does not take into account | 175 // Note that this is not quite correct because it does not take into account |
| 176 // transforms such as rotation and scaling. This should be in TouchEditable. | 176 // transforms such as rotation and scaling. This should be in TouchEditable. |
| 177 // TODO(varunjain): Fix this. | 177 // TODO(varunjain): Fix this. |
| 178 ui::SelectionBound ConvertFromScreen(ui::TouchEditable* client, | 178 ui::SelectionBound ConvertFromScreen(ui::TouchEditable* client, |
| 179 const ui::SelectionBound& bound) { | 179 const ui::SelectionBound& bound) { |
| 180 ui::SelectionBound result = bound; | 180 ui::SelectionBound result = bound; |
| 181 gfx::Point edge_bottom = bound.edge_bottom_rounded(); | 181 gfx::Point edge_bottom = bound.edge_bottom_rounded(); |
| 182 gfx::Point edge_top = bound.edge_top_rounded(); | 182 gfx::Point edge_top = bound.edge_top_rounded(); |
| 183 client->ConvertPointFromScreen(&edge_bottom); | 183 client->ConvertPointFromScreen(&edge_bottom); |
| 184 client->ConvertPointFromScreen(&edge_top); | 184 client->ConvertPointFromScreen(&edge_top); |
| 185 result.SetEdge(edge_top, edge_bottom); | 185 result.SetEdge(gfx::PointF(edge_top), gfx::PointF(edge_bottom)); |
| 186 return result; | 186 return result; |
| 187 } | 187 } |
| 188 | 188 |
| 189 ui::SelectionBound ConvertToScreen(ui::TouchEditable* client, | 189 ui::SelectionBound ConvertToScreen(ui::TouchEditable* client, |
| 190 const ui::SelectionBound& bound) { | 190 const ui::SelectionBound& bound) { |
| 191 ui::SelectionBound result = bound; | 191 ui::SelectionBound result = bound; |
| 192 gfx::Point edge_bottom = bound.edge_bottom_rounded(); | 192 gfx::Point edge_bottom = bound.edge_bottom_rounded(); |
| 193 gfx::Point edge_top = bound.edge_top_rounded(); | 193 gfx::Point edge_top = bound.edge_top_rounded(); |
| 194 client->ConvertPointToScreen(&edge_bottom); | 194 client->ConvertPointToScreen(&edge_bottom); |
| 195 client->ConvertPointToScreen(&edge_top); | 195 client->ConvertPointToScreen(&edge_top); |
| 196 result.SetEdge(edge_top, edge_bottom); | 196 result.SetEdge(gfx::PointF(edge_top), gfx::PointF(edge_bottom)); |
| 197 return result; | 197 return result; |
| 198 } | 198 } |
| 199 | 199 |
| 200 gfx::Rect BoundToRect(const ui::SelectionBound& bound) { | 200 gfx::Rect BoundToRect(const ui::SelectionBound& bound) { |
| 201 return gfx::BoundingRect(bound.edge_top_rounded(), | 201 return gfx::BoundingRect(bound.edge_top_rounded(), |
| 202 bound.edge_bottom_rounded()); | 202 bound.edge_bottom_rounded()); |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace | 205 } // namespace |
| 206 | 206 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } | 348 } |
| 349 selection_bound_.SetEdge(bound.edge_top(), bound.edge_bottom()); | 349 selection_bound_.SetEdge(bound.edge_top(), bound.edge_bottom()); |
| 350 | 350 |
| 351 widget_->SetBounds(GetSelectionWidgetBounds(selection_bound_)); | 351 widget_->SetBounds(GetSelectionWidgetBounds(selection_bound_)); |
| 352 | 352 |
| 353 aura::Window* window = widget_->GetNativeView(); | 353 aura::Window* window = widget_->GetNativeView(); |
| 354 gfx::Point edge_top = selection_bound_.edge_top_rounded(); | 354 gfx::Point edge_top = selection_bound_.edge_top_rounded(); |
| 355 gfx::Point edge_bottom = selection_bound_.edge_bottom_rounded(); | 355 gfx::Point edge_bottom = selection_bound_.edge_bottom_rounded(); |
| 356 wm::ConvertPointFromScreen(window, &edge_top); | 356 wm::ConvertPointFromScreen(window, &edge_top); |
| 357 wm::ConvertPointFromScreen(window, &edge_bottom); | 357 wm::ConvertPointFromScreen(window, &edge_bottom); |
| 358 selection_bound_.SetEdge(edge_top, edge_bottom); | 358 selection_bound_.SetEdge(gfx::PointF(edge_top), gfx::PointF(edge_bottom)); |
| 359 } | 359 } |
| 360 | 360 |
| 361 void SetDrawInvisible(bool draw_invisible) { | 361 void SetDrawInvisible(bool draw_invisible) { |
| 362 if (draw_invisible_ == draw_invisible) | 362 if (draw_invisible_ == draw_invisible) |
| 363 return; | 363 return; |
| 364 draw_invisible_ = draw_invisible; | 364 draw_invisible_ = draw_invisible; |
| 365 SchedulePaint(); | 365 SchedulePaint(); |
| 366 } | 366 } |
| 367 | 367 |
| 368 private: | 368 private: |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 } | 439 } |
| 440 | 440 |
| 441 void TouchSelectionControllerImpl::SelectionChanged() { | 441 void TouchSelectionControllerImpl::SelectionChanged() { |
| 442 ui::SelectionBound anchor, focus; | 442 ui::SelectionBound anchor, focus; |
| 443 client_view_->GetSelectionEndPoints(&anchor, &focus); | 443 client_view_->GetSelectionEndPoints(&anchor, &focus); |
| 444 ui::SelectionBound screen_bound_anchor = | 444 ui::SelectionBound screen_bound_anchor = |
| 445 ConvertToScreen(client_view_, anchor); | 445 ConvertToScreen(client_view_, anchor); |
| 446 ui::SelectionBound screen_bound_focus = ConvertToScreen(client_view_, focus); | 446 ui::SelectionBound screen_bound_focus = ConvertToScreen(client_view_, focus); |
| 447 gfx::Rect client_bounds = client_view_->GetBounds(); | 447 gfx::Rect client_bounds = client_view_->GetBounds(); |
| 448 if (anchor.edge_top().y() < client_bounds.y()) { | 448 if (anchor.edge_top().y() < client_bounds.y()) { |
| 449 gfx::Point anchor_edge_top = anchor.edge_top_rounded(); | 449 auto anchor_edge_top = gfx::PointF(anchor.edge_top_rounded()); |
| 450 anchor_edge_top.set_y(client_bounds.y()); | 450 anchor_edge_top.set_y(client_bounds.y()); |
| 451 anchor.SetEdgeTop(anchor_edge_top); | 451 anchor.SetEdgeTop(anchor_edge_top); |
| 452 } | 452 } |
| 453 if (focus.edge_top().y() < client_bounds.y()) { | 453 if (focus.edge_top().y() < client_bounds.y()) { |
| 454 gfx::Point focus_edge_top = focus.edge_top_rounded(); | 454 auto focus_edge_top = gfx::PointF(focus.edge_top_rounded()); |
| 455 focus_edge_top.set_y(client_bounds.y()); | 455 focus_edge_top.set_y(client_bounds.y()); |
| 456 focus.SetEdgeTop(focus_edge_top); | 456 focus.SetEdgeTop(focus_edge_top); |
| 457 } | 457 } |
| 458 ui::SelectionBound screen_bound_anchor_clipped = | 458 ui::SelectionBound screen_bound_anchor_clipped = |
| 459 ConvertToScreen(client_view_, anchor); | 459 ConvertToScreen(client_view_, anchor); |
| 460 ui::SelectionBound screen_bound_focus_clipped = | 460 ui::SelectionBound screen_bound_focus_clipped = |
| 461 ConvertToScreen(client_view_, focus); | 461 ConvertToScreen(client_view_, focus); |
| 462 if (screen_bound_anchor_clipped == selection_bound_1_clipped_ && | 462 if (screen_bound_anchor_clipped == selection_bound_1_clipped_ && |
| 463 screen_bound_focus_clipped == selection_bound_2_clipped_) | 463 screen_bound_focus_clipped == selection_bound_2_clipped_) |
| 464 return; | 464 return; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 | 750 |
| 751 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle1View() { | 751 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle1View() { |
| 752 return selection_handle_1_.get(); | 752 return selection_handle_1_.get(); |
| 753 } | 753 } |
| 754 | 754 |
| 755 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle2View() { | 755 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle2View() { |
| 756 return selection_handle_2_.get(); | 756 return selection_handle_2_.get(); |
| 757 } | 757 } |
| 758 | 758 |
| 759 } // namespace views | 759 } // namespace views |
| OLD | NEW |