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

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

Issue 2336803003: Make SyntheticPointerAction to flush the pointer action sequence (Closed)
Patch Set: pointer controller Created 4 years, 1 month 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_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <set> 9 #include <set>
10 #include <tuple> 10 #include <tuple>
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event, 1177 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event,
1178 latency_info); 1178 latency_info);
1179 key_event_with_latency.event.isBrowserShortcut = is_shortcut; 1179 key_event_with_latency.event.isBrowserShortcut = is_shortcut;
1180 DispatchInputEventWithLatencyInfo(key_event, &key_event_with_latency.latency); 1180 DispatchInputEventWithLatencyInfo(key_event, &key_event_with_latency.latency);
1181 input_router_->SendKeyboardEvent(key_event_with_latency); 1181 input_router_->SendKeyboardEvent(key_event_with_latency);
1182 } 1182 }
1183 1183
1184 void RenderWidgetHostImpl::QueueSyntheticGesture( 1184 void RenderWidgetHostImpl::QueueSyntheticGesture(
1185 std::unique_ptr<SyntheticGesture> synthetic_gesture, 1185 std::unique_ptr<SyntheticGesture> synthetic_gesture,
1186 const base::Callback<void(SyntheticGesture::Result)>& on_complete) { 1186 const base::Callback<void(SyntheticGesture::Result)>& on_complete) {
1187 if (!synthetic_gesture_controller_ && view_) { 1187 if (!synthetic_gesture_controller_) {
1188 synthetic_gesture_controller_.reset( 1188 if(!CreateSyntheticGestureController())
1189 new SyntheticGestureController(view_->CreateSyntheticGestureTarget())); 1189 return;
tdresser 2016/10/31 14:22:58 Should this ever happen? Should there be a CHECK o
lanwei 2016/12/04 18:08:02 Done.
1190 } 1190 }
1191 if (synthetic_gesture_controller_) { 1191
1192 synthetic_gesture_controller_->QueueSyntheticGesture( 1192 synthetic_gesture_controller_->QueueSyntheticGesture(
1193 std::move(synthetic_gesture), on_complete); 1193 std::move(synthetic_gesture), on_complete);
1194 }
1195 } 1194 }
1196 1195
1197 void RenderWidgetHostImpl::SetCursor(const WebCursor& cursor) { 1196 void RenderWidgetHostImpl::SetCursor(const WebCursor& cursor) {
1198 if (!view_) 1197 if (!view_)
1199 return; 1198 return;
1200 view_->UpdateCursor(cursor); 1199 view_->UpdateCursor(cursor);
1201 } 1200 }
1202 1201
1203 void RenderWidgetHostImpl::ShowContextMenuAtPoint(const gfx::Point& point) { 1202 void RenderWidgetHostImpl::ShowContextMenuAtPoint(const gfx::Point& point) {
1204 Send(new ViewMsg_ShowContextMenu( 1203 Send(new ViewMsg_ShowContextMenu(
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 void RenderWidgetHostImpl::OnQueueSyntheticGesture( 1738 void RenderWidgetHostImpl::OnQueueSyntheticGesture(
1740 const SyntheticGesturePacket& gesture_packet) { 1739 const SyntheticGesturePacket& gesture_packet) {
1741 // Only allow untrustworthy gestures if explicitly enabled. 1740 // Only allow untrustworthy gestures if explicitly enabled.
1742 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 1741 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
1743 cc::switches::kEnableGpuBenchmarking)) { 1742 cc::switches::kEnableGpuBenchmarking)) {
1744 bad_message::ReceivedBadMessage(GetProcess(), 1743 bad_message::ReceivedBadMessage(GetProcess(),
1745 bad_message::RWH_SYNTHETIC_GESTURE); 1744 bad_message::RWH_SYNTHETIC_GESTURE);
1746 return; 1745 return;
1747 } 1746 }
1748 1747
1748 if (!synthetic_gesture_controller_) {
1749 if(!CreateSyntheticGestureController())
1750 return;
tdresser 2016/10/31 14:22:58 Should this ever happen?
lanwei 2016/12/04 18:08:02 Done.
1751 }
1752 std::unique_ptr<SyntheticGesture> synthetic_gesture;
1753 const SyntheticGestureParams* gesture_params =
1754 gesture_packet.gesture_params();
1755 if (gesture_params->GetGestureType() ==
1756 SyntheticGestureParams::POINTER_ACTION_LIST) {
1757 synthetic_gesture =
1758 synthetic_gesture_controller_->CreateSyntheticPointerAction(
1759 *SyntheticPointerActionListParams::Cast(gesture_params));
1760 } else {
1761 synthetic_gesture = SyntheticGesture::Create(*gesture_params);
1762 }
1763
1749 QueueSyntheticGesture( 1764 QueueSyntheticGesture(
1750 SyntheticGesture::Create(*gesture_packet.gesture_params()), 1765 std::move(synthetic_gesture),
1751 base::Bind(&RenderWidgetHostImpl::OnSyntheticGestureCompleted, 1766 base::Bind(&RenderWidgetHostImpl::OnSyntheticGestureCompleted,
1752 weak_factory_.GetWeakPtr())); 1767 weak_factory_.GetWeakPtr()));
1753 } 1768 }
1754 1769
1755 void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) { 1770 void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) {
1756 SetCursor(cursor); 1771 SetCursor(cursor);
1757 } 1772 }
1758 1773
1759 void RenderWidgetHostImpl::SetTouchEventEmulationEnabled( 1774 void RenderWidgetHostImpl::SetTouchEventEmulationEnabled(
1760 bool enabled, ui::GestureProviderConfigType config_type) { 1775 bool enabled, ui::GestureProviderConfigType config_type) {
1761 if (enabled) { 1776 if (enabled) {
1762 if (!touch_emulator_) { 1777 if (!touch_emulator_) {
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
2185 2200
2186 void RenderWidgetHostImpl::OnSnapshotDataReceivedAsync( 2201 void RenderWidgetHostImpl::OnSnapshotDataReceivedAsync(
2187 int snapshot_id, 2202 int snapshot_id,
2188 scoped_refptr<base::RefCountedBytes> png_data) { 2203 scoped_refptr<base::RefCountedBytes> png_data) {
2189 if (png_data.get()) 2204 if (png_data.get())
2190 OnSnapshotDataReceived(snapshot_id, png_data->front(), png_data->size()); 2205 OnSnapshotDataReceived(snapshot_id, png_data->front(), png_data->size());
2191 else 2206 else
2192 OnSnapshotDataReceived(snapshot_id, NULL, 0); 2207 OnSnapshotDataReceived(snapshot_id, NULL, 0);
2193 } 2208 }
2194 2209
2210 bool RenderWidgetHostImpl::CreateSyntheticGestureController() {
2211 DCHECK(!synthetic_gesture_controller_);
2212
2213 if (!view_)
2214 return false;
2215
2216 synthetic_gesture_controller_.reset(
2217 new SyntheticGestureController(view_->CreateSyntheticGestureTarget()));
2218 return true;
2219 }
2220
2195 // static 2221 // static
2196 void RenderWidgetHostImpl::CompositorFrameDrawn( 2222 void RenderWidgetHostImpl::CompositorFrameDrawn(
2197 const std::vector<ui::LatencyInfo>& latency_info) { 2223 const std::vector<ui::LatencyInfo>& latency_info) {
2198 for (size_t i = 0; i < latency_info.size(); i++) { 2224 for (size_t i = 0; i < latency_info.size(); i++) {
2199 std::set<RenderWidgetHostImpl*> rwhi_set; 2225 std::set<RenderWidgetHostImpl*> rwhi_set;
2200 for (const auto& lc : latency_info[i].latency_components()) { 2226 for (const auto& lc : latency_info[i].latency_components()) {
2201 if (lc.first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || 2227 if (lc.first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT ||
2202 lc.first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT || 2228 lc.first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT ||
2203 lc.first.first == ui::TAB_SHOW_COMPONENT) { 2229 lc.first.first == ui::TAB_SHOW_COMPONENT) {
2204 // Matches with GetLatencyComponentId 2230 // Matches with GetLatencyComponentId
(...skipping 17 matching lines...) Expand all
2222 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; 2248 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL;
2223 } 2249 }
2224 2250
2225 BrowserAccessibilityManager* 2251 BrowserAccessibilityManager*
2226 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { 2252 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() {
2227 return delegate_ ? 2253 return delegate_ ?
2228 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; 2254 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL;
2229 } 2255 }
2230 2256
2231 } // namespace content 2257 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698