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

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

Issue 8704005: Add autoresize capability to chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Standardize on resize everywhere. Created 9 years 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "content/browser/renderer_host/render_widget_host.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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 : renderer_initialized_(false), 82 : renderer_initialized_(false),
83 renderer_accessible_(false), 83 renderer_accessible_(false),
84 view_(NULL), 84 view_(NULL),
85 process_(process), 85 process_(process),
86 routing_id_(routing_id), 86 routing_id_(routing_id),
87 is_loading_(false), 87 is_loading_(false),
88 is_hidden_(false), 88 is_hidden_(false),
89 is_accelerated_compositing_active_(false), 89 is_accelerated_compositing_active_(false),
90 repaint_ack_pending_(false), 90 repaint_ack_pending_(false),
91 resize_ack_pending_(false), 91 resize_ack_pending_(false),
92 should_auto_resize_(false),
92 mouse_move_pending_(false), 93 mouse_move_pending_(false),
93 mouse_wheel_pending_(false), 94 mouse_wheel_pending_(false),
94 touch_move_pending_(false), 95 touch_move_pending_(false),
95 touch_event_is_queued_(false), 96 touch_event_is_queued_(false),
96 needs_repainting_on_restore_(false), 97 needs_repainting_on_restore_(false),
97 is_unresponsive_(false), 98 is_unresponsive_(false),
98 in_get_backing_store_(false), 99 in_get_backing_store_(false),
99 view_being_painted_(false), 100 view_being_painted_(false),
100 ignore_input_events_(false), 101 ignore_input_events_(false),
101 text_direction_updated_(false), 102 text_direction_updated_(false),
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // 326 //
326 // TODO: ideally ViewMsg_WasRestored would take a size. This way, the renderer 327 // TODO: ideally ViewMsg_WasRestored would take a size. This way, the renderer
327 // could handle both the restore and resize at once. This isn't that big a 328 // could handle both the restore and resize at once. This isn't that big a
328 // deal as RenderWidget::WasRestored delays updating, so that the resize from 329 // deal as RenderWidget::WasRestored delays updating, so that the resize from
329 // WasResized is usually processed before the renderer is painted. 330 // WasResized is usually processed before the renderer is painted.
330 WasResized(); 331 WasResized();
331 } 332 }
332 333
333 void RenderWidgetHost::WasResized() { 334 void RenderWidgetHost::WasResized() {
334 if (resize_ack_pending_ || !process_->HasConnection() || !view_ || 335 if (resize_ack_pending_ || !process_->HasConnection() || !view_ ||
335 !renderer_initialized_) { 336 !renderer_initialized_ || should_auto_resize_) {
336 return; 337 return;
337 } 338 }
338 339
339 #if !defined(OS_MACOSX) 340 #if !defined(OS_MACOSX)
340 gfx::Size new_size = view_->GetViewBounds().size(); 341 gfx::Size new_size = view_->GetViewBounds().size();
341 #else 342 #else
342 // When UI scaling is enabled on OS X, allocate a smaller bitmap and 343 // When UI scaling is enabled on OS X, allocate a smaller bitmap and
343 // pixel-scale it up. 344 // pixel-scale it up.
344 // TODO(thakis): Use pixel size on mac and set UI scale in renderer. 345 // TODO(thakis): Use pixel size on mac and set UI scale in renderer.
345 // http://crbug.com/31960 346 // http://crbug.com/31960
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 } 862 }
862 863
863 bool RenderWidgetHost::IsMouseLocked() const { 864 bool RenderWidgetHost::IsMouseLocked() const {
864 return view_ ? view_->mouse_locked() : false; 865 return view_ ? view_->mouse_locked() : false;
865 } 866 }
866 867
867 bool RenderWidgetHost::IsFullscreen() const { 868 bool RenderWidgetHost::IsFullscreen() const {
868 return false; 869 return false;
869 } 870 }
870 871
872 void RenderWidgetHost::SetShouldAutoResize(bool enable) {
873 // Note if this switches from true to false then one has to verify that the
874 // mechanics about all the messaging works. For example, what happens to a
875 // update message rect that was in progress from the render widget. Perhaps,
876 // on a transition to false, this should do a WasResized, but what if that
877 // will not trigger a resize message...etc. Due to these complications it is
878 // fitting that this method doesn't look like a simple set method.
879 DCHECK(enable);
880
881 // TODO: Change this to enable instead of true when this supports turning
882 // off auto-resize.
883 should_auto_resize_ = true;
884 }
885
871 void RenderWidgetHost::Destroy() { 886 void RenderWidgetHost::Destroy() {
872 content::NotificationService::current()->Notify( 887 content::NotificationService::current()->Notify(
873 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 888 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
874 content::Source<RenderWidgetHost>(this), 889 content::Source<RenderWidgetHost>(this),
875 content::NotificationService::NoDetails()); 890 content::NotificationService::NoDetails());
876 891
877 // Tell the view to die. 892 // Tell the view to die.
878 // Note that in the process of the view shutting down, it can call a ton 893 // Note that in the process of the view shutting down, it can call a ton
879 // of other messages on us. So if you do any other deinitialization here, 894 // of other messages on us. So if you do any other deinitialization here,
880 // do it after this call to view_->Destroy(). 895 // do it after this call to view_->Destroy().
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 // Update our knowledge of the RenderWidget's size. 999 // Update our knowledge of the RenderWidget's size.
985 current_size_ = params.view_size; 1000 current_size_ = params.view_size;
986 // Update our knowledge of the RenderWidget's scroll offset. 1001 // Update our knowledge of the RenderWidget's scroll offset.
987 last_scroll_offset_ = params.scroll_offset; 1002 last_scroll_offset_ = params.scroll_offset;
988 1003
989 bool is_resize_ack = 1004 bool is_resize_ack =
990 ViewHostMsg_UpdateRect_Flags::is_resize_ack(params.flags); 1005 ViewHostMsg_UpdateRect_Flags::is_resize_ack(params.flags);
991 1006
992 // resize_ack_pending_ needs to be cleared before we call DidPaintRect, since 1007 // resize_ack_pending_ needs to be cleared before we call DidPaintRect, since
993 // that will end up reaching GetBackingStore. 1008 // that will end up reaching GetBackingStore.
994 if (is_resize_ack) { 1009 if (is_resize_ack || should_auto_resize_) {
995 DCHECK(resize_ack_pending_); 1010 if (is_resize_ack) {
996 resize_ack_pending_ = false; 1011 DCHECK(resize_ack_pending_);
997 in_flight_size_.SetSize(0, 0); 1012 resize_ack_pending_ = false;
998 in_flight_reserved_rect_.SetRect(0, 0, 0, 0); 1013 in_flight_size_.SetSize(0, 0);
1014 in_flight_reserved_rect_.SetRect(0, 0, 0, 0);
1015 }
999 // Update our knowledge of the RenderWidget's resizer rect. 1016 // Update our knowledge of the RenderWidget's resizer rect.
1000 // ViewMsg_Resize is acknowledged only when view size is actually changed, 1017 // ViewMsg_Resize is acknowledged only when view size is actually changed,
1001 // otherwise current_reserved_rect_ is updated immediately after sending 1018 // otherwise current_reserved_rect_ is updated immediately after sending
1002 // ViewMsg_Resize to the RenderWidget and can be clobbered by 1019 // ViewMsg_Resize to the RenderWidget and can be clobbered by
1003 // OnMsgUpdateRect called for a paint that was initiated before the resize 1020 // OnMsgUpdateRect called for a paint that was initiated before the resize
1004 // message was sent. 1021 // message was sent.
1005 current_reserved_rect_ = params.resizer_rect; 1022 current_reserved_rect_ = params.resizer_rect;
1006 } 1023 }
1007 1024
1008 bool is_repaint_ack = 1025 bool is_repaint_ack =
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 base::Bind(&RenderWidgetHost::DidUpdateBackingStore, 1066 base::Bind(&RenderWidgetHost::DidUpdateBackingStore,
1050 weak_factory_.GetWeakPtr(), params, paint_start)); 1067 weak_factory_.GetWeakPtr(), params, paint_start));
1051 } 1068 }
1052 } 1069 }
1053 } 1070 }
1054 1071
1055 if (!was_async) { 1072 if (!was_async) {
1056 DidUpdateBackingStore(params, paint_start); 1073 DidUpdateBackingStore(params, paint_start);
1057 } 1074 }
1058 1075
1076 if (should_auto_resize_) {
1077 OnRenderAutoResized(params.view_size);
1078 }
1079
1059 // Log the time delta for processing a paint message. On platforms that don't 1080 // Log the time delta for processing a paint message. On platforms that don't
1060 // support asynchronous painting, this is equivalent to 1081 // support asynchronous painting, this is equivalent to
1061 // MPArch.RWH_TotalPaintTime. 1082 // MPArch.RWH_TotalPaintTime.
1062 TimeDelta delta = TimeTicks::Now() - paint_start; 1083 TimeDelta delta = TimeTicks::Now() - paint_start;
1063 UMA_HISTOGRAM_TIMES("MPArch.RWH_OnMsgUpdateRect", delta); 1084 UMA_HISTOGRAM_TIMES("MPArch.RWH_OnMsgUpdateRect", delta);
1064 } 1085 }
1065 1086
1066 void RenderWidgetHost::DidUpdateBackingStore( 1087 void RenderWidgetHost::DidUpdateBackingStore(
1067 const ViewHostMsg_UpdateRect_Params& params, 1088 const ViewHostMsg_UpdateRect_Params& params,
1068 const TimeTicks& paint_start) { 1089 const TimeTicks& paint_start) {
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 } 1538 }
1518 1539
1519 // static 1540 // static
1520 void RenderWidgetHost::AcknowledgePostSubBuffer(int32 route_id, 1541 void RenderWidgetHost::AcknowledgePostSubBuffer(int32 route_id,
1521 int gpu_host_id) { 1542 int gpu_host_id) {
1522 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id); 1543 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id);
1523 if (ui_shim) 1544 if (ui_shim)
1524 ui_shim->Send(new AcceleratedSurfaceMsg_PostSubBufferACK(route_id)); 1545 ui_shim->Send(new AcceleratedSurfaceMsg_PostSubBufferACK(route_id));
1525 } 1546 }
1526 #endif 1547 #endif
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698