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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 10696158: Rename WasRestored to WasShown across all uses. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Bring to ToT to commit Created 8 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
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/browser/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 // Tell the RenderProcessHost we were hidden. 357 // Tell the RenderProcessHost we were hidden.
358 process_->WidgetHidden(); 358 process_->WidgetHidden();
359 359
360 bool is_visible = false; 360 bool is_visible = false;
361 NotificationService::current()->Notify( 361 NotificationService::current()->Notify(
362 NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, 362 NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED,
363 Source<RenderWidgetHost>(this), 363 Source<RenderWidgetHost>(this),
364 Details<bool>(&is_visible)); 364 Details<bool>(&is_visible));
365 } 365 }
366 366
367 void RenderWidgetHostImpl::WasRestored() { 367 void RenderWidgetHostImpl::WasShown() {
368 // When we create the widget, it is created as *not* hidden. 368 // When we create the widget, it is created as *not* hidden.
369 if (!is_hidden_) 369 if (!is_hidden_)
370 return; 370 return;
371 is_hidden_ = false; 371 is_hidden_ = false;
372 372
373 BackingStore* backing_store = BackingStoreManager::Lookup(this); 373 BackingStore* backing_store = BackingStoreManager::Lookup(this);
374 // If we already have a backing store for this widget, then we don't need to 374 // If we already have a backing store for this widget, then we don't need to
375 // repaint on restore _unless_ we know that our backing store is invalid. 375 // repaint on restore _unless_ we know that our backing store is invalid.
376 // When accelerated compositing is on, we must always repaint, even when 376 // When accelerated compositing is on, we must always repaint, even when
377 // the backing store exists. 377 // the backing store exists.
378 bool needs_repainting; 378 bool needs_repainting;
379 if (needs_repainting_on_restore_ || !backing_store || 379 if (needs_repainting_on_restore_ || !backing_store ||
380 is_accelerated_compositing_active()) { 380 is_accelerated_compositing_active()) {
381 needs_repainting = true; 381 needs_repainting = true;
382 needs_repainting_on_restore_ = false; 382 needs_repainting_on_restore_ = false;
383 } else { 383 } else {
384 needs_repainting = false; 384 needs_repainting = false;
385 } 385 }
386 Send(new ViewMsg_WasRestored(routing_id_, needs_repainting)); 386 Send(new ViewMsg_WasShown(routing_id_, needs_repainting));
387 387
388 process_->WidgetRestored(); 388 process_->WidgetRestored();
389 389
390 bool is_visible = true; 390 bool is_visible = true;
391 NotificationService::current()->Notify( 391 NotificationService::current()->Notify(
392 NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, 392 NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED,
393 Source<RenderWidgetHost>(this), 393 Source<RenderWidgetHost>(this),
394 Details<bool>(&is_visible)); 394 Details<bool>(&is_visible));
395 395
396 // It's possible for our size to be out of sync with the renderer. The 396 // It's possible for our size to be out of sync with the renderer. The
397 // following is one case that leads to this: 397 // following is one case that leads to this:
398 // 1. WasResized -> Send ViewMsg_Resize to render 398 // 1. WasResized -> Send ViewMsg_Resize to render
399 // 2. WasResized -> do nothing as resize_ack_pending_ is true 399 // 2. WasResized -> do nothing as resize_ack_pending_ is true
400 // 3. WasHidden 400 // 3. WasHidden
401 // 4. OnMsgUpdateRect from (1) processed. Does NOT invoke WasResized as view 401 // 4. OnMsgUpdateRect from (1) processed. Does NOT invoke WasResized as view
402 // is hidden. Now renderer/browser out of sync with what they think size 402 // is hidden. Now renderer/browser out of sync with what they think size
403 // is. 403 // is.
404 // By invoking WasResized the renderer is updated as necessary. WasResized 404 // By invoking WasResized the renderer is updated as necessary. WasResized
405 // does nothing if the sizes are already in sync. 405 // does nothing if the sizes are already in sync.
406 // 406 //
407 // TODO: ideally ViewMsg_WasRestored would take a size. This way, the renderer 407 // TODO: ideally ViewMsg_WasShown would take a size. This way, the renderer
408 // could handle both the restore and resize at once. This isn't that big a 408 // could handle both the restore and resize at once. This isn't that big a
409 // deal as RenderWidget::WasRestored delays updating, so that the resize from 409 // deal as RenderWidget::WasShown delays updating, so that the resize from
410 // WasResized is usually processed before the renderer is painted. 410 // WasResized is usually processed before the renderer is painted.
411 WasResized(); 411 WasResized();
412 } 412 }
413 413
414 void RenderWidgetHostImpl::WasResized() { 414 void RenderWidgetHostImpl::WasResized() {
415 if (resize_ack_pending_ || !process_->HasConnection() || !view_ || 415 if (resize_ack_pending_ || !process_->HasConnection() || !view_ ||
416 !renderer_initialized_ || should_auto_resize_) { 416 !renderer_initialized_ || should_auto_resize_) {
417 return; 417 return;
418 } 418 }
419 419
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 if (view_rect.IsEmpty()) 599 if (view_rect.IsEmpty())
600 return NULL; 600 return NULL;
601 view_size = view_rect.size(); 601 view_size = view_rect.size();
602 } 602 }
603 603
604 TRACE_EVENT2("renderer_host", "RenderWidgetHostImpl::GetBackingStore", 604 TRACE_EVENT2("renderer_host", "RenderWidgetHostImpl::GetBackingStore",
605 "width", base::IntToString(view_size.width()), 605 "width", base::IntToString(view_size.width()),
606 "height", base::IntToString(view_size.height())); 606 "height", base::IntToString(view_size.height()));
607 607
608 // We should not be asked to paint while we are hidden. If we are hidden, 608 // We should not be asked to paint while we are hidden. If we are hidden,
609 // then it means that our consumer failed to call WasRestored. If we're not 609 // then it means that our consumer failed to call WasShown. If we're not
610 // force creating the backing store, it's OK since we can feel free to give 610 // force creating the backing store, it's OK since we can feel free to give
611 // out our cached one if we have it. 611 // out our cached one if we have it.
612 DCHECK(!is_hidden_ || !force_create) << 612 DCHECK(!is_hidden_ || !force_create) <<
613 "GetBackingStore called while hidden!"; 613 "GetBackingStore called while hidden!";
614 614
615 // We should never be called recursively; this can theoretically lead to 615 // We should never be called recursively; this can theoretically lead to
616 // infinite recursion and almost certainly leads to lower performance. 616 // infinite recursion and almost certainly leads to lower performance.
617 DCHECK(!in_get_backing_store_) << "GetBackingStore called recursively!"; 617 DCHECK(!in_get_backing_store_) << "GetBackingStore called recursively!";
618 AutoReset<bool> auto_reset_in_get_backing_store(&in_get_backing_store_, true); 618 AutoReset<bool> auto_reset_in_get_backing_store(&in_get_backing_store_, true);
619 619
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 // indicate that no callback is in progress (i.e. without this line 1940 // indicate that no callback is in progress (i.e. without this line
1941 // DelayedAutoResized will not get called again). 1941 // DelayedAutoResized will not get called again).
1942 new_auto_size_.SetSize(0, 0); 1942 new_auto_size_.SetSize(0, 0);
1943 if (!should_auto_resize_) 1943 if (!should_auto_resize_)
1944 return; 1944 return;
1945 1945
1946 OnRenderAutoResized(new_size); 1946 OnRenderAutoResized(new_size);
1947 } 1947 }
1948 1948
1949 } // namespace content 1949 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698