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

Side by Side Diff: content/browser/web_contents/touch_editable_impl_aura.cc

Issue 138033014: Consistent fading behavior for touch editing handles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fade out handles on destruction by default Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
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 "content/browser/web_contents/touch_editable_impl_aura.h" 5 #include "content/browser/web_contents/touch_editable_impl_aura.h"
6 6
7 #include "content/browser/renderer_host/render_widget_host_impl.h" 7 #include "content/browser/renderer_host/render_widget_host_impl.h"
8 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 8 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
9 #include "content/common/view_messages.h" 9 #include "content/common/view_messages.h"
10 #include "content/public/browser/render_widget_host.h" 10 #include "content/public/browser/render_widget_host.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // using mouse or keyboard). 55 // using mouse or keyboard).
56 if (selection_gesture_in_process_ && !scroll_in_progress_ && 56 if (selection_gesture_in_process_ && !scroll_in_progress_ &&
57 selection_anchor_rect_ != selection_focus_rect_) 57 selection_anchor_rect_ != selection_focus_rect_)
58 StartTouchEditing(); 58 StartTouchEditing();
59 59
60 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE || 60 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE ||
61 selection_anchor_rect_ != selection_focus_rect_) { 61 selection_anchor_rect_ != selection_focus_rect_) {
62 if (touch_selection_controller_) 62 if (touch_selection_controller_)
63 touch_selection_controller_->SelectionChanged(); 63 touch_selection_controller_->SelectionChanged();
64 } else { 64 } else {
65 EndTouchEditing(); 65 EndTouchEditing(false);
66 } 66 }
67 } 67 }
68 68
69 void TouchEditableImplAura::OverscrollStarted() { 69 void TouchEditableImplAura::OverscrollStarted() {
70 overscroll_in_progress_ = true; 70 overscroll_in_progress_ = true;
71 } 71 }
72 72
73 void TouchEditableImplAura::OverscrollCompleted() { 73 void TouchEditableImplAura::OverscrollCompleted() {
74 // We might receive multiple OverscrollStarted() and OverscrollCompleted() 74 // We might receive multiple OverscrollStarted() and OverscrollCompleted()
75 // during the same scroll session (for example, when the scroll direction 75 // during the same scroll session (for example, when the scroll direction
(...skipping 22 matching lines...) Expand all
98 return; 98 return;
99 99
100 if (!touch_selection_controller_) { 100 if (!touch_selection_controller_) {
101 touch_selection_controller_.reset( 101 touch_selection_controller_.reset(
102 ui::TouchSelectionController::create(this)); 102 ui::TouchSelectionController::create(this));
103 } 103 }
104 if (touch_selection_controller_) 104 if (touch_selection_controller_)
105 touch_selection_controller_->SelectionChanged(); 105 touch_selection_controller_->SelectionChanged();
106 } 106 }
107 107
108 void TouchEditableImplAura::EndTouchEditing() { 108 void TouchEditableImplAura::EndTouchEditing(bool quick) {
109 if (touch_selection_controller_) { 109 if (touch_selection_controller_) {
110 if (touch_selection_controller_->IsHandleDragInProgress()) 110 if (touch_selection_controller_->IsHandleDragInProgress()) {
111 touch_selection_controller_->SelectionChanged(); 111 touch_selection_controller_->SelectionChanged();
112 else 112 } else {
113 touch_selection_controller_->HideHandles(quick);
113 touch_selection_controller_.reset(); 114 touch_selection_controller_.reset();
115 }
114 } 116 }
115 } 117 }
116 118
117 void TouchEditableImplAura::OnSelectionOrCursorChanged(const gfx::Rect& anchor, 119 void TouchEditableImplAura::OnSelectionOrCursorChanged(const gfx::Rect& anchor,
118 const gfx::Rect& focus) { 120 const gfx::Rect& focus) {
119 selection_anchor_rect_ = anchor; 121 selection_anchor_rect_ = anchor;
120 selection_focus_rect_ = focus; 122 selection_focus_rect_ = focus;
121 UpdateEditingController(); 123 UpdateEditingController();
122 } 124 }
123 125
124 void TouchEditableImplAura::OnTextInputTypeChanged(ui::TextInputType type) { 126 void TouchEditableImplAura::OnTextInputTypeChanged(ui::TextInputType type) {
125 text_input_type_ = type; 127 text_input_type_ = type;
126 } 128 }
127 129
128 bool TouchEditableImplAura::HandleInputEvent(const ui::Event* event) { 130 bool TouchEditableImplAura::HandleInputEvent(const ui::Event* event) {
129 DCHECK(rwhva_); 131 DCHECK(rwhva_);
130 if (event->IsTouchEvent()) 132 if (event->IsTouchEvent())
131 return false; 133 return false;
132 134
133 if (!event->IsGestureEvent()) { 135 if (!event->IsGestureEvent()) {
134 EndTouchEditing(); 136 EndTouchEditing(false);
135 return false; 137 return false;
136 } 138 }
137 139
138 const ui::GestureEvent* gesture_event = 140 const ui::GestureEvent* gesture_event =
139 static_cast<const ui::GestureEvent*>(event); 141 static_cast<const ui::GestureEvent*>(event);
140 switch (event->type()) { 142 switch (event->type()) {
141 case ui::ET_GESTURE_TAP: 143 case ui::ET_GESTURE_TAP:
142 tap_gesture_tap_count_queue_.push(gesture_event->details().tap_count()); 144 tap_gesture_tap_count_queue_.push(gesture_event->details().tap_count());
143 if (gesture_event->details().tap_count() > 1) 145 if (gesture_event->details().tap_count() > 1)
144 selection_gesture_in_process_ = true; 146 selection_gesture_in_process_ = true;
(...skipping 23 matching lines...) Expand all
168 break; 170 break;
169 case ui::ET_GESTURE_SCROLL_BEGIN: 171 case ui::ET_GESTURE_SCROLL_BEGIN:
170 // If selection handles are currently visible, we want to get them back up 172 // If selection handles are currently visible, we want to get them back up
171 // when scrolling ends. So we set |handles_hidden_due_to_scroll_| so that 173 // when scrolling ends. So we set |handles_hidden_due_to_scroll_| so that
172 // we can re-start touch editing when we call |UpdateEditingController()| 174 // we can re-start touch editing when we call |UpdateEditingController()|
173 // on scroll end gesture. 175 // on scroll end gesture.
174 scroll_in_progress_ = true; 176 scroll_in_progress_ = true;
175 handles_hidden_due_to_scroll_ = false; 177 handles_hidden_due_to_scroll_ = false;
176 if (touch_selection_controller_) 178 if (touch_selection_controller_)
177 handles_hidden_due_to_scroll_ = true; 179 handles_hidden_due_to_scroll_ = true;
178 EndTouchEditing(); 180 EndTouchEditing(true);
179 break; 181 break;
180 case ui::ET_GESTURE_SCROLL_END: 182 case ui::ET_GESTURE_SCROLL_END:
181 // Scroll has ended, but we might still be in overscroll animation. 183 // Scroll has ended, but we might still be in overscroll animation.
182 if (handles_hidden_due_to_scroll_ && !overscroll_in_progress_ && 184 if (handles_hidden_due_to_scroll_ && !overscroll_in_progress_ &&
183 (selection_anchor_rect_ != selection_focus_rect_ || 185 (selection_anchor_rect_ != selection_focus_rect_ ||
184 text_input_type_ != ui::TEXT_INPUT_TYPE_NONE)) { 186 text_input_type_ != ui::TEXT_INPUT_TYPE_NONE)) {
185 StartTouchEditing(); 187 StartTouchEditing();
186 UpdateEditingController(); 188 UpdateEditingController();
187 } 189 }
188 // fall through to reset |scroll_in_progress_|. 190 // fall through to reset |scroll_in_progress_|.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 return false; 282 return false;
281 } 283 }
282 284
283 void TouchEditableImplAura::OpenContextMenu(const gfx::Point& anchor) { 285 void TouchEditableImplAura::OpenContextMenu(const gfx::Point& anchor) {
284 if (!rwhva_) 286 if (!rwhva_)
285 return; 287 return;
286 gfx::Point point = anchor; 288 gfx::Point point = anchor;
287 ConvertPointFromScreen(&point); 289 ConvertPointFromScreen(&point);
288 RenderWidgetHost* host = rwhva_->GetRenderWidgetHost(); 290 RenderWidgetHost* host = rwhva_->GetRenderWidgetHost();
289 host->Send(new ViewMsg_ShowContextMenu(host->GetRoutingID(), point)); 291 host->Send(new ViewMsg_ShowContextMenu(host->GetRoutingID(), point));
290 EndTouchEditing(); 292 EndTouchEditing(false);
291 } 293 }
292 294
293 bool TouchEditableImplAura::IsCommandIdChecked(int command_id) const { 295 bool TouchEditableImplAura::IsCommandIdChecked(int command_id) const {
294 NOTREACHED(); 296 NOTREACHED();
295 return false; 297 return false;
296 } 298 }
297 299
298 bool TouchEditableImplAura::IsCommandIdEnabled(int command_id) const { 300 bool TouchEditableImplAura::IsCommandIdEnabled(int command_id) const {
299 if (!rwhva_) 301 if (!rwhva_)
300 return false; 302 return false;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 case IDS_APP_DELETE: 347 case IDS_APP_DELETE:
346 host->Delete(); 348 host->Delete();
347 break; 349 break;
348 case IDS_APP_SELECT_ALL: 350 case IDS_APP_SELECT_ALL:
349 host->SelectAll(); 351 host->SelectAll();
350 break; 352 break;
351 default: 353 default:
352 NOTREACHED(); 354 NOTREACHED();
353 break; 355 break;
354 } 356 }
355 EndTouchEditing(); 357 EndTouchEditing(false);
356 } 358 }
357 359
358 //////////////////////////////////////////////////////////////////////////////// 360 ////////////////////////////////////////////////////////////////////////////////
359 // TouchEditableImplAura, private: 361 // TouchEditableImplAura, private:
360 362
361 TouchEditableImplAura::TouchEditableImplAura() 363 TouchEditableImplAura::TouchEditableImplAura()
362 : text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 364 : text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
363 rwhva_(NULL), 365 rwhva_(NULL),
364 selection_gesture_in_process_(false), 366 selection_gesture_in_process_(false),
365 handles_hidden_due_to_scroll_(false), 367 handles_hidden_due_to_scroll_(false),
366 scroll_in_progress_(false), 368 scroll_in_progress_(false),
367 overscroll_in_progress_(false), 369 overscroll_in_progress_(false),
368 is_tap_on_focused_textfield_(false) { 370 is_tap_on_focused_textfield_(false) {
369 } 371 }
370 372
371 void TouchEditableImplAura::Cleanup() { 373 void TouchEditableImplAura::Cleanup() {
372 if (rwhva_) { 374 if (rwhva_) {
373 rwhva_->set_touch_editing_client(NULL); 375 rwhva_->set_touch_editing_client(NULL);
374 rwhva_ = NULL; 376 rwhva_ = NULL;
375 } 377 }
376 text_input_type_ = ui::TEXT_INPUT_TYPE_NONE; 378 text_input_type_ = ui::TEXT_INPUT_TYPE_NONE;
377 touch_selection_controller_.reset(); 379 EndTouchEditing(true);
378 handles_hidden_due_to_scroll_ = false; 380 handles_hidden_due_to_scroll_ = false;
379 scroll_in_progress_ = false; 381 scroll_in_progress_ = false;
380 overscroll_in_progress_ = false; 382 overscroll_in_progress_ = false;
381 } 383 }
382 384
383 } // namespace content 385 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/touch_editable_impl_aura.h ('k') | content/browser/web_contents/web_contents_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698