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

Unified Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 375863005: Touch emulator: allow multiple touch streams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better touch sequence end check Created 6 years, 5 months 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/browser/renderer_host/render_widget_host_impl.cc
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index c0196dee6140393cb403eaa4d5a7b024e484e1c2..f378a26e4c57ce18ce58914b42f9f38973ceeb98 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -964,22 +964,41 @@ void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo(
input_router_->SendGestureEvent(gesture_with_latency);
}
-void RenderWidgetHostImpl::ForwardTouchEvent(
+void RenderWidgetHostImpl::ForwardEmulatedTouchEvent(
const blink::WebTouchEvent& touch_event) {
- ForwardTouchEventWithLatencyInfo(touch_event, ui::LatencyInfo());
+ ForwardTouchEventWithLatencyInfoFromStream(
+ touch_event, ui::LatencyInfo(), TouchStreamTracker::EMULATED_STREAM);
}
void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo(
const blink::WebTouchEvent& touch_event,
const ui::LatencyInfo& ui_latency) {
+ ForwardTouchEventWithLatencyInfoFromStream(
+ touch_event, ui_latency, TouchStreamTracker::NATIVE_STREAM);
+}
+
+void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfoFromStream(
+ const blink::WebTouchEvent& touch_event,
+ const ui::LatencyInfo& ui_latency,
+ TouchStreamTracker::TouchStream stream) {
TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent");
- // Always forward TouchEvents for touch stream consistency. They will be
- // ignored if appropriate in FilterInputEvent().
+ // Always forward TouchEvents from active touch stream for consistency.
+ // They will be ignored if appropriate in FilterInputEvent().
ui::LatencyInfo latency_info =
CreateRWHLatencyInfoIfNotExist(&ui_latency, touch_event.type);
TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info);
+
+ if (touch_stream_tracker_) {
+ InputEventAckState ack_result =
+ touch_stream_tracker_->FilterTouchEventFromStream(touch_event, stream);
+ if (ack_result != INPUT_EVENT_ACK_STATE_UNKNOWN) {
+ OnTouchEventAckFromStream(touch_with_latency, ack_result, stream);
+ return;
+ }
+ }
+
input_router_->SendTouchEvent(touch_with_latency);
}
@@ -1629,8 +1648,10 @@ void RenderWidgetHostImpl::OnSetTouchEventEmulationEnabled(
delegate_->OnTouchEmulationEnabled(enabled);
if (enabled) {
- if (!touch_emulator_)
+ if (!touch_emulator_) {
+ touch_stream_tracker_.reset(new TouchStreamTracker());
touch_emulator_.reset(new TouchEmulator(this));
+ }
touch_emulator_->Enable(allow_pinch);
} else {
if (touch_emulator_)
@@ -1891,6 +1912,16 @@ void RenderWidgetHostImpl::OnGestureEventAck(
void RenderWidgetHostImpl::OnTouchEventAck(
const TouchEventWithLatencyInfo& event,
InputEventAckState ack_result) {
+ TouchStreamTracker::TouchStream stream = TouchStreamTracker::NATIVE_STREAM;
+ if (touch_stream_tracker_)
+ stream = touch_stream_tracker_->OnTouchEventAck(event, ack_result);
+ OnTouchEventAckFromStream(event, ack_result, stream);
+}
+
+void RenderWidgetHostImpl::OnTouchEventAckFromStream(
+ const TouchEventWithLatencyInfo& event,
+ InputEventAckState ack_result,
+ TouchStreamTracker::TouchStream stream) {
TouchEventWithLatencyInfo touch_event = event;
touch_event.latency.AddLatencyNumber(
ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT, 0, 0);
@@ -1902,9 +1933,13 @@ void RenderWidgetHostImpl::OnTouchEventAck(
}
ComputeTouchLatency(touch_event.latency);
- if (touch_emulator_ && touch_emulator_->HandleTouchEventAck(ack_result))
+ if (stream == TouchStreamTracker::EMULATED_STREAM) {
+ DCHECK(touch_emulator_);
+ touch_emulator_->HandleTouchEventAck(ack_result);
return;
+ }
+ DCHECK(stream == TouchStreamTracker::NATIVE_STREAM);
if (view_)
view_->ProcessAckedTouchEvent(touch_event, ack_result);
}

Powered by Google App Engine
This is Rietveld 408576698