Chromium Code Reviews| 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); |