| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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_SHOWN) |
| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 blink::WebInputEvent::isGestureEventType(input_event.type)) { | 1593 blink::WebInputEvent::isGestureEventType(input_event.type)) { |
| 1587 const blink::WebGestureEvent& gesture_event = | 1594 const blink::WebGestureEvent& gesture_event = |
| 1588 static_cast<const blink::WebGestureEvent&>(input_event); | 1595 static_cast<const blink::WebGestureEvent&>(input_event); |
| 1589 gfx::PointF gesture_location(gesture_event.x, gesture_event.y); | 1596 switch (gesture_event.type) { |
| 1590 if (input_event.type == blink::WebInputEvent::GestureLongPress) { | 1597 case blink::WebInputEvent::GestureLongPress: |
| 1591 if (selection_controller_->WillHandleLongPressEvent(gesture_location)) | 1598 if (selection_controller_->WillHandleLongPressEvent( |
| 1592 return INPUT_EVENT_ACK_STATE_CONSUMED; | 1599 base::TimeTicks() + |
| 1593 } else if (input_event.type == blink::WebInputEvent::GestureTap) { | 1600 base::TimeDelta::FromSecondsD(input_event.timeStampSeconds), |
| 1594 if (selection_controller_->WillHandleTapEvent(gesture_location)) | 1601 gfx::PointF(gesture_event.x, gesture_event.y))) { |
| 1595 return INPUT_EVENT_ACK_STATE_CONSUMED; | 1602 return INPUT_EVENT_ACK_STATE_CONSUMED; |
| 1603 } |
| 1604 break; |
| 1605 |
| 1606 case blink::WebInputEvent::GestureTap: |
| 1607 if (selection_controller_->WillHandleTapEvent( |
| 1608 gfx::PointF(gesture_event.x, gesture_event.y))) { |
| 1609 return INPUT_EVENT_ACK_STATE_CONSUMED; |
| 1610 } |
| 1611 break; |
| 1612 |
| 1613 default: |
| 1614 break; |
| 1596 } | 1615 } |
| 1597 } | 1616 } |
| 1598 | 1617 |
| 1599 if (overscroll_controller_ && | 1618 if (overscroll_controller_ && |
| 1600 blink::WebInputEvent::isGestureEventType(input_event.type) && | 1619 blink::WebInputEvent::isGestureEventType(input_event.type) && |
| 1601 overscroll_controller_->WillHandleGestureEvent( | 1620 overscroll_controller_->WillHandleGestureEvent( |
| 1602 static_cast<const blink::WebGestureEvent&>(input_event))) { | 1621 static_cast<const blink::WebGestureEvent&>(input_event))) { |
| 1603 return INPUT_EVENT_ACK_STATE_CONSUMED; | 1622 return INPUT_EVENT_ACK_STATE_CONSUMED; |
| 1604 } | 1623 } |
| 1605 | 1624 |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 results->orientationAngle = display.RotationAsDegree(); | 2035 results->orientationAngle = display.RotationAsDegree(); |
| 2017 results->orientationType = | 2036 results->orientationType = |
| 2018 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 2037 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
| 2019 gfx::DeviceDisplayInfo info; | 2038 gfx::DeviceDisplayInfo info; |
| 2020 results->depth = info.GetBitsPerPixel(); | 2039 results->depth = info.GetBitsPerPixel(); |
| 2021 results->depthPerComponent = info.GetBitsPerComponent(); | 2040 results->depthPerComponent = info.GetBitsPerComponent(); |
| 2022 results->isMonochrome = (results->depthPerComponent == 0); | 2041 results->isMonochrome = (results->depthPerComponent == 0); |
| 2023 } | 2042 } |
| 2024 | 2043 |
| 2025 } // namespace content | 2044 } // namespace content |
| OLD | NEW |