Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 510793003: Remove ui::TouchEvent -> blink::WebTouchEvent conversion methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "cc/layers/layer.h" 16 #include "cc/layers/layer.h"
17 #include "cc/output/copy_output_request.h" 17 #include "cc/output/copy_output_request.h"
18 #include "cc/output/copy_output_result.h" 18 #include "cc/output/copy_output_result.h"
19 #include "cc/resources/texture_mailbox.h" 19 #include "cc/resources/texture_mailbox.h"
20 #include "cc/trees/layer_tree_settings.h" 20 #include "cc/trees/layer_tree_settings.h"
21 #include "content/browser/accessibility/browser_accessibility_manager.h" 21 #include "content/browser/accessibility/browser_accessibility_manager.h"
22 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 22 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
23 #include "content/browser/frame_host/frame_tree.h" 23 #include "content/browser/frame_host/frame_tree.h"
24 #include "content/browser/frame_host/frame_tree_node.h" 24 #include "content/browser/frame_host/frame_tree_node.h"
25 #include "content/browser/frame_host/render_frame_host_impl.h" 25 #include "content/browser/frame_host/render_frame_host_impl.h"
26 #include "content/browser/gpu/compositor_util.h" 26 #include "content/browser/gpu/compositor_util.h"
27 #include "content/browser/renderer_host/compositor_resize_lock_aura.h" 27 #include "content/browser/renderer_host/compositor_resize_lock_aura.h"
28 #include "content/browser/renderer_host/dip_util.h" 28 #include "content/browser/renderer_host/dip_util.h"
29 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" 29 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h"
30 #include "content/browser/renderer_host/input/web_input_event_util.h"
30 #include "content/browser/renderer_host/overscroll_controller.h" 31 #include "content/browser/renderer_host/overscroll_controller.h"
31 #include "content/browser/renderer_host/render_view_host_delegate.h" 32 #include "content/browser/renderer_host/render_view_host_delegate.h"
32 #include "content/browser/renderer_host/render_view_host_impl.h" 33 #include "content/browser/renderer_host/render_view_host_impl.h"
33 #include "content/browser/renderer_host/render_widget_host_impl.h" 34 #include "content/browser/renderer_host/render_widget_host_impl.h"
34 #include "content/browser/renderer_host/ui_events_helper.h" 35 #include "content/browser/renderer_host/ui_events_helper.h"
35 #include "content/browser/renderer_host/web_input_event_aura.h" 36 #include "content/browser/renderer_host/web_input_event_aura.h"
36 #include "content/common/gpu/client/gl_helper.h" 37 #include "content/common/gpu/client/gl_helper.h"
37 #include "content/common/gpu/gpu_messages.h" 38 #include "content/common/gpu/gpu_messages.h"
38 #include "content/common/view_messages.h" 39 #include "content/common/view_messages.h"
39 #include "content/public/browser/content_browser_client.h" 40 #include "content/public/browser/content_browser_client.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 const HWND owner = ::GetWindow(window, GW_OWNER); 223 const HWND owner = ::GetWindow(window, GW_OWNER);
223 if (toplevel_hwnd == owner) { 224 if (toplevel_hwnd == owner) {
224 ::PostMessage(window, WM_CANCELMODE, 0, 0); 225 ::PostMessage(window, WM_CANCELMODE, 0, 0);
225 } 226 }
226 } 227 }
227 228
228 return TRUE; 229 return TRUE;
229 } 230 }
230 #endif 231 #endif
231 232
232 void UpdateWebTouchEventAfterDispatch(blink::WebTouchEvent* event,
233 blink::WebTouchPoint* point) {
234 if (point->state != blink::WebTouchPoint::StateReleased &&
235 point->state != blink::WebTouchPoint::StateCancelled)
236 return;
237
238 const unsigned new_length = event->touchesLength - 1;
239 // Work around a gcc 4.9 bug. crbug.com/392872
240 if (new_length >= event->touchesLengthCap)
241 return;
242
243 for (unsigned i = point - event->touches; i < new_length; ++i)
244 event->touches[i] = event->touches[i + 1];
245 event->touchesLength = new_length;
246 }
247
248 bool CanRendererHandleEvent(const ui::MouseEvent* event) { 233 bool CanRendererHandleEvent(const ui::MouseEvent* event) {
249 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) 234 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED)
250 return false; 235 return false;
251 236
252 #if defined(OS_WIN) 237 #if defined(OS_WIN)
253 // Renderer cannot handle WM_XBUTTON or NC events. 238 // Renderer cannot handle WM_XBUTTON or NC events.
254 switch (event->native_event().message) { 239 switch (event->native_event().message) {
255 case WM_XBUTTONDOWN: 240 case WM_XBUTTONDOWN:
256 case WM_XBUTTONUP: 241 case WM_XBUTTONUP:
257 case WM_XBUTTONDBLCLK: 242 case WM_XBUTTONDBLCLK:
(...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 1900
1916 event->SetHandled(); 1901 event->SetHandled();
1917 } 1902 }
1918 1903
1919 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { 1904 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) {
1920 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); 1905 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent");
1921 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) 1906 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
1922 return; 1907 return;
1923 1908
1924 // Update the touch event first. 1909 // Update the touch event first.
1925 blink::WebTouchPoint* point = UpdateWebTouchEventFromUIEvent(*event, 1910 pointer_state_.OnTouch(*event);
1926 &touch_event_); 1911 touch_event_ = CreateWebTouchEventFromMotionEvent(pointer_state_);
1912 pointer_state_.CleanupRemovedTouchPoints(*event);
1927 1913
1928 // Forward the touch event only if a touch point was updated, and there's a 1914 // Forward the touch event only if there's a touch-event handler in the page,
1929 // touch-event handler in the page, and no other touch-event is in the queue. 1915 // and no other touch-event is in the queue. It is important to always
1930 // It is important to always consume the event if there is a touch-event 1916 // consume the event if there is a touch-event handler in the page, or some
1931 // handler in the page, or some touch-event is already in the queue, even if 1917 // touch-event is already in the queue, even if no point has been updated, to
1932 // no point has been updated, to make sure that this event does not get 1918 // make sure that this event does not get processed by the gesture recognizer
1933 // processed by the gesture recognizer before the events in the queue. 1919 // before the events in the queue.
1934 if (host_->ShouldForwardTouchEvent()) 1920 if (host_->ShouldForwardTouchEvent()) {
1935 event->StopPropagation(); 1921 event->StopPropagation();
1936 1922 host_->ForwardTouchEventWithLatencyInfo(touch_event_, *event->latency());
1937 if (point) {
1938 if (host_->ShouldForwardTouchEvent())
1939 host_->ForwardTouchEventWithLatencyInfo(touch_event_, *event->latency());
1940 UpdateWebTouchEventAfterDispatch(&touch_event_, point);
1941 } 1923 }
1942 } 1924 }
1943 1925
1944 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { 1926 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
1945 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); 1927 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent");
1946 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || 1928 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN ||
1947 event->type() == ui::ET_GESTURE_PINCH_UPDATE || 1929 event->type() == ui::ET_GESTURE_PINCH_UPDATE ||
1948 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { 1930 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) {
1949 event->SetHandled(); 1931 event->SetHandled();
1950 return; 1932 return;
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
2488 2470
2489 //////////////////////////////////////////////////////////////////////////////// 2471 ////////////////////////////////////////////////////////////////////////////////
2490 // RenderWidgetHostViewBase, public: 2472 // RenderWidgetHostViewBase, public:
2491 2473
2492 // static 2474 // static
2493 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2475 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2494 GetScreenInfoForWindow(results, NULL); 2476 GetScreenInfoForWindow(results, NULL);
2495 } 2477 }
2496 2478
2497 } // namespace content 2479 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698