diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 23:01:26 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 23:01:26 +0000 |
commit | 01b0df26a5cbdd2e66d244246d815695b7f2363a (patch) | |
tree | e3b048736aeafd4d61947825b4cbe7eeb256e58a /chrome/browser | |
parent | b959a02903739c2e78245e0afb5c97d6c433ccfb (diff) | |
download | chromium_src-01b0df26a5cbdd2e66d244246d815695b7f2363a.zip chromium_src-01b0df26a5cbdd2e66d244246d815695b7f2363a.tar.gz chromium_src-01b0df26a5cbdd2e66d244246d815695b7f2363a.tar.bz2 |
Fix a DCHECK that I hit while working on the extension shelf for OS X.
BUG=Part of 19073
TEST=unittest in CL
Review URL: http://codereview.chromium.org/185015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25261 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host.cc | 6 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host.h | 7 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_unittest.cc | 19 |
3 files changed, 32 insertions, 0 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index 40fba47..e14b846 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -224,6 +224,9 @@ void RenderWidgetHost::WasResized() { if (new_size == current_size_) return; + if (in_flight_size_ != gfx::Size() && new_size == in_flight_size_) + return; + // We don't expect to receive an ACK when the requested size is empty. if (!new_size.IsEmpty()) resize_ack_pending_ = true; @@ -231,6 +234,8 @@ void RenderWidgetHost::WasResized() { if (!Send(new ViewMsg_Resize(routing_id_, new_size, GetRootWindowResizerRect()))) resize_ack_pending_ = false; + else + in_flight_size_ = new_size; } void RenderWidgetHost::GotFocus() { @@ -588,6 +593,7 @@ void RenderWidgetHost::OnMsgPaintRect( if (is_resize_ack) { DCHECK(resize_ack_pending_); resize_ack_pending_ = false; + in_flight_size_.SetSize(0, 0); } bool is_repaint_ack = diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h index 242d56b..b06bce3 100644 --- a/chrome/browser/renderer_host/render_widget_host.h +++ b/chrome/browser/renderer_host/render_widget_host.h @@ -460,6 +460,13 @@ class RenderWidgetHost : public IPC::Channel::Listener, // The current size of the RenderWidget. gfx::Size current_size_; + // The size we last sent as requested size to the renderer. |current_size_| + // is only updated once the resize message has been ack'd. This on the other + // hand is updated when the resize message is sent. This is very similar to + // |resize_ack_pending_|, but the latter is not set if the new size has width + // or height zero, which is why we need this too. + gfx::Size in_flight_size_; + // True if a mouse move event was sent to the render view and we are waiting // for a corresponding ViewHostMsg_HandleInputEvent_ACK message. bool mouse_move_pending_; diff --git a/chrome/browser/renderer_host/render_widget_host_unittest.cc b/chrome/browser/renderer_host/render_widget_host_unittest.cc index 1b05260..4f16e8d 100644 --- a/chrome/browser/renderer_host/render_widget_host_unittest.cc +++ b/chrome/browser/renderer_host/render_widget_host_unittest.cc @@ -239,6 +239,25 @@ TEST_F(RenderWidgetHostTest, Resize) { host_->WasResized(); EXPECT_FALSE(host_->resize_ack_pending_); EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); + + // Send a rect that has no area but has either width or height set. + process_->sink().ClearMessages(); + view_->set_bounds(gfx::Rect(0, 0, 0, 30)); + host_->WasResized(); + EXPECT_FALSE(host_->resize_ack_pending_); + EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); + + // Set the same size again. It should not be sent again. + process_->sink().ClearMessages(); + host_->WasResized(); + EXPECT_FALSE(host_->resize_ack_pending_); + EXPECT_FALSE(process_->sink().GetFirstMessageMatching(ViewMsg_Resize::ID)); + + // A different size should be sent again, however. + view_->set_bounds(gfx::Rect(0, 0, 0, 31)); + host_->WasResized(); + EXPECT_FALSE(host_->resize_ack_pending_); + EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); } // Tests setting custom background |