| 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_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1930 DismissOwnedPopups, | 1930 DismissOwnedPopups, |
| 1931 reinterpret_cast<LPARAM>(toplevel_hwnd)); | 1931 reinterpret_cast<LPARAM>(toplevel_hwnd)); |
| 1932 } | 1932 } |
| 1933 #endif | 1933 #endif |
| 1934 blink::WebMouseWheelEvent mouse_wheel_event = | 1934 blink::WebMouseWheelEvent mouse_wheel_event = |
| 1935 ui::MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event), | 1935 ui::MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event), |
| 1936 base::Bind(&GetScreenLocationFromEvent)); | 1936 base::Bind(&GetScreenLocationFromEvent)); |
| 1937 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { | 1937 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { |
| 1938 if (ShouldRouteEvent(event)) { | 1938 if (ShouldRouteEvent(event)) { |
| 1939 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( | 1939 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( |
| 1940 this, &mouse_wheel_event); | 1940 this, &mouse_wheel_event, *event->latency()); |
| 1941 } else { | 1941 } else { |
| 1942 ProcessMouseWheelEvent(mouse_wheel_event, *event->latency()); | 1942 ProcessMouseWheelEvent(mouse_wheel_event, *event->latency()); |
| 1943 } | 1943 } |
| 1944 } | 1944 } |
| 1945 } else { | 1945 } else { |
| 1946 bool is_selection_popup = | 1946 bool is_selection_popup = |
| 1947 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); | 1947 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); |
| 1948 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && | 1948 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && |
| 1949 !(event->flags() & ui::EF_FROM_TOUCH)) { | 1949 !(event->flags() & ui::EF_FROM_TOUCH)) { |
| 1950 // Confirm existing composition text on mouse press, to make sure | 1950 // Confirm existing composition text on mouse press, to make sure |
| 1951 // the input caret won't be moved with an ongoing composition text. | 1951 // the input caret won't be moved with an ongoing composition text. |
| 1952 if (event->type() == ui::ET_MOUSE_PRESSED) | 1952 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 1953 FinishImeCompositionSession(); | 1953 FinishImeCompositionSession(); |
| 1954 | 1954 |
| 1955 blink::WebMouseEvent mouse_event = ui::MakeWebMouseEvent( | 1955 blink::WebMouseEvent mouse_event = ui::MakeWebMouseEvent( |
| 1956 *event, base::Bind(&GetScreenLocationFromEvent)); | 1956 *event, base::Bind(&GetScreenLocationFromEvent)); |
| 1957 ModifyEventMovementAndCoords(&mouse_event); | 1957 ModifyEventMovementAndCoords(&mouse_event); |
| 1958 if (ShouldRouteEvent(event)) { | 1958 if (ShouldRouteEvent(event)) { |
| 1959 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this, | 1959 host_->delegate()->GetInputEventRouter()->RouteMouseEvent( |
| 1960 &mouse_event); | 1960 this, &mouse_event, *event->latency()); |
| 1961 } else { | 1961 } else { |
| 1962 ProcessMouseEvent(mouse_event, *event->latency()); | 1962 ProcessMouseEvent(mouse_event, *event->latency()); |
| 1963 } | 1963 } |
| 1964 | 1964 |
| 1965 // Ensure that we get keyboard focus on mouse down as a plugin window may | 1965 // Ensure that we get keyboard focus on mouse down as a plugin window may |
| 1966 // have grabbed keyboard focus. | 1966 // have grabbed keyboard focus. |
| 1967 if (event->type() == ui::ET_MOUSE_PRESSED) | 1967 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 1968 SetKeyboardFocus(); | 1968 SetKeyboardFocus(); |
| 1969 } | 1969 } |
| 1970 } | 1970 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2082 blink::WebGestureEvent gesture_event = ui::MakeWebGestureEventFlingCancel(); | 2082 blink::WebGestureEvent gesture_event = ui::MakeWebGestureEventFlingCancel(); |
| 2083 // Coordinates need to be transferred to the fling cancel gesture only | 2083 // Coordinates need to be transferred to the fling cancel gesture only |
| 2084 // for Surface-targeting to ensure that it is targeted to the correct | 2084 // for Surface-targeting to ensure that it is targeted to the correct |
| 2085 // RenderWidgetHost. | 2085 // RenderWidgetHost. |
| 2086 gesture_event.x = event->x(); | 2086 gesture_event.x = event->x(); |
| 2087 gesture_event.y = event->y(); | 2087 gesture_event.y = event->y(); |
| 2088 blink::WebMouseWheelEvent mouse_wheel_event = ui::MakeWebMouseWheelEvent( | 2088 blink::WebMouseWheelEvent mouse_wheel_event = ui::MakeWebMouseWheelEvent( |
| 2089 *event, base::Bind(&GetScreenLocationFromEvent)); | 2089 *event, base::Bind(&GetScreenLocationFromEvent)); |
| 2090 if (ShouldRouteEvent(event)) { | 2090 if (ShouldRouteEvent(event)) { |
| 2091 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( | 2091 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( |
| 2092 this, &gesture_event, ui::LatencyInfo()); | 2092 this, &gesture_event, ui::LatencyInfo(ui::SourceEventType::WHEEL)); |
| 2093 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( | 2093 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( |
| 2094 this, &mouse_wheel_event); | 2094 this, &mouse_wheel_event, *event->latency()); |
| 2095 } else { | 2095 } else { |
| 2096 host_->ForwardGestureEvent(gesture_event); | 2096 host_->ForwardGestureEvent(gesture_event); |
| 2097 host_->ForwardWheelEventWithLatencyInfo(mouse_wheel_event, | 2097 host_->ForwardWheelEventWithLatencyInfo(mouse_wheel_event, |
| 2098 *event->latency()); | 2098 *event->latency()); |
| 2099 } | 2099 } |
| 2100 RecordAction(base::UserMetricsAction("TrackpadScroll")); | 2100 RecordAction(base::UserMetricsAction("TrackpadScroll")); |
| 2101 } else if (event->type() == ui::ET_SCROLL_FLING_START || | 2101 } else if (event->type() == ui::ET_SCROLL_FLING_START || |
| 2102 event->type() == ui::ET_SCROLL_FLING_CANCEL) { | 2102 event->type() == ui::ET_SCROLL_FLING_CANCEL) { |
| 2103 blink::WebGestureEvent gesture_event = ui::MakeWebGestureEvent( | 2103 blink::WebGestureEvent gesture_event = ui::MakeWebGestureEvent( |
| 2104 *event, base::Bind(&GetScreenLocationFromEvent)); | 2104 *event, base::Bind(&GetScreenLocationFromEvent)); |
| 2105 if (ShouldRouteEvent(event)) { | 2105 if (ShouldRouteEvent(event)) { |
| 2106 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( | 2106 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( |
| 2107 this, &gesture_event, ui::LatencyInfo()); | 2107 this, &gesture_event, ui::LatencyInfo(ui::SourceEventType::WHEEL)); |
| 2108 } else { | 2108 } else { |
| 2109 host_->ForwardGestureEvent(gesture_event); | 2109 host_->ForwardGestureEvent(gesture_event); |
| 2110 } | 2110 } |
| 2111 if (event->type() == ui::ET_SCROLL_FLING_START) | 2111 if (event->type() == ui::ET_SCROLL_FLING_START) |
| 2112 RecordAction(base::UserMetricsAction("TrackpadScrollFling")); | 2112 RecordAction(base::UserMetricsAction("TrackpadScrollFling")); |
| 2113 } | 2113 } |
| 2114 | 2114 |
| 2115 event->SetHandled(); | 2115 event->SetHandled(); |
| 2116 } | 2116 } |
| 2117 | 2117 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2183 blink::WebGestureEvent gesture = | 2183 blink::WebGestureEvent gesture = |
| 2184 ui::MakeWebGestureEvent(*event, base::Bind(&GetScreenLocationFromEvent)); | 2184 ui::MakeWebGestureEvent(*event, base::Bind(&GetScreenLocationFromEvent)); |
| 2185 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 2185 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
| 2186 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an | 2186 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an |
| 2187 // event to stop any in-progress flings. | 2187 // event to stop any in-progress flings. |
| 2188 blink::WebGestureEvent fling_cancel = gesture; | 2188 blink::WebGestureEvent fling_cancel = gesture; |
| 2189 fling_cancel.type = blink::WebInputEvent::GestureFlingCancel; | 2189 fling_cancel.type = blink::WebInputEvent::GestureFlingCancel; |
| 2190 fling_cancel.sourceDevice = blink::WebGestureDeviceTouchscreen; | 2190 fling_cancel.sourceDevice = blink::WebGestureDeviceTouchscreen; |
| 2191 if (ShouldRouteEvent(event)) { | 2191 if (ShouldRouteEvent(event)) { |
| 2192 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( | 2192 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( |
| 2193 this, &fling_cancel, ui::LatencyInfo()); | 2193 this, &fling_cancel, ui::LatencyInfo(ui::SourceEventType::TOUCH)); |
| 2194 } else { | 2194 } else { |
| 2195 host_->ForwardGestureEvent(fling_cancel); | 2195 host_->ForwardGestureEvent(fling_cancel); |
| 2196 } | 2196 } |
| 2197 } | 2197 } |
| 2198 | 2198 |
| 2199 if (gesture.type != blink::WebInputEvent::Undefined) { | 2199 if (gesture.type != blink::WebInputEvent::Undefined) { |
| 2200 if (ShouldRouteEvent(event)) { | 2200 if (ShouldRouteEvent(event)) { |
| 2201 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( | 2201 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( |
| 2202 this, &gesture, *event->latency()); | 2202 this, &gesture, *event->latency()); |
| 2203 } else { | 2203 } else { |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3040 ->GetTextSelection(focused_view) | 3040 ->GetTextSelection(focused_view) |
| 3041 ->GetSelectedText(&selected_text)) { | 3041 ->GetSelectedText(&selected_text)) { |
| 3042 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. | 3042 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. |
| 3043 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); | 3043 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); |
| 3044 clipboard_writer.WriteText(selected_text); | 3044 clipboard_writer.WriteText(selected_text); |
| 3045 } | 3045 } |
| 3046 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) | 3046 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) |
| 3047 } | 3047 } |
| 3048 | 3048 |
| 3049 } // namespace content | 3049 } // namespace content |
| OLD | NEW |