Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: content/renderer/render_widget.cc

Issue 23129015: Initialize RenderWidget(Host)(View)s with correct visibility state (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 16 matching lines...) Expand all
27 #include "content/renderer/cursor_utils.h" 27 #include "content/renderer/cursor_utils.h"
28 #include "content/renderer/gpu/compositor_output_surface.h" 28 #include "content/renderer/gpu/compositor_output_surface.h"
29 #include "content/renderer/gpu/compositor_software_output_device.h" 29 #include "content/renderer/gpu/compositor_software_output_device.h"
30 #include "content/renderer/gpu/delegated_compositor_output_surface.h" 30 #include "content/renderer/gpu/delegated_compositor_output_surface.h"
31 #include "content/renderer/gpu/input_handler_manager.h" 31 #include "content/renderer/gpu/input_handler_manager.h"
32 #include "content/renderer/gpu/mailbox_output_surface.h" 32 #include "content/renderer/gpu/mailbox_output_surface.h"
33 #include "content/renderer/gpu/render_widget_compositor.h" 33 #include "content/renderer/gpu/render_widget_compositor.h"
34 #include "content/renderer/ime_event_guard.h" 34 #include "content/renderer/ime_event_guard.h"
35 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 35 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
36 #include "content/renderer/render_process.h" 36 #include "content/renderer/render_process.h"
37 #include "content/renderer/render_process_visibility_manager.h"
38 #include "content/renderer/render_thread_impl.h" 37 #include "content/renderer/render_thread_impl.h"
39 #include "content/renderer/renderer_webkitplatformsupport_impl.h" 38 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
40 #include "ipc/ipc_sync_message.h" 39 #include "ipc/ipc_sync_message.h"
41 #include "skia/ext/platform_canvas.h" 40 #include "skia/ext/platform_canvas.h"
42 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" 41 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
43 #include "third_party/WebKit/public/platform/WebPoint.h" 42 #include "third_party/WebKit/public/platform/WebPoint.h"
44 #include "third_party/WebKit/public/platform/WebRect.h" 43 #include "third_party/WebKit/public/platform/WebRect.h"
45 #include "third_party/WebKit/public/platform/WebSize.h" 44 #include "third_party/WebKit/public/platform/WebSize.h"
46 #include "third_party/WebKit/public/platform/WebString.h" 45 #include "third_party/WebKit/public/platform/WebString.h"
47 #include "third_party/WebKit/public/web/WebCursorInfo.h" 46 #include "third_party/WebKit/public/web/WebCursorInfo.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 return ui::TEXT_INPUT_MODE_DEFAULT; 180 return ui::TEXT_INPUT_MODE_DEFAULT;
182 return it->second; 181 return it->second;
183 } 182 }
184 183
185 } // namespace 184 } // namespace
186 185
187 namespace content { 186 namespace content {
188 187
189 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, 188 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type,
190 const WebKit::WebScreenInfo& screen_info, 189 const WebKit::WebScreenInfo& screen_info,
191 bool swapped_out) 190 bool swapped_out,
191 bool hidden)
192 : routing_id_(MSG_ROUTING_NONE), 192 : routing_id_(MSG_ROUTING_NONE),
193 surface_id_(0), 193 surface_id_(0),
194 webwidget_(NULL), 194 webwidget_(NULL),
195 opener_id_(MSG_ROUTING_NONE), 195 opener_id_(MSG_ROUTING_NONE),
196 init_complete_(false), 196 init_complete_(false),
197 current_paint_buf_(NULL), 197 current_paint_buf_(NULL),
198 overdraw_bottom_height_(0.f), 198 overdraw_bottom_height_(0.f),
199 next_paint_flags_(0), 199 next_paint_flags_(0),
200 filtered_time_per_frame_(0.0f), 200 filtered_time_per_frame_(0.0f),
201 update_reply_pending_(false), 201 update_reply_pending_(false),
202 auto_resize_mode_(false), 202 auto_resize_mode_(false),
203 need_update_rect_for_auto_resize_(false), 203 need_update_rect_for_auto_resize_(false),
204 using_asynchronous_swapbuffers_(false), 204 using_asynchronous_swapbuffers_(false),
205 num_swapbuffers_complete_pending_(0), 205 num_swapbuffers_complete_pending_(0),
206 did_show_(false), 206 did_show_(false),
207 is_hidden_(false), 207 is_hidden_(hidden),
208 is_fullscreen_(false), 208 is_fullscreen_(false),
209 needs_repainting_on_restore_(false), 209 needs_repainting_on_restore_(false),
210 has_focus_(false), 210 has_focus_(false),
211 handling_input_event_(false), 211 handling_input_event_(false),
212 handling_ime_event_(false), 212 handling_ime_event_(false),
213 closing_(false), 213 closing_(false),
214 is_swapped_out_(swapped_out), 214 is_swapped_out_(swapped_out),
215 input_method_is_active_(false), 215 input_method_is_active_(false),
216 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 216 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
217 can_compose_inline_(true), 217 can_compose_inline_(true),
(...skipping 13 matching lines...) Expand all
231 #endif 231 #endif
232 weak_ptr_factory_(this) { 232 weak_ptr_factory_(this) {
233 if (!swapped_out) 233 if (!swapped_out)
234 RenderProcess::current()->AddRefProcess(); 234 RenderProcess::current()->AddRefProcess();
235 DCHECK(RenderThread::Get()); 235 DCHECK(RenderThread::Get());
236 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( 236 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch(
237 switches::kDisableGpuVsync); 237 switches::kDisableGpuVsync);
238 is_threaded_compositing_enabled_ = 238 is_threaded_compositing_enabled_ =
239 CommandLine::ForCurrentProcess()->HasSwitch( 239 CommandLine::ForCurrentProcess()->HasSwitch(
240 switches::kEnableThreadedCompositing); 240 switches::kEnableThreadedCompositing);
241
242 RenderProcessVisibilityManager::GetInstance()->WidgetVisibilityChanged(true);
sky 2013/08/19 20:21:47 How come we now longer need to invoke this?
243 } 241 }
244 242
245 RenderWidget::~RenderWidget() { 243 RenderWidget::~RenderWidget() {
246 DCHECK(!webwidget_) << "Leaking our WebWidget!"; 244 DCHECK(!webwidget_) << "Leaking our WebWidget!";
247 STLDeleteElements(&updates_pending_swap_); 245 STLDeleteElements(&updates_pending_swap_);
248 if (current_paint_buf_) { 246 if (current_paint_buf_) {
249 if (RenderProcess::current()) { 247 if (RenderProcess::current()) {
250 // If the RenderProcess is already gone, it will have released all DIBs 248 // If the RenderProcess is already gone, it will have released all DIBs
251 // in its destructor anyway. 249 // in its destructor anyway.
252 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); 250 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_);
253 } 251 }
254 current_paint_buf_ = NULL; 252 current_paint_buf_ = NULL;
255 } 253 }
256 // If we are swapped out, we have released already. 254 // If we are swapped out, we have released already.
257 if (!is_swapped_out_) 255 if (!is_swapped_out_)
258 RenderProcess::current()->ReleaseProcess(); 256 RenderProcess::current()->ReleaseProcess();
259 } 257 }
260 258
261 // static 259 // static
262 RenderWidget* RenderWidget::Create(int32 opener_id, 260 RenderWidget* RenderWidget::Create(int32 opener_id,
263 WebKit::WebPopupType popup_type, 261 WebKit::WebPopupType popup_type,
264 const WebKit::WebScreenInfo& screen_info) { 262 const WebKit::WebScreenInfo& screen_info) {
265 DCHECK(opener_id != MSG_ROUTING_NONE); 263 DCHECK(opener_id != MSG_ROUTING_NONE);
266 scoped_refptr<RenderWidget> widget( 264 scoped_refptr<RenderWidget> widget(
267 new RenderWidget(popup_type, screen_info, false)); 265 new RenderWidget(popup_type, screen_info, false, false));
268 if (widget->Init(opener_id)) { // adds reference on success. 266 if (widget->Init(opener_id)) { // adds reference on success.
269 return widget.get(); 267 return widget.get();
270 } 268 }
271 return NULL; 269 return NULL;
272 } 270 }
273 271
274 // static 272 // static
275 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { 273 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) {
276 switch (render_widget->popup_type_) { 274 switch (render_widget->popup_type_) {
277 case WebKit::WebPopupTypeNone: // Nothing to create. 275 case WebKit::WebPopupTypeNone: // Nothing to create.
(...skipping 27 matching lines...) Expand all
305 opener_id_ = opener_id; 303 opener_id_ = opener_id;
306 304
307 webwidget_ = web_widget; 305 webwidget_ = web_widget;
308 306
309 bool result = RenderThread::Get()->Send(create_widget_message); 307 bool result = RenderThread::Get()->Send(create_widget_message);
310 if (result) { 308 if (result) {
311 RenderThread::Get()->AddRoute(routing_id_, this); 309 RenderThread::Get()->AddRoute(routing_id_, this);
312 // Take a reference on behalf of the RenderThread. This will be balanced 310 // Take a reference on behalf of the RenderThread. This will be balanced
313 // when we receive ViewMsg_Close. 311 // when we receive ViewMsg_Close.
314 AddRef(); 312 AddRef();
313 if (is_hidden_)
314 RenderThread::Get()->WidgetHidden();
315 return true; 315 return true;
316 } else { 316 } else {
317 // The above Send can fail when the tab is closing. 317 // The above Send can fail when the tab is closing.
318 return false; 318 return false;
319 } 319 }
320 } 320 }
321 321
322 // This is used to complete pending inits and non-pending inits. 322 // This is used to complete pending inits and non-pending inits.
323 void RenderWidget::CompleteInit() { 323 void RenderWidget::CompleteInit() {
324 DCHECK(routing_id_ != MSG_ROUTING_NONE); 324 DCHECK(routing_id_ != MSG_ROUTING_NONE);
(...skipping 2197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2522 2522
2523 if (!context->InitializeWithDefaultBufferSizes( 2523 if (!context->InitializeWithDefaultBufferSizes(
2524 attributes, 2524 attributes,
2525 false /* bind generates resources */, 2525 false /* bind generates resources */,
2526 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) 2526 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) )
2527 return NULL; 2527 return NULL;
2528 return context.release(); 2528 return context.release();
2529 } 2529 }
2530 2530
2531 } // namespace content 2531 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698