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

Side by Side Diff: content/renderer/render_widget.cc

Issue 2479663002: Move compositor InputHandler from RenderViewImpl to RenderWidget. (Closed)
Patch Set: Add early out to accommodate null frameWidget in webkit_unit_tests. 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/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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 #include "ui/base/ui_base_switches.h" 80 #include "ui/base/ui_base_switches.h"
81 #include "ui/gfx/geometry/point_conversions.h" 81 #include "ui/gfx/geometry/point_conversions.h"
82 #include "ui/gfx/geometry/rect_conversions.h" 82 #include "ui/gfx/geometry/rect_conversions.h"
83 #include "ui/gfx/geometry/size_conversions.h" 83 #include "ui/gfx/geometry/size_conversions.h"
84 #include "ui/gfx/skia_util.h" 84 #include "ui/gfx/skia_util.h"
85 #include "ui/gl/gl_switches.h" 85 #include "ui/gl/gl_switches.h"
86 #include "ui/surface/transport_dib.h" 86 #include "ui/surface/transport_dib.h"
87 87
88 #if defined(OS_ANDROID) 88 #if defined(OS_ANDROID)
89 #include <android/keycodes.h> 89 #include <android/keycodes.h>
90 #include "base/time/time.h"
90 #endif 91 #endif
91 92
92 #if defined(OS_POSIX) 93 #if defined(OS_POSIX)
93 #include "third_party/skia/include/core/SkMallocPixelRef.h" 94 #include "third_party/skia/include/core/SkMallocPixelRef.h"
94 #include "third_party/skia/include/core/SkPixelRef.h" 95 #include "third_party/skia/include/core/SkPixelRef.h"
95 #endif // defined(OS_POSIX) 96 #endif // defined(OS_POSIX)
96 97
97 #if defined(USE_AURA) 98 #if defined(USE_AURA)
98 #include "content/public/common/service_manager_connection.h" 99 #include "content/public/common/service_manager_connection.h"
99 #include "content/renderer/mus/render_widget_mus_connection.h" 100 #include "content/renderer/mus/render_widget_mus_connection.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // Check the mode is in the range representable by ui::TextInputMode. 199 // Check the mode is in the range representable by ui::TextInputMode.
199 DCHECK_LE(mode, static_cast<int>(ui::TEXT_INPUT_MODE_MAX)) 200 DCHECK_LE(mode, static_cast<int>(ui::TEXT_INPUT_MODE_MAX))
200 << "blink::WebTextInputMode and ui::TextInputMode not synchronized"; 201 << "blink::WebTextInputMode and ui::TextInputMode not synchronized";
201 return static_cast<ui::TextInputMode>(mode); 202 return static_cast<ui::TextInputMode>(mode);
202 } 203 }
203 204
204 } // namespace 205 } // namespace
205 206
206 namespace content { 207 namespace content {
207 208
209 #if defined(OS_ANDROID)
210 // Delay between tapping in content and launching the associated android intent.
211 // Used to allow users see what has been recognized as content.
212 constexpr base::TimeDelta kContentIntentDelay =
213 base::TimeDelta::FromMilliseconds(700);
214 #endif
215
208 // RenderWidget --------------------------------------------------------------- 216 // RenderWidget ---------------------------------------------------------------
209 217
210 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, 218 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
211 blink::WebPopupType popup_type, 219 blink::WebPopupType popup_type,
212 const ScreenInfo& screen_info, 220 const ScreenInfo& screen_info,
213 bool swapped_out, 221 bool swapped_out,
214 bool hidden, 222 bool hidden,
215 bool never_visible) 223 bool never_visible)
216 : routing_id_(MSG_ROUTING_NONE), 224 : routing_id_(MSG_ROUTING_NONE),
217 compositor_deps_(compositor_deps), 225 compositor_deps_(compositor_deps),
(...skipping 23 matching lines...) Expand all
241 screen_info_(screen_info), 249 screen_info_(screen_info),
242 device_scale_factor_(screen_info_.device_scale_factor), 250 device_scale_factor_(screen_info_.device_scale_factor),
243 #if defined(OS_ANDROID) 251 #if defined(OS_ANDROID)
244 text_field_is_dirty_(false), 252 text_field_is_dirty_(false),
245 #endif 253 #endif
246 monitor_composition_info_(false), 254 monitor_composition_info_(false),
247 popup_origin_scale_for_emulation_(0.f), 255 popup_origin_scale_for_emulation_(0.f),
248 frame_swap_message_queue_(new FrameSwapMessageQueue()), 256 frame_swap_message_queue_(new FrameSwapMessageQueue()),
249 resizing_mode_selector_(new ResizingModeSelector()), 257 resizing_mode_selector_(new ResizingModeSelector()),
250 has_host_context_menu_location_(false), 258 has_host_context_menu_location_(false),
259 has_added_input_handler_(false),
251 has_focus_(false), 260 has_focus_(false),
252 #if defined(OS_MACOSX) 261 #if defined(OS_MACOSX)
253 text_input_client_observer_(new TextInputClientObserver(this)), 262 text_input_client_observer_(new TextInputClientObserver(this)),
254 #endif 263 #endif
255 focused_pepper_plugin_(nullptr) { 264 focused_pepper_plugin_(nullptr),
265 weak_ptr_factory_(this) {
256 if (!swapped_out) 266 if (!swapped_out)
257 RenderProcess::current()->AddRefProcess(); 267 RenderProcess::current()->AddRefProcess();
258 DCHECK(RenderThread::Get()); 268 DCHECK(RenderThread::Get());
259 device_color_profile_.push_back('0'); 269 device_color_profile_.push_back('0');
260 #if defined(OS_ANDROID) 270 #if defined(OS_ANDROID)
261 text_input_info_history_.push_back(blink::WebTextInputInfo()); 271 text_input_info_history_.push_back(blink::WebTextInputInfo());
262 #endif 272 #endif
263 273
264 // In tests there may not be a RenderThreadImpl. 274 // In tests there may not be a RenderThreadImpl.
265 if (RenderThreadImpl::current()) { 275 if (RenderThreadImpl::current()) {
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 compositor_->SetDeviceColorSpace(screen_info_.icc_profile.GetColorSpace()); 1133 compositor_->SetDeviceColorSpace(screen_info_.icc_profile.GetColorSpace());
1124 // For background pages and certain tests, we don't want to trigger 1134 // For background pages and certain tests, we don't want to trigger
1125 // CompositorFrameSink creation. 1135 // CompositorFrameSink creation.
1126 if (compositor_never_visible_ || !RenderThreadImpl::current()) 1136 if (compositor_never_visible_ || !RenderThreadImpl::current())
1127 compositor_->SetNeverVisible(); 1137 compositor_->SetNeverVisible();
1128 1138
1129 StartCompositor(); 1139 StartCompositor();
1130 DCHECK_NE(MSG_ROUTING_NONE, routing_id_); 1140 DCHECK_NE(MSG_ROUTING_NONE, routing_id_);
1131 compositor_->SetFrameSinkId( 1141 compositor_->SetFrameSinkId(
1132 cc::FrameSinkId(RenderThread::Get()->GetClientId(), routing_id_)); 1142 cc::FrameSinkId(RenderThread::Get()->GetClientId(), routing_id_));
1143
1144 bool use_threaded_event_handling = true;
1145 #if defined(OS_MACOSX)
1146 // Disable threaded event handling if content is not handling the elastic
1147 // overscroll effect. This includes the cases where the elastic overscroll
1148 // effect is being handled by Blink (because of command line flags) and older
1149 // operating system versions which do not have an elastic overscroll effect
1150 // (SnowLeopard, which has Aqua scrollbars which need synchronous updates).
1151 use_threaded_event_handling = compositor_deps_->IsElasticOverscrollEnabled();
1152 #endif
1153 if (!use_threaded_event_handling)
1154 return;
1155
1156 RenderThreadImpl* render_thread = RenderThreadImpl::current();
1157 // render_thread may be NULL in tests.
1158 InputHandlerManager* input_handler_manager =
1159 render_thread ? render_thread->input_handler_manager() : NULL;
1160 if (input_handler_manager) {
1161 input_handler_manager->AddInputHandler(
1162 routing_id_, compositor()->GetInputHandler(),
1163 weak_ptr_factory_.GetWeakPtr(),
1164 compositor_deps_->IsScrollAnimatorEnabled());
1165 has_added_input_handler_ = true;
1166 }
1133 } 1167 }
1134 1168
1135 void RenderWidget::WillCloseLayerTreeView() { 1169 void RenderWidget::WillCloseLayerTreeView() {
1136 if (host_closing_) 1170 if (host_closing_)
1137 return; 1171 return;
1138 1172
1139 // Prevent new compositors or output surfaces from being created. 1173 // Prevent new compositors or output surfaces from being created.
1140 host_closing_ = true; 1174 host_closing_ = true;
1141 1175
1142 // Always send this notification to prevent new layer tree views from 1176 // Always send this notification to prevent new layer tree views from
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 void RenderWidget::OnImeEventAck() { 1642 void RenderWidget::OnImeEventAck() {
1609 DCHECK_GE(text_input_info_history_.size(), 1u); 1643 DCHECK_GE(text_input_info_history_.size(), 1u);
1610 text_input_info_history_.pop_front(); 1644 text_input_info_history_.pop_front();
1611 } 1645 }
1612 1646
1613 void RenderWidget::OnRequestTextInputStateUpdate() { 1647 void RenderWidget::OnRequestTextInputStateUpdate() {
1614 DCHECK(!ime_event_guard_); 1648 DCHECK(!ime_event_guard_);
1615 UpdateSelectionBounds(); 1649 UpdateSelectionBounds();
1616 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME); 1650 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME);
1617 } 1651 }
1652
1653 void RenderWidget::scheduleContentIntentForRenderView(
1654 const blink::WebURL& intent,
1655 bool is_main_frame,
1656 size_t expected_content_intent_id) {
1657 // Introduce a short delay so that the user can notice the content.
1658 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1659 FROM_HERE, base::Bind(&RenderWidget::LaunchAndroidContentIntent,
1660 weak_ptr_factory_.GetWeakPtr(), intent,
1661 expected_content_intent_id, is_main_frame),
1662 kContentIntentDelay);
1663 }
1618 #endif 1664 #endif
1619 1665
1620 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request, 1666 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request,
1621 bool monitor_request) { 1667 bool monitor_request) {
1622 monitor_composition_info_ = monitor_request; 1668 monitor_composition_info_ = monitor_request;
1623 if (!immediate_request) 1669 if (!immediate_request)
1624 return; 1670 return;
1625 UpdateCompositionInfo(true /* immediate request */); 1671 UpdateCompositionInfo(true /* immediate request */);
1626 } 1672 }
1627 1673
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 Send(new DragHostMsg_StartDragging(routing_id_, drop_data, mask, 2136 Send(new DragHostMsg_StartDragging(routing_id_, drop_data, mask,
2091 image.getSkBitmap(), imageOffset, 2137 image.getSkBitmap(), imageOffset,
2092 possible_drag_event_info_)); 2138 possible_drag_event_info_));
2093 } 2139 }
2094 2140
2095 blink::WebWidget* RenderWidget::GetWebWidget() const { 2141 blink::WebWidget* RenderWidget::GetWebWidget() const {
2096 return webwidget_internal_; 2142 return webwidget_internal_;
2097 } 2143 }
2098 2144
2099 } // namespace content 2145 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698