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

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

Issue 1120293003: Make sure send one WebTouchEvent ack per ui::TouchEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use touch_id and add unittest Created 5 years, 7 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 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 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 } 798 }
799 #endif 799 #endif
800 } 800 }
801 801
802 void RenderWidgetHostViewAura::ParentHierarchyChanged() { 802 void RenderWidgetHostViewAura::ParentHierarchyChanged() {
803 ancestor_window_observer_.reset(new WindowAncestorObserver(this)); 803 ancestor_window_observer_.reset(new WindowAncestorObserver(this));
804 // Snap when we receive a hierarchy changed. http://crbug.com/388908. 804 // Snap when we receive a hierarchy changed. http://crbug.com/388908.
805 HandleParentBoundsChanged(); 805 HandleParentBoundsChanged();
806 } 806 }
807 807
808 void RenderWidgetHostViewAura::SetTouchPointStateStationary(
jdduke (slow) 2015/05/07 15:20:28 Hmm, ideally this would just be a free, nonmember
lanwei 2015/05/08 02:12:32 Because I need to use this function in the unittes
jdduke (slow) 2015/05/08 02:20:32 Yeah, noticed that later, let's see what Tim says
809 blink::WebTouchEvent* event,
810 int touch_id) {
jdduke (slow) 2015/05/07 15:20:28 Maybe |changed_touch_id|?
lanwei 2015/05/08 02:12:32 Done.
811 if (event->type == blink::WebInputEvent::TouchMove ||
812 event->type == blink::WebInputEvent::TouchCancel) {
813 for (size_t i = 0; i < event->touchesLength; ++i) {
814 if (event->touches[i].id != touch_id)
815 event->touches[i].state = blink::WebTouchPoint::StateStationary;
816 }
817 }
818 }
819
808 void RenderWidgetHostViewAura::MovePluginWindows( 820 void RenderWidgetHostViewAura::MovePluginWindows(
809 const std::vector<WebPluginGeometry>& plugin_window_moves) { 821 const std::vector<WebPluginGeometry>& plugin_window_moves) {
810 #if defined(OS_WIN) 822 #if defined(OS_WIN)
811 // We need to clip the rectangle to the tab's viewport, otherwise we will draw 823 // We need to clip the rectangle to the tab's viewport, otherwise we will draw
812 // over the browser UI. 824 // over the browser UI.
813 if (!window_->GetRootWindow()) { 825 if (!window_->GetRootWindow()) {
814 DCHECK(plugin_window_moves.empty()); 826 DCHECK(plugin_window_moves.empty());
815 return; 827 return;
816 } 828 }
817 HWND parent = window_->GetHost()->GetAcceleratedWidget(); 829 HWND parent = window_->GetHost()->GetAcceleratedWidget();
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 case blink::WebInputEvent::TouchCancel: 1288 case blink::WebInputEvent::TouchCancel:
1277 required_state = blink::WebTouchPoint::StateCancelled; 1289 required_state = blink::WebTouchPoint::StateCancelled;
1278 break; 1290 break;
1279 default: 1291 default:
1280 required_state = blink::WebTouchPoint::StateUndefined; 1292 required_state = blink::WebTouchPoint::StateUndefined;
1281 NOTREACHED(); 1293 NOTREACHED();
1282 break; 1294 break;
1283 } 1295 }
1284 1296
1285 // Only send acks for changed touches. 1297 // Only send acks for changed touches.
1286 for (size_t i = 0; i < touch.event.touchesLength; ++i) { 1298 for (size_t i = 0; i < touch.event.touchesLength; ++i) {
jdduke (slow) 2015/05/07 15:20:28 Should we be validating here that we only process
lanwei 2015/05/08 02:12:32 Done.
1287 if (touch.event.touches[i].state == required_state) 1299 if (touch.event.touches[i].state == required_state)
1288 host->dispatcher()->ProcessedTouchEvent(window_, result); 1300 host->dispatcher()->ProcessedTouchEvent(window_, result);
1289 } 1301 }
1290 } 1302 }
1291 1303
1292 scoped_ptr<SyntheticGestureTarget> 1304 scoped_ptr<SyntheticGestureTarget>
1293 RenderWidgetHostViewAura::CreateSyntheticGestureTarget() { 1305 RenderWidgetHostViewAura::CreateSyntheticGestureTarget() {
1294 return scoped_ptr<SyntheticGestureTarget>( 1306 return scoped_ptr<SyntheticGestureTarget>(
1295 new SyntheticGestureTargetAura(host_)); 1307 new SyntheticGestureTargetAura(host_));
1296 } 1308 }
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 2189
2178 blink::WebTouchEvent touch_event = ui::CreateWebTouchEventFromMotionEvent( 2190 blink::WebTouchEvent touch_event = ui::CreateWebTouchEventFromMotionEvent(
2179 pointer_state_, event->may_cause_scrolling()); 2191 pointer_state_, event->may_cause_scrolling());
2180 pointer_state_.CleanupRemovedTouchPoints(*event); 2192 pointer_state_.CleanupRemovedTouchPoints(*event);
2181 2193
2182 // It is important to always mark events as being handled asynchronously when 2194 // It is important to always mark events as being handled asynchronously when
2183 // they are forwarded. This ensures that the current event does not get 2195 // they are forwarded. This ensures that the current event does not get
2184 // processed by the gesture recognizer before events currently awaiting 2196 // processed by the gesture recognizer before events currently awaiting
2185 // dispatch in the touch queue. 2197 // dispatch in the touch queue.
2186 event->DisableSynchronousHandling(); 2198 event->DisableSynchronousHandling();
2199
2200 // Set unchange touch point to StateStationary for touchmove and
2201 // touchcancel to make sure only send one ack per WebTouchEvent.
2202 SetTouchPointStateStationary(&touch_event, event->touch_id());
2187 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); 2203 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency());
2188 } 2204 }
2189 2205
2190 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { 2206 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
2191 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); 2207 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent");
2192 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || 2208 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN ||
2193 event->type() == ui::ET_GESTURE_PINCH_UPDATE || 2209 event->type() == ui::ET_GESTURE_PINCH_UPDATE ||
2194 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { 2210 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) {
2195 event->SetHandled(); 2211 event->SetHandled();
2196 return; 2212 return;
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
2764 2780
2765 //////////////////////////////////////////////////////////////////////////////// 2781 ////////////////////////////////////////////////////////////////////////////////
2766 // RenderWidgetHostViewBase, public: 2782 // RenderWidgetHostViewBase, public:
2767 2783
2768 // static 2784 // static
2769 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2785 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2770 GetScreenInfoForWindow(results, NULL); 2786 GetScreenInfoForWindow(results, NULL);
2771 } 2787 }
2772 2788
2773 } // namespace content 2789 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698