| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/renderer_host/input/touch_selection_controller_client_
aura.h" | 5 #include "content/browser/renderer_host/input/touch_selection_controller_client_
aura.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 8 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 9 #include "content/browser/renderer_host/render_widget_host_impl.h" | 9 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 10 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 10 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 void TouchSelectionControllerClientAura::OnScrollCompleted() { | 151 void TouchSelectionControllerClientAura::OnScrollCompleted() { |
| 152 scroll_in_progress_ = false; | 152 scroll_in_progress_ = false; |
| 153 rwhva_->selection_controller()->SetTemporarilyHidden(false); | 153 rwhva_->selection_controller()->SetTemporarilyHidden(false); |
| 154 UpdateQuickMenu(); | 154 UpdateQuickMenu(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 bool TouchSelectionControllerClientAura::HandleContextMenu( | 157 bool TouchSelectionControllerClientAura::HandleContextMenu( |
| 158 const ContextMenuParams& params) { | 158 const ContextMenuParams& params) { |
| 159 if (params.source_type == ui::MENU_SOURCE_LONG_PRESS && | 159 if (params.source_type == ui::MENU_SOURCE_LONG_PRESS && |
| 160 params.is_editable && | 160 rwhva_->selection_controller()->insertion_active_or_requested() && |
| 161 params.selection_text.empty() && | |
| 162 IsQuickMenuAvailable()) { | 161 IsQuickMenuAvailable()) { |
| 162 DCHECK(params.is_editable); |
| 163 DCHECK(params.selection_text.empty()); |
| 163 quick_menu_requested_ = true; | 164 quick_menu_requested_ = true; |
| 164 UpdateQuickMenu(); | 165 UpdateQuickMenu(); |
| 165 return true; | 166 return true; |
| 166 } | 167 } |
| 167 rwhva_->selection_controller()->HideAndDisallowShowingAutomatically(); | 168 rwhva_->selection_controller()->HideAndDisallowShowingAutomatically(); |
| 168 return false; | 169 return false; |
| 169 } | 170 } |
| 170 | 171 |
| 171 bool TouchSelectionControllerClientAura::IsQuickMenuAvailable() const { | 172 bool TouchSelectionControllerClientAura::IsQuickMenuAvailable() const { |
| 172 return ui::TouchSelectionMenuRunner::GetInstance() && | 173 return ui::TouchSelectionMenuRunner::GetInstance() && |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 UpdateQuickMenu(); | 293 UpdateQuickMenu(); |
| 293 break; | 294 break; |
| 294 case ui::SELECTION_HANDLES_MOVED: | 295 case ui::SELECTION_HANDLES_MOVED: |
| 295 case ui::INSERTION_HANDLE_MOVED: | 296 case ui::INSERTION_HANDLE_MOVED: |
| 296 UpdateQuickMenu(); | 297 UpdateQuickMenu(); |
| 297 break; | 298 break; |
| 298 case ui::INSERTION_HANDLE_TAPPED: | 299 case ui::INSERTION_HANDLE_TAPPED: |
| 299 quick_menu_requested_ = !quick_menu_requested_; | 300 quick_menu_requested_ = !quick_menu_requested_; |
| 300 UpdateQuickMenu(); | 301 UpdateQuickMenu(); |
| 301 break; | 302 break; |
| 303 case ui::SELECTION_ESTABLISHED: |
| 304 case ui::SELECTION_DISSOLVED: |
| 305 break; |
| 302 }; | 306 }; |
| 303 } | 307 } |
| 304 | 308 |
| 305 std::unique_ptr<ui::TouchHandleDrawable> | 309 std::unique_ptr<ui::TouchHandleDrawable> |
| 306 TouchSelectionControllerClientAura::CreateDrawable() { | 310 TouchSelectionControllerClientAura::CreateDrawable() { |
| 307 return std::unique_ptr<ui::TouchHandleDrawable>( | 311 return std::unique_ptr<ui::TouchHandleDrawable>( |
| 308 new ui::TouchHandleDrawableAura(rwhva_->GetNativeView())); | 312 new ui::TouchHandleDrawableAura(rwhva_->GetNativeView())); |
| 309 } | 313 } |
| 310 | 314 |
| 311 bool TouchSelectionControllerClientAura::IsCommandIdEnabled( | 315 bool TouchSelectionControllerClientAura::IsCommandIdEnabled( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 ui::MENU_SOURCE_TOUCH_EDIT_MENU, | 370 ui::MENU_SOURCE_TOUCH_EDIT_MENU, |
| 367 gfx::ToRoundedPoint(anchor_point))); | 371 gfx::ToRoundedPoint(anchor_point))); |
| 368 | 372 |
| 369 // Hide selection handles after getting rect-between-bounds from touch | 373 // Hide selection handles after getting rect-between-bounds from touch |
| 370 // selection controller; otherwise, rect would be empty and the above | 374 // selection controller; otherwise, rect would be empty and the above |
| 371 // calculations would be invalid. | 375 // calculations would be invalid. |
| 372 rwhva_->selection_controller()->HideAndDisallowShowingAutomatically(); | 376 rwhva_->selection_controller()->HideAndDisallowShowingAutomatically(); |
| 373 } | 377 } |
| 374 | 378 |
| 375 } // namespace content | 379 } // namespace content |
| OLD | NEW |