Chromium Code Reviews| Index: content/renderer/browser_plugin/browser_plugin.cc |
| diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc |
| index ebcbd3ab8c797924889f28827003f22fba36afcb..96c9d074cfcaecd566ab478877389abb75e9d7e4 100644 |
| --- a/content/renderer/browser_plugin/browser_plugin.cc |
| +++ b/content/renderer/browser_plugin/browser_plugin.cc |
| @@ -102,7 +102,7 @@ void BrowserPlugin::SetSrcAttribute(const std::string& src) { |
| instance_id_, |
| parent_frame_, |
| src, |
| - gfx::Size(width(), height()))); |
| + *GetPendingResizeParams())); |
|
Fady Samuel
2012/09/24 22:16:58
Shouldn't this get freed after we send it?
lazyboy
2012/09/25 17:57:22
Done.
|
| // Record that we sent a NavigateGuest message to embedder. Once we send |
| // such a message, subsequent SetSrcAttribute() calls must always send |
| // NavigateGuest messages to the embedder (even if |src| is empty), so |
| @@ -362,11 +362,6 @@ void BrowserPlugin::updateGeometry( |
| old_height == window_rect.height) { |
| return; |
| } |
| - // Until an actual navigation occurs, there is no browser side embedder |
| - // present to notify about geometry updates. In this case, after we've updated |
| - // the BrowserPlugin's state we are done and can return immediately. |
| - if (!navigate_src_sent_) |
| - return; |
| const size_t stride = skia::PlatformCanvas::StrideForWidth(window_rect.width); |
| // Make sure the size of the damage buffer is at least four bytes so that we |
| @@ -399,26 +394,55 @@ void BrowserPlugin::updateGeometry( |
| // Insert the magic word. |
| *static_cast<unsigned int*>(new_damage_buffer->memory()) = 0xdeadbeef; |
| - BrowserPluginHostMsg_ResizeGuest_Params params; |
| - params.damage_buffer_id = new_damage_buffer->id(); |
| -#if defined(OS_WIN) |
| - params.damage_buffer_size = size; |
| -#endif |
| - params.width = window_rect.width; |
| - params.height = window_rect.height; |
| - params.resize_pending = resize_pending_; |
| - params.scale_factor = GetDeviceScaleFactor(); |
| - BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest( |
| - render_view_->GetRoutingID(), |
| - instance_id_, |
| - params)); |
| - resize_pending_ = true; |
| - |
| if (damage_buffer_) { |
| RenderProcess::current()->FreeTransportDIB(damage_buffer_); |
| damage_buffer_ = NULL; |
| } |
| damage_buffer_ = new_damage_buffer; |
| + |
| + pending_resize_params_.reset(); |
| + |
| + scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params( |
| + new BrowserPluginHostMsg_ResizeGuest_Params); |
| + params->damage_buffer_id = new_damage_buffer->id(); |
| +#if defined(OS_WIN) |
| + params->damage_buffer_size = size; |
| +#endif |
| + params->width = window_rect.width; |
| + params->height = window_rect.height; |
| + params->resize_pending = resize_pending_; |
| + params->scale_factor = GetDeviceScaleFactor(); |
| + |
| + // Until an actual navigation occurs, there is no browser side embedder |
| + // present to notify about geometry updates. In this case, after we've updated |
| + // the BrowserPlugin's state we are done and we do not send a resize message |
| + // to the browser. |
| + if (navigate_src_sent_) { |
| + resize_pending_ = true; |
| + BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest( |
| + render_view_->GetRoutingID(), |
| + instance_id_, |
| + *(params.get()))); |
| + } else { |
| + pending_resize_params_.reset(params.release()); |
| + } |
| +} |
| + |
| +BrowserPluginHostMsg_ResizeGuest_Params* |
| + BrowserPlugin::GetPendingResizeParams() { |
| + if (pending_resize_params_.get()) { |
| + return pending_resize_params_.release(); |
| + } else { |
| + BrowserPluginHostMsg_ResizeGuest_Params* params = |
| + new BrowserPluginHostMsg_ResizeGuest_Params; |
| + |
| + // We don't have a pending resize to send, so we send an invalid transport |
| + // dib Id. |
| + params->damage_buffer_id = TransportDIB::Id(); |
| + params->width = width(); |
| + params->height = height(); |
| + return params; |
| + } |
| } |
| void BrowserPlugin::updateFocus(bool focused) { |