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

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: use gfx::Size 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..2e7bcdc0371c7020b8c4a50da7cf698a8fcddb8d 100644
--- a/content/renderer/pepper/pepper_plugin_instance_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc
@@ -807,19 +807,38 @@ bool PepperPluginInstanceImpl::Initialize(
if (!render_frame_)
return false;
+ // Get plugin dimensions directly.
+ blink::WebElement element = container()->element();
+ blink::WebRect bounds = element.boundsInViewportSpace();
+ int width = bounds.width;
+ int height = 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();
Lei Zhang 2015/03/18 00:48:12 You can change the type of |bounds| to gfx::Rect()
tommycli 2015/03/19 22:10:12 Done.
+
+ if (bounds.width < width)
+ width = bounds.width;
+ if (bounds.height < height)
+ height = bounds.height;
+
+ node = node.parentNode();
+ }
+
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(width, height);
}
if (throttler) {
throttler_ = throttler.Pass();
throttler_->AddObserver(this);
throttler_->Initialize(render_frame_, plugin_url_.GetOrigin(),
- module()->name(),
- container()->element().boundsInViewportSpace());
+ module()->name(), gfx::Size(width, height));
}
message_channel_ = MessageChannel::Create(this, &message_channel_object_);

Powered by Google App Engine
This is Rietveld 408576698