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

Unified Diff: content/common/input/event_with_latency_info.cc

Issue 2479123003: WIP Add getCoalescedEvents API using vector of WebInputEvents (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/common/input/event_with_latency_info.cc
diff --git a/content/common/input/event_with_latency_info.cc b/content/common/input/event_with_latency_info.cc
index bafa99e15ad2befeed972416825e382cf57e45e5..ff78f0025f527f3fac7f1fb0d01f6e5119e51d50 100644
--- a/content/common/input/event_with_latency_info.cc
+++ b/content/common/input/event_with_latency_info.cc
@@ -259,12 +259,37 @@ void Coalesce(const blink::WebInputEvent& event_to_coalesce,
}
}
+ui::ScopedWebInputEvent makeDeepCopyUniquePtr(
+ const blink::WebInputEvent& event) {
+ if (blink::WebInputEvent::isGestureEventType(event.type)) {
+ return ui::ScopedWebInputEvent(new blink::WebGestureEvent(
+ static_cast<const blink::WebGestureEvent&>(event)));
+ }
+ if (blink::WebInputEvent::isMouseEventType(event.type)) {
+ return ui::ScopedWebInputEvent(new blink::WebMouseEvent(
+ static_cast<const blink::WebMouseEvent&>(event)));
+ }
+ if (blink::WebInputEvent::isTouchEventType(event.type)) {
+ return ui::ScopedWebInputEvent(new blink::WebTouchEvent(
+ static_cast<const blink::WebTouchEvent&>(event)));
+ }
+ if (event.type == blink::WebInputEvent::MouseWheel) {
+ return ui::ScopedWebInputEvent(new blink::WebMouseWheelEvent(
+ static_cast<const blink::WebMouseWheelEvent&>(event)));
+ }
+ NOTREACHED();
+ return ui::ScopedWebInputEvent();
+}
+
} // namespace internal
ScopedWebInputEventWithLatencyInfo::ScopedWebInputEventWithLatencyInfo(
ui::ScopedWebInputEvent event,
const ui::LatencyInfo& latency_info)
- : event_(std::move(event)), latency_(latency_info) {
+ : event_(internal::makeDeepCopyUniquePtr(*event.get())),
+ latency_(latency_info) {
+ scopedCoalescedEvents_.push_back(std::move(event));
+ coalescedEvents_.push_back(scopedCoalescedEvents_.back().get());
}
ScopedWebInputEventWithLatencyInfo::~ScopedWebInputEventWithLatencyInfo() {}
@@ -283,6 +308,9 @@ void ScopedWebInputEventWithLatencyInfo::CoalesceWith(
// New events get coalesced into older events, and the newer timestamp
// should always be preserved.
const double time_stamp_seconds = other.event().timeStampSeconds;
+ scopedCoalescedEvents_.push_back(
+ internal::makeDeepCopyUniquePtr(other.event()));
+ coalescedEvents_.push_back(scopedCoalescedEvents_.back().get());
internal::Coalesce(other.event(), event_.get());
event_->timeStampSeconds = time_stamp_seconds;
@@ -300,4 +328,9 @@ blink::WebInputEvent& ScopedWebInputEventWithLatencyInfo::event() {
return *event_;
}
+const std::vector<const blink::WebInputEvent*>&
+ScopedWebInputEventWithLatencyInfo::coalescedEvents() {
+ return coalescedEvents_;
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698