15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_BROWSER_RENDERER_HOST_UI_EVENTS_HELPER_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_BROWSER_RENDERER_HOST_UI_EVENTS_HELPER_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_vector.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h"
107d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "content/port/browser/event_with_latency_info.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace WebKit {
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebGestureEvent;
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebTouchEvent;
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebTouchPoint;
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ui {
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class GestureEvent;
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TouchEvent;
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)enum TouchEventCoordinateSystem {
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  SCREEN_COORDINATES,
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  LOCAL_COORDINATES
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Creates a list of ui::TouchEvents out of a single WebTouchEvent.
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// A WebTouchEvent can contain information about a number of WebTouchPoints,
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// whereas a ui::TouchEvent contains information about a single touch-point. So
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// it is possible to create more than one ui::TouchEvents out of a single
347d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// WebTouchEvent. All the ui::TouchEvent in the list will carry the same
357d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// LatencyInfo the WebTouchEvent carries.
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)CONTENT_EXPORT bool MakeUITouchEventsFromWebTouchEvents(
377d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)    const TouchEventWithLatencyInfo& touch,
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    ScopedVector<ui::TouchEvent>* list,
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    TouchEventCoordinateSystem coordinate_system);
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Creates a WebGestureEvent from a ui::GestureEvent. Note that it does not
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// populate the event coordinates (i.e. |x|, |y|, |globalX|, and |globalY|). So
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the caller must populate these fields.
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)WebKit::WebGestureEvent MakeWebGestureEventFromUIEvent(
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const ui::GestureEvent& event);
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)int EventFlagsToWebEventModifiers(int flags);
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Updates the WebTouchEvent based on the TouchEvent. It returns the updated
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// WebTouchPoint contained in the WebTouchEvent, or NULL if no point was
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// updated.
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)WebKit::WebTouchPoint* UpdateWebTouchEventFromUIEvent(
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const ui::TouchEvent& event,
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    WebKit::WebTouchEvent* web_event);
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CONTENT_BROWSER_RENDERER_HOST_UI_EVENTS_HELPER_H_
58