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

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

Issue 2479123003: WIP Add getCoalescedEvents API using vector of WebInputEvents (Closed)
Patch Set: Creating CoalescedWebInputEvent 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..7cae5380edac8ba8e03a307ef362d25270997694 100644
--- a/content/common/input/event_with_latency_info.cc
+++ b/content/common/input/event_with_latency_info.cc
@@ -262,16 +262,17 @@ void Coalesce(const blink::WebInputEvent& event_to_coalesce,
} // namespace internal
ScopedWebInputEventWithLatencyInfo::ScopedWebInputEventWithLatencyInfo(
- ui::ScopedWebInputEvent event,
+ blink::CoalescedWebInputEvent::ScopedWebInputEvent event,
const ui::LatencyInfo& latency_info)
- : event_(std::move(event)), latency_(latency_info) {
-}
+ : event_(new blink::CoalescedWebInputEvent(std::move(event))),
+ latency_(latency_info) {}
ScopedWebInputEventWithLatencyInfo::~ScopedWebInputEventWithLatencyInfo() {}
bool ScopedWebInputEventWithLatencyInfo::CanCoalesceWith(
const ScopedWebInputEventWithLatencyInfo& other) const {
- return internal::CanCoalesce(other.event(), event());
+ return internal::CanCoalesce(other.coalescedEvent().event(),
+ coalescedEvent().event());
}
void ScopedWebInputEventWithLatencyInfo::CoalesceWith(
@@ -282,9 +283,14 @@ 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;
- internal::Coalesce(other.event(), event_.get());
- event_->timeStampSeconds = time_stamp_seconds;
+ const double time_stamp_seconds =
+ other.coalescedEvent().event().timeStampSeconds;
+
+ // The new event will have no coalesced events itself. So we do not copy all
+ // the coalesced event over here.
+ event_->addCoalescedEvent(other.coalescedEvent().event());
+ internal::Coalesce(other.coalescedEvent().event(), event_->eventPointer());
+ event_->eventPointer()->timeStampSeconds = time_stamp_seconds;
// When coalescing two input events, we keep the oldest LatencyInfo
// since it will represent the longest latency.
@@ -292,11 +298,13 @@ void ScopedWebInputEventWithLatencyInfo::CoalesceWith(
other.latency_.set_coalesced();
}
-const blink::WebInputEvent& ScopedWebInputEventWithLatencyInfo::event() const {
+const blink::CoalescedWebInputEvent&
+ScopedWebInputEventWithLatencyInfo::coalescedEvent() const {
return *event_;
}
-blink::WebInputEvent& ScopedWebInputEventWithLatencyInfo::event() {
+blink::CoalescedWebInputEvent&
+ScopedWebInputEventWithLatencyInfo::coalescedEvent() {
return *event_;
}

Powered by Google App Engine
This is Rietveld 408576698