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

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

Issue 3547008: Handle resize corner layout entirely in the platform BrowserWindow*/BrowserView* code... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/render_widget_host.h" 5 #include "chrome/browser/renderer_host/render_widget_host.h"
6 6
7 #include "app/keyboard_codes.h" 7 #include "app/keyboard_codes.h"
8 #include "base/auto_reset.h" 8 #include "base/auto_reset.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 Source<RenderWidgetHost>(this), 248 Source<RenderWidgetHost>(this),
249 Details<bool>(&is_visible)); 249 Details<bool>(&is_visible));
250 } 250 }
251 251
252 void RenderWidgetHost::WasResized() { 252 void RenderWidgetHost::WasResized() {
253 if (resize_ack_pending_ || !process_->HasConnection() || !view_ || 253 if (resize_ack_pending_ || !process_->HasConnection() || !view_ ||
254 !renderer_initialized_) { 254 !renderer_initialized_) {
255 return; 255 return;
256 } 256 }
257 257
258 gfx::Rect view_bounds = view_->GetViewBounds(); 258 gfx::Size new_size = view_->GetViewBounds().size();
259 gfx::Size new_size(view_bounds.width(), view_bounds.height()); 259 gfx::Rect reserved_rect = view_->reserved_contents_rect();
260 260
261 // Avoid asking the RenderWidget to resize to its current size, since it 261 // Avoid asking the RenderWidget to resize to its current size, since it
262 // won't send us a PaintRect message in that case. 262 // won't send us a PaintRect message in that case, unless reserved area is
263 if (new_size == current_size_) 263 // changed, but even in this case PaintRect message won't be sent.
264 if (new_size == current_size_ && reserved_rect == current_reserved_rect_)
264 return; 265 return;
265 266
266 if (in_flight_size_ != gfx::Size() && new_size == in_flight_size_) 267 if (in_flight_size_ != gfx::Size() && new_size == in_flight_size_ &&
268 in_flight_reserved_rect_ == reserved_rect) {
267 return; 269 return;
270 }
268 271
269 // We don't expect to receive an ACK when the requested size is empty. 272 // We don't expect to receive an ACK when the requested size is empty or
270 if (!new_size.IsEmpty()) 273 // only reserved area is changed.
271 resize_ack_pending_ = true; 274 resize_ack_pending_ = !new_size.IsEmpty() && new_size != current_size_;
272 275
273 if (!Send(new ViewMsg_Resize(routing_id_, new_size, 276 if (!Send(new ViewMsg_Resize(routing_id_, new_size, reserved_rect))) {
274 GetRootWindowResizerRect())))
275 resize_ack_pending_ = false; 277 resize_ack_pending_ = false;
276 else 278 } else {
277 in_flight_size_ = new_size; 279 if (resize_ack_pending_) {
280 in_flight_size_ = new_size;
281 in_flight_reserved_rect_ = reserved_rect;
282 } else {
283 // Message was sent successfully, but we do not expect to receive an ACK,
284 // so update current values right away.
285 current_size_ = new_size;
286 current_reserved_rect_ = reserved_rect;
287 }
288 }
278 } 289 }
279 290
280 void RenderWidgetHost::GotFocus() { 291 void RenderWidgetHost::GotFocus() {
281 Focus(); 292 Focus();
282 } 293 }
283 294
284 void RenderWidgetHost::Focus() { 295 void RenderWidgetHost::Focus() {
285 Send(new ViewMsg_SetFocus(routing_id_, true)); 296 Send(new ViewMsg_SetFocus(routing_id_, true));
286 } 297 }
287 298
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 621
611 // Must reset these to ensure that keyboard events work with a new renderer. 622 // Must reset these to ensure that keyboard events work with a new renderer.
612 key_queue_.clear(); 623 key_queue_.clear();
613 suppress_next_char_events_ = false; 624 suppress_next_char_events_ = false;
614 625
615 // Reset some fields in preparation for recovering from a crash. 626 // Reset some fields in preparation for recovering from a crash.
616 resize_ack_pending_ = false; 627 resize_ack_pending_ = false;
617 repaint_ack_pending_ = false; 628 repaint_ack_pending_ = false;
618 629
619 in_flight_size_.SetSize(0, 0); 630 in_flight_size_.SetSize(0, 0);
631 in_flight_reserved_rect_.SetRect(0, 0, 0, 0);
620 current_size_.SetSize(0, 0); 632 current_size_.SetSize(0, 0);
633 current_reserved_rect_.SetRect(0, 0, 0, 0);
621 is_hidden_ = false; 634 is_hidden_ = false;
622 635
623 if (view_) { 636 if (view_) {
624 view_->RenderViewGone(); 637 view_->RenderViewGone();
625 view_ = NULL; // The View should be deleted by RenderViewGone. 638 view_ = NULL; // The View should be deleted by RenderViewGone.
626 } 639 }
627 640
628 BackingStoreManager::RemoveBackingStore(this); 641 BackingStoreManager::RemoveBackingStore(this);
629 } 642 }
630 643
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 681
669 void RenderWidgetHost::ImeConfirmComposition() { 682 void RenderWidgetHost::ImeConfirmComposition() {
670 Send(new ViewMsg_ImeConfirmComposition(routing_id())); 683 Send(new ViewMsg_ImeConfirmComposition(routing_id()));
671 } 684 }
672 685
673 void RenderWidgetHost::ImeCancelComposition() { 686 void RenderWidgetHost::ImeCancelComposition() {
674 Send(new ViewMsg_ImeSetComposition(routing_id(), string16(), 687 Send(new ViewMsg_ImeSetComposition(routing_id(), string16(),
675 std::vector<WebKit::WebCompositionUnderline>(), 0, 0)); 688 std::vector<WebKit::WebCompositionUnderline>(), 0, 0));
676 } 689 }
677 690
678 gfx::Rect RenderWidgetHost::GetRootWindowResizerRect() const {
679 return gfx::Rect();
680 }
681
682 void RenderWidgetHost::SetActive(bool active) { 691 void RenderWidgetHost::SetActive(bool active) {
683 Send(new ViewMsg_SetActive(routing_id(), active)); 692 Send(new ViewMsg_SetActive(routing_id(), active));
684 } 693 }
685 694
686 void RenderWidgetHost::Destroy() { 695 void RenderWidgetHost::Destroy() {
687 NotificationService::current()->Notify( 696 NotificationService::current()->Notify(
688 NotificationType::RENDER_WIDGET_HOST_DESTROYED, 697 NotificationType::RENDER_WIDGET_HOST_DESTROYED,
689 Source<RenderWidgetHost>(this), 698 Source<RenderWidgetHost>(this),
690 NotificationService::NoDetails()); 699 NotificationService::NoDetails());
691 700
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 767
759 void RenderWidgetHost::OnMsgUpdateRect( 768 void RenderWidgetHost::OnMsgUpdateRect(
760 const ViewHostMsg_UpdateRect_Params& params) { 769 const ViewHostMsg_UpdateRect_Params& params) {
761 TimeTicks paint_start = TimeTicks::Now(); 770 TimeTicks paint_start = TimeTicks::Now();
762 771
763 if (paint_observer_.get()) 772 if (paint_observer_.get())
764 paint_observer_->RenderWidgetHostWillPaint(this); 773 paint_observer_->RenderWidgetHostWillPaint(this);
765 774
766 // Update our knowledge of the RenderWidget's size. 775 // Update our knowledge of the RenderWidget's size.
767 current_size_ = params.view_size; 776 current_size_ = params.view_size;
777 current_reserved_rect_ = params.resizer_rect;
768 778
769 bool is_resize_ack = 779 bool is_resize_ack =
770 ViewHostMsg_UpdateRect_Flags::is_resize_ack(params.flags); 780 ViewHostMsg_UpdateRect_Flags::is_resize_ack(params.flags);
771 781
772 // resize_ack_pending_ needs to be cleared before we call DidPaintRect, since 782 // resize_ack_pending_ needs to be cleared before we call DidPaintRect, since
773 // that will end up reaching GetBackingStore. 783 // that will end up reaching GetBackingStore.
774 if (is_resize_ack) { 784 if (is_resize_ack) {
775 DCHECK(resize_ack_pending_); 785 DCHECK(resize_ack_pending_);
776 resize_ack_pending_ = false; 786 resize_ack_pending_ = false;
777 in_flight_size_.SetSize(0, 0); 787 in_flight_size_.SetSize(0, 0);
788 in_flight_reserved_rect_.SetRect(0, 0, 0, 0);
778 } 789 }
779 790
780 bool is_repaint_ack = 791 bool is_repaint_ack =
781 ViewHostMsg_UpdateRect_Flags::is_repaint_ack(params.flags); 792 ViewHostMsg_UpdateRect_Flags::is_repaint_ack(params.flags);
782 if (is_repaint_ack) { 793 if (is_repaint_ack) {
783 repaint_ack_pending_ = false; 794 repaint_ack_pending_ = false;
784 TimeDelta delta = TimeTicks::Now() - repaint_start_time_; 795 TimeDelta delta = TimeTicks::Now() - repaint_start_time_;
785 UMA_HISTOGRAM_TIMES("MPArch.RWH_RepaintDelta", delta); 796 UMA_HISTOGRAM_TIMES("MPArch.RWH_RepaintDelta", delta);
786 } 797 }
787 798
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 params.copy_rects); 852 params.copy_rects);
842 view_being_painted_ = false; 853 view_being_painted_ = false;
843 } 854 }
844 } 855 }
845 856
846 if (paint_observer_.get()) 857 if (paint_observer_.get())
847 paint_observer_->RenderWidgetHostDidPaint(this); 858 paint_observer_->RenderWidgetHostDidPaint(this);
848 859
849 // If we got a resize ack, then perhaps we have another resize to send? 860 // If we got a resize ack, then perhaps we have another resize to send?
850 if (is_resize_ack && view_) { 861 if (is_resize_ack && view_) {
851 gfx::Rect view_bounds = view_->GetViewBounds(); 862 // WasResized checks the current size and sends the resize update only
852 if (current_size_.width() != view_bounds.width() || 863 // when something was actually changed.
853 current_size_.height() != view_bounds.height()) { 864 WasResized();
854 WasResized();
855 }
856 } 865 }
857 866
858 if (painting_observer_) 867 if (painting_observer_)
859 painting_observer_->WidgetDidUpdateBackingStore(this); 868 painting_observer_->WidgetDidUpdateBackingStore(this);
860 869
861 // Log the time delta for processing a paint message. 870 // Log the time delta for processing a paint message.
862 TimeDelta delta = TimeTicks::Now() - paint_start; 871 TimeDelta delta = TimeTicks::Now() - paint_start;
863 UMA_HISTOGRAM_TIMES("MPArch.RWH_OnMsgUpdateRect", delta); 872 UMA_HISTOGRAM_TIMES("MPArch.RWH_OnMsgUpdateRect", delta);
864 } 873 }
865 874
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 // of this key event. 1168 // of this key event.
1160 if (!processed && !is_hidden_ && !front_item.skip_in_browser) { 1169 if (!processed && !is_hidden_ && !front_item.skip_in_browser) {
1161 UnhandledKeyboardEvent(front_item); 1170 UnhandledKeyboardEvent(front_item);
1162 1171
1163 // WARNING: This RenderWidgetHost can be deallocated at this point 1172 // WARNING: This RenderWidgetHost can be deallocated at this point
1164 // (i.e. in the case of Ctrl+W, where the call to 1173 // (i.e. in the case of Ctrl+W, where the call to
1165 // UnhandledKeyboardEvent destroys this RenderWidgetHost). 1174 // UnhandledKeyboardEvent destroys this RenderWidgetHost).
1166 } 1175 }
1167 } 1176 }
1168 } 1177 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host.h ('k') | chrome/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698