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

Unified Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 1015023002: Plugin Power Saver: Throttle 'large' plugins that appear small. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months 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 side-by-side diff with in-line comments
Download patch
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 4e051349df677dd1cd701dbbb682effbd3b8a8b3..b18c5a8ecaa64e748726f1f2d20411db8c1e18f9 100644
--- a/content/renderer/pepper/pepper_plugin_instance_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc
@@ -807,19 +807,32 @@ bool PepperPluginInstanceImpl::Initialize(
if (!render_frame_)
return false;
+ // Get plugin dimensions directly.
+ blink::WebElement element = container()->element();
+ blink::WebRect bounds = element.boundsInViewportSpace();
+ gfx::Size size(bounds.width, bounds.height);
+
+ // Plugins are sometimes only partially visible. This is to support content
+ // that may expand. Walk up the DOM tree here to find a parent container
+ // that is smaller, and use that as the plugin's effective visible size.
+ blink::WebNode node = element.parentNode();
+ while (!node.isNull() && node.isElementNode()) {
+ blink::WebRect bounds = node.to<WebElement>().boundsInViewportSpace();
+ size.SetToMin(gfx::Size(bounds.width, bounds.height));
+ node = node.parentNode();
+ }
piman 2015/03/18 01:58:57 This seems crazy. It's also most likely wrong beca
tommycli 2015/03/19 22:10:13 Hi piman, The clip rect passed to ViewChanged was
+
if (is_flash_plugin_ && RenderThread::Get()) {
RenderThread::Get()->RecordAction(
base::UserMetricsAction("Flash.PluginInstanceCreated"));
- blink::WebRect bounds = container()->element().boundsInViewportSpace();
- RecordFlashSizeMetric(bounds.width, bounds.height);
+ RecordFlashSizeMetric(size.width(), size.height());
}
if (throttler) {
throttler_ = throttler.Pass();
throttler_->AddObserver(this);
throttler_->Initialize(render_frame_, plugin_url_.GetOrigin(),
- module()->name(),
- container()->element().boundsInViewportSpace());
+ module()->name(), size);
}
message_channel_ = MessageChannel::Create(this, &message_channel_object_);
« no previous file with comments | « content/public/renderer/plugin_instance_throttler.h ('k') | content/renderer/pepper/plugin_instance_throttler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698