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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 did_show_(false), | 386 did_show_(false), |
387 is_hidden_(hidden), | 387 is_hidden_(hidden), |
388 never_visible_(never_visible), | 388 never_visible_(never_visible), |
389 is_fullscreen_(false), | 389 is_fullscreen_(false), |
390 has_focus_(false), | 390 has_focus_(false), |
391 handling_input_event_(false), | 391 handling_input_event_(false), |
392 handling_ime_event_(false), | 392 handling_ime_event_(false), |
393 handling_event_type_(WebInputEvent::Undefined), | 393 handling_event_type_(WebInputEvent::Undefined), |
394 ignore_ack_for_mouse_move_from_debugger_(false), | 394 ignore_ack_for_mouse_move_from_debugger_(false), |
395 closing_(false), | 395 closing_(false), |
| 396 host_closing_(false), |
396 is_swapped_out_(swapped_out), | 397 is_swapped_out_(swapped_out), |
397 input_method_is_active_(false), | 398 input_method_is_active_(false), |
398 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 399 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
399 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 400 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
400 can_compose_inline_(true), | 401 can_compose_inline_(true), |
401 popup_type_(popup_type), | 402 popup_type_(popup_type), |
402 pending_window_rect_count_(0), | 403 pending_window_rect_count_(0), |
403 suppress_next_char_events_(false), | 404 suppress_next_char_events_(false), |
404 screen_info_(screen_info), | 405 screen_info_(screen_info), |
405 device_scale_factor_(screen_info_.deviceScaleFactor), | 406 device_scale_factor_(screen_info_.deviceScaleFactor), |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 } | 1189 } |
1189 | 1190 |
1190 void RenderWidget::AutoResizeCompositor() { | 1191 void RenderWidget::AutoResizeCompositor() { |
1191 physical_backing_size_ = gfx::ToCeiledSize(gfx::ScaleSize(size_, | 1192 physical_backing_size_ = gfx::ToCeiledSize(gfx::ScaleSize(size_, |
1192 device_scale_factor_)); | 1193 device_scale_factor_)); |
1193 if (compositor_) | 1194 if (compositor_) |
1194 compositor_->setViewportSize(size_, physical_backing_size_); | 1195 compositor_->setViewportSize(size_, physical_backing_size_); |
1195 } | 1196 } |
1196 | 1197 |
1197 void RenderWidget::initializeLayerTreeView() { | 1198 void RenderWidget::initializeLayerTreeView() { |
| 1199 DCHECK(!host_closing_); |
| 1200 |
1198 compositor_ = | 1201 compositor_ = |
1199 RenderWidgetCompositor::Create(this, IsThreadedCompositingEnabled()); | 1202 RenderWidgetCompositor::Create(this, IsThreadedCompositingEnabled()); |
1200 compositor_->setViewportSize(size_, physical_backing_size_); | 1203 compositor_->setViewportSize(size_, physical_backing_size_); |
1201 if (init_complete_) | 1204 if (init_complete_) |
1202 StartCompositor(); | 1205 StartCompositor(); |
1203 } | 1206 } |
1204 | 1207 |
| 1208 void RenderWidget::DestroyLayerTreeView() { |
| 1209 // Always send this notification to prevent new layer tree views from |
| 1210 // being created, even if one hasn't been created yet. |
| 1211 webwidget_->willCloseLayerTreeView(); |
| 1212 compositor_.reset(); |
| 1213 } |
| 1214 |
1205 blink::WebLayerTreeView* RenderWidget::layerTreeView() { | 1215 blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
1206 return compositor_.get(); | 1216 return compositor_.get(); |
1207 } | 1217 } |
1208 | 1218 |
1209 void RenderWidget::suppressCompositorScheduling(bool enable) { | |
1210 if (compositor_) | |
1211 compositor_->SetSuppressScheduleComposite(enable); | |
1212 } | |
1213 | |
1214 void RenderWidget::willBeginCompositorFrame() { | 1219 void RenderWidget::willBeginCompositorFrame() { |
1215 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); | 1220 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
1216 | 1221 |
1217 DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get()); | |
1218 | |
1219 // The following two can result in further layout and possibly | 1222 // The following two can result in further layout and possibly |
1220 // enable GPU acceleration so they need to be called before any painting | 1223 // enable GPU acceleration so they need to be called before any painting |
1221 // is done. | 1224 // is done. |
1222 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); | 1225 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); |
1223 UpdateSelectionBounds(); | 1226 UpdateSelectionBounds(); |
1224 } | 1227 } |
1225 | 1228 |
1226 void RenderWidget::didBecomeReadyForAdditionalInput() { | 1229 void RenderWidget::didBecomeReadyForAdditionalInput() { |
1227 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); | 1230 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); |
1228 FlushPendingInputEventAck(); | 1231 FlushPendingInputEventAck(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 SetPendingWindowRect(initial_pos_); | 1368 SetPendingWindowRect(initial_pos_); |
1366 } | 1369 } |
1367 | 1370 |
1368 void RenderWidget::didFocus() { | 1371 void RenderWidget::didFocus() { |
1369 } | 1372 } |
1370 | 1373 |
1371 void RenderWidget::didBlur() { | 1374 void RenderWidget::didBlur() { |
1372 } | 1375 } |
1373 | 1376 |
1374 void RenderWidget::DoDeferredClose() { | 1377 void RenderWidget::DoDeferredClose() { |
| 1378 // No more compositing is possible. This prevents shutdown races between |
| 1379 // previously posted CreateOutputSurface tasks and the host being unable to |
| 1380 // create them because the close message was handled. |
| 1381 DestroyLayerTreeView(); |
| 1382 // Also prevent new compositors from being created. |
| 1383 host_closing_ = true; |
1375 Send(new ViewHostMsg_Close(routing_id_)); | 1384 Send(new ViewHostMsg_Close(routing_id_)); |
1376 } | 1385 } |
1377 | 1386 |
1378 void RenderWidget::closeWidgetSoon() { | 1387 void RenderWidget::closeWidgetSoon() { |
1379 if (is_swapped_out_) { | 1388 if (is_swapped_out_) { |
1380 // This widget is currently swapped out, and the active widget is in a | 1389 // This widget is currently swapped out, and the active widget is in a |
1381 // different process. Have the browser route the close request to the | 1390 // different process. Have the browser route the close request to the |
1382 // active widget instead, so that the correct unload handlers are run. | 1391 // active widget instead, so that the correct unload handlers are run. |
1383 Send(new ViewHostMsg_RouteCloseEvent(routing_id_)); | 1392 Send(new ViewHostMsg_RouteCloseEvent(routing_id_)); |
1384 return; | 1393 return; |
(...skipping 20 matching lines...) Expand all Loading... |
1405 | 1414 |
1406 SyntheticGesturePacket gesture_packet; | 1415 SyntheticGesturePacket gesture_packet; |
1407 gesture_packet.set_gesture_params(gesture_params.Pass()); | 1416 gesture_packet.set_gesture_params(gesture_params.Pass()); |
1408 | 1417 |
1409 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet)); | 1418 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet)); |
1410 } | 1419 } |
1411 | 1420 |
1412 void RenderWidget::Close() { | 1421 void RenderWidget::Close() { |
1413 screen_metrics_emulator_.reset(); | 1422 screen_metrics_emulator_.reset(); |
1414 if (webwidget_) { | 1423 if (webwidget_) { |
1415 webwidget_->willCloseLayerTreeView(); | 1424 DestroyLayerTreeView(); |
1416 compositor_.reset(); | |
1417 webwidget_->close(); | 1425 webwidget_->close(); |
1418 webwidget_ = NULL; | 1426 webwidget_ = NULL; |
1419 } | 1427 } |
1420 } | 1428 } |
1421 | 1429 |
1422 WebRect RenderWidget::windowRect() { | 1430 WebRect RenderWidget::windowRect() { |
1423 if (pending_window_rect_count_) | 1431 if (pending_window_rect_count_) |
1424 return pending_window_rect_; | 1432 return pending_window_rect_; |
1425 | 1433 |
1426 return view_screen_rect_; | 1434 return view_screen_rect_; |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2149 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2157 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2150 video_hole_frames_.AddObserver(frame); | 2158 video_hole_frames_.AddObserver(frame); |
2151 } | 2159 } |
2152 | 2160 |
2153 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2161 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2154 video_hole_frames_.RemoveObserver(frame); | 2162 video_hole_frames_.RemoveObserver(frame); |
2155 } | 2163 } |
2156 #endif // defined(VIDEO_HOLE) | 2164 #endif // defined(VIDEO_HOLE) |
2157 | 2165 |
2158 } // namespace content | 2166 } // namespace content |
OLD | NEW |