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

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: 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::MarkUnchangedTouchPointsAsStationary(
809 blink::WebTouchEvent* event,
810 int changed_touch_id) {
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 != changed_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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 break; 1287 break;
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 one changed touch point.
1298 bool sent_ack = false;
1286 for (size_t i = 0; i < touch.event.touchesLength; ++i) { 1299 for (size_t i = 0; i < touch.event.touchesLength; ++i) {
1287 if (touch.event.touches[i].state == required_state) 1300 if (touch.event.touches[i].state == required_state) {
1301 DCHECK(!sent_ack);
1288 host->dispatcher()->ProcessedTouchEvent(window_, result); 1302 host->dispatcher()->ProcessedTouchEvent(window_, result);
1303 sent_ack = true;
1304 }
1289 } 1305 }
1290 } 1306 }
1291 1307
1292 scoped_ptr<SyntheticGestureTarget> 1308 scoped_ptr<SyntheticGestureTarget>
1293 RenderWidgetHostViewAura::CreateSyntheticGestureTarget() { 1309 RenderWidgetHostViewAura::CreateSyntheticGestureTarget() {
1294 return scoped_ptr<SyntheticGestureTarget>( 1310 return scoped_ptr<SyntheticGestureTarget>(
1295 new SyntheticGestureTargetAura(host_)); 1311 new SyntheticGestureTargetAura(host_));
1296 } 1312 }
1297 1313
1298 InputEventAckState RenderWidgetHostViewAura::FilterInputEvent( 1314 InputEventAckState RenderWidgetHostViewAura::FilterInputEvent(
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 2193
2178 blink::WebTouchEvent touch_event = ui::CreateWebTouchEventFromMotionEvent( 2194 blink::WebTouchEvent touch_event = ui::CreateWebTouchEventFromMotionEvent(
2179 pointer_state_, event->may_cause_scrolling()); 2195 pointer_state_, event->may_cause_scrolling());
2180 pointer_state_.CleanupRemovedTouchPoints(*event); 2196 pointer_state_.CleanupRemovedTouchPoints(*event);
2181 2197
2182 // It is important to always mark events as being handled asynchronously when 2198 // 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 2199 // they are forwarded. This ensures that the current event does not get
2184 // processed by the gesture recognizer before events currently awaiting 2200 // processed by the gesture recognizer before events currently awaiting
2185 // dispatch in the touch queue. 2201 // dispatch in the touch queue.
2186 event->DisableSynchronousHandling(); 2202 event->DisableSynchronousHandling();
2203
2204 // Set unchange touch point to StateStationary for touchmove and
2205 // touchcancel to make sure only send one ack per WebTouchEvent.
2206 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id());
2187 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); 2207 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency());
2188 } 2208 }
2189 2209
2190 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { 2210 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
2191 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); 2211 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent");
2192 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || 2212 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN ||
2193 event->type() == ui::ET_GESTURE_PINCH_UPDATE || 2213 event->type() == ui::ET_GESTURE_PINCH_UPDATE ||
2194 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { 2214 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) {
2195 event->SetHandled(); 2215 event->SetHandled();
2196 return; 2216 return;
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
2764 2784
2765 //////////////////////////////////////////////////////////////////////////////// 2785 ////////////////////////////////////////////////////////////////////////////////
2766 // RenderWidgetHostViewBase, public: 2786 // RenderWidgetHostViewBase, public:
2767 2787
2768 // static 2788 // static
2769 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2789 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2770 GetScreenInfoForWindow(results, NULL); 2790 GetScreenInfoForWindow(results, NULL);
2771 } 2791 }
2772 2792
2773 } // namespace content 2793 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698