Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(759)

Side by Side Diff: content/browser/renderer_host/input/touch_selection_controller.cc

Issue 359033002: [Android] Enable composited selection updates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@input_native_handles_0_compositor
Patch Set: Rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.h" 5 #include "content/browser/renderer_host/input/touch_selection_controller.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "third_party/WebKit/public/web/WebInputEvent.h" 9 #include "third_party/WebKit/public/web/WebInputEvent.h"
10 10
(...skipping 25 matching lines...) Expand all
36 tap_timeout_(tap_timeout), 36 tap_timeout_(tap_timeout),
37 tap_slop_(tap_slop), 37 tap_slop_(tap_slop),
38 response_pending_input_event_(INPUT_EVENT_TYPE_NONE), 38 response_pending_input_event_(INPUT_EVENT_TYPE_NONE),
39 start_orientation_(TOUCH_HANDLE_ORIENTATION_UNDEFINED), 39 start_orientation_(TOUCH_HANDLE_ORIENTATION_UNDEFINED),
40 end_orientation_(TOUCH_HANDLE_ORIENTATION_UNDEFINED), 40 end_orientation_(TOUCH_HANDLE_ORIENTATION_UNDEFINED),
41 is_insertion_active_(false), 41 is_insertion_active_(false),
42 activate_insertion_automatically_(false), 42 activate_insertion_automatically_(false),
43 is_selection_active_(false), 43 is_selection_active_(false),
44 activate_selection_automatically_(false), 44 activate_selection_automatically_(false),
45 selection_empty_(false), 45 selection_empty_(false),
46 selection_editable_(false), 46 selection_editable_(false) {
47 temporarily_hidden_(false) {
48 DCHECK(client_); 47 DCHECK(client_);
49 HideAndDisallowShowingAutomatically(); 48 HideAndDisallowShowingAutomatically();
50 } 49 }
51 50
52 TouchSelectionController::~TouchSelectionController() { 51 TouchSelectionController::~TouchSelectionController() {
53 } 52 }
54 53
55 void TouchSelectionController::OnSelectionBoundsChanged( 54 void TouchSelectionController::OnSelectionBoundsChanged(
56 const cc::ViewportSelectionBound& start, 55 const cc::ViewportSelectionBound& start,
57 const cc::ViewportSelectionBound& end) { 56 const cc::ViewportSelectionBound& end) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 152 }
154 153
155 void TouchSelectionController::HideAndDisallowShowingAutomatically() { 154 void TouchSelectionController::HideAndDisallowShowingAutomatically() {
156 response_pending_input_event_ = INPUT_EVENT_TYPE_NONE; 155 response_pending_input_event_ = INPUT_EVENT_TYPE_NONE;
157 DeactivateInsertion(); 156 DeactivateInsertion();
158 DeactivateSelection(); 157 DeactivateSelection();
159 activate_insertion_automatically_ = false; 158 activate_insertion_automatically_ = false;
160 activate_selection_automatically_ = false; 159 activate_selection_automatically_ = false;
161 } 160 }
162 161
163 void TouchSelectionController::SetTemporarilyHidden(bool hidden) {
164 if (temporarily_hidden_ == hidden)
165 return;
166 temporarily_hidden_ = hidden;
167
168 TouchHandle::AnimationStyle animation_style = GetAnimationStyle(true);
169 if (is_selection_active_) {
170 start_selection_handle_->SetVisible(GetStartVisible(), animation_style);
171 end_selection_handle_->SetVisible(GetEndVisible(), animation_style);
172 }
173 if (is_insertion_active_)
174 insertion_handle_->SetVisible(GetStartVisible(), animation_style);
175 }
176
177 void TouchSelectionController::OnSelectionEditable(bool editable) { 162 void TouchSelectionController::OnSelectionEditable(bool editable) {
178 if (selection_editable_ == editable) 163 if (selection_editable_ == editable)
179 return; 164 return;
180 selection_editable_ = editable; 165 selection_editable_ = editable;
181 ResetCachedValuesIfInactive(); 166 ResetCachedValuesIfInactive();
182 if (!selection_editable_) 167 if (!selection_editable_)
183 DeactivateInsertion(); 168 DeactivateInsertion();
184 } 169 }
185 170
186 void TouchSelectionController::OnSelectionEmpty(bool empty) { 171 void TouchSelectionController::OnSelectionEmpty(bool empty) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 if (!activate_insertion_automatically_) 270 if (!activate_insertion_automatically_)
286 return; 271 return;
287 272
288 const bool was_active = is_insertion_active_; 273 const bool was_active = is_insertion_active_;
289 const gfx::PointF position = GetStartPosition(); 274 const gfx::PointF position = GetStartPosition();
290 if (!is_insertion_active_) 275 if (!is_insertion_active_)
291 ActivateInsertion(); 276 ActivateInsertion();
292 else 277 else
293 client_->OnSelectionEvent(INSERTION_MOVED, position); 278 client_->OnSelectionEvent(INSERTION_MOVED, position);
294 279
295 insertion_handle_->SetVisible(GetStartVisible(), 280 insertion_handle_->SetVisible(start_.visible, GetAnimationStyle(was_active));
296 GetAnimationStyle(was_active));
297 insertion_handle_->SetPosition(position); 281 insertion_handle_->SetPosition(position);
298 } 282 }
299 283
300 void TouchSelectionController::OnSelectionChanged() { 284 void TouchSelectionController::OnSelectionChanged() {
301 DeactivateInsertion(); 285 DeactivateInsertion();
302 286
303 if (!activate_selection_automatically_) 287 if (!activate_selection_automatically_)
304 return; 288 return;
305 289
306 const bool was_active = is_selection_active_; 290 const bool was_active = is_selection_active_;
307 ActivateSelection(); 291 ActivateSelection();
308 292
309 const TouchHandle::AnimationStyle animation = GetAnimationStyle(was_active); 293 const TouchHandle::AnimationStyle animation = GetAnimationStyle(was_active);
310 start_selection_handle_->SetVisible(GetStartVisible(), animation); 294 start_selection_handle_->SetVisible(start_.visible, animation);
311 end_selection_handle_->SetVisible(GetEndVisible(), animation); 295 end_selection_handle_->SetVisible(end_.visible, animation);
312 296
313 start_selection_handle_->SetPosition(GetStartPosition()); 297 start_selection_handle_->SetPosition(GetStartPosition());
314 end_selection_handle_->SetPosition(GetEndPosition()); 298 end_selection_handle_->SetPosition(GetEndPosition());
315 } 299 }
316 300
317 void TouchSelectionController::ActivateInsertion() { 301 void TouchSelectionController::ActivateInsertion() {
318 DCHECK(!is_selection_active_); 302 DCHECK(!is_selection_active_);
319 303
320 if (!insertion_handle_) 304 if (!insertion_handle_)
321 insertion_handle_.reset(new TouchHandle(this, TOUCH_HANDLE_CENTER)); 305 insertion_handle_.reset(new TouchHandle(this, TOUCH_HANDLE_CENTER));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 } 376 }
393 377
394 gfx::Vector2dF TouchSelectionController::GetStartLineOffset() const { 378 gfx::Vector2dF TouchSelectionController::GetStartLineOffset() const {
395 return gfx::ScaleVector2d(start_.edge_top - start_.edge_bottom, 0.5f); 379 return gfx::ScaleVector2d(start_.edge_top - start_.edge_bottom, 0.5f);
396 } 380 }
397 381
398 gfx::Vector2dF TouchSelectionController::GetEndLineOffset() const { 382 gfx::Vector2dF TouchSelectionController::GetEndLineOffset() const {
399 return gfx::ScaleVector2d(end_.edge_top - end_.edge_bottom, 0.5f); 383 return gfx::ScaleVector2d(end_.edge_top - end_.edge_bottom, 0.5f);
400 } 384 }
401 385
402 bool TouchSelectionController::GetStartVisible() const {
403 return start_.visible && !temporarily_hidden_;
404 }
405
406 bool TouchSelectionController::GetEndVisible() const {
407 return end_.visible && !temporarily_hidden_;
408 }
409
410 TouchHandle::AnimationStyle TouchSelectionController::GetAnimationStyle( 386 TouchHandle::AnimationStyle TouchSelectionController::GetAnimationStyle(
411 bool was_active) const { 387 bool was_active) const {
412 return was_active && client_->SupportsAnimation() 388 return was_active && client_->SupportsAnimation()
413 ? TouchHandle::ANIMATION_SMOOTH 389 ? TouchHandle::ANIMATION_SMOOTH
414 : TouchHandle::ANIMATION_NONE; 390 : TouchHandle::ANIMATION_NONE;
415 } 391 }
416 392
417 } // namespace content 393 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698