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 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 DismissOwnedPopups, | 1952 DismissOwnedPopups, |
1953 reinterpret_cast<LPARAM>(toplevel_hwnd)); | 1953 reinterpret_cast<LPARAM>(toplevel_hwnd)); |
1954 } | 1954 } |
1955 #endif | 1955 #endif |
1956 blink::WebMouseWheelEvent mouse_wheel_event = | 1956 blink::WebMouseWheelEvent mouse_wheel_event = |
1957 ui::MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event), | 1957 ui::MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event), |
1958 base::Bind(&GetScreenLocationFromEvent)); | 1958 base::Bind(&GetScreenLocationFromEvent)); |
1959 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { | 1959 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { |
1960 if (ShouldRouteEvent(event)) { | 1960 if (ShouldRouteEvent(event)) { |
1961 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( | 1961 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( |
1962 this, &mouse_wheel_event); | 1962 this, &mouse_wheel_event, *event->latency()); |
1963 } else { | 1963 } else { |
1964 ProcessMouseWheelEvent(mouse_wheel_event, *event->latency()); | 1964 ProcessMouseWheelEvent(mouse_wheel_event, *event->latency()); |
1965 } | 1965 } |
1966 } | 1966 } |
1967 } else { | 1967 } else { |
1968 bool is_selection_popup = | 1968 bool is_selection_popup = |
1969 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); | 1969 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); |
1970 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && | 1970 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && |
1971 !(event->flags() & ui::EF_FROM_TOUCH)) { | 1971 !(event->flags() & ui::EF_FROM_TOUCH)) { |
1972 // Confirm existing composition text on mouse press, to make sure | 1972 // Confirm existing composition text on mouse press, to make sure |
1973 // the input caret won't be moved with an ongoing composition text. | 1973 // the input caret won't be moved with an ongoing composition text. |
1974 if (event->type() == ui::ET_MOUSE_PRESSED) | 1974 if (event->type() == ui::ET_MOUSE_PRESSED) |
1975 FinishImeCompositionSession(); | 1975 FinishImeCompositionSession(); |
1976 | 1976 |
1977 blink::WebMouseEvent mouse_event = ui::MakeWebMouseEvent( | 1977 blink::WebMouseEvent mouse_event = ui::MakeWebMouseEvent( |
1978 *event, base::Bind(&GetScreenLocationFromEvent)); | 1978 *event, base::Bind(&GetScreenLocationFromEvent)); |
1979 ModifyEventMovementAndCoords(&mouse_event); | 1979 ModifyEventMovementAndCoords(&mouse_event); |
1980 if (ShouldRouteEvent(event)) { | 1980 if (ShouldRouteEvent(event)) { |
1981 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this, | 1981 host_->delegate()->GetInputEventRouter()->RouteMouseEvent( |
1982 &mouse_event); | 1982 this, &mouse_event, *event->latency()); |
1983 } else { | 1983 } else { |
1984 ProcessMouseEvent(mouse_event, *event->latency()); | 1984 ProcessMouseEvent(mouse_event, *event->latency()); |
1985 } | 1985 } |
1986 | 1986 |
1987 // Ensure that we get keyboard focus on mouse down as a plugin window may | 1987 // Ensure that we get keyboard focus on mouse down as a plugin window may |
1988 // have grabbed keyboard focus. | 1988 // have grabbed keyboard focus. |
1989 if (event->type() == ui::ET_MOUSE_PRESSED) | 1989 if (event->type() == ui::ET_MOUSE_PRESSED) |
1990 SetKeyboardFocus(); | 1990 SetKeyboardFocus(); |
1991 } | 1991 } |
1992 } | 1992 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2106 blink::WebGestureEvent gesture_event = ui::MakeWebGestureEventFlingCancel(); | 2106 blink::WebGestureEvent gesture_event = ui::MakeWebGestureEventFlingCancel(); |
2107 // Coordinates need to be transferred to the fling cancel gesture only | 2107 // Coordinates need to be transferred to the fling cancel gesture only |
2108 // for Surface-targeting to ensure that it is targeted to the correct | 2108 // for Surface-targeting to ensure that it is targeted to the correct |
2109 // RenderWidgetHost. | 2109 // RenderWidgetHost. |
2110 gesture_event.x = event->x(); | 2110 gesture_event.x = event->x(); |
2111 gesture_event.y = event->y(); | 2111 gesture_event.y = event->y(); |
2112 blink::WebMouseWheelEvent mouse_wheel_event = ui::MakeWebMouseWheelEvent( | 2112 blink::WebMouseWheelEvent mouse_wheel_event = ui::MakeWebMouseWheelEvent( |
2113 *event, base::Bind(&GetScreenLocationFromEvent)); | 2113 *event, base::Bind(&GetScreenLocationFromEvent)); |
2114 if (ShouldRouteEvent(event)) { | 2114 if (ShouldRouteEvent(event)) { |
2115 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( | 2115 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( |
2116 this, &gesture_event, ui::LatencyInfo()); | 2116 this, &gesture_event, ui::LatencyInfo(ui::SourceEventType::WHEEL)); |
2117 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( | 2117 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( |
2118 this, &mouse_wheel_event); | 2118 this, &mouse_wheel_event, *event->latency()); |
2119 } else { | 2119 } else { |
2120 host_->ForwardGestureEvent(gesture_event); | 2120 host_->ForwardGestureEvent(gesture_event); |
2121 host_->ForwardWheelEventWithLatencyInfo(mouse_wheel_event, | 2121 host_->ForwardWheelEventWithLatencyInfo(mouse_wheel_event, |
2122 *event->latency()); | 2122 *event->latency()); |
2123 } | 2123 } |
2124 RecordAction(base::UserMetricsAction("TrackpadScroll")); | 2124 RecordAction(base::UserMetricsAction("TrackpadScroll")); |
2125 } else if (event->type() == ui::ET_SCROLL_FLING_START || | 2125 } else if (event->type() == ui::ET_SCROLL_FLING_START || |
2126 event->type() == ui::ET_SCROLL_FLING_CANCEL) { | 2126 event->type() == ui::ET_SCROLL_FLING_CANCEL) { |
2127 blink::WebGestureEvent gesture_event = ui::MakeWebGestureEvent( | 2127 blink::WebGestureEvent gesture_event = ui::MakeWebGestureEvent( |
2128 *event, base::Bind(&GetScreenLocationFromEvent)); | 2128 *event, base::Bind(&GetScreenLocationFromEvent)); |
2129 if (ShouldRouteEvent(event)) { | 2129 if (ShouldRouteEvent(event)) { |
2130 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( | 2130 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( |
2131 this, &gesture_event, ui::LatencyInfo()); | 2131 this, &gesture_event, ui::LatencyInfo(ui::SourceEventType::WHEEL)); |
2132 } else { | 2132 } else { |
2133 host_->ForwardGestureEvent(gesture_event); | 2133 host_->ForwardGestureEvent(gesture_event); |
2134 } | 2134 } |
2135 if (event->type() == ui::ET_SCROLL_FLING_START) | 2135 if (event->type() == ui::ET_SCROLL_FLING_START) |
2136 RecordAction(base::UserMetricsAction("TrackpadScrollFling")); | 2136 RecordAction(base::UserMetricsAction("TrackpadScrollFling")); |
2137 } | 2137 } |
2138 | 2138 |
2139 event->SetHandled(); | 2139 event->SetHandled(); |
2140 } | 2140 } |
2141 | 2141 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2207 blink::WebGestureEvent gesture = | 2207 blink::WebGestureEvent gesture = |
2208 ui::MakeWebGestureEvent(*event, base::Bind(&GetScreenLocationFromEvent)); | 2208 ui::MakeWebGestureEvent(*event, base::Bind(&GetScreenLocationFromEvent)); |
2209 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 2209 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
2210 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an | 2210 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an |
2211 // event to stop any in-progress flings. | 2211 // event to stop any in-progress flings. |
2212 blink::WebGestureEvent fling_cancel = gesture; | 2212 blink::WebGestureEvent fling_cancel = gesture; |
2213 fling_cancel.type = blink::WebInputEvent::GestureFlingCancel; | 2213 fling_cancel.type = blink::WebInputEvent::GestureFlingCancel; |
2214 fling_cancel.sourceDevice = blink::WebGestureDeviceTouchscreen; | 2214 fling_cancel.sourceDevice = blink::WebGestureDeviceTouchscreen; |
2215 if (ShouldRouteEvent(event)) { | 2215 if (ShouldRouteEvent(event)) { |
2216 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( | 2216 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( |
2217 this, &fling_cancel, ui::LatencyInfo()); | 2217 this, &fling_cancel, ui::LatencyInfo(ui::SourceEventType::TOUCH)); |
2218 } else { | 2218 } else { |
2219 host_->ForwardGestureEvent(fling_cancel); | 2219 host_->ForwardGestureEvent(fling_cancel); |
2220 } | 2220 } |
2221 } | 2221 } |
2222 | 2222 |
2223 if (gesture.type != blink::WebInputEvent::Undefined) { | 2223 if (gesture.type != blink::WebInputEvent::Undefined) { |
2224 if (ShouldRouteEvent(event)) { | 2224 if (ShouldRouteEvent(event)) { |
2225 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( | 2225 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( |
2226 this, &gesture, *event->latency()); | 2226 this, &gesture, *event->latency()); |
2227 } else { | 2227 } else { |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3064 ->GetTextSelection(focused_view) | 3064 ->GetTextSelection(focused_view) |
3065 ->GetSelectedText(&selected_text)) { | 3065 ->GetSelectedText(&selected_text)) { |
3066 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. | 3066 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. |
3067 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); | 3067 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); |
3068 clipboard_writer.WriteText(selected_text); | 3068 clipboard_writer.WriteText(selected_text); |
3069 } | 3069 } |
3070 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) | 3070 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) |
3071 } | 3071 } |
3072 | 3072 |
3073 } // namespace content | 3073 } // namespace content |
OLD | NEW |