| 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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 did_show_(false), | 379 did_show_(false), |
| 380 is_hidden_(hidden), | 380 is_hidden_(hidden), |
| 381 never_visible_(never_visible), | 381 never_visible_(never_visible), |
| 382 is_fullscreen_(false), | 382 is_fullscreen_(false), |
| 383 has_focus_(false), | 383 has_focus_(false), |
| 384 handling_input_event_(false), | 384 handling_input_event_(false), |
| 385 handling_ime_event_(false), | 385 handling_ime_event_(false), |
| 386 handling_event_type_(WebInputEvent::Undefined), | 386 handling_event_type_(WebInputEvent::Undefined), |
| 387 ignore_ack_for_mouse_move_from_debugger_(false), | 387 ignore_ack_for_mouse_move_from_debugger_(false), |
| 388 closing_(false), | 388 closing_(false), |
| 389 host_closing_(false), |
| 389 is_swapped_out_(swapped_out), | 390 is_swapped_out_(swapped_out), |
| 390 input_method_is_active_(false), | 391 input_method_is_active_(false), |
| 391 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 392 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 392 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 393 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
| 393 can_compose_inline_(true), | 394 can_compose_inline_(true), |
| 394 popup_type_(popup_type), | 395 popup_type_(popup_type), |
| 395 pending_window_rect_count_(0), | 396 pending_window_rect_count_(0), |
| 396 suppress_next_char_events_(false), | 397 suppress_next_char_events_(false), |
| 397 screen_info_(screen_info), | 398 screen_info_(screen_info), |
| 398 device_scale_factor_(screen_info_.deviceScaleFactor), | 399 device_scale_factor_(screen_info_.deviceScaleFactor), |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 } | 1166 } |
| 1166 | 1167 |
| 1167 void RenderWidget::AutoResizeCompositor() { | 1168 void RenderWidget::AutoResizeCompositor() { |
| 1168 physical_backing_size_ = gfx::ToCeiledSize(gfx::ScaleSize(size_, | 1169 physical_backing_size_ = gfx::ToCeiledSize(gfx::ScaleSize(size_, |
| 1169 device_scale_factor_)); | 1170 device_scale_factor_)); |
| 1170 if (compositor_) | 1171 if (compositor_) |
| 1171 compositor_->setViewportSize(size_, physical_backing_size_); | 1172 compositor_->setViewportSize(size_, physical_backing_size_); |
| 1172 } | 1173 } |
| 1173 | 1174 |
| 1174 void RenderWidget::initializeLayerTreeView() { | 1175 void RenderWidget::initializeLayerTreeView() { |
| 1176 // The host is currently shutting down and any old compositors have |
| 1177 // been destroyed, so don't create any new ones. |
| 1178 if (host_closing_) |
| 1179 return; |
| 1180 |
| 1175 compositor_ = RenderWidgetCompositor::Create( | 1181 compositor_ = RenderWidgetCompositor::Create( |
| 1176 this, is_threaded_compositing_enabled_); | 1182 this, is_threaded_compositing_enabled_); |
| 1177 compositor_->setViewportSize(size_, physical_backing_size_); | 1183 compositor_->setViewportSize(size_, physical_backing_size_); |
| 1178 if (init_complete_) | 1184 if (init_complete_) |
| 1179 StartCompositor(); | 1185 StartCompositor(); |
| 1180 } | 1186 } |
| 1181 | 1187 |
| 1188 void RenderWidget::DestroyLayerTreeView() { |
| 1189 if (!compositor_) |
| 1190 return; |
| 1191 webwidget_->willCloseLayerTreeView(); |
| 1192 compositor_.reset(); |
| 1193 } |
| 1194 |
| 1182 blink::WebLayerTreeView* RenderWidget::layerTreeView() { | 1195 blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
| 1183 return compositor_.get(); | 1196 return compositor_.get(); |
| 1184 } | 1197 } |
| 1185 | 1198 |
| 1186 void RenderWidget::suppressCompositorScheduling(bool enable) { | 1199 void RenderWidget::suppressCompositorScheduling(bool enable) { |
| 1187 if (compositor_) | 1200 if (compositor_) |
| 1188 compositor_->SetSuppressScheduleComposite(enable); | 1201 compositor_->SetSuppressScheduleComposite(enable); |
| 1189 } | 1202 } |
| 1190 | 1203 |
| 1191 void RenderWidget::willBeginCompositorFrame() { | 1204 void RenderWidget::willBeginCompositorFrame() { |
| 1192 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); | 1205 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
| 1193 | 1206 |
| 1194 DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get()); | |
| 1195 | |
| 1196 // The following two can result in further layout and possibly | 1207 // The following two can result in further layout and possibly |
| 1197 // enable GPU acceleration so they need to be called before any painting | 1208 // enable GPU acceleration so they need to be called before any painting |
| 1198 // is done. | 1209 // is done. |
| 1199 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); | 1210 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); |
| 1200 UpdateSelectionBounds(); | 1211 UpdateSelectionBounds(); |
| 1201 } | 1212 } |
| 1202 | 1213 |
| 1203 void RenderWidget::didBecomeReadyForAdditionalInput() { | 1214 void RenderWidget::didBecomeReadyForAdditionalInput() { |
| 1204 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); | 1215 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); |
| 1205 FlushPendingInputEventAck(); | 1216 FlushPendingInputEventAck(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 SetPendingWindowRect(initial_pos_); | 1300 SetPendingWindowRect(initial_pos_); |
| 1290 } | 1301 } |
| 1291 | 1302 |
| 1292 void RenderWidget::didFocus() { | 1303 void RenderWidget::didFocus() { |
| 1293 } | 1304 } |
| 1294 | 1305 |
| 1295 void RenderWidget::didBlur() { | 1306 void RenderWidget::didBlur() { |
| 1296 } | 1307 } |
| 1297 | 1308 |
| 1298 void RenderWidget::DoDeferredClose() { | 1309 void RenderWidget::DoDeferredClose() { |
| 1310 // No more compositing is possible. This prevents shutdown races between |
| 1311 // previously posted CreateOutputSurface tasks and the host being unable to |
| 1312 // create them because the close message was handled. |
| 1313 DestroyLayerTreeView(); |
| 1314 // Also prevent new compositors from being created. |
| 1315 host_closing_ = true; |
| 1299 Send(new ViewHostMsg_Close(routing_id_)); | 1316 Send(new ViewHostMsg_Close(routing_id_)); |
| 1300 } | 1317 } |
| 1301 | 1318 |
| 1302 void RenderWidget::closeWidgetSoon() { | 1319 void RenderWidget::closeWidgetSoon() { |
| 1303 if (is_swapped_out_) { | 1320 if (is_swapped_out_) { |
| 1304 // This widget is currently swapped out, and the active widget is in a | 1321 // This widget is currently swapped out, and the active widget is in a |
| 1305 // different process. Have the browser route the close request to the | 1322 // different process. Have the browser route the close request to the |
| 1306 // active widget instead, so that the correct unload handlers are run. | 1323 // active widget instead, so that the correct unload handlers are run. |
| 1307 Send(new ViewHostMsg_RouteCloseEvent(routing_id_)); | 1324 Send(new ViewHostMsg_RouteCloseEvent(routing_id_)); |
| 1308 return; | 1325 return; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1329 | 1346 |
| 1330 SyntheticGesturePacket gesture_packet; | 1347 SyntheticGesturePacket gesture_packet; |
| 1331 gesture_packet.set_gesture_params(gesture_params.Pass()); | 1348 gesture_packet.set_gesture_params(gesture_params.Pass()); |
| 1332 | 1349 |
| 1333 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet)); | 1350 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet)); |
| 1334 } | 1351 } |
| 1335 | 1352 |
| 1336 void RenderWidget::Close() { | 1353 void RenderWidget::Close() { |
| 1337 screen_metrics_emulator_.reset(); | 1354 screen_metrics_emulator_.reset(); |
| 1338 if (webwidget_) { | 1355 if (webwidget_) { |
| 1339 webwidget_->willCloseLayerTreeView(); | 1356 DestroyLayerTreeView(); |
| 1340 compositor_.reset(); | |
| 1341 webwidget_->close(); | 1357 webwidget_->close(); |
| 1342 webwidget_ = NULL; | 1358 webwidget_ = NULL; |
| 1343 } | 1359 } |
| 1344 } | 1360 } |
| 1345 | 1361 |
| 1346 WebRect RenderWidget::windowRect() { | 1362 WebRect RenderWidget::windowRect() { |
| 1347 if (pending_window_rect_count_) | 1363 if (pending_window_rect_count_) |
| 1348 return pending_window_rect_; | 1364 return pending_window_rect_; |
| 1349 | 1365 |
| 1350 return view_screen_rect_; | 1366 return view_screen_rect_; |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2073 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2089 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2074 video_hole_frames_.AddObserver(frame); | 2090 video_hole_frames_.AddObserver(frame); |
| 2075 } | 2091 } |
| 2076 | 2092 |
| 2077 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2093 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2078 video_hole_frames_.RemoveObserver(frame); | 2094 video_hole_frames_.RemoveObserver(frame); |
| 2079 } | 2095 } |
| 2080 #endif // defined(VIDEO_HOLE) | 2096 #endif // defined(VIDEO_HOLE) |
| 2081 | 2097 |
| 2082 } // namespace content | 2098 } // namespace content |
| OLD | NEW |