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

Unified Diff: content/browser/renderer_host/input/touch_event_queue.cc

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Fix nits Created 3 years, 11 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/input/touch_event_queue.cc
diff --git a/content/browser/renderer_host/input/touch_event_queue.cc b/content/browser/renderer_host/input/touch_event_queue.cc
index 8ac5d7a5262000c9a32851525e0b3bf9c0255c1c..5b594addabcb2a729098642010cedc4c7f277e12 100644
--- a/content/browser/renderer_host/input/touch_event_queue.cc
+++ b/content/browser/renderer_host/input/touch_event_queue.cc
@@ -38,14 +38,13 @@ TouchEventWithLatencyInfo ObtainCancelEventForTouchEvent(
WebTouchEventTraits::ResetTypeAndTouchStates(
WebInputEvent::TouchCancel,
// TODO(rbyers): Shouldn't we use a fresh timestamp?
- event.event.timeStampSeconds,
- &event.event);
+ event.event.timeStampSeconds(), &event.event);
return event;
}
bool ShouldTouchTriggerTimeout(const WebTouchEvent& event) {
- return (event.type == WebInputEvent::TouchStart ||
- event.type == WebInputEvent::TouchMove) &&
+ return (event.type() == WebInputEvent::TouchStart ||
+ event.type() == WebInputEvent::TouchMove) &&
event.dispatchType == WebInputEvent::Blocking;
}
@@ -298,11 +297,11 @@ class TouchEventQueue::TouchMoveSlopSuppressor {
touch_start_location_ = gfx::PointF(event.touches[0].position);
}
- if (event.type == WebInputEvent::TouchEnd ||
- event.type == WebInputEvent::TouchCancel)
+ if (event.type() == WebInputEvent::TouchEnd ||
+ event.type() == WebInputEvent::TouchCancel)
suppressing_touchmoves_ = false;
- if (event.type != WebInputEvent::TouchMove)
+ if (event.type() != WebInputEvent::TouchMove)
return false;
if (suppressing_touchmoves_) {
@@ -532,7 +531,7 @@ void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result,
DCHECK(touch_queue_.empty());
// Dispatch the next pending async touch move when time expires.
- if (pending_async_touchmove_->event.timeStampSeconds >=
+ if (pending_async_touchmove_->event.timeStampSeconds() >=
last_sent_touch_timestamp_sec_ + kAsyncTouchMoveIntervalSec) {
FlushPendingAsyncTouchmove();
}
@@ -595,7 +594,7 @@ void TouchEventQueue::ForwardNextEventToRenderer() {
TouchEventWithLatencyInfo touch = touch_queue_.front()->coalesced_event();
if (send_touch_events_async_ &&
- touch.event.type == WebInputEvent::TouchMove) {
+ touch.event.type() == WebInputEvent::TouchMove) {
// Throttling touchmove's in a continuous touchmove stream while scrolling
// reduces the risk of jank. However, it's still important that the web
// application be sent touches at key points in the gesture stream,
@@ -606,7 +605,7 @@ void TouchEventQueue::ForwardNextEventToRenderer() {
!pending_async_touchmove_->CanCoalesceWith(touch);
send_touchmove_now |=
ack_pending_async_touchmove_ids_.empty() &&
- (touch.event.timeStampSeconds >=
+ (touch.event.timeStampSeconds() >=
last_sent_touch_timestamp_sec_ + kAsyncTouchMoveIntervalSec);
if (!send_touchmove_now) {
@@ -627,7 +626,7 @@ void TouchEventQueue::ForwardNextEventToRenderer() {
}
}
- last_sent_touch_timestamp_sec_ = touch.event.timeStampSeconds;
+ last_sent_touch_timestamp_sec_ = touch.event.timeStampSeconds();
// Flush any pending async touch move. If it can be combined with the current
// (touchmove) event, great, otherwise send it immediately but separately. Its
@@ -649,7 +648,8 @@ void TouchEventQueue::ForwardNextEventToRenderer() {
// Note: Touchstart events are marked cancelable to allow transitions between
// platform scrolling and JS pinching. Touchend events, however, remain
// uncancelable, mitigating the risk of jank when transitioning to a fling.
- if (send_touch_events_async_ && touch.event.type != WebInputEvent::TouchStart)
+ if (send_touch_events_async_ &&
+ touch.event.type() != WebInputEvent::TouchStart)
touch.event.dispatchType = WebInputEvent::EventNonBlocking;
SendTouchEventImmediately(&touch);
@@ -667,7 +667,7 @@ void TouchEventQueue::FlushPendingAsyncTouchmove() {
void TouchEventQueue::OnGestureScrollEvent(
const GestureEventWithLatencyInfo& gesture_event) {
- if (gesture_event.event.type == blink::WebInputEvent::GestureScrollBegin) {
+ if (gesture_event.event.type() == blink::WebInputEvent::GestureScrollBegin) {
if (has_handler_for_current_sequence_ &&
!drop_remaining_touches_in_sequence_) {
DCHECK(!touchmove_slop_suppressor_->suppressing_touchmoves())
@@ -679,7 +679,7 @@ void TouchEventQueue::OnGestureScrollEvent(
return;
}
- if (gesture_event.event.type == blink::WebInputEvent::GestureScrollUpdate &&
+ if (gesture_event.event.type() == blink::WebInputEvent::GestureScrollUpdate &&
gesture_event.event.resendingPluginId == -1) {
send_touch_events_async_ = true;
}
@@ -695,7 +695,7 @@ void TouchEventQueue::OnGestureEventAck(
// A valid |pending_async_touchmove_| will be flushed when the next event is
// forwarded. Scroll updates that are being resent from a GuestView are
// ignored.
- if (event.event.type == blink::WebInputEvent::GestureScrollUpdate &&
+ if (event.event.type() == blink::WebInputEvent::GestureScrollUpdate &&
event.event.resendingPluginId == -1) {
send_touch_events_async_ = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED);
}
@@ -714,7 +714,7 @@ bool TouchEventQueue::IsPendingAckTouchStart() const {
const blink::WebTouchEvent& event =
touch_queue_.front()->coalesced_event().event;
- return (event.type == WebInputEvent::TouchStart);
+ return (event.type() == WebInputEvent::TouchStart);
}
void TouchEventQueue::SetAckTimeoutEnabled(bool enabled) {
@@ -782,7 +782,7 @@ void TouchEventQueue::AckTouchEventToClient(
base::AutoReset<bool> dispatching_touch_ack(&dispatching_touch_ack_, true);
// Skip ack for TouchScrollStarted since it was synthesized within the queue.
- if (acked_event->coalesced_event().event.type !=
+ if (acked_event->coalesced_event().event.type() !=
WebInputEvent::TouchScrollStarted) {
acked_event->DispatchAckToClient(ack_result, optional_latency_info,
client_);
@@ -797,14 +797,14 @@ void TouchEventQueue::SendTouchEventImmediately(
if (dispatching_touch_)
return;
- if (touch->event.type == WebInputEvent::TouchStart)
+ if (touch->event.type() == WebInputEvent::TouchStart)
touch->event.touchStartOrFirstTouchMove = true;
// For touchmove events, compare touch points position from current event
// to last sent event and update touch points state.
- if (touch->event.type == WebInputEvent::TouchMove) {
+ if (touch->event.type() == WebInputEvent::TouchMove) {
CHECK(last_sent_touchevent_);
- if (last_sent_touchevent_->type == WebInputEvent::TouchStart)
+ if (last_sent_touchevent_->type() == WebInputEvent::TouchStart)
touch->event.touchStartOrFirstTouchMove = true;
for (unsigned int i = 0; i < last_sent_touchevent_->touchesLength; ++i) {
const WebTouchPoint& last_touch_point =
@@ -823,7 +823,7 @@ void TouchEventQueue::SendTouchEventImmediately(
}
}
- if (touch->event.type != WebInputEvent::TouchScrollStarted) {
+ if (touch->event.type() != WebInputEvent::TouchScrollStarted) {
if (last_sent_touchevent_)
*last_sent_touchevent_ = touch->event;
else
@@ -837,7 +837,7 @@ void TouchEventQueue::SendTouchEventImmediately(
// A synchronous ack will reset |dispatching_touch_|, in which case the touch
// timeout should not be started and the count also should not be increased.
if (dispatching_touch_) {
- if (touch->event.type == WebInputEvent::TouchMove &&
+ if (touch->event.type() == WebInputEvent::TouchMove &&
touch->event.dispatchType != WebInputEvent::Blocking) {
// When we send out a uncancelable touch move, we increase the count and
// we do not process input event ack any more, we will just ack to client
@@ -858,7 +858,7 @@ void TouchEventQueue::SendTouchEventImmediately(
TouchEventQueue::PreFilterResult
TouchEventQueue::FilterBeforeForwarding(const WebTouchEvent& event) {
- if (event.type == WebInputEvent::TouchScrollStarted)
+ if (event.type() == WebInputEvent::TouchScrollStarted)
return FORWARD_TO_RENDERER;
if (WebTouchEventTraits::IsTouchSequenceStart(event)) {
@@ -882,11 +882,11 @@ TouchEventQueue::FilterBeforeForwarding(const WebTouchEvent& event) {
return ACK_WITH_NOT_CONSUMED;
if (drop_remaining_touches_in_sequence_ &&
- event.type != WebInputEvent::TouchCancel) {
+ event.type() != WebInputEvent::TouchCancel) {
return ACK_WITH_NO_CONSUMER_EXISTS;
}
- if (event.type == WebInputEvent::TouchStart) {
+ if (event.type() == WebInputEvent::TouchStart) {
return (has_handlers_ || has_handler_for_current_sequence_)
? FORWARD_TO_RENDERER
: ACK_WITH_NO_CONSUMER_EXISTS;
@@ -909,7 +909,7 @@ TouchEventQueue::FilterBeforeForwarding(const WebTouchEvent& event) {
if (point.id != last_sent_touchevent_->touches[j].id)
continue;
- if (event.type != WebInputEvent::TouchMove)
+ if (event.type() != WebInputEvent::TouchMove)
return FORWARD_TO_RENDERER;
// All pointers in TouchMove events may have state as StateMoved,
@@ -932,7 +932,7 @@ TouchEventQueue::FilterBeforeForwarding(const WebTouchEvent& event) {
void TouchEventQueue::UpdateTouchConsumerStates(const WebTouchEvent& event,
InputEventAckState ack_result) {
- if (event.type == WebInputEvent::TouchStart) {
+ if (event.type() == WebInputEvent::TouchStart) {
if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED)
send_touch_events_async_ = false;
has_handler_for_current_sequence_ |=

Powered by Google App Engine
This is Rietveld 408576698