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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 1087893003: Support longpress drag selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/render_widget_host_view_android.h" 5 #include "content/browser/renderer_host/render_widget_host_view_android.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 8
9 #include "base/android/build_info.h" 9 #include "base/android/build_info.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 775
776 bool RenderWidgetHostViewAndroid::OnTouchHandleEvent( 776 bool RenderWidgetHostViewAndroid::OnTouchHandleEvent(
777 const ui::MotionEvent& event) { 777 const ui::MotionEvent& event) {
778 return selection_controller_ && 778 return selection_controller_ &&
779 selection_controller_->WillHandleTouchEvent(event); 779 selection_controller_->WillHandleTouchEvent(event);
780 } 780 }
781 781
782 void RenderWidgetHostViewAndroid::ResetGestureDetection() { 782 void RenderWidgetHostViewAndroid::ResetGestureDetection() {
783 const ui::MotionEvent* current_down_event = 783 const ui::MotionEvent* current_down_event =
784 gesture_provider_.GetCurrentDownEvent(); 784 gesture_provider_.GetCurrentDownEvent();
785 if (current_down_event) { 785 if (!current_down_event) {
786 scoped_ptr<ui::MotionEvent> cancel_event = current_down_event->Cancel(); 786 // A hard reset ensures prevention of any timer-based events that might fire
787 OnTouchEvent(*cancel_event); 787 // after a touch sequence has ended.
788 gesture_provider_.ResetDetection();
789 return;
788 } 790 }
789 791
790 // A hard reset ensures prevention of any timer-based events. 792 scoped_ptr<ui::MotionEvent> cancel_event = current_down_event->Cancel();
791 gesture_provider_.ResetDetection(); 793 if (gesture_provider_.OnTouchEvent(*cancel_event).succeeded) {
794 bool causes_scrolling = false;
795 host_->ForwardTouchEventWithLatencyInfo(
796 ui::CreateWebTouchEventFromMotionEvent(*cancel_event, causes_scrolling),
797 ui::LatencyInfo());
798 }
792 } 799 }
793 800
794 void RenderWidgetHostViewAndroid::OnDidNavigateMainFrameToNewPage() { 801 void RenderWidgetHostViewAndroid::OnDidNavigateMainFrameToNewPage() {
795 ResetGestureDetection(); 802 ResetGestureDetection();
796 } 803 }
797 804
798 void RenderWidgetHostViewAndroid::SetDoubleTapSupportEnabled(bool enabled) { 805 void RenderWidgetHostViewAndroid::SetDoubleTapSupportEnabled(bool enabled) {
799 gesture_provider_.SetDoubleTapSupportForPlatformEnabled(enabled); 806 gesture_provider_.SetDoubleTapSupportForPlatformEnabled(enabled);
800 } 807 }
801 808
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 const gfx::PointF& base, 1263 const gfx::PointF& base,
1257 const gfx::PointF& extent) { 1264 const gfx::PointF& extent) {
1258 DCHECK(content_view_core_); 1265 DCHECK(content_view_core_);
1259 content_view_core_->SelectBetweenCoordinates(base, extent); 1266 content_view_core_->SelectBetweenCoordinates(base, extent);
1260 } 1267 }
1261 1268
1262 void RenderWidgetHostViewAndroid::OnSelectionEvent( 1269 void RenderWidgetHostViewAndroid::OnSelectionEvent(
1263 ui::SelectionEventType event) { 1270 ui::SelectionEventType event) {
1264 DCHECK(content_view_core_); 1271 DCHECK(content_view_core_);
1265 DCHECK(selection_controller_); 1272 DCHECK(selection_controller_);
1266 // Showing the selection action bar can alter the current View coordinates in 1273 // If a selection drag has started, it has taken over the active touch
1267 // such a way that the current MotionEvent stream is suddenly shifted in 1274 // sequence. Immediately cancel gesture detection and any downstream touch
1268 // space. Avoid the associated scroll jump by pre-emptively cancelling gesture 1275 // listeners (e.g., web content) to communicate this transfer.
1269 // detection; scrolling after the selection is activated is unnecessary. 1276 if (event == ui::SELECTION_DRAG_STARTED)
1270 if (event == ui::SelectionEventType::SELECTION_SHOWN)
1271 ResetGestureDetection(); 1277 ResetGestureDetection();
1278
1272 content_view_core_->OnSelectionEvent( 1279 content_view_core_->OnSelectionEvent(
1273 event, selection_controller_->GetStartPosition(), 1280 event, selection_controller_->GetStartPosition(),
1274 GetSelectionRect(*selection_controller_)); 1281 GetSelectionRect(*selection_controller_));
1275 } 1282 }
1276 1283
1277 scoped_ptr<ui::TouchHandleDrawable> 1284 scoped_ptr<ui::TouchHandleDrawable>
1278 RenderWidgetHostViewAndroid::CreateDrawable() { 1285 RenderWidgetHostViewAndroid::CreateDrawable() {
1279 DCHECK(content_view_core_); 1286 DCHECK(content_view_core_);
1280 if (!using_browser_compositor_) 1287 if (!using_browser_compositor_)
1281 return content_view_core_->CreatePopupTouchHandleDrawable(); 1288 return content_view_core_->CreatePopupTouchHandleDrawable();
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 if (overscroll_controller_) 1583 if (overscroll_controller_)
1577 overscroll_controller_->OnGestureEventAck(event, ack_result); 1584 overscroll_controller_->OnGestureEventAck(event, ack_result);
1578 1585
1579 if (content_view_core_) 1586 if (content_view_core_)
1580 content_view_core_->OnGestureEventAck(event, ack_result); 1587 content_view_core_->OnGestureEventAck(event, ack_result);
1581 } 1588 }
1582 1589
1583 InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent( 1590 InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent(
1584 const blink::WebInputEvent& input_event) { 1591 const blink::WebInputEvent& input_event) {
1585 if (selection_controller_) { 1592 if (selection_controller_) {
1586 switch (input_event.type) { 1593 if (input_event.type == blink::WebInputEvent::GestureLongPress) {
1587 case blink::WebInputEvent::GestureLongPress: 1594 const blink::WebGestureEvent& longpress =
1588 selection_controller_->OnLongPressEvent(); 1595 static_cast<const blink::WebGestureEvent&>(input_event);
1589 break; 1596 selection_controller_->OnLongPressEvent(
1590 case blink::WebInputEvent::GestureTap: 1597 base::TimeTicks() +
1591 selection_controller_->OnTapEvent(); 1598 base::TimeDelta::FromSecondsD(input_event.timeStampSeconds),
1592 break; 1599 gfx::PointF(longpress.x, longpress.y));
1593 default: 1600 } else if (input_event.type == blink::WebInputEvent::GestureTap) {
1594 break; 1601 selection_controller_->OnTapEvent();
1595 } 1602 }
1596 } 1603 }
1597 1604
1598 if (overscroll_controller_ && 1605 if (overscroll_controller_ &&
1599 blink::WebInputEvent::isGestureEventType(input_event.type) && 1606 blink::WebInputEvent::isGestureEventType(input_event.type) &&
1600 overscroll_controller_->WillHandleGestureEvent( 1607 overscroll_controller_->WillHandleGestureEvent(
1601 static_cast<const blink::WebGestureEvent&>(input_event))) { 1608 static_cast<const blink::WebGestureEvent&>(input_event))) {
1602 return INPUT_EVENT_ACK_STATE_CONSUMED; 1609 return INPUT_EVENT_ACK_STATE_CONSUMED;
1603 } 1610 }
1604 1611
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 results->orientationAngle = display.RotationAsDegree(); 2022 results->orientationAngle = display.RotationAsDegree();
2016 results->orientationType = 2023 results->orientationType =
2017 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); 2024 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
2018 gfx::DeviceDisplayInfo info; 2025 gfx::DeviceDisplayInfo info;
2019 results->depth = info.GetBitsPerPixel(); 2026 results->depth = info.GetBitsPerPixel();
2020 results->depthPerComponent = info.GetBitsPerComponent(); 2027 results->depthPerComponent = info.GetBitsPerComponent();
2021 results->isMonochrome = (results->depthPerComponent == 0); 2028 results->isMonochrome = (results->depthPerComponent == 0);
2022 } 2029 }
2023 2030
2024 } // namespace content 2031 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | ui/events/test/motion_event_test_utils.h » ('j') | ui/touch_selection/longpress_drag_selector_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698