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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 const TouchEventWithLatencyInfo& touch, 1018 const TouchEventWithLatencyInfo& touch,
1019 InputEventAckState ack_result) { 1019 InputEventAckState ack_result) {
1020 ScopedVector<ui::TouchEvent> events; 1020 ScopedVector<ui::TouchEvent> events;
1021 aura::WindowTreeHost* host = window_->GetHost(); 1021 aura::WindowTreeHost* host = window_->GetHost();
1022 // |host| is NULL during tests. 1022 // |host| is NULL during tests.
1023 if (!host) 1023 if (!host)
1024 return; 1024 return;
1025 1025
1026 // The TouchScrollStarted event is generated & consumed downstream from the 1026 // The TouchScrollStarted event is generated & consumed downstream from the
1027 // TouchEventQueue. So we don't expect an ACK up here. 1027 // TouchEventQueue. So we don't expect an ACK up here.
1028 DCHECK(touch.event.type != blink::WebInputEvent::TouchScrollStarted); 1028 DCHECK(touch.event.type() != blink::WebInputEvent::TouchScrollStarted);
1029 1029
1030 ui::EventResult result = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) 1030 ui::EventResult result = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED)
1031 ? ui::ER_HANDLED 1031 ? ui::ER_HANDLED
1032 : ui::ER_UNHANDLED; 1032 : ui::ER_UNHANDLED;
1033 1033
1034 blink::WebTouchPoint::State required_state; 1034 blink::WebTouchPoint::State required_state;
1035 switch (touch.event.type) { 1035 switch (touch.event.type()) {
1036 case blink::WebInputEvent::TouchStart: 1036 case blink::WebInputEvent::TouchStart:
1037 required_state = blink::WebTouchPoint::StatePressed; 1037 required_state = blink::WebTouchPoint::StatePressed;
1038 break; 1038 break;
1039 case blink::WebInputEvent::TouchEnd: 1039 case blink::WebInputEvent::TouchEnd:
1040 required_state = blink::WebTouchPoint::StateReleased; 1040 required_state = blink::WebTouchPoint::StateReleased;
1041 break; 1041 break;
1042 case blink::WebInputEvent::TouchMove: 1042 case blink::WebInputEvent::TouchMove:
1043 required_state = blink::WebTouchPoint::StateMoved; 1043 required_state = blink::WebTouchPoint::StateMoved;
1044 break; 1044 break;
1045 case blink::WebInputEvent::TouchCancel: 1045 case blink::WebInputEvent::TouchCancel:
(...skipping 19 matching lines...) Expand all
1065 1065
1066 std::unique_ptr<SyntheticGestureTarget> 1066 std::unique_ptr<SyntheticGestureTarget>
1067 RenderWidgetHostViewAura::CreateSyntheticGestureTarget() { 1067 RenderWidgetHostViewAura::CreateSyntheticGestureTarget() {
1068 return std::unique_ptr<SyntheticGestureTarget>( 1068 return std::unique_ptr<SyntheticGestureTarget>(
1069 new SyntheticGestureTargetAura(host_)); 1069 new SyntheticGestureTargetAura(host_));
1070 } 1070 }
1071 1071
1072 InputEventAckState RenderWidgetHostViewAura::FilterInputEvent( 1072 InputEventAckState RenderWidgetHostViewAura::FilterInputEvent(
1073 const blink::WebInputEvent& input_event) { 1073 const blink::WebInputEvent& input_event) {
1074 bool consumed = false; 1074 bool consumed = false;
1075 if (input_event.type == WebInputEvent::GestureFlingStart) { 1075 if (input_event.type() == WebInputEvent::GestureFlingStart) {
1076 const WebGestureEvent& gesture_event = 1076 const WebGestureEvent& gesture_event =
1077 static_cast<const WebGestureEvent&>(input_event); 1077 static_cast<const WebGestureEvent&>(input_event);
1078 // Zero-velocity touchpad flings are an Aura-specific signal that the 1078 // Zero-velocity touchpad flings are an Aura-specific signal that the
1079 // touchpad scroll has ended, and should not be forwarded to the renderer. 1079 // touchpad scroll has ended, and should not be forwarded to the renderer.
1080 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad && 1080 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad &&
1081 !gesture_event.data.flingStart.velocityX && 1081 !gesture_event.data.flingStart.velocityX &&
1082 !gesture_event.data.flingStart.velocityY) { 1082 !gesture_event.data.flingStart.velocityY) {
1083 consumed = true; 1083 consumed = true;
1084 } 1084 }
1085 } 1085 }
1086 1086
1087 if (overscroll_controller_) 1087 if (overscroll_controller_)
1088 consumed |= overscroll_controller_->WillHandleEvent(input_event); 1088 consumed |= overscroll_controller_->WillHandleEvent(input_event);
1089 1089
1090 // Touch events should always propagate to the renderer. 1090 // Touch events should always propagate to the renderer.
1091 if (WebTouchEvent::isTouchEventType(input_event.type)) 1091 if (WebTouchEvent::isTouchEventType(input_event.type()))
1092 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 1092 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
1093 1093
1094 if (consumed && input_event.type == blink::WebInputEvent::GestureFlingStart) { 1094 if (consumed &&
1095 input_event.type() == blink::WebInputEvent::GestureFlingStart) {
1095 // Here we indicate that there was no consumer for this event, as 1096 // Here we indicate that there was no consumer for this event, as
1096 // otherwise the fling animation system will try to run an animation 1097 // otherwise the fling animation system will try to run an animation
1097 // and will also expect a notification when the fling ends. Since 1098 // and will also expect a notification when the fling ends. Since
1098 // CrOS just uses the GestureFlingStart with zero-velocity as a means 1099 // CrOS just uses the GestureFlingStart with zero-velocity as a means
1099 // of indicating that touchpad scroll has ended, we don't actually want 1100 // of indicating that touchpad scroll has ended, we don't actually want
1100 // a fling animation. Note: Similar code exists in 1101 // a fling animation. Note: Similar code exists in
1101 // RenderWidgetHostViewChildFrame::FilterInputEvent() 1102 // RenderWidgetHostViewChildFrame::FilterInputEvent()
1102 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; 1103 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
1103 } 1104 }
1104 1105
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 2395
2395 void RenderWidgetHostViewAura::SetPopupChild( 2396 void RenderWidgetHostViewAura::SetPopupChild(
2396 RenderWidgetHostViewAura* popup_child_host_view) { 2397 RenderWidgetHostViewAura* popup_child_host_view) {
2397 popup_child_host_view_ = popup_child_host_view; 2398 popup_child_host_view_ = popup_child_host_view;
2398 event_handler_->SetPopupChild( 2399 event_handler_->SetPopupChild(
2399 popup_child_host_view, 2400 popup_child_host_view,
2400 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); 2401 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr);
2401 } 2402 }
2402 2403
2403 } // namespace content 2404 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698