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