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 DCHECK(!host_closing_); | |
1177 | |
1175 compositor_ = RenderWidgetCompositor::Create( | 1178 compositor_ = RenderWidgetCompositor::Create( |
1176 this, is_threaded_compositing_enabled_); | 1179 this, is_threaded_compositing_enabled_); |
1177 compositor_->setViewportSize(size_, physical_backing_size_); | 1180 compositor_->setViewportSize(size_, physical_backing_size_); |
1178 if (init_complete_) | 1181 if (init_complete_) |
1179 StartCompositor(); | 1182 StartCompositor(); |
1180 } | 1183 } |
1181 | 1184 |
1185 void RenderWidget::DestroyLayerTreeView() { | |
1186 // Always send this notification to prevent new layer tree views from | |
enne (OOO)
2014/07/10 20:37:42
This fixed a race where the layer tree view would
| |
1187 // being created, even if one hasn't been created yet. | |
1188 webwidget_->willCloseLayerTreeView(); | |
1189 compositor_.reset(); | |
1190 } | |
1191 | |
1182 blink::WebLayerTreeView* RenderWidget::layerTreeView() { | 1192 blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
1183 return compositor_.get(); | 1193 return compositor_.get(); |
1184 } | 1194 } |
1185 | 1195 |
1186 void RenderWidget::suppressCompositorScheduling(bool enable) { | |
1187 if (compositor_) | |
1188 compositor_->SetSuppressScheduleComposite(enable); | |
1189 } | |
1190 | |
1191 void RenderWidget::willBeginCompositorFrame() { | 1196 void RenderWidget::willBeginCompositorFrame() { |
1192 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); | 1197 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
1193 | 1198 |
1194 DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get()); | |
1195 | |
1196 // The following two can result in further layout and possibly | 1199 // The following two can result in further layout and possibly |
1197 // enable GPU acceleration so they need to be called before any painting | 1200 // enable GPU acceleration so they need to be called before any painting |
1198 // is done. | 1201 // is done. |
1199 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); | 1202 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); |
1200 UpdateSelectionBounds(); | 1203 UpdateSelectionBounds(); |
1201 } | 1204 } |
1202 | 1205 |
1203 void RenderWidget::didBecomeReadyForAdditionalInput() { | 1206 void RenderWidget::didBecomeReadyForAdditionalInput() { |
1204 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); | 1207 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); |
1205 FlushPendingInputEventAck(); | 1208 FlushPendingInputEventAck(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1289 SetPendingWindowRect(initial_pos_); | 1292 SetPendingWindowRect(initial_pos_); |
1290 } | 1293 } |
1291 | 1294 |
1292 void RenderWidget::didFocus() { | 1295 void RenderWidget::didFocus() { |
1293 } | 1296 } |
1294 | 1297 |
1295 void RenderWidget::didBlur() { | 1298 void RenderWidget::didBlur() { |
1296 } | 1299 } |
1297 | 1300 |
1298 void RenderWidget::DoDeferredClose() { | 1301 void RenderWidget::DoDeferredClose() { |
1302 // No more compositing is possible. This prevents shutdown races between | |
1303 // previously posted CreateOutputSurface tasks and the host being unable to | |
1304 // create them because the close message was handled. | |
1305 DestroyLayerTreeView(); | |
1306 // Also prevent new compositors from being created. | |
1307 host_closing_ = true; | |
1299 Send(new ViewHostMsg_Close(routing_id_)); | 1308 Send(new ViewHostMsg_Close(routing_id_)); |
1300 } | 1309 } |
1301 | 1310 |
1302 void RenderWidget::closeWidgetSoon() { | 1311 void RenderWidget::closeWidgetSoon() { |
1303 if (is_swapped_out_) { | 1312 if (is_swapped_out_) { |
1304 // This widget is currently swapped out, and the active widget is in a | 1313 // 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 | 1314 // different process. Have the browser route the close request to the |
1306 // active widget instead, so that the correct unload handlers are run. | 1315 // active widget instead, so that the correct unload handlers are run. |
1307 Send(new ViewHostMsg_RouteCloseEvent(routing_id_)); | 1316 Send(new ViewHostMsg_RouteCloseEvent(routing_id_)); |
1308 return; | 1317 return; |
(...skipping 20 matching lines...) Expand all Loading... | |
1329 | 1338 |
1330 SyntheticGesturePacket gesture_packet; | 1339 SyntheticGesturePacket gesture_packet; |
1331 gesture_packet.set_gesture_params(gesture_params.Pass()); | 1340 gesture_packet.set_gesture_params(gesture_params.Pass()); |
1332 | 1341 |
1333 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet)); | 1342 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet)); |
1334 } | 1343 } |
1335 | 1344 |
1336 void RenderWidget::Close() { | 1345 void RenderWidget::Close() { |
1337 screen_metrics_emulator_.reset(); | 1346 screen_metrics_emulator_.reset(); |
1338 if (webwidget_) { | 1347 if (webwidget_) { |
1339 webwidget_->willCloseLayerTreeView(); | 1348 DestroyLayerTreeView(); |
1340 compositor_.reset(); | |
1341 webwidget_->close(); | 1349 webwidget_->close(); |
1342 webwidget_ = NULL; | 1350 webwidget_ = NULL; |
1343 } | 1351 } |
1344 } | 1352 } |
1345 | 1353 |
1346 WebRect RenderWidget::windowRect() { | 1354 WebRect RenderWidget::windowRect() { |
1347 if (pending_window_rect_count_) | 1355 if (pending_window_rect_count_) |
1348 return pending_window_rect_; | 1356 return pending_window_rect_; |
1349 | 1357 |
1350 return view_screen_rect_; | 1358 return view_screen_rect_; |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2073 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2081 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2074 video_hole_frames_.AddObserver(frame); | 2082 video_hole_frames_.AddObserver(frame); |
2075 } | 2083 } |
2076 | 2084 |
2077 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2085 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2078 video_hole_frames_.RemoveObserver(frame); | 2086 video_hole_frames_.RemoveObserver(frame); |
2079 } | 2087 } |
2080 #endif // defined(VIDEO_HOLE) | 2088 #endif // defined(VIDEO_HOLE) |
2081 | 2089 |
2082 } // namespace content | 2090 } // namespace content |
OLD | NEW |