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

Side by Side Diff: ui/events/blink/event_with_callback.cc

Issue 2552853002: [Compositor event queue] Coalesce gesture scroll&pinch of the same sequence (Closed)
Patch Set: Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ui/events/blink/event_with_callback.h" 5 #include "ui/events/blink/event_with_callback.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "ui/events/blink/blink_event_util.h" 8 #include "ui/events/blink/blink_event_util.h"
9 #include "ui/events/blink/did_overscroll_params.h" 9 #include "ui/events/blink/did_overscroll_params.h"
10 #include "ui/events/blink/web_input_event_traits.h" 10 #include "ui/events/blink/web_input_event_traits.h"
11 11
12 using blink::WebInputEvent; 12 using blink::WebInputEvent;
13 using blink::WebGestureEvent; 13 using blink::WebGestureEvent;
14 14
15 namespace ui { 15 namespace ui {
16 16
17 EventWithCallback::EventWithCallback( 17 EventWithCallback::EventWithCallback(
18 ScopedWebInputEvent event, 18 ScopedWebInputEvent event,
19 const LatencyInfo& latency, 19 const LatencyInfo& latency,
20 base::TimeTicks timestamp_now, 20 base::TimeTicks timestamp_now,
21 const InputHandlerProxy::EventDispositionCallback& callback) 21 const InputHandlerProxy::EventDispositionCallback& callback)
22 : event_(WebInputEventTraits::Clone(*event)), 22 : event_(WebInputEventTraits::Clone(*event)),
23 latency_(latency), 23 latency_(latency),
24 creation_timestamp_(timestamp_now), 24 creation_timestamp_(timestamp_now),
25 last_coalesced_timestamp_(timestamp_now) { 25 last_coalesced_timestamp_(timestamp_now) {
26 original_events_.emplace_back(std::move(event), callback); 26 original_events_.emplace_back(std::move(event), callback);
27 } 27 }
28 28
29 EventWithCallback::EventWithCallback(
30 ScopedWebInputEvent event,
31 const LatencyInfo& latency,
32 base::TimeTicks creation_timestamp,
33 base::TimeTicks last_coalesced_timestamp,
34 std::unique_ptr<OriginalEventList> original_events)
35 : event_(std::move(event)),
36 latency_(latency),
37 creation_timestamp_(creation_timestamp),
38 last_coalesced_timestamp_(last_coalesced_timestamp) {
39 if (original_events)
40 original_events_.splice(original_events_.end(), *original_events);
41 }
42
29 EventWithCallback::~EventWithCallback() {} 43 EventWithCallback::~EventWithCallback() {}
30 44
31 bool EventWithCallback::CanCoalesceWith(const EventWithCallback& other) const { 45 bool EventWithCallback::CanCoalesceWith(const EventWithCallback& other) const {
32 return CanCoalesce(other.event(), event()); 46 return CanCoalesce(other.event(), event());
33 } 47 }
34 48
35 void EventWithCallback::CoalesceWith(EventWithCallback* other, 49 void EventWithCallback::CoalesceWith(EventWithCallback* other,
36 base::TimeTicks timestamp_now) { 50 base::TimeTicks timestamp_now) {
37 // |other| should be a newer event than |this|. 51 // |other| should be a newer event than |this|.
38 if (other->latency_.trace_id() >= 0 && latency_.trace_id() >= 0) 52 if (other->latency_.trace_id() >= 0 && latency_.trace_id() >= 0)
(...skipping 23 matching lines...) Expand all
62 std::unique_ptr<DidOverscrollParams> did_overscroll_params_copy; 76 std::unique_ptr<DidOverscrollParams> did_overscroll_params_copy;
63 if (did_overscroll_params) { 77 if (did_overscroll_params) {
64 did_overscroll_params_copy = 78 did_overscroll_params_copy =
65 base::MakeUnique<DidOverscrollParams>(*did_overscroll_params); 79 base::MakeUnique<DidOverscrollParams>(*did_overscroll_params);
66 } 80 }
67 original_event.callback_.Run(disposition, std::move(original_event.event_), 81 original_event.callback_.Run(disposition, std::move(original_event.event_),
68 latency, std::move(did_overscroll_params)); 82 latency, std::move(did_overscroll_params));
69 } 83 }
70 } 84 }
71 85
86 const blink::WebGestureEvent& EventWithCallback::ToWebGestureEvent() const {
87 DCHECK(blink::WebInputEvent::isGestureEventType(event_->type));
88 return static_cast<const blink::WebGestureEvent&>(*event_);
89 }
90
72 EventWithCallback::OriginalEventWithCallback::OriginalEventWithCallback( 91 EventWithCallback::OriginalEventWithCallback::OriginalEventWithCallback(
73 ScopedWebInputEvent event, 92 ScopedWebInputEvent event,
74 const InputHandlerProxy::EventDispositionCallback& callback) 93 const InputHandlerProxy::EventDispositionCallback& callback)
75 : event_(std::move(event)), callback_(callback) {} 94 : event_(std::move(event)), callback_(callback) {}
76 95
77 EventWithCallback::OriginalEventWithCallback::~OriginalEventWithCallback() {} 96 EventWithCallback::OriginalEventWithCallback::~OriginalEventWithCallback() {}
78 97
79 } // namespace ui 98 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698