Chromium Code Reviews| Index: content/renderer/pepper/pepper_plugin_instance_impl.cc |
| diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc |
| index c7e400527979f8b71886e9e2339c27c426cf720a..0b86054c066f3036808685e2ecaaa081ba128430 100644 |
| --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc |
| +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc |
| @@ -809,19 +809,9 @@ bool PepperPluginInstanceImpl::Initialize( |
| if (!render_frame_) |
| return false; |
| - if (is_flash_plugin_ && RenderThread::Get()) { |
| - RenderThread::Get()->RecordAction( |
| - base::UserMetricsAction("Flash.PluginInstanceCreated")); |
| - blink::WebRect bounds = container()->element().boundsInViewportSpace(); |
| - RecordFlashSizeMetric(bounds.width, bounds.height); |
| - } |
| - |
| if (throttler) { |
| throttler_ = throttler.Pass(); |
| throttler_->AddObserver(this); |
| - throttler_->Initialize(render_frame_, plugin_url_.GetOrigin(), |
| - module()->name(), |
| - container()->element().boundsInViewportSpace()); |
| } |
| message_channel_ = MessageChannel::Create(this, &message_channel_object_); |
| @@ -1233,8 +1223,9 @@ PP_Var PepperPluginInstanceImpl::GetInstanceObject(v8::Isolate* isolate) { |
| } |
| void PepperPluginInstanceImpl::ViewChanged( |
| - const gfx::Rect& position, |
| + const gfx::Rect& window, |
| const gfx::Rect& clip, |
| + const gfx::Rect& unobscured, |
| const std::vector<gfx::Rect>& cut_outs_rects) { |
| // WebKit can give weird (x,y) positions for empty clip rects (since the |
| // position technically doesn't matter). But we want to make these |
| @@ -1244,9 +1235,11 @@ void PepperPluginInstanceImpl::ViewChanged( |
| if (!clip.IsEmpty()) |
| new_clip = clip; |
| + unobscured_ = unobscured; |
| + |
| cut_outs_rects_ = cut_outs_rects; |
| - view_data_.rect = PP_FromGfxRect(position); |
| + view_data_.rect = PP_FromGfxRect(window); |
| view_data_.clip_rect = PP_FromGfxRect(clip); |
| view_data_.device_scale = container_->deviceScaleFactor(); |
| view_data_.css_scale = |
| @@ -1288,7 +1281,12 @@ void PepperPluginInstanceImpl::ViewChanged( |
| UpdateFlashFullscreenState(fullscreen_container_ != NULL); |
| - SendDidChangeView(); |
| + // During plugin initialization, there are often re-layouts. Avoid sending |
| + // intermediate sizes the plugin and throttler. |
| + if (sent_initial_did_change_view_) |
| + SendDidChangeView(); |
| + else |
| + ScheduleAsyncDidChangeView(); |
| } |
| void PepperPluginInstanceImpl::SetWebKitFocus(bool has_focus) { |
| @@ -1630,6 +1628,20 @@ void PepperPluginInstanceImpl::SendDidChangeView() { |
| ppapi::ViewData view_data = view_data_; |
| + if (!sent_initial_did_change_view_) { |
|
piman
2015/04/01 01:02:41
So, you may be getting into this code more than on
tommycli
2015/04/01 18:55:28
Done. Thanks for the explanation. That's a pretty
|
| + if (is_flash_plugin_ && RenderThread::Get()) { |
| + RenderThread::Get()->RecordAction( |
| + base::UserMetricsAction("Flash.PluginInstanceCreated")); |
| + RecordFlashSizeMetric(unobscured_.width(), unobscured_.height()); |
| + } |
| + |
| + // Initialize the throttler if necessary. |
| + if (throttler_) { |
| + throttler_->Initialize(render_frame_, plugin_url_.GetOrigin(), |
| + module()->name(), unobscured_.size()); |
| + } |
| + } |
| + |
| // When plugin content is throttled, fake the page being offscreen. We cannot |
| // send empty view data here, as some plugins rely on accurate view data. |
| if (throttler_ && throttler_->IsThrottled()) { |