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 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 switches::kDisableHangMonitor)) { | 234 switches::kDisableHangMonitor)) { |
235 hang_monitor_timeout_.reset(new TimeoutMonitor( | 235 hang_monitor_timeout_.reset(new TimeoutMonitor( |
236 base::Bind(&RenderWidgetHostImpl::RendererIsUnresponsive, | 236 base::Bind(&RenderWidgetHostImpl::RendererIsUnresponsive, |
237 weak_factory_.GetWeakPtr()))); | 237 weak_factory_.GetWeakPtr()))); |
238 } | 238 } |
239 | 239 |
240 new_content_rendering_timeout_.reset(new TimeoutMonitor( | 240 new_content_rendering_timeout_.reset(new TimeoutMonitor( |
241 base::Bind(&RenderWidgetHostImpl::ClearDisplayedGraphics, | 241 base::Bind(&RenderWidgetHostImpl::ClearDisplayedGraphics, |
242 weak_factory_.GetWeakPtr()))); | 242 weak_factory_.GetWeakPtr()))); |
243 | 243 |
244 for (size_t i = 0; i < arraysize(index_map_); ++i) | |
245 index_map_[i] = -1; | |
246 | |
244 delegate_->RenderWidgetCreated(this); | 247 delegate_->RenderWidgetCreated(this); |
245 } | 248 } |
246 | 249 |
247 RenderWidgetHostImpl::~RenderWidgetHostImpl() { | 250 RenderWidgetHostImpl::~RenderWidgetHostImpl() { |
248 if (!destroyed_) | 251 if (!destroyed_) |
249 Destroy(false); | 252 Destroy(false); |
250 } | 253 } |
251 | 254 |
252 // static | 255 // static |
253 RenderWidgetHost* RenderWidgetHost::FromID( | 256 RenderWidgetHost* RenderWidgetHost::FromID( |
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1693 void RenderWidgetHostImpl::OnQueueSyntheticGesture( | 1696 void RenderWidgetHostImpl::OnQueueSyntheticGesture( |
1694 const SyntheticGesturePacket& gesture_packet) { | 1697 const SyntheticGesturePacket& gesture_packet) { |
1695 // Only allow untrustworthy gestures if explicitly enabled. | 1698 // Only allow untrustworthy gestures if explicitly enabled. |
1696 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 1699 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
1697 cc::switches::kEnableGpuBenchmarking)) { | 1700 cc::switches::kEnableGpuBenchmarking)) { |
1698 bad_message::ReceivedBadMessage(GetProcess(), | 1701 bad_message::ReceivedBadMessage(GetProcess(), |
1699 bad_message::RWH_SYNTHETIC_GESTURE); | 1702 bad_message::RWH_SYNTHETIC_GESTURE); |
1700 return; | 1703 return; |
1701 } | 1704 } |
1702 | 1705 |
1706 if (gesture_packet.gesture_params()->GetGestureType() == | |
1707 SyntheticGestureParams::POINTER_ACTION) { | |
1708 QueueSyntheticPointerAction( | |
1709 *SyntheticPointerActionParams::Cast(gesture_packet.gesture_params())); | |
1710 return; | |
1711 } | |
1712 | |
1703 QueueSyntheticGesture( | 1713 QueueSyntheticGesture( |
1704 SyntheticGesture::Create(*gesture_packet.gesture_params()), | 1714 SyntheticGesture::Create(*gesture_packet.gesture_params()), |
1705 base::Bind(&RenderWidgetHostImpl::OnSyntheticGestureCompleted, | 1715 base::Bind(&RenderWidgetHostImpl::OnSyntheticGestureCompleted, |
1706 weak_factory_.GetWeakPtr())); | 1716 weak_factory_.GetWeakPtr())); |
1707 } | 1717 } |
1708 | 1718 |
1719 void RenderWidgetHostImpl::QueueSyntheticPointerAction( | |
tdresser
2016/04/18 15:24:39
We'd prefer to have this logic encapsulated within
lanwei
2016/04/19 19:05:32
No, you are right, I will move this part related t
| |
1720 const SyntheticPointerActionParams& gesture_params) { | |
1721 if (gesture_params.pointer_action_type() == | |
1722 SyntheticPointerActionParams::PointerActionType::PROCESS) { | |
1723 if (!synthetic_gesture_controller_ && view_) { | |
1724 synthetic_gesture_controller_.reset(new SyntheticGestureController( | |
1725 view_->CreateSyntheticGestureTarget())); | |
1726 } | |
1727 if (synthetic_gesture_controller_) { | |
1728 // Todo(lanwei@): Should check if type is pointer, make sure | |
1729 // synthetic_pointer_ is not null. | |
1730 DCHECK(gesture_params.pointer_action_type() != | |
1731 SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED); | |
1732 | |
1733 if (!synthetic_pointer_) | |
1734 SetSyntheticPointer(gesture_params); | |
1735 | |
1736 QueueSyntheticGesture( | |
1737 std::unique_ptr<SyntheticGesture>(new SyntheticPointerAction( | |
1738 action_param_list_, synthetic_pointer_.get(), index_map_)), | |
1739 base::Bind(&RenderWidgetHostImpl::OnSyntheticPointerActionCompleted, | |
1740 weak_factory_.GetWeakPtr())); | |
1741 } | |
1742 action_param_list_.clear(); | |
1743 return; | |
1744 } | |
1745 | |
1746 action_param_list_.push_back(gesture_params); | |
1747 } | |
1748 | |
1749 void RenderWidgetHostImpl::SetSyntheticPointer( | |
1750 const SyntheticPointerActionParams& gesture_params) { | |
1751 SyntheticGestureParams::GestureSourceType gesture_source_type = | |
1752 gesture_params.gesture_source_type; | |
1753 if (gesture_source_type == SyntheticGestureParams::DEFAULT_INPUT) { | |
1754 if (synthetic_gesture_controller_) { | |
1755 gesture_source_type = | |
1756 synthetic_gesture_controller_->GetDefaultSyntheticGestureSourceType(); | |
1757 DCHECK_NE(gesture_source_type, SyntheticGestureParams::DEFAULT_INPUT); | |
1758 synthetic_pointer_ = SyntheticPointer::Create(gesture_source_type); | |
1759 } | |
1760 } | |
1761 } | |
1762 | |
1709 void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) { | 1763 void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) { |
1710 SetCursor(cursor); | 1764 SetCursor(cursor); |
1711 } | 1765 } |
1712 | 1766 |
1713 void RenderWidgetHostImpl::SetTouchEventEmulationEnabled( | 1767 void RenderWidgetHostImpl::SetTouchEventEmulationEnabled( |
1714 bool enabled, ui::GestureProviderConfigType config_type) { | 1768 bool enabled, ui::GestureProviderConfigType config_type) { |
1715 if (enabled) { | 1769 if (enabled) { |
1716 if (!touch_emulator_) { | 1770 if (!touch_emulator_) { |
1717 touch_emulator_.reset(new TouchEmulator( | 1771 touch_emulator_.reset(new TouchEmulator( |
1718 this, | 1772 this, |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1955 if (type == BAD_ACK_MESSAGE) { | 2009 if (type == BAD_ACK_MESSAGE) { |
1956 bad_message::ReceivedBadMessage(process_, bad_message::RWH_BAD_ACK_MESSAGE); | 2010 bad_message::ReceivedBadMessage(process_, bad_message::RWH_BAD_ACK_MESSAGE); |
1957 } else if (type == UNEXPECTED_EVENT_TYPE) { | 2011 } else if (type == UNEXPECTED_EVENT_TYPE) { |
1958 suppress_next_char_events_ = false; | 2012 suppress_next_char_events_ = false; |
1959 } | 2013 } |
1960 } | 2014 } |
1961 | 2015 |
1962 void RenderWidgetHostImpl::OnSyntheticGestureCompleted( | 2016 void RenderWidgetHostImpl::OnSyntheticGestureCompleted( |
1963 SyntheticGesture::Result result) { | 2017 SyntheticGesture::Result result) { |
1964 Send(new InputMsg_SyntheticGestureCompleted(GetRoutingID())); | 2018 Send(new InputMsg_SyntheticGestureCompleted(GetRoutingID())); |
2019 synthetic_pointer_.reset(nullptr); | |
2020 ; | |
2021 } | |
2022 | |
2023 void RenderWidgetHostImpl::OnSyntheticPointerActionCompleted( | |
2024 SyntheticGesture::Result result) { | |
2025 // Do nothing | |
1965 } | 2026 } |
1966 | 2027 |
1967 bool RenderWidgetHostImpl::ShouldDropInputEvents() const { | 2028 bool RenderWidgetHostImpl::ShouldDropInputEvents() const { |
1968 return ignore_input_events_ || process_->IgnoreInputEvents() || !delegate_; | 2029 return ignore_input_events_ || process_->IgnoreInputEvents() || !delegate_; |
1969 } | 2030 } |
1970 | 2031 |
1971 void RenderWidgetHostImpl::SetBackgroundOpaque(bool opaque) { | 2032 void RenderWidgetHostImpl::SetBackgroundOpaque(bool opaque) { |
1972 Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque)); | 2033 Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque)); |
1973 } | 2034 } |
1974 | 2035 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2163 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | 2224 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
2164 } | 2225 } |
2165 | 2226 |
2166 BrowserAccessibilityManager* | 2227 BrowserAccessibilityManager* |
2167 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2228 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
2168 return delegate_ ? | 2229 return delegate_ ? |
2169 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2230 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
2170 } | 2231 } |
2171 | 2232 |
2172 } // namespace content | 2233 } // namespace content |
OLD | NEW |