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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 #include "ui/base/ui_base_switches.h" | 90 #include "ui/base/ui_base_switches.h" |
91 #include "ui/gfx/geometry/point_conversions.h" | 91 #include "ui/gfx/geometry/point_conversions.h" |
92 #include "ui/gfx/geometry/rect_conversions.h" | 92 #include "ui/gfx/geometry/rect_conversions.h" |
93 #include "ui/gfx/geometry/size_conversions.h" | 93 #include "ui/gfx/geometry/size_conversions.h" |
94 #include "ui/gfx/skia_util.h" | 94 #include "ui/gfx/skia_util.h" |
95 #include "ui/gl/gl_switches.h" | 95 #include "ui/gl/gl_switches.h" |
96 #include "ui/surface/transport_dib.h" | 96 #include "ui/surface/transport_dib.h" |
97 | 97 |
98 #if defined(OS_ANDROID) | 98 #if defined(OS_ANDROID) |
99 #include <android/keycodes.h> | 99 #include <android/keycodes.h> |
| 100 #include "base/time/time.h" |
100 #endif | 101 #endif |
101 | 102 |
102 #if defined(OS_POSIX) | 103 #if defined(OS_POSIX) |
103 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 104 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
104 #include "third_party/skia/include/core/SkPixelRef.h" | 105 #include "third_party/skia/include/core/SkPixelRef.h" |
105 #endif // defined(OS_POSIX) | 106 #endif // defined(OS_POSIX) |
106 | 107 |
107 #if defined(USE_AURA) | 108 #if defined(USE_AURA) |
108 #include "content/public/common/service_manager_connection.h" | 109 #include "content/public/common/service_manager_connection.h" |
109 #include "content/renderer/mus/render_widget_mus_connection.h" | 110 #include "content/renderer/mus/render_widget_mus_connection.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 composition_range_(gfx::Range::InvalidRange()), | 375 composition_range_(gfx::Range::InvalidRange()), |
375 popup_type_(popup_type), | 376 popup_type_(popup_type), |
376 pending_window_rect_count_(0), | 377 pending_window_rect_count_(0), |
377 screen_info_(screen_info), | 378 screen_info_(screen_info), |
378 device_scale_factor_(screen_info_.device_scale_factor), | 379 device_scale_factor_(screen_info_.device_scale_factor), |
379 monitor_composition_info_(false), | 380 monitor_composition_info_(false), |
380 popup_origin_scale_for_emulation_(0.f), | 381 popup_origin_scale_for_emulation_(0.f), |
381 frame_swap_message_queue_(new FrameSwapMessageQueue()), | 382 frame_swap_message_queue_(new FrameSwapMessageQueue()), |
382 resizing_mode_selector_(new ResizingModeSelector()), | 383 resizing_mode_selector_(new ResizingModeSelector()), |
383 has_host_context_menu_location_(false), | 384 has_host_context_menu_location_(false), |
| 385 has_added_input_handler_(false), |
384 has_focus_(false), | 386 has_focus_(false), |
385 #if defined(OS_MACOSX) | 387 #if defined(OS_MACOSX) |
386 text_input_client_observer_(new TextInputClientObserver(this)), | 388 text_input_client_observer_(new TextInputClientObserver(this)), |
387 #endif | 389 #endif |
388 focused_pepper_plugin_(nullptr) { | 390 focused_pepper_plugin_(nullptr), |
| 391 weak_ptr_factory_(this) { |
389 DCHECK_NE(routing_id_, MSG_ROUTING_NONE); | 392 DCHECK_NE(routing_id_, MSG_ROUTING_NONE); |
390 if (!swapped_out) | 393 if (!swapped_out) |
391 RenderProcess::current()->AddRefProcess(); | 394 RenderProcess::current()->AddRefProcess(); |
392 DCHECK(RenderThread::Get()); | 395 DCHECK(RenderThread::Get()); |
393 | 396 |
394 // In tests there may not be a RenderThreadImpl. | 397 // In tests there may not be a RenderThreadImpl. |
395 if (RenderThreadImpl::current()) { | 398 if (RenderThreadImpl::current()) { |
396 render_widget_scheduling_state_ = RenderThreadImpl::current() | 399 render_widget_scheduling_state_ = RenderThreadImpl::current() |
397 ->GetRendererScheduler() | 400 ->GetRendererScheduler() |
398 ->NewRenderWidgetSchedulingState(); | 401 ->NewRenderWidgetSchedulingState(); |
(...skipping 28 matching lines...) Expand all Loading... |
427 int32_t routing_id = MSG_ROUTING_NONE; | 430 int32_t routing_id = MSG_ROUTING_NONE; |
428 if (!RenderThreadImpl::current_render_message_filter()->CreateNewWidget( | 431 if (!RenderThreadImpl::current_render_message_filter()->CreateNewWidget( |
429 opener->GetRoutingID(), popup_type, &routing_id)) { | 432 opener->GetRoutingID(), popup_type, &routing_id)) { |
430 return nullptr; | 433 return nullptr; |
431 } | 434 } |
432 | 435 |
433 scoped_refptr<RenderWidget> widget( | 436 scoped_refptr<RenderWidget> widget( |
434 new RenderWidget(routing_id, compositor_deps, popup_type, screen_info, | 437 new RenderWidget(routing_id, compositor_deps, popup_type, screen_info, |
435 false, false, false)); | 438 false, false, false)); |
436 ShowCallback opener_callback = | 439 ShowCallback opener_callback = |
437 base::Bind(&RenderViewImpl::ShowCreatedPopupWidget, opener->AsWeakPtr()); | 440 base::Bind(&RenderViewImpl::ShowCreatedPopupWidget, opener->GetWeakPtr()); |
438 widget->Init(opener_callback, RenderWidget::CreateWebWidget(widget.get())); | 441 widget->Init(opener_callback, RenderWidget::CreateWebWidget(widget.get())); |
439 DCHECK(!widget->HasOneRef()); // RenderWidget::Init() adds a reference. | 442 DCHECK(!widget->HasOneRef()); // RenderWidget::Init() adds a reference. |
440 return widget.get(); | 443 return widget.get(); |
441 } | 444 } |
442 | 445 |
443 // static | 446 // static |
444 RenderWidget* RenderWidget::CreateForFrame( | 447 RenderWidget* RenderWidget::CreateForFrame( |
445 int widget_routing_id, | 448 int widget_routing_id, |
446 bool hidden, | 449 bool hidden, |
447 const ScreenInfo& screen_info, | 450 const ScreenInfo& screen_info, |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 | 1237 |
1235 compositor_ = RenderWidgetCompositor::Create(this, compositor_deps_); | 1238 compositor_ = RenderWidgetCompositor::Create(this, compositor_deps_); |
1236 auto animation_host = cc::AnimationHost::CreateMainInstance(); | 1239 auto animation_host = cc::AnimationHost::CreateMainInstance(); |
1237 | 1240 |
1238 auto layer_tree_host = RenderWidgetCompositor::CreateLayerTreeHost( | 1241 auto layer_tree_host = RenderWidgetCompositor::CreateLayerTreeHost( |
1239 compositor_.get(), compositor_.get(), animation_host.get(), | 1242 compositor_.get(), compositor_.get(), animation_host.get(), |
1240 compositor_deps_, device_scale_factor_, screen_info_); | 1243 compositor_deps_, device_scale_factor_, screen_info_); |
1241 compositor_->Initialize(std::move(layer_tree_host), | 1244 compositor_->Initialize(std::move(layer_tree_host), |
1242 std::move(animation_host)); | 1245 std::move(animation_host)); |
1243 | 1246 |
| 1247 compositor_->SetIsForOopif(for_oopif_); |
1244 compositor_->setViewportSize(physical_backing_size_); | 1248 compositor_->setViewportSize(physical_backing_size_); |
1245 OnDeviceScaleFactorChanged(); | 1249 OnDeviceScaleFactorChanged(); |
1246 compositor_->SetDeviceColorSpace(screen_info_.icc_profile.GetColorSpace()); | 1250 compositor_->SetDeviceColorSpace(screen_info_.icc_profile.GetColorSpace()); |
1247 // For background pages and certain tests, we don't want to trigger | 1251 // For background pages and certain tests, we don't want to trigger |
1248 // CompositorFrameSink creation. | 1252 // CompositorFrameSink creation. |
1249 if (compositor_never_visible_ || !RenderThreadImpl::current()) | 1253 if (compositor_never_visible_ || !RenderThreadImpl::current()) |
1250 compositor_->SetNeverVisible(); | 1254 compositor_->SetNeverVisible(); |
1251 | 1255 |
1252 StartCompositor(); | 1256 StartCompositor(); |
1253 DCHECK_NE(MSG_ROUTING_NONE, routing_id_); | 1257 DCHECK_NE(MSG_ROUTING_NONE, routing_id_); |
1254 compositor_->SetFrameSinkId( | 1258 compositor_->SetFrameSinkId( |
1255 cc::FrameSinkId(RenderThread::Get()->GetClientId(), routing_id_)); | 1259 cc::FrameSinkId(RenderThread::Get()->GetClientId(), routing_id_)); |
1256 | 1260 |
| 1261 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 1262 // render_thread may be NULL in tests. |
| 1263 InputHandlerManager* input_handler_manager = |
| 1264 render_thread ? render_thread->input_handler_manager() : NULL; |
| 1265 if (input_handler_manager) { |
| 1266 input_handler_manager->AddInputHandler( |
| 1267 routing_id_, compositor()->GetInputHandler(), |
| 1268 weak_ptr_factory_.GetWeakPtr(), |
| 1269 compositor_deps_->IsScrollAnimatorEnabled()); |
| 1270 has_added_input_handler_ = true; |
| 1271 } |
| 1272 |
1257 return compositor_.get(); | 1273 return compositor_.get(); |
1258 } | 1274 } |
1259 | 1275 |
1260 void RenderWidget::WillCloseLayerTreeView() { | 1276 void RenderWidget::WillCloseLayerTreeView() { |
1261 if (host_closing_) | 1277 if (host_closing_) |
1262 return; | 1278 return; |
1263 | 1279 |
1264 // Prevent new compositors or output surfaces from being created. | 1280 // Prevent new compositors or output surfaces from being created. |
1265 host_closing_ = true; | 1281 host_closing_ = true; |
1266 | 1282 |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 } | 2194 } |
2179 | 2195 |
2180 void RenderWidget::hasTouchEventHandlers(bool has_handlers) { | 2196 void RenderWidget::hasTouchEventHandlers(bool has_handlers) { |
2181 if (render_widget_scheduling_state_) | 2197 if (render_widget_scheduling_state_) |
2182 render_widget_scheduling_state_->SetHasTouchHandler(has_handlers); | 2198 render_widget_scheduling_state_->SetHasTouchHandler(has_handlers); |
2183 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); | 2199 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); |
2184 } | 2200 } |
2185 | 2201 |
2186 void RenderWidget::setTouchAction( | 2202 void RenderWidget::setTouchAction( |
2187 blink::WebTouchAction web_touch_action) { | 2203 blink::WebTouchAction web_touch_action) { |
2188 | |
2189 // Ignore setTouchAction calls that result from synthetic touch events (eg. | 2204 // Ignore setTouchAction calls that result from synthetic touch events (eg. |
2190 // when blink is emulating touch with mouse). | 2205 // when blink is emulating touch with mouse). |
2191 if (input_handler_->handling_event_type() != WebInputEvent::TouchStart) | 2206 if (input_handler_->handling_event_type() != WebInputEvent::TouchStart) |
2192 return; | 2207 return; |
2193 | 2208 |
2194 content::TouchAction content_touch_action = | 2209 content::TouchAction content_touch_action = |
2195 static_cast<content::TouchAction>(web_touch_action); | 2210 static_cast<content::TouchAction>(web_touch_action); |
2196 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); | 2211 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); |
2197 } | 2212 } |
2198 | 2213 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 // browser side (https://crbug.com/669219). | 2286 // browser side (https://crbug.com/669219). |
2272 // If there is no WebFrameWidget, then there will be no | 2287 // If there is no WebFrameWidget, then there will be no |
2273 // InputMethodControllers for a WebLocalFrame. | 2288 // InputMethodControllers for a WebLocalFrame. |
2274 return nullptr; | 2289 return nullptr; |
2275 } | 2290 } |
2276 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) | 2291 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) |
2277 ->getActiveWebInputMethodController(); | 2292 ->getActiveWebInputMethodController(); |
2278 } | 2293 } |
2279 | 2294 |
2280 } // namespace content | 2295 } // namespace content |
OLD | NEW |