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

Unified Diff: components/plugins/renderer/webview_plugin.cc

Issue 981623003: Plugin Power Saver: Implement srcset syntax for posters. (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
« no previous file with comments | « components/plugins/renderer/plugin_placeholder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/plugins/renderer/webview_plugin.cc
diff --git a/components/plugins/renderer/webview_plugin.cc b/components/plugins/renderer/webview_plugin.cc
index d14e4f7235af237575e186fd9f3bf07dfcedc347..062e6e102b1bc5586d5a51a2206315700308c6ca 100644
--- a/components/plugins/renderer/webview_plugin.cc
+++ b/components/plugins/renderer/webview_plugin.cc
@@ -109,8 +109,13 @@ WebPluginContainer* WebViewPlugin::container() const { return container_; }
bool WebViewPlugin::initialize(WebPluginContainer* container) {
container_ = container;
- if (container_)
+ if (container_) {
old_title_ = container_->element().getAttribute("title");
+
+ // Propagate device scale to inner webview to load the correct resource
+ // when images have a "srcset" attribute.
+ web_view_->setDeviceScaleFactor(container_->deviceScaleFactor());
+ }
return true;
}
@@ -136,8 +141,14 @@ void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) {
paint_rect.Offset(-rect_.x(), -rect_.y());
- canvas->translate(SkIntToScalar(rect_.x()), SkIntToScalar(rect_.y()));
canvas->save();
tommycli 2015/03/06 21:30:55 I also changed the order so 'save' is called befor
jbroman 2015/03/07 03:56:02 Yeah, looks good.
+ canvas->translate(SkIntToScalar(rect_.x()), SkIntToScalar(rect_.y()));
+
+ // Apply inverse device scale factor, as the outer webview has already
+ // applied it, and the inner webview will apply it again.
+ SkScalar inverse_scale =
+ SkFloatToScalar(1.0 / container_->deviceScaleFactor());
+ canvas->scale(inverse_scale, inverse_scale);
web_view_->layout();
web_view_->paint(canvas, paint_rect);
« no previous file with comments | « components/plugins/renderer/plugin_placeholder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698