Index: mojo/services/html_viewer/html_document.cc |
diff --git a/mojo/services/html_viewer/html_document.cc b/mojo/services/html_viewer/html_document.cc |
index 0f35b8d7d94de8895b479d2d41d3ae1839d70cea..32a468923c8b3b453eb0b1527da4495732c74da7 100644 |
--- a/mojo/services/html_viewer/html_document.cc |
+++ b/mojo/services/html_viewer/html_document.cc |
@@ -41,6 +41,7 @@ |
#include "third_party/skia/include/core/SkCanvas.h" |
#include "third_party/skia/include/core/SkColor.h" |
#include "third_party/skia/include/core/SkDevice.h" |
+#include "ui/gfx/geometry/dip_util.h" |
using mojo::AxProvider; |
using mojo::Rect; |
@@ -135,10 +136,7 @@ void HTMLDocument::OnEmbed( |
root_ = root; |
embedder_service_provider_ = exposed_services.Pass(); |
navigator_host_.set_service_provider(embedder_service_provider_.get()); |
- |
- blink::WebSize root_size(root_->bounds().width, root_->bounds().height); |
- web_view_->resize(root_size); |
- web_layer_tree_view_impl_->setViewportSize(root_size); |
+ UpdateWebviewSizeFromViewSize(); |
web_layer_tree_view_impl_->set_view(root_); |
root_->AddObserver(this); |
} |
@@ -174,6 +172,17 @@ void HTMLDocument::Load(URLResponsePtr response) { |
web_view_->mainFrame()->loadRequest(web_request); |
} |
+void HTMLDocument::UpdateWebviewSizeFromViewSize() { |
+ web_view_->setDeviceScaleFactor(root_->viewport_metrics().device_pixel_ratio); |
+ const gfx::Size size_in_pixels(root_->bounds().width, root_->bounds().height); |
+ // TODO: WebView should really take pixels (or float) so it has the real size. |
jamesr
2015/03/17 17:28:45
i still think this TODO is incorrect and should be
sky
2015/03/17 22:05:38
Done.
|
+ const gfx::Size size_in_dips = gfx::ConvertSizeToDIP( |
jamesr
2015/03/17 17:28:45
do we always snap the x/y offset of a view to a ph
sky
2015/03/17 22:05:37
Yes. mojo::Views is pixel based.
|
+ root_->viewport_metrics().device_pixel_ratio, size_in_pixels); |
+ web_view_->resize( |
+ blink::WebSize(size_in_dips.width(), size_in_dips.height())); |
+ web_layer_tree_view_impl_->setViewportSize(size_in_pixels); |
jamesr
2015/03/17 17:28:45
this is the number of physical pixels to use for c
|
+} |
+ |
blink::WebStorageNamespace* HTMLDocument::createSessionStorageNamespace() { |
return new WebStorageNamespaceImpl(); |
} |
@@ -301,8 +310,7 @@ void HTMLDocument::OnViewBoundsChanged(View* view, |
const Rect& old_bounds, |
const Rect& new_bounds) { |
DCHECK_EQ(view, root_); |
- web_view_->resize( |
- blink::WebSize(view->bounds().width, view->bounds().height)); |
+ UpdateWebviewSizeFromViewSize(); |
} |
void HTMLDocument::OnViewDestroyed(View* view) { |