| 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/ui_events_helper.h" | 5 #include "content/browser/renderer_host/ui_events_helper.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" |
| 9 #include "content/common/input/web_touch_event_traits.h" | 10 #include "content/common/input/web_touch_event_traits.h" |
| 10 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 11 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 11 #include "ui/events/base_event_utils.h" | 12 #include "ui/events/base_event_utils.h" |
| 12 #include "ui/events/blink/blink_event_util.h" | 13 #include "ui/events/blink/blink_event_util.h" |
| 13 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
| 14 #include "ui/events/event_constants.h" | 15 #include "ui/events/event_constants.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 ui::EventType WebTouchPointStateToEventType( | 19 ui::EventType WebTouchPointStateToEventType( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 34 return ui::ET_UNKNOWN; | 35 return ui::ET_UNKNOWN; |
| 35 } | 36 } |
| 36 } | 37 } |
| 37 | 38 |
| 38 } // namespace | 39 } // namespace |
| 39 | 40 |
| 40 namespace content { | 41 namespace content { |
| 41 | 42 |
| 42 bool MakeUITouchEventsFromWebTouchEvents( | 43 bool MakeUITouchEventsFromWebTouchEvents( |
| 43 const TouchEventWithLatencyInfo& touch_with_latency, | 44 const TouchEventWithLatencyInfo& touch_with_latency, |
| 44 ScopedVector<ui::TouchEvent>* list, | 45 std::vector<std::unique_ptr<ui::TouchEvent>>* list, |
| 45 TouchEventCoordinateSystem coordinate_system) { | 46 TouchEventCoordinateSystem coordinate_system) { |
| 46 const blink::WebTouchEvent& touch = touch_with_latency.event; | 47 const blink::WebTouchEvent& touch = touch_with_latency.event; |
| 47 ui::EventType type = ui::ET_UNKNOWN; | 48 ui::EventType type = ui::ET_UNKNOWN; |
| 48 switch (touch.type()) { | 49 switch (touch.type()) { |
| 49 case blink::WebInputEvent::TouchStart: | 50 case blink::WebInputEvent::TouchStart: |
| 50 type = ui::ET_TOUCH_PRESSED; | 51 type = ui::ET_TOUCH_PRESSED; |
| 51 break; | 52 break; |
| 52 case blink::WebInputEvent::TouchEnd: | 53 case blink::WebInputEvent::TouchEnd: |
| 53 type = ui::ET_TOUCH_RELEASED; | 54 type = ui::ET_TOUCH_RELEASED; |
| 54 break; | 55 break; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 69 for (unsigned i = 0; i < touch.touchesLength; ++i) { | 70 for (unsigned i = 0; i < touch.touchesLength; ++i) { |
| 70 const blink::WebTouchPoint& point = touch.touches[i]; | 71 const blink::WebTouchPoint& point = touch.touches[i]; |
| 71 if (WebTouchPointStateToEventType(point.state) != type) | 72 if (WebTouchPointStateToEventType(point.state) != type) |
| 72 continue; | 73 continue; |
| 73 // ui events start in the co-ordinate space of the EventDispatcher. | 74 // ui events start in the co-ordinate space of the EventDispatcher. |
| 74 gfx::PointF location; | 75 gfx::PointF location; |
| 75 if (coordinate_system == LOCAL_COORDINATES) | 76 if (coordinate_system == LOCAL_COORDINATES) |
| 76 location = point.position; | 77 location = point.position; |
| 77 else | 78 else |
| 78 location = point.screenPosition; | 79 location = point.screenPosition; |
| 79 ui::TouchEvent* uievent = new ui::TouchEvent( | 80 auto uievent = base::MakeUnique<ui::TouchEvent>( |
| 80 type, gfx::Point(), flags, point.id, timestamp, point.radiusX, | 81 type, gfx::Point(), flags, point.id, timestamp, point.radiusX, |
| 81 point.radiusY, point.rotationAngle, point.force); | 82 point.radiusY, point.rotationAngle, point.force); |
| 82 uievent->set_location_f(location); | 83 uievent->set_location_f(location); |
| 83 uievent->set_root_location_f(location); | 84 uievent->set_root_location_f(location); |
| 84 uievent->set_latency(touch_with_latency.latency); | 85 uievent->set_latency(touch_with_latency.latency); |
| 85 list->push_back(uievent); | 86 list->push_back(std::move(uievent)); |
| 86 } | 87 } |
| 87 return true; | 88 return true; |
| 88 } | 89 } |
| 89 | 90 |
| 90 } // namespace content | 91 } // namespace content |
| OLD | NEW |