Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 SetSyntheticGestureController(); |
|
tdresser
2016/10/26 18:28:40
We call SetSyntheticGestureController before we ev
lanwei
2016/10/30 23:23:13
Yes, there are some other places which also call t
| |
| 1188 synthetic_gesture_controller_.reset( | |
| 1189 new SyntheticGestureController(view_->CreateSyntheticGestureTarget())); | |
| 1190 } | |
| 1191 if (synthetic_gesture_controller_) { | 1188 if (synthetic_gesture_controller_) { |
| 1192 synthetic_gesture_controller_->QueueSyntheticGesture( | 1189 synthetic_gesture_controller_->QueueSyntheticGesture( |
| 1193 std::move(synthetic_gesture), on_complete); | 1190 std::move(synthetic_gesture), on_complete); |
| 1194 } | 1191 } |
| 1195 } | 1192 } |
| 1196 | 1193 |
| 1197 void RenderWidgetHostImpl::SetCursor(const WebCursor& cursor) { | 1194 void RenderWidgetHostImpl::SetCursor(const WebCursor& cursor) { |
| 1198 if (!view_) | 1195 if (!view_) |
| 1199 return; | 1196 return; |
| 1200 view_->UpdateCursor(cursor); | 1197 view_->UpdateCursor(cursor); |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1739 void RenderWidgetHostImpl::OnQueueSyntheticGesture( | 1736 void RenderWidgetHostImpl::OnQueueSyntheticGesture( |
| 1740 const SyntheticGesturePacket& gesture_packet) { | 1737 const SyntheticGesturePacket& gesture_packet) { |
| 1741 // Only allow untrustworthy gestures if explicitly enabled. | 1738 // Only allow untrustworthy gestures if explicitly enabled. |
| 1742 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 1739 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1743 cc::switches::kEnableGpuBenchmarking)) { | 1740 cc::switches::kEnableGpuBenchmarking)) { |
| 1744 bad_message::ReceivedBadMessage(GetProcess(), | 1741 bad_message::ReceivedBadMessage(GetProcess(), |
| 1745 bad_message::RWH_SYNTHETIC_GESTURE); | 1742 bad_message::RWH_SYNTHETIC_GESTURE); |
| 1746 return; | 1743 return; |
| 1747 } | 1744 } |
| 1748 | 1745 |
| 1746 SetSyntheticGestureController(); | |
| 1747 std::unique_ptr<SyntheticGesture> synthetic_gesture; | |
| 1748 const SyntheticGestureParams* gesture_params = | |
| 1749 gesture_packet.gesture_params(); | |
| 1750 if (gesture_params->GetGestureType() == | |
| 1751 SyntheticGestureParams::POINTER_ACTION_LIST) { | |
| 1752 synthetic_gesture = | |
| 1753 synthetic_gesture_controller_->CreateSyntheticPointerAction( | |
| 1754 *SyntheticPointerActionListParams::Cast(gesture_params)); | |
| 1755 } else { | |
| 1756 synthetic_gesture = SyntheticGesture::Create(*gesture_params); | |
| 1757 } | |
| 1758 | |
| 1749 QueueSyntheticGesture( | 1759 QueueSyntheticGesture( |
| 1750 SyntheticGesture::Create(*gesture_packet.gesture_params()), | 1760 std::move(synthetic_gesture), |
| 1751 base::Bind(&RenderWidgetHostImpl::OnSyntheticGestureCompleted, | 1761 base::Bind(&RenderWidgetHostImpl::OnSyntheticGestureCompleted, |
| 1752 weak_factory_.GetWeakPtr())); | 1762 weak_factory_.GetWeakPtr())); |
| 1753 } | 1763 } |
| 1754 | 1764 |
| 1755 void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) { | 1765 void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) { |
| 1756 SetCursor(cursor); | 1766 SetCursor(cursor); |
| 1757 } | 1767 } |
| 1758 | 1768 |
| 1759 void RenderWidgetHostImpl::SetTouchEventEmulationEnabled( | 1769 void RenderWidgetHostImpl::SetTouchEventEmulationEnabled( |
| 1760 bool enabled, ui::GestureProviderConfigType config_type) { | 1770 bool enabled, ui::GestureProviderConfigType config_type) { |
| 1761 if (enabled) { | 1771 if (enabled) { |
| 1762 if (!touch_emulator_) { | 1772 if (!touch_emulator_) { |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2185 | 2195 |
| 2186 void RenderWidgetHostImpl::OnSnapshotDataReceivedAsync( | 2196 void RenderWidgetHostImpl::OnSnapshotDataReceivedAsync( |
| 2187 int snapshot_id, | 2197 int snapshot_id, |
| 2188 scoped_refptr<base::RefCountedBytes> png_data) { | 2198 scoped_refptr<base::RefCountedBytes> png_data) { |
| 2189 if (png_data.get()) | 2199 if (png_data.get()) |
| 2190 OnSnapshotDataReceived(snapshot_id, png_data->front(), png_data->size()); | 2200 OnSnapshotDataReceived(snapshot_id, png_data->front(), png_data->size()); |
| 2191 else | 2201 else |
| 2192 OnSnapshotDataReceived(snapshot_id, NULL, 0); | 2202 OnSnapshotDataReceived(snapshot_id, NULL, 0); |
| 2193 } | 2203 } |
| 2194 | 2204 |
| 2205 void RenderWidgetHostImpl::SetSyntheticGestureController() { | |
|
tdresser
2016/10/26 18:28:40
This method is confusing. Should it be called Crea
lanwei
2016/10/30 23:23:13
Done.
| |
| 2206 if (synthetic_gesture_controller_ || !view_) | |
| 2207 return; | |
| 2208 | |
| 2209 synthetic_gesture_controller_.reset( | |
| 2210 new SyntheticGestureController(view_->CreateSyntheticGestureTarget())); | |
| 2211 } | |
| 2212 | |
| 2195 // static | 2213 // static |
| 2196 void RenderWidgetHostImpl::CompositorFrameDrawn( | 2214 void RenderWidgetHostImpl::CompositorFrameDrawn( |
| 2197 const std::vector<ui::LatencyInfo>& latency_info) { | 2215 const std::vector<ui::LatencyInfo>& latency_info) { |
| 2198 for (size_t i = 0; i < latency_info.size(); i++) { | 2216 for (size_t i = 0; i < latency_info.size(); i++) { |
| 2199 std::set<RenderWidgetHostImpl*> rwhi_set; | 2217 std::set<RenderWidgetHostImpl*> rwhi_set; |
| 2200 for (const auto& lc : latency_info[i].latency_components()) { | 2218 for (const auto& lc : latency_info[i].latency_components()) { |
| 2201 if (lc.first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || | 2219 if (lc.first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || |
| 2202 lc.first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT || | 2220 lc.first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT || |
| 2203 lc.first.first == ui::TAB_SHOW_COMPONENT) { | 2221 lc.first.first == ui::TAB_SHOW_COMPONENT) { |
| 2204 // Matches with GetLatencyComponentId | 2222 // Matches with GetLatencyComponentId |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 2222 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | 2240 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
| 2223 } | 2241 } |
| 2224 | 2242 |
| 2225 BrowserAccessibilityManager* | 2243 BrowserAccessibilityManager* |
| 2226 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2244 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
| 2227 return delegate_ ? | 2245 return delegate_ ? |
| 2228 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2246 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
| 2229 } | 2247 } |
| 2230 | 2248 |
| 2231 } // namespace content | 2249 } // namespace content |
| OLD | NEW |