| 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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 | 689 |
| 690 bool RenderWidgetHostViewAndroid::OnTouchEvent( | 690 bool RenderWidgetHostViewAndroid::OnTouchEvent( |
| 691 const ui::MotionEvent& event) { | 691 const ui::MotionEvent& event) { |
| 692 if (!host_) | 692 if (!host_) |
| 693 return false; | 693 return false; |
| 694 | 694 |
| 695 if (selection_controller_ && | 695 if (selection_controller_ && |
| 696 selection_controller_->WillHandleTouchEvent(event)) | 696 selection_controller_->WillHandleTouchEvent(event)) |
| 697 return true; | 697 return true; |
| 698 | 698 |
| 699 if (gesture_text_selector_.OnTouchEvent(event)) |
| 700 return true; |
| 701 |
| 699 if (!gesture_provider_.OnTouchEvent(event)) | 702 if (!gesture_provider_.OnTouchEvent(event)) |
| 700 return false; | 703 return false; |
| 701 | 704 |
| 702 if (gesture_text_selector_.OnTouchEvent(event)) { | |
| 703 gesture_provider_.OnTouchEventAck(false); | |
| 704 return true; | |
| 705 } | |
| 706 | |
| 707 if (host_->ShouldForwardTouchEvent()) { | 705 if (host_->ShouldForwardTouchEvent()) { |
| 708 blink::WebTouchEvent web_event = CreateWebTouchEventFromMotionEvent(event); | 706 blink::WebTouchEvent web_event = CreateWebTouchEventFromMotionEvent(event); |
| 709 host_->ForwardTouchEventWithLatencyInfo(web_event, | 707 host_->ForwardTouchEventWithLatencyInfo(web_event, |
| 710 CreateLatencyInfo(web_event)); | 708 CreateLatencyInfo(web_event)); |
| 711 } else { | 709 } else { |
| 712 const bool event_consumed = false; | 710 const bool event_consumed = false; |
| 713 gesture_provider_.OnTouchEventAck(event_consumed); | 711 gesture_provider_.OnTouchEventAck(event_consumed); |
| 714 } | 712 } |
| 715 | 713 |
| 716 // Send a proactive BeginFrame on the next vsync to reduce latency. | 714 // Send a proactive BeginFrame on the next vsync to reduce latency. |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 | 1587 |
| 1590 void RenderWidgetHostViewAndroid::RunAckCallbacks() { | 1588 void RenderWidgetHostViewAndroid::RunAckCallbacks() { |
| 1591 while (!ack_callbacks_.empty()) { | 1589 while (!ack_callbacks_.empty()) { |
| 1592 ack_callbacks_.front().Run(); | 1590 ack_callbacks_.front().Run(); |
| 1593 ack_callbacks_.pop(); | 1591 ack_callbacks_.pop(); |
| 1594 } | 1592 } |
| 1595 } | 1593 } |
| 1596 | 1594 |
| 1597 void RenderWidgetHostViewAndroid::OnGestureEvent( | 1595 void RenderWidgetHostViewAndroid::OnGestureEvent( |
| 1598 const ui::GestureEventData& gesture) { | 1596 const ui::GestureEventData& gesture) { |
| 1599 if (gesture_text_selector_.OnGestureEvent(gesture)) | |
| 1600 return; | |
| 1601 | |
| 1602 SendGestureEvent(CreateWebGestureEventFromGestureEventData(gesture)); | 1597 SendGestureEvent(CreateWebGestureEventFromGestureEventData(gesture)); |
| 1603 } | 1598 } |
| 1604 | 1599 |
| 1605 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { | 1600 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { |
| 1606 RunAckCallbacks(); | 1601 RunAckCallbacks(); |
| 1607 } | 1602 } |
| 1608 | 1603 |
| 1609 | |
| 1610 void RenderWidgetHostViewAndroid::OnAttachCompositor() { | 1604 void RenderWidgetHostViewAndroid::OnAttachCompositor() { |
| 1611 DCHECK(content_view_core_); | 1605 DCHECK(content_view_core_); |
| 1612 if (overscroll_effect_enabled_ && !overscroll_effect_) | 1606 if (overscroll_effect_enabled_ && !overscroll_effect_) |
| 1613 overscroll_effect_ = CreateOverscrollEffect(content_view_core_); | 1607 overscroll_effect_ = CreateOverscrollEffect(content_view_core_); |
| 1614 } | 1608 } |
| 1615 | 1609 |
| 1616 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1610 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
| 1617 DCHECK(content_view_core_); | 1611 DCHECK(content_view_core_); |
| 1618 DCHECK(!using_synchronous_compositor_); | 1612 DCHECK(!using_synchronous_compositor_); |
| 1619 RunAckCallbacks(); | 1613 RunAckCallbacks(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1755 selection_controller_->OnLongPressEvent(); | 1749 selection_controller_->OnLongPressEvent(); |
| 1756 } | 1750 } |
| 1757 | 1751 |
| 1758 void RenderWidgetHostViewAndroid::SelectRange( | 1752 void RenderWidgetHostViewAndroid::SelectRange( |
| 1759 float x1, float y1, float x2, float y2) { | 1753 float x1, float y1, float x2, float y2) { |
| 1760 if (content_view_core_) | 1754 if (content_view_core_) |
| 1761 static_cast<WebContentsImpl*>(content_view_core_->GetWebContents())-> | 1755 static_cast<WebContentsImpl*>(content_view_core_->GetWebContents())-> |
| 1762 SelectRange(gfx::Point(x1, y1), gfx::Point(x2, y2)); | 1756 SelectRange(gfx::Point(x1, y1), gfx::Point(x2, y2)); |
| 1763 } | 1757 } |
| 1764 | 1758 |
| 1765 void RenderWidgetHostViewAndroid::Unselect() { | |
| 1766 if (content_view_core_) | |
| 1767 content_view_core_->GetWebContents()->Unselect(); | |
| 1768 } | |
| 1769 | |
| 1770 void RenderWidgetHostViewAndroid::LongPress( | 1759 void RenderWidgetHostViewAndroid::LongPress( |
| 1771 base::TimeTicks time, float x, float y) { | 1760 base::TimeTicks time, float x, float y) { |
| 1772 blink::WebGestureEvent long_press = WebGestureEventBuilder::Build( | 1761 blink::WebGestureEvent long_press = WebGestureEventBuilder::Build( |
| 1773 blink::WebInputEvent::GestureLongPress, | 1762 blink::WebInputEvent::GestureLongPress, |
| 1774 (time - base::TimeTicks()).InSecondsF(), x, y); | 1763 (time - base::TimeTicks()).InSecondsF(), x, y); |
| 1775 SendGestureEvent(long_press); | 1764 SendGestureEvent(long_press); |
| 1776 } | 1765 } |
| 1777 | 1766 |
| 1778 // static | 1767 // static |
| 1779 void RenderWidgetHostViewBase::GetDefaultScreenInfo( | 1768 void RenderWidgetHostViewBase::GetDefaultScreenInfo( |
| 1780 blink::WebScreenInfo* results) { | 1769 blink::WebScreenInfo* results) { |
| 1781 const gfx::Display& display = | 1770 const gfx::Display& display = |
| 1782 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 1771 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| 1783 results->rect = display.bounds(); | 1772 results->rect = display.bounds(); |
| 1784 // TODO(husky): Remove any system controls from availableRect. | 1773 // TODO(husky): Remove any system controls from availableRect. |
| 1785 results->availableRect = display.work_area(); | 1774 results->availableRect = display.work_area(); |
| 1786 results->deviceScaleFactor = display.device_scale_factor(); | 1775 results->deviceScaleFactor = display.device_scale_factor(); |
| 1787 results->orientationAngle = display.RotationAsDegree(); | 1776 results->orientationAngle = display.RotationAsDegree(); |
| 1788 results->orientationType = | 1777 results->orientationType = |
| 1789 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 1778 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
| 1790 gfx::DeviceDisplayInfo info; | 1779 gfx::DeviceDisplayInfo info; |
| 1791 results->depth = info.GetBitsPerPixel(); | 1780 results->depth = info.GetBitsPerPixel(); |
| 1792 results->depthPerComponent = info.GetBitsPerComponent(); | 1781 results->depthPerComponent = info.GetBitsPerComponent(); |
| 1793 results->isMonochrome = (results->depthPerComponent == 0); | 1782 results->isMonochrome = (results->depthPerComponent == 0); |
| 1794 } | 1783 } |
| 1795 | 1784 |
| 1796 } // namespace content | 1785 } // namespace content |
| OLD | NEW |