| 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 <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1317 bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata); | 1317 bool is_mobile_optimized = IsMobileOptimizedFrame(frame_metadata); |
| 1318 gesture_provider_.SetDoubleTapSupportForPageEnabled(!is_mobile_optimized); | 1318 gesture_provider_.SetDoubleTapSupportForPageEnabled(!is_mobile_optimized); |
| 1319 | 1319 |
| 1320 if (!content_view_core_) | 1320 if (!content_view_core_) |
| 1321 return; | 1321 return; |
| 1322 | 1322 |
| 1323 if (overscroll_controller_) | 1323 if (overscroll_controller_) |
| 1324 overscroll_controller_->OnFrameMetadataUpdated(frame_metadata); | 1324 overscroll_controller_->OnFrameMetadataUpdated(frame_metadata); |
| 1325 | 1325 |
| 1326 if (selection_controller_) { | 1326 if (selection_controller_) { |
| 1327 selection_controller_->OnSelectionEditable( | |
| 1328 frame_metadata.selection.is_editable); | |
| 1329 selection_controller_->OnSelectionEmpty( | |
| 1330 frame_metadata.selection.is_empty_text_form_control); | |
| 1331 selection_controller_->OnSelectionBoundsChanged( | 1327 selection_controller_->OnSelectionBoundsChanged( |
| 1332 frame_metadata.selection.start, frame_metadata.selection.end); | 1328 frame_metadata.selection.start, frame_metadata.selection.end); |
| 1333 | 1329 |
| 1334 // Set parameters for adaptive handle orientation. | 1330 // Set parameters for adaptive handle orientation. |
| 1335 gfx::SizeF viewport_size(frame_metadata.scrollable_viewport_size); | 1331 gfx::SizeF viewport_size(frame_metadata.scrollable_viewport_size); |
| 1336 viewport_size.Scale(frame_metadata.page_scale_factor); | 1332 viewport_size.Scale(frame_metadata.page_scale_factor); |
| 1337 gfx::RectF viewport_rect(0.0f, frame_metadata.top_controls_height * | 1333 gfx::RectF viewport_rect(0.0f, frame_metadata.top_controls_height * |
| 1338 frame_metadata.top_controls_shown_ratio, | 1334 frame_metadata.top_controls_shown_ratio, |
| 1339 viewport_size.width(), viewport_size.height()); | 1335 viewport_size.width(), viewport_size.height()); |
| 1340 selection_controller_->OnViewportChanged(viewport_rect); | 1336 selection_controller_->OnViewportChanged(viewport_rect); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 } | 1553 } |
| 1558 | 1554 |
| 1559 InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent( | 1555 InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent( |
| 1560 const blink::WebInputEvent& input_event) { | 1556 const blink::WebInputEvent& input_event) { |
| 1561 if (selection_controller_ && | 1557 if (selection_controller_ && |
| 1562 blink::WebInputEvent::isGestureEventType(input_event.type)) { | 1558 blink::WebInputEvent::isGestureEventType(input_event.type)) { |
| 1563 const blink::WebGestureEvent& gesture_event = | 1559 const blink::WebGestureEvent& gesture_event = |
| 1564 static_cast<const blink::WebGestureEvent&>(input_event); | 1560 static_cast<const blink::WebGestureEvent&>(input_event); |
| 1565 switch (gesture_event.type) { | 1561 switch (gesture_event.type) { |
| 1566 case blink::WebInputEvent::GestureLongPress: | 1562 case blink::WebInputEvent::GestureLongPress: |
| 1567 if (selection_controller_->WillHandleLongPressEvent( | 1563 selection_controller_->WillHandleLongPressEvent( |
| 1568 base::TimeTicks() + | 1564 base::TimeTicks() + |
| 1569 base::TimeDelta::FromSecondsD(input_event.timeStampSeconds), | 1565 base::TimeDelta::FromSecondsD(input_event.timeStampSeconds), |
| 1570 gfx::PointF(gesture_event.x, gesture_event.y))) { | 1566 gfx::PointF(gesture_event.x, gesture_event.y)); |
| 1571 return INPUT_EVENT_ACK_STATE_CONSUMED; | |
| 1572 } | |
| 1573 break; | 1567 break; |
| 1574 | 1568 |
| 1575 case blink::WebInputEvent::GestureTap: | 1569 case blink::WebInputEvent::GestureTap: |
| 1576 if (selection_controller_->WillHandleTapEvent( | 1570 selection_controller_->WillHandleTapEvent( |
| 1577 gfx::PointF(gesture_event.x, gesture_event.y), | 1571 gfx::PointF(gesture_event.x, gesture_event.y), |
| 1578 gesture_event.data.tap.tapCount)) { | 1572 gesture_event.data.tap.tapCount); |
| 1579 return INPUT_EVENT_ACK_STATE_CONSUMED; | |
| 1580 } | |
| 1581 break; | 1573 break; |
| 1582 | 1574 |
| 1583 case blink::WebInputEvent::GestureScrollBegin: | 1575 case blink::WebInputEvent::GestureScrollBegin: |
| 1584 selection_controller_->OnScrollBeginEvent(); | 1576 selection_controller_->OnScrollBeginEvent(); |
| 1585 break; | 1577 break; |
| 1586 | 1578 |
| 1587 default: | 1579 default: |
| 1588 break; | 1580 break; |
| 1589 } | 1581 } |
| 1590 } | 1582 } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1709 | 1701 |
| 1710 // As the paste popup may be triggered *before* the bounds and editability | 1702 // As the paste popup may be triggered *before* the bounds and editability |
| 1711 // of the region have been updated, explicitly set the properties now. | 1703 // of the region have been updated, explicitly set the properties now. |
| 1712 // TODO(jdduke): Remove this workaround when auxiliary paste popup | 1704 // TODO(jdduke): Remove this workaround when auxiliary paste popup |
| 1713 // notifications are no longer required, crbug.com/398170. | 1705 // notifications are no longer required, crbug.com/398170. |
| 1714 gfx::SelectionBound insertion_bound; | 1706 gfx::SelectionBound insertion_bound; |
| 1715 insertion_bound.set_type(gfx::SelectionBound::CENTER); | 1707 insertion_bound.set_type(gfx::SelectionBound::CENTER); |
| 1716 insertion_bound.set_visible(true); | 1708 insertion_bound.set_visible(true); |
| 1717 insertion_bound.SetEdge(point, point); | 1709 insertion_bound.SetEdge(point, point); |
| 1718 selection_controller_->HideAndDisallowShowingAutomatically(); | 1710 selection_controller_->HideAndDisallowShowingAutomatically(); |
| 1719 selection_controller_->OnSelectionEditable(true); | |
| 1720 selection_controller_->OnSelectionEmpty(true); | |
| 1721 selection_controller_->OnSelectionBoundsChanged(insertion_bound, | 1711 selection_controller_->OnSelectionBoundsChanged(insertion_bound, |
| 1722 insertion_bound); | 1712 insertion_bound); |
| 1723 selection_controller_->AllowShowingFromCurrentSelection(); | |
| 1724 } | 1713 } |
| 1725 | 1714 |
| 1726 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { | 1715 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { |
| 1727 return cached_background_color_; | 1716 return cached_background_color_; |
| 1728 } | 1717 } |
| 1729 | 1718 |
| 1730 void RenderWidgetHostViewAndroid::DidOverscroll( | 1719 void RenderWidgetHostViewAndroid::DidOverscroll( |
| 1731 const ui::DidOverscrollParams& params) { | 1720 const ui::DidOverscrollParams& params) { |
| 1732 if (sync_compositor_) | 1721 if (sync_compositor_) |
| 1733 sync_compositor_->DidOverscroll(params); | 1722 sync_compositor_->DidOverscroll(params); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 float y0, | 1939 float y0, |
| 1951 float x1, | 1940 float x1, |
| 1952 float y1) { | 1941 float y1) { |
| 1953 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1)); | 1942 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1)); |
| 1954 } | 1943 } |
| 1955 | 1944 |
| 1956 void RenderWidgetHostViewAndroid::OnStylusSelectUpdate(float x, float y) { | 1945 void RenderWidgetHostViewAndroid::OnStylusSelectUpdate(float x, float y) { |
| 1957 MoveRangeSelectionExtent(gfx::PointF(x, y)); | 1946 MoveRangeSelectionExtent(gfx::PointF(x, y)); |
| 1958 } | 1947 } |
| 1959 | 1948 |
| 1960 void RenderWidgetHostViewAndroid::OnStylusSelectEnd() { | |
| 1961 if (selection_controller_) | |
| 1962 selection_controller_->AllowShowingFromCurrentSelection(); | |
| 1963 } | |
| 1964 | |
| 1965 void RenderWidgetHostViewAndroid::OnStylusSelectTap(base::TimeTicks time, | 1949 void RenderWidgetHostViewAndroid::OnStylusSelectTap(base::TimeTicks time, |
| 1966 float x, | 1950 float x, |
| 1967 float y) { | 1951 float y) { |
| 1968 // Treat the stylus tap as a long press, activating either a word selection or | 1952 // Treat the stylus tap as a long press, activating either a word selection or |
| 1969 // context menu depending on the targetted content. | 1953 // context menu depending on the targetted content. |
| 1970 blink::WebGestureEvent long_press = WebGestureEventBuilder::Build( | 1954 blink::WebGestureEvent long_press = WebGestureEventBuilder::Build( |
| 1971 blink::WebInputEvent::GestureLongPress, | 1955 blink::WebInputEvent::GestureLongPress, |
| 1972 (time - base::TimeTicks()).InSecondsF(), x, y); | 1956 (time - base::TimeTicks()).InSecondsF(), x, y); |
| 1973 SendGestureEvent(long_press); | 1957 SendGestureEvent(long_press); |
| 1974 } | 1958 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1990 case ui::MotionEvent::ACTION_UP: | 1974 case ui::MotionEvent::ACTION_UP: |
| 1991 case ui::MotionEvent::ACTION_POINTER_UP: | 1975 case ui::MotionEvent::ACTION_POINTER_UP: |
| 1992 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 1976 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
| 1993 delta.InMicroseconds(), 1, 1000000, 50); | 1977 delta.InMicroseconds(), 1, 1000000, 50); |
| 1994 default: | 1978 default: |
| 1995 return; | 1979 return; |
| 1996 } | 1980 } |
| 1997 } | 1981 } |
| 1998 | 1982 |
| 1999 } // namespace content | 1983 } // namespace content |
| OLD | NEW |