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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 #include "ui/base/ui_base_switches.h" | 77 #include "ui/base/ui_base_switches.h" |
78 #include "ui/gfx/geometry/point_conversions.h" | 78 #include "ui/gfx/geometry/point_conversions.h" |
79 #include "ui/gfx/geometry/rect_conversions.h" | 79 #include "ui/gfx/geometry/rect_conversions.h" |
80 #include "ui/gfx/geometry/size_conversions.h" | 80 #include "ui/gfx/geometry/size_conversions.h" |
81 #include "ui/gfx/skia_util.h" | 81 #include "ui/gfx/skia_util.h" |
82 #include "ui/gl/gl_switches.h" | 82 #include "ui/gl/gl_switches.h" |
83 #include "ui/surface/transport_dib.h" | 83 #include "ui/surface/transport_dib.h" |
84 | 84 |
85 #if defined(OS_ANDROID) | 85 #if defined(OS_ANDROID) |
86 #include <android/keycodes.h> | 86 #include <android/keycodes.h> |
| 87 #include "base/time/time.h" |
87 #endif | 88 #endif |
88 | 89 |
89 #if defined(OS_POSIX) | 90 #if defined(OS_POSIX) |
90 #include "ipc/ipc_channel_posix.h" | 91 #include "ipc/ipc_channel_posix.h" |
91 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 92 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
92 #include "third_party/skia/include/core/SkPixelRef.h" | 93 #include "third_party/skia/include/core/SkPixelRef.h" |
93 #endif // defined(OS_POSIX) | 94 #endif // defined(OS_POSIX) |
94 | 95 |
95 #if defined(USE_AURA) | 96 #if defined(USE_AURA) |
96 #include "content/public/common/service_manager_connection.h" | 97 #include "content/public/common/service_manager_connection.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // Check the mode is in the range representable by ui::TextInputMode. | 193 // Check the mode is in the range representable by ui::TextInputMode. |
193 DCHECK_LE(mode, static_cast<int>(ui::TEXT_INPUT_MODE_MAX)) | 194 DCHECK_LE(mode, static_cast<int>(ui::TEXT_INPUT_MODE_MAX)) |
194 << "blink::WebTextInputMode and ui::TextInputMode not synchronized"; | 195 << "blink::WebTextInputMode and ui::TextInputMode not synchronized"; |
195 return static_cast<ui::TextInputMode>(mode); | 196 return static_cast<ui::TextInputMode>(mode); |
196 } | 197 } |
197 | 198 |
198 } // namespace | 199 } // namespace |
199 | 200 |
200 namespace content { | 201 namespace content { |
201 | 202 |
| 203 #if defined(OS_ANDROID) |
| 204 // Delay between tapping in content and launching the associated android intent. |
| 205 // Used to allow users see what has been recognized as content. |
| 206 constexpr base::TimeDelta kContentIntentDelay = |
| 207 base::TimeDelta::FromMilliseconds(700); |
| 208 #endif |
| 209 |
202 // RenderWidget --------------------------------------------------------------- | 210 // RenderWidget --------------------------------------------------------------- |
203 | 211 |
204 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, | 212 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, |
205 blink::WebPopupType popup_type, | 213 blink::WebPopupType popup_type, |
206 const ScreenInfo& screen_info, | 214 const ScreenInfo& screen_info, |
207 bool swapped_out, | 215 bool swapped_out, |
208 bool hidden, | 216 bool hidden, |
209 bool never_visible) | 217 bool never_visible) |
210 : routing_id_(MSG_ROUTING_NONE), | 218 : routing_id_(MSG_ROUTING_NONE), |
211 compositor_deps_(compositor_deps), | 219 compositor_deps_(compositor_deps), |
(...skipping 23 matching lines...) Expand all Loading... |
235 screen_info_(screen_info), | 243 screen_info_(screen_info), |
236 device_scale_factor_(screen_info_.device_scale_factor), | 244 device_scale_factor_(screen_info_.device_scale_factor), |
237 #if defined(OS_ANDROID) | 245 #if defined(OS_ANDROID) |
238 text_field_is_dirty_(false), | 246 text_field_is_dirty_(false), |
239 #endif | 247 #endif |
240 monitor_composition_info_(false), | 248 monitor_composition_info_(false), |
241 popup_origin_scale_for_emulation_(0.f), | 249 popup_origin_scale_for_emulation_(0.f), |
242 frame_swap_message_queue_(new FrameSwapMessageQueue()), | 250 frame_swap_message_queue_(new FrameSwapMessageQueue()), |
243 resizing_mode_selector_(new ResizingModeSelector()), | 251 resizing_mode_selector_(new ResizingModeSelector()), |
244 has_host_context_menu_location_(false), | 252 has_host_context_menu_location_(false), |
| 253 has_added_input_handler_(false), |
245 has_focus_(false), | 254 has_focus_(false), |
246 #if defined(OS_MACOSX) | 255 #if defined(OS_MACOSX) |
247 text_input_client_observer_(new TextInputClientObserver(this)), | 256 text_input_client_observer_(new TextInputClientObserver(this)), |
248 #endif | 257 #endif |
249 focused_pepper_plugin_(nullptr) { | 258 focused_pepper_plugin_(nullptr), |
| 259 weak_ptr_factory_(this) { |
250 if (!swapped_out) | 260 if (!swapped_out) |
251 RenderProcess::current()->AddRefProcess(); | 261 RenderProcess::current()->AddRefProcess(); |
252 DCHECK(RenderThread::Get()); | 262 DCHECK(RenderThread::Get()); |
253 device_color_profile_.push_back('0'); | 263 device_color_profile_.push_back('0'); |
254 #if defined(OS_ANDROID) | 264 #if defined(OS_ANDROID) |
255 text_input_info_history_.push_back(blink::WebTextInputInfo()); | 265 text_input_info_history_.push_back(blink::WebTextInputInfo()); |
256 #endif | 266 #endif |
257 | 267 |
258 // In tests there may not be a RenderThreadImpl. | 268 // In tests there may not be a RenderThreadImpl. |
259 if (RenderThreadImpl::current()) { | 269 if (RenderThreadImpl::current()) { |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 compositor_deps_); | 1118 compositor_deps_); |
1109 compositor_->setViewportSize(physical_backing_size_); | 1119 compositor_->setViewportSize(physical_backing_size_); |
1110 OnDeviceScaleFactorChanged(); | 1120 OnDeviceScaleFactorChanged(); |
1111 compositor_->SetDeviceColorSpace(screen_info_.icc_profile.GetColorSpace()); | 1121 compositor_->SetDeviceColorSpace(screen_info_.icc_profile.GetColorSpace()); |
1112 // For background pages and certain tests, we don't want to trigger | 1122 // For background pages and certain tests, we don't want to trigger |
1113 // CompositorFrameSink creation. | 1123 // CompositorFrameSink creation. |
1114 if (compositor_never_visible_ || !RenderThreadImpl::current()) | 1124 if (compositor_never_visible_ || !RenderThreadImpl::current()) |
1115 compositor_->SetNeverVisible(); | 1125 compositor_->SetNeverVisible(); |
1116 | 1126 |
1117 StartCompositor(); | 1127 StartCompositor(); |
| 1128 |
| 1129 bool use_threaded_event_handling = true; |
| 1130 #if defined(OS_MACOSX) |
| 1131 // Disable threaded event handling if content is not handling the elastic |
| 1132 // overscroll effect. This includes the cases where the elastic overscroll |
| 1133 // effect is being handled by Blink (because of command line flags) and older |
| 1134 // operating system versions which do not have an elastic overscroll effect |
| 1135 // (SnowLeopard, which has Aqua scrollbars which need synchronous updates). |
| 1136 use_threaded_event_handling = compositor_deps_->IsElasticOverscrollEnabled(); |
| 1137 #endif |
| 1138 if (!use_threaded_event_handling) |
| 1139 return; |
| 1140 |
| 1141 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 1142 // render_thread may be NULL in tests. |
| 1143 InputHandlerManager* input_handler_manager = |
| 1144 render_thread ? render_thread->input_handler_manager() : NULL; |
| 1145 if (input_handler_manager) { |
| 1146 input_handler_manager->AddInputHandler( |
| 1147 routing_id_, compositor()->GetInputHandler(), |
| 1148 weak_ptr_factory_.GetWeakPtr(), |
| 1149 compositor_deps_->IsScrollAnimatorEnabled()); |
| 1150 has_added_input_handler_ = true; |
| 1151 } |
1118 } | 1152 } |
1119 | 1153 |
1120 void RenderWidget::WillCloseLayerTreeView() { | 1154 void RenderWidget::WillCloseLayerTreeView() { |
1121 if (host_closing_) | 1155 if (host_closing_) |
1122 return; | 1156 return; |
1123 | 1157 |
1124 // Prevent new compositors or output surfaces from being created. | 1158 // Prevent new compositors or output surfaces from being created. |
1125 host_closing_ = true; | 1159 host_closing_ = true; |
1126 | 1160 |
1127 // Always send this notification to prevent new layer tree views from | 1161 // Always send this notification to prevent new layer tree views from |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 void RenderWidget::OnImeEventAck() { | 1632 void RenderWidget::OnImeEventAck() { |
1599 DCHECK_GE(text_input_info_history_.size(), 1u); | 1633 DCHECK_GE(text_input_info_history_.size(), 1u); |
1600 text_input_info_history_.pop_front(); | 1634 text_input_info_history_.pop_front(); |
1601 } | 1635 } |
1602 | 1636 |
1603 void RenderWidget::OnRequestTextInputStateUpdate() { | 1637 void RenderWidget::OnRequestTextInputStateUpdate() { |
1604 DCHECK(!ime_event_guard_); | 1638 DCHECK(!ime_event_guard_); |
1605 UpdateSelectionBounds(); | 1639 UpdateSelectionBounds(); |
1606 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME); | 1640 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME); |
1607 } | 1641 } |
| 1642 |
| 1643 void RenderWidget::scheduleContentIntentForRenderView( |
| 1644 const blink::WebURL& intent, |
| 1645 bool is_main_frame, |
| 1646 size_t expected_content_intent_id) { |
| 1647 // Introduce a short delay so that the user can notice the content. |
| 1648 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 1649 FROM_HERE, base::Bind(&RenderWidget::LaunchAndroidContentIntent, |
| 1650 weak_ptr_factory_.GetWeakPtr(), intent, |
| 1651 expected_content_intent_id, is_main_frame), |
| 1652 kContentIntentDelay); |
| 1653 } |
1608 #endif | 1654 #endif |
1609 | 1655 |
1610 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request, | 1656 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request, |
1611 bool monitor_request) { | 1657 bool monitor_request) { |
1612 monitor_composition_info_ = monitor_request; | 1658 monitor_composition_info_ = monitor_request; |
1613 if (!immediate_request) | 1659 if (!immediate_request) |
1614 return; | 1660 return; |
1615 UpdateCompositionInfo(true /* immediate request */); | 1661 UpdateCompositionInfo(true /* immediate request */); |
1616 } | 1662 } |
1617 | 1663 |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2067 bool RenderWidget::isPointerLocked() { | 2113 bool RenderWidget::isPointerLocked() { |
2068 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2114 return mouse_lock_dispatcher_->IsMouseLockedTo( |
2069 webwidget_mouse_lock_target_.get()); | 2115 webwidget_mouse_lock_target_.get()); |
2070 } | 2116 } |
2071 | 2117 |
2072 blink::WebWidget* RenderWidget::GetWebWidget() const { | 2118 blink::WebWidget* RenderWidget::GetWebWidget() const { |
2073 return webwidget_internal_; | 2119 return webwidget_internal_; |
2074 } | 2120 } |
2075 | 2121 |
2076 } // namespace content | 2122 } // namespace content |
OLD | NEW |