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 const size_t kContentIntentDelayMilliseconds = 700; | |
dcheng
2016/11/04 21:00:02
constexpr base::TimeDelta kContentIntentDelay = ba
wjmaclean
2016/11/07 15:57:27
Done.
| |
207 #endif | |
208 | |
202 // RenderWidget --------------------------------------------------------------- | 209 // RenderWidget --------------------------------------------------------------- |
203 | 210 |
204 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, | 211 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, |
205 blink::WebPopupType popup_type, | 212 blink::WebPopupType popup_type, |
206 const ScreenInfo& screen_info, | 213 const ScreenInfo& screen_info, |
207 bool swapped_out, | 214 bool swapped_out, |
208 bool hidden, | 215 bool hidden, |
209 bool never_visible) | 216 bool never_visible) |
210 : routing_id_(MSG_ROUTING_NONE), | 217 : routing_id_(MSG_ROUTING_NONE), |
211 compositor_deps_(compositor_deps), | 218 compositor_deps_(compositor_deps), |
(...skipping 23 matching lines...) Expand all Loading... | |
235 screen_info_(screen_info), | 242 screen_info_(screen_info), |
236 device_scale_factor_(screen_info_.device_scale_factor), | 243 device_scale_factor_(screen_info_.device_scale_factor), |
237 #if defined(OS_ANDROID) | 244 #if defined(OS_ANDROID) |
238 text_field_is_dirty_(false), | 245 text_field_is_dirty_(false), |
239 #endif | 246 #endif |
240 monitor_composition_info_(false), | 247 monitor_composition_info_(false), |
241 popup_origin_scale_for_emulation_(0.f), | 248 popup_origin_scale_for_emulation_(0.f), |
242 frame_swap_message_queue_(new FrameSwapMessageQueue()), | 249 frame_swap_message_queue_(new FrameSwapMessageQueue()), |
243 resizing_mode_selector_(new ResizingModeSelector()), | 250 resizing_mode_selector_(new ResizingModeSelector()), |
244 has_host_context_menu_location_(false), | 251 has_host_context_menu_location_(false), |
252 has_added_input_handler_(false), | |
245 has_focus_(false), | 253 has_focus_(false), |
246 #if defined(OS_MACOSX) | 254 #if defined(OS_MACOSX) |
247 text_input_client_observer_(new TextInputClientObserver(this)), | 255 text_input_client_observer_(new TextInputClientObserver(this)), |
248 #endif | 256 #endif |
249 focused_pepper_plugin_(nullptr) { | 257 focused_pepper_plugin_(nullptr) { |
250 if (!swapped_out) | 258 if (!swapped_out) |
251 RenderProcess::current()->AddRefProcess(); | 259 RenderProcess::current()->AddRefProcess(); |
252 DCHECK(RenderThread::Get()); | 260 DCHECK(RenderThread::Get()); |
253 device_color_profile_.push_back('0'); | 261 device_color_profile_.push_back('0'); |
254 #if defined(OS_ANDROID) | 262 #if defined(OS_ANDROID) |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1108 compositor_deps_); | 1116 compositor_deps_); |
1109 compositor_->setViewportSize(physical_backing_size_); | 1117 compositor_->setViewportSize(physical_backing_size_); |
1110 OnDeviceScaleFactorChanged(); | 1118 OnDeviceScaleFactorChanged(); |
1111 compositor_->SetDeviceColorSpace(screen_info_.icc_profile.GetColorSpace()); | 1119 compositor_->SetDeviceColorSpace(screen_info_.icc_profile.GetColorSpace()); |
1112 // For background pages and certain tests, we don't want to trigger | 1120 // For background pages and certain tests, we don't want to trigger |
1113 // CompositorFrameSink creation. | 1121 // CompositorFrameSink creation. |
1114 if (compositor_never_visible_ || !RenderThreadImpl::current()) | 1122 if (compositor_never_visible_ || !RenderThreadImpl::current()) |
1115 compositor_->SetNeverVisible(); | 1123 compositor_->SetNeverVisible(); |
1116 | 1124 |
1117 StartCompositor(); | 1125 StartCompositor(); |
1126 | |
1127 bool use_threaded_event_handling = true; | |
1128 #if defined(OS_MACOSX) | |
1129 // Disable threaded event handling if content is not handling the elastic | |
1130 // overscroll effect. This includes the cases where the elastic overscroll | |
1131 // effect is being handled by Blink (because of command line flags) and older | |
1132 // operating system versions which do not have an elastic overscroll effect | |
1133 // (SnowLeopard, which has Aqua scrollbars which need synchronous updates). | |
1134 use_threaded_event_handling = compositor_deps_->IsElasticOverscrollEnabled(); | |
1135 #endif | |
1136 if (!use_threaded_event_handling) | |
1137 return; | |
1138 | |
1139 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | |
1140 // render_thread may be NULL in tests. | |
1141 InputHandlerManager* input_handler_manager = | |
1142 render_thread ? render_thread->input_handler_manager() : NULL; | |
1143 if (input_handler_manager) { | |
1144 input_handler_manager->AddInputHandler( | |
1145 routing_id_, compositor()->GetInputHandler(), AsWeakPtr(), true); | |
lfg
2016/11/04 17:22:05
We were using webkit_preferences_.enable_scroll_an
wjmaclean
2016/11/04 17:27:51
I'll plumb that through from RenderViewImpl in the
| |
1146 has_added_input_handler_ = true; | |
1147 } | |
1118 } | 1148 } |
1119 | 1149 |
1120 void RenderWidget::WillCloseLayerTreeView() { | 1150 void RenderWidget::WillCloseLayerTreeView() { |
1121 if (host_closing_) | 1151 if (host_closing_) |
1122 return; | 1152 return; |
1123 | 1153 |
1124 // Prevent new compositors or output surfaces from being created. | 1154 // Prevent new compositors or output surfaces from being created. |
1125 host_closing_ = true; | 1155 host_closing_ = true; |
1126 | 1156 |
1127 // Always send this notification to prevent new layer tree views from | 1157 // 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() { | 1628 void RenderWidget::OnImeEventAck() { |
1599 DCHECK_GE(text_input_info_history_.size(), 1u); | 1629 DCHECK_GE(text_input_info_history_.size(), 1u); |
1600 text_input_info_history_.pop_front(); | 1630 text_input_info_history_.pop_front(); |
1601 } | 1631 } |
1602 | 1632 |
1603 void RenderWidget::OnRequestTextInputStateUpdate() { | 1633 void RenderWidget::OnRequestTextInputStateUpdate() { |
1604 DCHECK(!ime_event_guard_); | 1634 DCHECK(!ime_event_guard_); |
1605 UpdateSelectionBounds(); | 1635 UpdateSelectionBounds(); |
1606 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME); | 1636 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME); |
1607 } | 1637 } |
1638 | |
1639 void RenderWidget::scheduleContentIntentForRenderView( | |
1640 const blink::WebURL& intent, | |
1641 bool is_main_frame, | |
1642 size_t expected_content_intent_id) { | |
1643 // Introduce a short delay so that the user can notice the content. | |
1644 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | |
1645 FROM_HERE, | |
1646 base::Bind(&RenderWidget::LaunchAndroidContentIntent, | |
1647 static_cast<RenderWidget*>(this)->AsWeakPtr(), | |
dcheng
2016/11/04 21:00:02
Why do we need to do this cast?
wjmaclean
2016/11/07 15:57:27
We don't ... stale cruft. Fixed.
| |
1648 intent, expected_content_intent_id, is_main_frame), | |
1649 base::TimeDelta::FromMilliseconds(kContentIntentDelayMilliseconds)); | |
1650 } | |
1608 #endif | 1651 #endif |
1609 | 1652 |
1610 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request, | 1653 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request, |
1611 bool monitor_request) { | 1654 bool monitor_request) { |
1612 monitor_composition_info_ = monitor_request; | 1655 monitor_composition_info_ = monitor_request; |
1613 if (!immediate_request) | 1656 if (!immediate_request) |
1614 return; | 1657 return; |
1615 UpdateCompositionInfo(true /* immediate request */); | 1658 UpdateCompositionInfo(true /* immediate request */); |
1616 } | 1659 } |
1617 | 1660 |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2067 bool RenderWidget::isPointerLocked() { | 2110 bool RenderWidget::isPointerLocked() { |
2068 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2111 return mouse_lock_dispatcher_->IsMouseLockedTo( |
2069 webwidget_mouse_lock_target_.get()); | 2112 webwidget_mouse_lock_target_.get()); |
2070 } | 2113 } |
2071 | 2114 |
2072 blink::WebWidget* RenderWidget::GetWebWidget() const { | 2115 blink::WebWidget* RenderWidget::GetWebWidget() const { |
2073 return webwidget_internal_; | 2116 return webwidget_internal_; |
2074 } | 2117 } |
2075 | 2118 |
2076 } // namespace content | 2119 } // namespace content |
OLD | NEW |