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