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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 resizing_mode_selector_(new ResizingModeSelector()), | 370 resizing_mode_selector_(new ResizingModeSelector()), |
371 has_host_context_menu_location_(false), | 371 has_host_context_menu_location_(false), |
372 has_added_input_handler_(false), | 372 has_added_input_handler_(false), |
373 has_focus_(false), | 373 has_focus_(false), |
374 #if defined(OS_MACOSX) | 374 #if defined(OS_MACOSX) |
375 text_input_client_observer_(new TextInputClientObserver(this)), | 375 text_input_client_observer_(new TextInputClientObserver(this)), |
376 #endif | 376 #endif |
377 focused_pepper_plugin_(nullptr), | 377 focused_pepper_plugin_(nullptr), |
378 time_to_first_active_paint_recorded_(true), | 378 time_to_first_active_paint_recorded_(true), |
379 was_shown_time_(base::TimeTicks::Now()), | 379 was_shown_time_(base::TimeTicks::Now()), |
| 380 current_content_source_id_(0), |
380 weak_ptr_factory_(this) { | 381 weak_ptr_factory_(this) { |
381 DCHECK_NE(routing_id_, MSG_ROUTING_NONE); | 382 DCHECK_NE(routing_id_, MSG_ROUTING_NONE); |
382 if (!swapped_out) | 383 if (!swapped_out) |
383 RenderProcess::current()->AddRefProcess(); | 384 RenderProcess::current()->AddRefProcess(); |
384 DCHECK(RenderThread::Get()); | 385 DCHECK(RenderThread::Get()); |
385 | 386 |
386 // In tests there may not be a RenderThreadImpl. | 387 // In tests there may not be a RenderThreadImpl. |
387 if (RenderThreadImpl::current()) { | 388 if (RenderThreadImpl::current()) { |
388 render_widget_scheduling_state_ = RenderThreadImpl::current() | 389 render_widget_scheduling_state_ = RenderThreadImpl::current() |
389 ->GetRendererScheduler() | 390 ->GetRendererScheduler() |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 auto layer_tree_host = RenderWidgetCompositor::CreateLayerTreeHost( | 1278 auto layer_tree_host = RenderWidgetCompositor::CreateLayerTreeHost( |
1278 compositor_.get(), compositor_.get(), animation_host.get(), | 1279 compositor_.get(), compositor_.get(), animation_host.get(), |
1279 compositor_deps_, device_scale_factor_, screen_info_); | 1280 compositor_deps_, device_scale_factor_, screen_info_); |
1280 compositor_->Initialize(std::move(layer_tree_host), | 1281 compositor_->Initialize(std::move(layer_tree_host), |
1281 std::move(animation_host)); | 1282 std::move(animation_host)); |
1282 | 1283 |
1283 compositor_->SetIsForOopif(for_oopif_); | 1284 compositor_->SetIsForOopif(for_oopif_); |
1284 compositor_->setViewportSize(physical_backing_size_); | 1285 compositor_->setViewportSize(physical_backing_size_); |
1285 OnDeviceScaleFactorChanged(); | 1286 OnDeviceScaleFactorChanged(); |
1286 compositor_->SetDeviceColorSpace(screen_info_.icc_profile.GetColorSpace()); | 1287 compositor_->SetDeviceColorSpace(screen_info_.icc_profile.GetColorSpace()); |
| 1288 compositor_->SetContentSourceId(current_content_source_id_); |
1287 // For background pages and certain tests, we don't want to trigger | 1289 // For background pages and certain tests, we don't want to trigger |
1288 // CompositorFrameSink creation. | 1290 // CompositorFrameSink creation. |
1289 if (compositor_never_visible_ || !RenderThreadImpl::current()) | 1291 if (compositor_never_visible_ || !RenderThreadImpl::current()) |
1290 compositor_->SetNeverVisible(); | 1292 compositor_->SetNeverVisible(); |
1291 | 1293 |
1292 StartCompositor(); | 1294 StartCompositor(); |
1293 DCHECK_NE(MSG_ROUTING_NONE, routing_id_); | 1295 DCHECK_NE(MSG_ROUTING_NONE, routing_id_); |
1294 compositor_->SetFrameSinkId( | 1296 compositor_->SetFrameSinkId( |
1295 cc::FrameSinkId(RenderThread::Get()->GetClientId(), routing_id_)); | 1297 cc::FrameSinkId(RenderThread::Get()->GetClientId(), routing_id_)); |
1296 | 1298 |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2291 blink::WebRect offset_in_window(webImageOffset.x, webImageOffset.y, 0, 0); | 2293 blink::WebRect offset_in_window(webImageOffset.x, webImageOffset.y, 0, 0); |
2292 convertViewportToWindow(&offset_in_window); | 2294 convertViewportToWindow(&offset_in_window); |
2293 DropData drop_data(DropDataBuilder::Build(data)); | 2295 DropData drop_data(DropDataBuilder::Build(data)); |
2294 drop_data.referrer_policy = policy; | 2296 drop_data.referrer_policy = policy; |
2295 gfx::Vector2d imageOffset(offset_in_window.x, offset_in_window.y); | 2297 gfx::Vector2d imageOffset(offset_in_window.x, offset_in_window.y); |
2296 Send(new DragHostMsg_StartDragging(routing_id(), drop_data, mask, | 2298 Send(new DragHostMsg_StartDragging(routing_id(), drop_data, mask, |
2297 image.getSkBitmap(), imageOffset, | 2299 image.getSkBitmap(), imageOffset, |
2298 possible_drag_event_info_)); | 2300 possible_drag_event_info_)); |
2299 } | 2301 } |
2300 | 2302 |
| 2303 uint32_t RenderWidget::GetContentSourceId() { |
| 2304 return current_content_source_id_; |
| 2305 } |
| 2306 |
| 2307 void RenderWidget::IncrementContentSourceId() { |
| 2308 if (compositor_) |
| 2309 compositor_->SetContentSourceId(++current_content_source_id_); |
| 2310 } |
| 2311 |
2301 blink::WebWidget* RenderWidget::GetWebWidget() const { | 2312 blink::WebWidget* RenderWidget::GetWebWidget() const { |
2302 return webwidget_internal_; | 2313 return webwidget_internal_; |
2303 } | 2314 } |
2304 | 2315 |
2305 blink::WebInputMethodController* RenderWidget::GetInputMethodController() | 2316 blink::WebInputMethodController* RenderWidget::GetInputMethodController() |
2306 const { | 2317 const { |
2307 if (!GetWebWidget()->isWebFrameWidget()) { | 2318 if (!GetWebWidget()->isWebFrameWidget()) { |
2308 // TODO(ekaramad): We should not get here in response to IME IPC or updates | 2319 // TODO(ekaramad): We should not get here in response to IME IPC or updates |
2309 // when the RenderWidget is swapped out. We should top sending IPCs from the | 2320 // when the RenderWidget is swapped out. We should top sending IPCs from the |
2310 // browser side (https://crbug.com/669219). | 2321 // browser side (https://crbug.com/669219). |
2311 // If there is no WebFrameWidget, then there will be no | 2322 // If there is no WebFrameWidget, then there will be no |
2312 // InputMethodControllers for a WebLocalFrame. | 2323 // InputMethodControllers for a WebLocalFrame. |
2313 return nullptr; | 2324 return nullptr; |
2314 } | 2325 } |
2315 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) | 2326 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) |
2316 ->getActiveWebInputMethodController(); | 2327 ->getActiveWebInputMethodController(); |
2317 } | 2328 } |
2318 | 2329 |
2319 } // namespace content | 2330 } // namespace content |
OLD | NEW |